Skip to content

Auto Upgrade DRM Embeds#1095

Merged
jdreetz merged 11 commits intomasterfrom
auto-upgrade-drm-embeds
Jul 14, 2025
Merged

Auto Upgrade DRM Embeds#1095
jdreetz merged 11 commits intomasterfrom
auto-upgrade-drm-embeds

Conversation

@jdreetz
Copy link
Contributor

@jdreetz jdreetz commented Jul 9, 2025

What

This pull request provides a workaround for failed playback in the case of DRM embeds that are missing the required encrypted-media in their allow attribute.

Why

In order to play a video that uses Encrypted Media Extensions inside an iframe, browsers require that encrypted-media is included in the allow attribute on the iframe. For Vimeo customers that enable DRM on existing embedded videos and are unable to update all of their videos to add the required attribute, the changes in this pull request will ensure their videos continue to playback (with DRM) by adding the attribute to embed once we've detected it's "required".

How

The changes in this pull request will apply the iframe updates when the SDK receives a "drminitfailed" failed event from an embed and we've determined it's missing the encrypted-media allow attribute. Once the attribute has been updated, the SDK will reload the iframe to ensure that playback will occur successfully.

In addition to the changes for DRM playback, this pull request does some minor refactoring to add a utility method for finding the iframe that sent a message, and using that utility method in the various places where iframe location is needed.

@jdreetz jdreetz force-pushed the auto-upgrade-drm-embeds branch from 94bdeeb to e706e4c Compare July 9, 2025 18:59
@jdreetz jdreetz marked this pull request as ready for review July 9, 2025 21:26
@jdreetz jdreetz changed the title Auto upgrade drm embeds Auto Upgrade DRM Embeds Jul 9, 2025
brandonhrowe
brandonhrowe previously approved these changes Jul 11, 2025
Copy link
Contributor

@brandonhrowe brandonhrowe left a comment

Choose a reason for hiding this comment

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

A couple of tiny nits, but otherwise I like this approach!

if (iframes[i].contentWindow !== event.source) {
continue;
}
const senderIFrame = event.source ? findIframeBySourceWindow(event.source, parent) : null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const senderIFrame = event.source ? findIframeBySourceWindow(event.source, parent) : null;
const senderIFrame = findIframeBySourceWindow(event.source, parent);

Nit. findIframeBySourceWindow already returns null if event.source is falsy.

return;
}

const currentAllow = senderIFrame.getAttribute('allow') || '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const currentAllow = senderIFrame.getAttribute('allow') || '';
const currentAllow = senderIFrame.allow;

Nit. allow lets you retrieve this a little easier.

* @param {Document} [doc=document] The document to search within
* @return {HTMLIFrameElement|null} The iframe element if found, otherwise null
*/
export function findIframeBySourceWindow(sourceWindow, doc = document) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@codecov
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

Attention: Patch coverage is 56.25000% with 21 lines in your changes missing coverage. Please review.

Project coverage is 73.76%. Comparing base (12e8446) to head (5a01123).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/lib/embed.js 47.36% 20 Missing ⚠️
src/player.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1095      +/-   ##
==========================================
+ Coverage   72.01%   73.76%   +1.74%     
==========================================
  Files           7        7              
  Lines         604      625      +21     
==========================================
+ Hits          435      461      +26     
+ Misses        169      164       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jdreetz jdreetz merged commit 2f96ddd into master Jul 14, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants