Skip to content

Conversation

@domlander
Copy link
Contributor

@domlander domlander commented Nov 12, 2025

What does this change?

Creates an option for looping videos to present cinemagraph-like behaviour.

Cinemagraphs are looping videos with the following changes:

  • No audio and subsequently no mute/unmute icon
  • No subtitles
  • No progress bar
  • No play/pause icon
  • Clicking a cinemagraph is a click to go into the article instead of play/pausing the video.

Why?

So that we can show a cinemagraph style of video on our fronts.

Screenshots

Before After
before after

Note: the cursor is a pointer when not in Screenshare mode

Screen.Recording.2025-11-12.at.10.34.15.mov

@domlander domlander self-assigned this Nov 12, 2025
@domlander domlander added run_chromatic Runs chromatic when label is applied fronts + curation maintenance Departmental tracking: maintenance work, not a fix or a feature labels Nov 12, 2025
@github-actions
Copy link

github-actions bot commented Nov 12, 2025

@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Nov 12, 2025
@github-actions
Copy link

github-actions bot commented Nov 12, 2025

@domlander domlander marked this pull request as ready for review November 12, 2025 10:37
@github-actions
Copy link

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

@domlander domlander requested a review from abeddow91 November 12, 2025 10:42
@domlander domlander added the run_chromatic Runs chromatic when label is applied label Nov 13, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Nov 13, 2025
Copy link
Contributor

@abeddow91 abeddow91 left a comment

Choose a reason for hiding this comment

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

In terms of functionality, this works well 👏

I've detailed in the PR but i've found the checks for isCinemagraph a bit hard to follow and I wonder if we would lift these up to a single decision point and pass that down, leaving the player agnostic to the video type.

I'm also not sure about keeping LoopVideo as the component as this now seems to be an optional characteristic of the player - similar to autoplay - rather than its explicit function, given that self hosted videos are now separated out into 'Loop' | 'Cinemagraph' | 'Default'. As far as I'm aware, the only thing that makes this player a loop player is setting loop=true

I wonder if its worth refactoring the player to be more generic before we implement Cinemagraph but I don't think this is blocking at this point.

{/* This overlay is styled when the CardLink is hovered */}
{(mediaType === 'picture' ||
mediaType === 'slideshow' ||
(mediaType === 'loop-video' && isCinemagraph)) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this media type correct?

I thought this should be SelfHostedVideo following #14827

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a different type CardMediaType: https://github.com/guardian/dotcom-rendering/blob/main/dotcom-rendering/src/types/layout.ts#L24

I understand this is confusing and could be refactored...I had a look and it wasn't trivial to do, so I have left it for now

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've addressed this here: c1693a9

<MediaWrapper
mediaSize={mediaSize}
mediaType={media.type}
isCinemagraph={
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just pass the videoStyle here instead of creating a new abstraction?

activeCue={activeCue}
isCinemagraph={isCinemagraph}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is somewhat personal preference but I find the isCinemagraph repetition quite tricky to parse and I wonder about how this might scale.

I did wonder about having a loop video wrapper to pass video preferences down depending on videoStyle rather than determining them all here. Do you have any thoughts on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering about having bundling up the player options so that we don't need to pepper the component with checks. Something like


const playerProps = {
  showPlayIcon: !isCinemagraph,
  enableSubtitles: !isCinemagraph,
  enableAudioControls: !isCinemagraph,
  pointerEventsNone: isCinemagraph,
  trackingStyle: videoStyle,
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed on the repetition being terrible. I have refactored to remove the duplication.

!!subtitleSource &&
!!subtitleSize &&
!!activeCue?.text &&
!isCinemagraph;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to check isCinemagraph here given we dont pass subtitleSource or subtitleSize the level above if it isCinemagraph?

'current' in ref &&
ref.current &&
isPlayable &&
!isCinemagraph && (
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to check isCinemagraph here given we set this at the wrapper above
showPlayIcon={!isCinemagraph ? showPlayIcon : false}

/* used in custom subtitle overlays */
activeCue?: ActiveCue | null;
/* Cinemagraphs do not display subtitles or video controls */
isCinemagraph: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

I've mentioned this below but I think we can get rid of this if we explicitly set props using isCinemagraph prior to this.

type="button"
onClick={handleAudioClick}
css={audioButtonStyles}
data-link-name={`gu-video-loop-${
Copy link
Contributor

Choose a reason for hiding this comment

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

At the moment we are specifying loop in the tracking.

Should this be the video style now rather than one hardcoded property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be handled in a follow up PR - these components should be renamed given they will soon be handling non-loops

@domlander domlander force-pushed the doml/cinemagraph branch 3 times, most recently from 33c30e4 to 8bc8a72 Compare November 18, 2025 12:42
@domlander domlander added the run_chromatic Runs chromatic when label is applied label Nov 18, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Nov 18, 2025
@domlander domlander requested a review from abeddow91 November 18, 2025 14:40
Copy link
Contributor

@abeddow91 abeddow91 left a comment

Choose a reason for hiding this comment

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

This looks great. Thanks for taking the time to refactor this.

@domlander domlander added the run_chromatic Runs chromatic when label is applied label Nov 24, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Nov 24, 2025
@domlander domlander merged commit 73a7410 into main Nov 24, 2025
32 checks passed
@domlander domlander deleted the doml/cinemagraph branch November 24, 2025 10:37
@gu-prout
Copy link

gu-prout bot commented Nov 24, 2025

Seen on PROD (merged by @domlander 7 minutes and 54 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dotcom-rendering fronts + curation maintenance Departmental tracking: maintenance work, not a fix or a feature Seen-on-PROD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants