Skip to content

Commit b88200a

Browse files
Looping video in article - initial work underway
1 parent 5e3caba commit b88200a

File tree

4 files changed

+25
-75
lines changed

4 files changed

+25
-75
lines changed

dotcom-rendering/src/components/LoopVideoInArticle.importable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const LoopVideoInArticle = ({
6767
<Caption
6868
captionText={caption}
6969
format={format}
70-
mediaType="Video"
70+
mediaType="SelfHostedVideo"
7171
isMainMedia={isMainMedia}
7272
/>
7373
)}

dotcom-rendering/src/components/LoopVideoPlayer.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,7 @@ export const LoopVideoPlayer = forwardRef(
213213
<source
214214
key={source.mimeType}
215215
/* The start time is set to 1ms so that Safari will autoplay the video */
216-
src={
217-
source.src
218-
? `${source.src}#t=0.001`
219-
: `${source.url}#t=0.001`
220-
}
216+
src={source.src}
221217
type={source.mimeType}
222218
/>
223219
))}

dotcom-rendering/src/lib/renderElement.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,13 @@ export const renderElement = ({
514514
`2 + 2 === 4` - display in the looping video player
515515
*/
516516

517-
if (2 + 2 === 5) {
517+
if (2 + 2 === 4) {
518+
console.log('Loop: element.assets', element.assets);
519+
const updatedSources = element.assets.map((a) => ({
520+
src: a.src || a.url,
521+
mimeType: a.mimeType,
522+
}));
523+
console.log('Loop: updatedSources', updatedSources);
518524
return (
519525
<>
520526
{element.posterImage?.[0]?.url && (
@@ -523,7 +529,7 @@ export const renderElement = ({
523529
defer={{ until: 'visible' }}
524530
>
525531
<LoopVideoInArticle
526-
sources={element.assets}
532+
sources={updatedSources}
527533
atomId={element.id}
528534
uniqueId={`${Math.random()}`}
529535
height={400}
@@ -546,6 +552,7 @@ export const renderElement = ({
546552
</>
547553
);
548554
} else {
555+
console.log('Default: element.assets', element.assets);
549556
return (
550557
<VideoAtom
551558
format={format}

dotcom-rendering/src/types/content.ts

Lines changed: 14 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,18 @@ export interface ListBlockElement {
411411
elementId: string;
412412
}
413413

414-
// interface LoopVideoInArticleElement {
415-
// _type: 'model.dotcomrendering.pageElements.MediaAtomBlockElement';
416-
// elementId: string;
417-
// id: string;
418-
// assets: VideoAssets[];
419-
// posterImage?: {
420-
// url: string;
421-
// width: number;
422-
// }[];
423-
// title?: string;
424-
// duration?: number;
425-
// }
414+
interface LoopVideoInArticleElement {
415+
_type: 'model.dotcomrendering.pageElements.MediaAtomBlockElement';
416+
elementId: string;
417+
id: string;
418+
assets: VideoAssets[];
419+
posterImage?: {
420+
url: string;
421+
width: number;
422+
}[];
423+
title?: string;
424+
duration?: number;
425+
}
426426

427427
export interface MapBlockElement extends ThirdPartyEmbeddedContent {
428428
_type: 'model.dotcomrendering.pageElements.MapBlockElement';
@@ -482,23 +482,6 @@ export interface InteractiveContentsBlockElement {
482482
endDocumentElementId?: string;
483483
}
484484

485-
export interface ProductBlockElement {
486-
_type: 'model.dotcomrendering.pageElements.ProductBlockElement';
487-
elementId: string;
488-
brandName: string;
489-
starRating: ProductStarRating;
490-
productName: string;
491-
image?: ProductImage;
492-
secondaryHeadingHtml: string;
493-
primaryHeadingHtml: string;
494-
customAttributes: ProductCustomAttribute[];
495-
content: FEElement[];
496-
h2Id?: string;
497-
displayType: ProductDisplayType;
498-
productCtas: ProductCta[];
499-
lowestPrice?: string;
500-
}
501-
502485
interface ProfileAtomBlockElement {
503486
_type: 'model.dotcomrendering.pageElements.ProfileAtomBlockElement';
504487
elementId: string;
@@ -832,6 +815,7 @@ export type FEElement =
832815
| KeyTakeawaysBlockElement
833816
| LinkBlockElement
834817
| ListBlockElement
818+
| LoopVideoInArticleElement
835819
| MapBlockElement
836820
| MediaAtomBlockElement
837821
| MiniProfilesBlockElement
@@ -863,8 +847,7 @@ export type FEElement =
863847
| VineBlockElement
864848
| YoutubeBlockElement
865849
| WitnessTypeBlockElement
866-
| CrosswordElement
867-
| ProductBlockElement;
850+
| CrosswordElement;
868851

869852
// -------------------------------------
870853
// Misc
@@ -896,47 +879,11 @@ export interface ImageSource {
896879
srcSet: SrcSetItem[];
897880
}
898881

899-
export type ProductDisplayType =
900-
| 'InlineOnly'
901-
| 'ProductCardOnly'
902-
| 'InlineWithProductCard';
903-
904-
export type ProductCta = {
905-
url: string;
906-
text: string;
907-
retailer: string;
908-
price: string;
909-
};
910-
911-
export type ProductCustomAttribute = {
912-
name: string;
913-
value: string;
914-
};
915-
916-
export type ProductStarRating =
917-
| '0'
918-
| '1'
919-
| '2'
920-
| '3'
921-
| '4'
922-
| '5'
923-
| 'none-selected';
924-
925882
export interface SrcSetItem {
926883
src: string;
927884
width: number;
928885
}
929886

930-
export interface ProductImage {
931-
url: string;
932-
caption: string;
933-
credit: string;
934-
alt: string;
935-
displayCredit: boolean;
936-
height: number;
937-
width: number;
938-
}
939-
940887
export interface Image {
941888
index: number;
942889
fields: {

0 commit comments

Comments
 (0)