Skip to content

Commit 7c2cf7c

Browse files
authored
Set if looping videos can play inline on a front (#14107)
* Make use of the canPlayInline card property to dictate if looping videos can play on a front * Explicitly set canPlayInline to false when the video is looping.
1 parent 8cfea57 commit 7c2cf7c

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

dotcom-rendering/src/components/Card/Card.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ const getMedia = ({
254254
canPlayInline?: boolean;
255255
isBetaContainer: boolean;
256256
}) => {
257-
if (mainMedia?.type === 'LoopVideo') {
257+
if (mainMedia?.type === 'LoopVideo' && canPlayInline) {
258258
return {
259259
type: 'loop-video',
260260
mainMedia,
@@ -887,18 +887,18 @@ export const Card = ({
887887
/>
888888
</AvatarContainer>
889889
)}
890-
{mainMedia?.type === 'LoopVideo' && (
890+
{media.type === 'loop-video' && (
891891
<Island
892892
priority="feature"
893893
defer={{ until: 'visible' }}
894894
>
895895
<LoopVideo
896-
src={mainMedia.videoId}
897-
height={mainMedia.height}
898-
width={mainMedia.width}
899-
videoId={mainMedia.videoId}
896+
src={media.mainMedia.videoId}
897+
height={media.mainMedia.height}
898+
width={media.mainMedia.width}
899+
videoId={media.mainMedia.videoId}
900900
thumbnailImage={
901-
mainMedia.thumbnailImage ?? ''
901+
media.mainMedia.thumbnailImage ?? ''
902902
}
903903
fallbackImageComponent={
904904
<CardPicture

dotcom-rendering/src/components/FlexibleGeneral.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ const ImmersiveCardLayout = ({
9999
imageLoading: Loading;
100100
collectionId: number;
101101
}) => {
102+
const isLoopingVideo = card.mainMedia?.type === 'LoopVideo';
103+
102104
return (
103105
<UL padBottom={true}>
104106
<LI key={card.url} padSides={true}>
@@ -113,7 +115,7 @@ const ImmersiveCardLayout = ({
113115
kickerText={card.kickerText}
114116
showClock={false}
115117
image={card.image}
116-
canPlayInline={true}
118+
canPlayInline={isLoopingVideo ? false : true}
117119
starRating={card.starRating}
118120
dataLinkName={card.dataLinkName}
119121
discussionApiUrl={card.discussionApiUrl}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const ScrollableFeature = ({
3838
visibleCarouselSlidesOnTablet={3}
3939
>
4040
{trails.map((card) => {
41+
const isLoopingVideo = card.mainMedia?.type === 'LoopVideo';
4142
return (
4243
<ScrollableCarousel.Item key={card.url}>
4344
<FeatureCard
@@ -54,7 +55,7 @@ export const ScrollableFeature = ({
5455
}
5556
showClock={false}
5657
image={card.image}
57-
canPlayInline={true}
58+
canPlayInline={isLoopingVideo ? false : true}
5859
starRating={card.starRating}
5960
dataLinkName={card.dataLinkName}
6061
discussionApiUrl={card.discussionApiUrl}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const ScrollableMedium = ({
7171
showLivePlayable={trail.showLivePlayable}
7272
showTopBarDesktop={false}
7373
showTopBarMobile={false}
74+
canPlayInline={false}
7475
/>
7576
</ScrollableCarousel.Item>
7677
);

dotcom-rendering/src/components/StaticFeatureTwo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ export const StaticFeatureTwo = ({
3333
collectionId,
3434
}: Props) => {
3535
const cards = trails.slice(0, 2);
36-
3736
return (
3837
<UL direction="row">
3938
{cards.map((card) => {
39+
const isLoopingVideo = card.mainMedia?.type === 'LoopVideo';
4040
return (
4141
<LI
4242
stretch={false}
@@ -59,7 +59,7 @@ export const StaticFeatureTwo = ({
5959
}
6060
showClock={false}
6161
image={card.image}
62-
canPlayInline={true}
62+
canPlayInline={isLoopingVideo ? false : true}
6363
starRating={card.starRating}
6464
dataLinkName={card.dataLinkName}
6565
discussionApiUrl={card.discussionApiUrl}

0 commit comments

Comments
 (0)