Skip to content

Add looping videos to articles#14843

Merged
RikRootsGuardian merged 15 commits intomainfrom
rjr-investigate-looping-video-in-articles
Dec 11, 2025
Merged

Add looping videos to articles#14843
RikRootsGuardian merged 15 commits intomainfrom
rjr-investigate-looping-video-in-articles

Conversation

@RikRootsGuardian
Copy link
Contributor

@RikRootsGuardian RikRootsGuardian commented Nov 14, 2025

What does this change?

Displays looping self-hosted videos (ones with videoPlayerFormat = Loop) in the appropriate player.

Why?

Looping videos currently render correctly on fronts, but not in articles.

How to test

Deploy to CODE. Create an article in CODE Composer and include a self-hosted video atom. When you preview the article, the video should display in the appropriate player, according the "Video Player Format" setting from Media Atom Maker:

Screenshot 2025-11-27 at 09 32 44

If set to "Standard", it should display in the normal player
If set to "Loop", it should display in the looping player

Screenshots

Before After
Screenshot 2025-11-26 at 10 36 23 looping

Related PRs

@RikRootsGuardian RikRootsGuardian marked this pull request as draft November 14, 2025 14:55
@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.

@github-actions
Copy link

github-actions bot commented Nov 14, 2025

@RikRootsGuardian
Copy link
Contributor Author

RikRootsGuardian commented Nov 17, 2025

(AI suggestions sent me down the wrong path)

@RikRootsGuardian
Copy link
Contributor Author

This appears to be a CORS issue rather than a code issue. When developing locally we test on http://localhost:3030, which leads to CORS issues for loading the video from eg https://uploads.guim.co.uk/2025/10/07/Metaxas_tests_audience_with_first_jokes_of_Talk_show___video--a182c225-e45f-4d6a-82ed-05fa50e17fbb-2.0.mp4#t=0.001 ...:
Screenshot 2025-11-17 at 14 45 10

The white space appears when the poster image fails to upload for some reason? This is an intermittent issue (because: see screen shot above which loaded the poster image fine 2 mins after failing and 2 mins before failing again):

Screenshot 2025-11-17 at 14 49 59

I noticed this comment in the last PR to touch the LoopVideoPlayer file:
Screenshot 2025-11-17 at 15 00 54

@RikRootsGuardian
Copy link
Contributor Author

Can confirm that the video src/url strings are correct (pasting the url into the browser address bar loads the video)

@RikRootsGuardian
Copy link
Contributor Author

Viewing the article locally, using http://r.thegulocal.com:3030/Article/https://www.theguardian.com/media/2025/oct/08/conservative-late-night-talkshow URL. doesn't solve the issue:
Screenshot 2025-11-17 at 15 12 28

@RikRootsGuardian
Copy link
Contributor Author

tl;dr: Looping videos now need to be served with a crossOrigin="anonymous" header (so subtitle files can be picked up) - failure will lead to the CORS issue. This is a fixed issue, except for this PR branch where we're testing on articles with self-hosted videos which are not looping videos, thus have not had the header added and old copies have not been purged from Fastly.

Chat messages: AnnaB, MarjanK

Anna:
Hey WebEx - we're running into a CORS issue and I wondered if you might have some advice.

We introduced (and rolled back) a crossOrigin="anonymous" header to looping videos so that we can retrieve the subtitle vtt file from uploads.guim. This change meant that both the video and the subtitle files are now requested as cross-origin CORS fetches, requiring fastly to include Access-Control-Allow-Origin headers.

Unsuprisingly, uploads.guim already has https://www.theguardian.com as an allowed origin but some users were getting the following error

Access to video at 'https://uploads.guim.co.uk/2025/11/05/Front_loop__Mamdani_victory_speech--4477e94a-a4a8-4a85-96c2-4ee8cff259f9-2.0.mp4#t=0.001' from origin 'https://www.theguardian.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Does anyone have any ideas as to why some users would be hitting this error?

I'm wondering if some users could be getting a cached mp4 response that does not have the headers attached because we did not ask for them before this change was rolled out and if we therefore need to purge the cache for some videos. Does that sound plausible? Are we able to purge certain items in the uploads.guim cache?

The fastly VCL is available here if anyone is interested in looking through it https://manage.fastly.com/configure/services/2TmfkSoyUoNo8aFNe6Htjs/versions/29/vcl/snippets/CORS%20headers

Marjan
Hi Anna, that is what I was thinking too, that we purge the cache for those videos. I think for uploads.guim.co.uk we'd need to do the purge manually in fastly by putting the whole url in Purge URL (for content & images we have this feature in the admin tool but I can't see anything there for uploads.guim)

[...etc]

@github-actions
Copy link

github-actions bot commented Nov 19, 2025

@simonbyford simonbyford force-pushed the rjr-investigate-looping-video-in-articles branch from 19644a1 to e8451e3 Compare November 25, 2025 16:22
@simonbyford simonbyford marked this pull request as ready for review November 26, 2025 10:07
@simonbyford simonbyford force-pushed the rjr-investigate-looping-video-in-articles branch from 979a78b to db38c0d Compare November 26, 2025 10:49
@simonbyford simonbyford added the run_chromatic Runs chromatic when label is applied label Nov 26, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Nov 26, 2025
@frederickobrien frederickobrien added this to the Features milestone Nov 26, 2025
fallbackImageLoading="lazy"
fallbackImageSize="small"
height={400}
linkTo="Article-embed-MediaAtomBlockElement"
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this magic string @RikRootsGuardian ?

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 needs to be considered. It's used for tracking events eg when video first comes into view. This was developed with Fronts in mind, so I don't know if that tracking is useful for progression through the article? I put it in as a hardcoded text, but maybe a better approach would be to use the article URL here?

@simonbyford simonbyford force-pushed the rjr-investigate-looping-video-in-articles branch from 07cd67d to 3463988 Compare December 2, 2025 15:32
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

@RikRootsGuardian RikRootsGuardian added the run_chromatic Runs chromatic when label is applied label Dec 5, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Dec 5, 2025
@RikRootsGuardian RikRootsGuardian added the run_chromatic Runs chromatic when label is applied label Dec 9, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Dec 9, 2025
Copy link
Contributor Author

@RikRootsGuardian RikRootsGuardian left a comment

Choose a reason for hiding this comment

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

I would approve if I was permitted to - but only for the code updates made by @simonbyford

Merging remains blocked until someone approves my code changes

Copy link
Contributor

@simonbyford simonbyford left a comment

Choose a reason for hiding this comment

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

Looks good to me! 🚢

@RikRootsGuardian RikRootsGuardian merged commit 642828e into main Dec 11, 2025
29 checks passed
@RikRootsGuardian RikRootsGuardian deleted the rjr-investigate-looping-video-in-articles branch December 11, 2025 09:36
@gu-prout
Copy link

gu-prout bot commented Dec 11, 2025

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

@groakland groakland added the feature Departmental tracking: work on a new feature label Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dotcom-rendering feature Departmental tracking: work on a new feature Seen-on-PROD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants