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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to rename this component to better reflect that it's no longer just used for Looping videos

Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@ import {
getSubtitleAsset,
} from '../lib/video';
import type { MediaAtomBlockElement } from '../types/content';
import type { VideoPlayerFormat } from '../types/mainMedia';
import { Caption } from './Caption';
import { Island } from './Island';
import { SelfHostedVideo } from './SelfHostedVideo.importable';

type LoopVideoInArticleProps = {
type SelfHostedVideoInArticleProps = {
element: MediaAtomBlockElement;
format: ArticleFormat;
isMainMedia: boolean;
videoStyle: VideoPlayerFormat;
};

export const LoopVideoInArticle = ({
export const SelfHostedVideoInArticle = ({
element,
format,
isMainMedia,
}: LoopVideoInArticleProps) => {
videoStyle,
}: SelfHostedVideoInArticleProps) => {
const posterImageUrl = element.posterImage?.[0]?.url;
const caption = element.title;
const firstVideoAsset = getFirstVideoAsset(element.assets);
Expand Down Expand Up @@ -59,7 +62,7 @@ export const LoopVideoInArticle = ({
sources={convertAssetsToVideoSources(element.assets)}
subtitleSize="medium"
subtitleSource={getSubtitleAsset(element.assets)}
videoStyle="Loop"
videoStyle={videoStyle}
uniqueId={element.id}
width={firstVideoAsset?.dimensions?.width ?? 500}
enableHls={false}
Expand Down
20 changes: 7 additions & 13 deletions dotcom-rendering/src/lib/renderElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { Island } from '../components/Island';
import { ItemLinkBlockElement } from '../components/ItemLinkBlockElement';
import { KeyTakeaways } from '../components/KeyTakeaways';
import { KnowledgeQuizAtom } from '../components/KnowledgeQuizAtom.importable';
import { LoopVideoInArticle } from '../components/LoopVideoInArticle';
import { MainMediaEmbedBlockComponent } from '../components/MainMediaEmbedBlockComponent';
import { MapEmbedBlockComponent } from '../components/MapEmbedBlockComponent.importable';
import { MiniProfiles } from '../components/MiniProfiles';
Expand All @@ -44,6 +43,7 @@ import { PullQuoteBlockComponent } from '../components/PullQuoteBlockComponent';
import { QandaAtom } from '../components/QandaAtom.importable';
import { QAndAExplainers } from '../components/QAndAExplainers';
import { RichLinkComponent } from '../components/RichLinkComponent.importable';
import { SelfHostedVideoInArticle } from '../components/SelfHostedVideoInArticle';
import { SoundcloudBlockComponent } from '../components/SoundcloudBlockComponent';
import { SpotifyBlockComponent } from '../components/SpotifyBlockComponent.importable';
import { StarRatingBlockComponent } from '../components/StarRatingBlockComponent';
Expand Down Expand Up @@ -493,22 +493,16 @@ export const renderElement = ({
</Island>
);
case 'model.dotcomrendering.pageElements.MediaAtomBlockElement':
/*
- MediaAtomBlockElement is used for self-hosted videos
- Historically, these videos have been self-hosted for legal or sensitive reasons
- These videos play in the `VideoAtom` component
- Looping videos, introduced in July 2025, are also self-hosted
- Thus they are delivered as a MediaAtomBlockElement
- However they need to display in a different video player
- We need to differentiate between the two forms of video
- We can do this by interrogating the atom's metadata, which includes the new attribute `videoPlayerFormat`
*/
Comment on lines -496 to -505
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this information can better be gleaned from git history but I am happy to be challenged on this

if (element.videoPlayerFormat === 'Loop') {
if (
element.videoPlayerFormat &&
['Loop', 'Cinemagraph'].includes(element.videoPlayerFormat)
) {
return (
<LoopVideoInArticle
<SelfHostedVideoInArticle
element={element}
format={format}
isMainMedia={isMainMedia}
videoStyle={element.videoPlayerFormat}
/>
);
} else {
Expand Down
Loading