Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dotcom-rendering/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export type Props = {
headlinePosition?: 'inner' | 'outer';
/** Feature flag for the labs redesign work */
showLabsRedesign?: boolean;
enableHls?: boolean;
};

const starWrapper = (cardHasImage: boolean) => css`
Expand Down Expand Up @@ -420,6 +421,7 @@ export const Card = ({
headlinePosition = 'inner',
showLabsRedesign = false,
subtitleSize = 'small',
enableHls = false,
}: Props) => {
const hasSublinks = supportingContent && supportingContent.length > 0;
const sublinkPosition = decideSublinkPosition(
Expand Down Expand Up @@ -978,6 +980,7 @@ export const Card = ({
media.mainMedia.subtitleSource
}
subtitleSize={subtitleSize}
enableHls={enableHls}
/>
</Island>
)}
Expand Down
4 changes: 4 additions & 0 deletions dotcom-rendering/src/components/DecideContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type Props = {
containerLevel?: DCRContainerLevel;
/** Feature flag for the labs redesign work */
showLabsRedesign?: boolean;
enableHls?: boolean;
};

export const DecideContainer = ({
Expand All @@ -65,6 +66,7 @@ export const DecideContainer = ({
collectionId,
containerLevel,
showLabsRedesign = false,
enableHls = false,
}: Props) => {
switch (containerType) {
case 'dynamic/fast':
Expand Down Expand Up @@ -248,6 +250,7 @@ export const DecideContainer = ({
aspectRatio={aspectRatio}
collectionId={collectionId}
showLabsRedesign={!!showLabsRedesign}
enableHls={enableHls}
/>
);
case 'flexible/general':
Expand All @@ -262,6 +265,7 @@ export const DecideContainer = ({
containerLevel={containerLevel}
collectionId={collectionId}
showLabsRedesign={!!showLabsRedesign}
enableHls={enableHls}
/>
);
case 'scrollable/small':
Expand Down
14 changes: 14 additions & 0 deletions dotcom-rendering/src/components/FlexibleGeneral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Props = {
collectionId: number;
/** Feature flag for the labs redesign work */
showLabsRedesign?: boolean;
enableHls?: boolean;
};

type RowLayout = 'oneCardHalfWidth' | 'oneCardFullWidth' | 'twoCard';
Expand Down Expand Up @@ -256,6 +257,7 @@ type SplashCardLayoutProps = {
collectionId: number;
/** Feature flag for the labs redesign work */
showLabsRedesign?: boolean;
enableHls?: boolean;
};

const SplashCardLayout = ({
Expand All @@ -269,6 +271,7 @@ const SplashCardLayout = ({
containerLevel,
collectionId,
showLabsRedesign,
enableHls,
}: SplashCardLayoutProps) => {
const card = cards[0];
if (!card) return null;
Expand Down Expand Up @@ -354,6 +357,7 @@ const SplashCardLayout = ({
subtitleSize={subtitleSize}
headlinePosition={card.showLivePlayable ? 'outer' : 'inner'}
showLabsRedesign={showLabsRedesign}
enableHls={enableHls}
/>
</LI>
</UL>
Expand Down Expand Up @@ -421,6 +425,7 @@ type FullWidthCardLayoutProps = {
collectionId: number;
/** Feature flag for the labs redesign work */
showLabsRedesign?: boolean;
enableHls?: boolean;
};

const FullWidthCardLayout = ({
Expand All @@ -435,6 +440,7 @@ const FullWidthCardLayout = ({
containerLevel,
collectionId,
showLabsRedesign,
enableHls,
}: FullWidthCardLayoutProps) => {
const card = cards[0];
if (!card) return null;
Expand Down Expand Up @@ -511,6 +517,7 @@ const FullWidthCardLayout = ({
showKickerImage={card.format.design === ArticleDesign.Audio}
showLabsRedesign={showLabsRedesign}
subtitleSize={subtitleSize}
enableHls={enableHls}
/>
</LI>
</UL>
Expand All @@ -530,6 +537,7 @@ type HalfWidthCardLayoutProps = {
containerLevel: DCRContainerLevel;
/** Feature flag for the labs redesign work */
showLabsRedesign?: boolean;
enableHls?: boolean;
};

const HalfWidthCardLayout = ({
Expand All @@ -544,6 +552,7 @@ const HalfWidthCardLayout = ({
isLastRow,
containerLevel,
showLabsRedesign,
enableHls,
}: HalfWidthCardLayoutProps) => {
if (cards.length === 0) return null;

Expand Down Expand Up @@ -599,6 +608,7 @@ const HalfWidthCardLayout = ({
headlineSizes={undefined}
canPlayInline={false}
showLabsRedesign={showLabsRedesign}
enableHls={enableHls}
/>
</LI>
);
Expand All @@ -617,6 +627,7 @@ export const FlexibleGeneral = ({
containerLevel = 'Primary',
collectionId,
showLabsRedesign,
enableHls,
}: Props) => {
const splash = [...groupedTrails.splash].slice(0, 1).map((snap) => ({
...snap,
Expand Down Expand Up @@ -646,6 +657,7 @@ export const FlexibleGeneral = ({
containerLevel={containerLevel}
collectionId={collectionId}
showLabsRedesign={showLabsRedesign}
enableHls={enableHls}
/>
)}
{groupedCards.map((row, i) => {
Expand All @@ -665,6 +677,7 @@ export const FlexibleGeneral = ({
containerLevel={containerLevel}
collectionId={collectionId}
showLabsRedesign={showLabsRedesign}
enableHls={enableHls}
/>
);

Expand All @@ -685,6 +698,7 @@ export const FlexibleGeneral = ({
isLastRow={i === groupedCards.length - 1}
containerLevel={containerLevel}
showLabsRedesign={showLabsRedesign}
enableHls={enableHls}
/>
);
}
Expand Down
7 changes: 7 additions & 0 deletions dotcom-rendering/src/components/FlexibleSpecial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Props = {
containerLevel?: DCRContainerLevel;
collectionId: number;
showLabsRedesign?: boolean;
enableHls?: boolean;
};

type BoostProperties = {
Expand Down Expand Up @@ -134,6 +135,7 @@ type OneCardLayoutProps = {
containerLevel: DCRContainerLevel;
isSplashCard?: boolean;
showLabsRedesign?: boolean;
enableHls?: boolean;
};

export const OneCardLayout = ({
Expand All @@ -148,6 +150,7 @@ export const OneCardLayout = ({
containerLevel,
isSplashCard,
showLabsRedesign,
enableHls,
}: OneCardLayoutProps) => {
const card = cards[0];
if (!card) return null;
Expand Down Expand Up @@ -202,6 +205,7 @@ export const OneCardLayout = ({
headlinePosition={isSplashCard ? 'outer' : 'inner'}
showLabsRedesign={showLabsRedesign}
subtitleSize={subtitleSize}
enableHls={enableHls}
/>
</LI>
</UL>
Expand Down Expand Up @@ -305,6 +309,7 @@ export const FlexibleSpecial = ({
containerLevel = 'Primary',
collectionId,
showLabsRedesign,
enableHls,
}: Props) => {
const snaps = [...groupedTrails.snap].slice(0, 1).map((snap) => ({
...snap,
Expand Down Expand Up @@ -334,6 +339,7 @@ export const FlexibleSpecial = ({
containerLevel={containerLevel}
isSplashCard={false}
showLabsRedesign={showLabsRedesign}
enableHls={enableHls}
/>
)}
{isNonEmptyArray(splash) && (
Expand All @@ -349,6 +355,7 @@ export const FlexibleSpecial = ({
containerLevel={containerLevel}
isSplashCard={true}
showLabsRedesign={showLabsRedesign}
enableHls={enableHls}
/>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ type Props = {
linkTo: string;
subtitleSource?: string;
subtitleSize: SubtitleSize;
enableHls: boolean;
};

export const SelfHostedVideo = ({
Expand All @@ -160,6 +161,7 @@ export const SelfHostedVideo = ({
linkTo,
subtitleSource,
subtitleSize,
enableHls,
}: Props) => {
const adapted = useShouldAdapt();
const { renderingTarget } = useConfig();
Expand Down Expand Up @@ -709,6 +711,7 @@ export const SelfHostedVideo = ({
subtitleSource={subtitleSource}
subtitleSize={subtitleSize}
activeCue={activeCue}
enableHls={enableHls}
/>
</figure>
</div>
Expand Down
52 changes: 26 additions & 26 deletions dotcom-rendering/src/components/SelfHostedVideo.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@ export const Loop5to4: Story = {
'https://media.guim.co.uk/9bdb802e6da5d3fd249b5060f367b3a817965f0c/0_0_1800_1080/master/1800.jpg',
fallbackImage: '',
},
};

// export const WithM3U8File: Story = {
// name: 'With M3U8 file',
// args: {
// ...Default.args,
// sources: [
// {
// src: 'https://uploads.guimcode.co.uk/2025/09/01/Loop__Japan_fireball--ace3fcf6-1378-41db-9d21-f3fc07072ab2-1.10.m3u8',
// mimeType: 'application/x-mpegURL',
// },
// {
// src: 'https://uploads.guim.co.uk/2025%2F06%2F20%2Ftesting+only%2C+please+ignore--3cb22b60-2c3f-48d6-8bce-38c956907cce-3.mp4',
// mimeType: 'video/mp4',
// },
// ],
// },
// };

export const Loop16to9: Story = {
} satisfies Story;

export const WithM3U8File = {
name: 'With M3U8 file',
args: {
...Loop5to4.args,
sources: [
{
src: 'https://uploads.guimcode.co.uk/2025/09/01/Loop__Japan_fireball--ace3fcf6-1378-41db-9d21-f3fc07072ab2-1.10.m3u8',
mimeType: 'application/x-mpegURL',
},
{
src: 'https://uploads.guim.co.uk/2025%2F06%2F20%2Ftesting+only%2C+please+ignore--3cb22b60-2c3f-48d6-8bce-38c956907cce-3.mp4',
mimeType: 'video/mp4',
},
],
},
} satisfies Story;

export const Loop16to9 = {
name: 'Looping video in 16:9 aspect ratio',
args: {
...Loop5to4.args,
Expand All @@ -70,14 +70,14 @@ export const Loop16to9: Story = {
height: 1080,
width: 1920,
},
};
} satisfies Story;

export const WithCinemagraph: Story = {
export const WithCinemagraph = {
args: {
...Loop5to4.args,
videoStyle: 'Cinemagraph',
},
};
} satisfies Story;

export const PausePlay: Story = {
...Loop5to4,
Expand All @@ -98,7 +98,7 @@ export const PausePlay: Story = {
await userEvent.click(videoEl);
await expect(canvas.queryByTestId('play-icon')).not.toBeInTheDocument();
},
};
} satisfies Story;

export const UnmuteMute: Story = {
...Loop5to4,
Expand All @@ -120,7 +120,7 @@ export const UnmuteMute: Story = {
await userEvent.click(canvas.getByTestId('mute-icon'));
await canvas.findByTestId('unmute-icon');
},
};
} satisfies Story;

// Function to emulate pausing between interactions
function sleep(ms: number) {
Expand Down Expand Up @@ -150,4 +150,4 @@ export const InteractionObserver: Story = {
await expect(Number(progressBar.ariaValueNow)).toEqual(progress);
await expect(canvas.queryByTestId('play-icon')).not.toBeInTheDocument();
},
};
} satisfies Story;
10 changes: 8 additions & 2 deletions dotcom-rendering/src/components/SelfHostedVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
} from 'react';
import { forwardRef } from 'react';
import type { ActiveCue } from '../lib/useSubtitles';
import type { Source } from '../lib/video';
import { filterOutHlsSources, type Source } from '../lib/video';
import { palette } from '../palette';
import type { VideoPlayerFormat } from '../types/mainMedia';
import { narrowPlayIconWidth, PlayIcon } from './Card/components/PlayIcon';
Expand Down Expand Up @@ -126,6 +126,7 @@ type Props = {
subtitleSize?: SubtitleSize;
/* used in custom subtitle overlays */
activeCue?: ActiveCue | null;
enableHls: boolean;
};

/**
Expand Down Expand Up @@ -167,6 +168,7 @@ export const SelfHostedVideoPlayer = forwardRef(
subtitleSource,
subtitleSize,
activeCue,
enableHls,
}: Props,
ref: React.ForwardedRef<HTMLVideoElement>,
) => {
Expand All @@ -185,6 +187,10 @@ export const SelfHostedVideoPlayer = forwardRef(
showPlayIcon ? 'play' : 'pause'
}-${atomId}`;

const filteredVideoSources = enableHls
? sources
: filterOutHlsSources(sources);

return (
<>
{/* eslint-disable-next-line jsx-a11y/media-has-caption -- Not all videos require captions. */}
Expand Down Expand Up @@ -226,7 +232,7 @@ export const SelfHostedVideoPlayer = forwardRef(
onKeyDown={handleKeyDown}
onError={onError}
>
{sources.map((source) => (
{filteredVideoSources.map((source) => (
<source
key={source.mimeType}
/* The start time is set to 1ms so that Safari will autoplay the video */
Expand Down
Loading
Loading