Skip to content

Commit

Permalink
fix(FairPlay): Install by default shaka.polyfill.PatchedMediaKeysAppl…
Browse files Browse the repository at this point in the history
…e on older Safari versions (#8106)
  • Loading branch information
avelad authored and joeyparrish committed Feb 22, 2025
1 parent da09b7c commit 55ddcf0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/tutorials/fairplay.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ The support in each case would be the following:

Adding FairPlay support involves a bit more work than other key systems.

Note: If you are using an older version of Safari that doesn't support
Modern EME, legacy Apple Media Keys is used by default.

## Keysystem used in EME

Expand Down
21 changes: 21 additions & 0 deletions lib/polyfill/patchedmediakeys_apple.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ goog.require('shaka.util.StringUtils');
* @export
*/
shaka.polyfill.PatchedMediaKeysApple = class {
/**
* Installs the polyfill if needed.
*/
static defaultInstall() {
if (!window.HTMLVideoElement || !window.WebKitMediaKeys) {
// No HTML5 video or no prefixed EME.
return;
}
if (navigator.requestMediaKeySystemAccess &&
// eslint-disable-next-line no-restricted-syntax
MediaKeySystemAccess.prototype.getConfiguration) {
// Unprefixed EME available
return;
}
// If there is no unprefixed EME and prefixed EME exists, apply installation
// by default. Eg: older versions of Safari.
shaka.polyfill.PatchedMediaKeysApple.install();
}

/**
* Installs the polyfill if needed.
* @param {boolean=} enableUninstall enables uninstalling the polyfill
Expand Down Expand Up @@ -798,3 +817,5 @@ shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap = class {
* @private {string}
*/
shaka.polyfill.PatchedMediaKeysApple.apiName_ = 'apple';

shaka.polyfill.register(shaka.polyfill.PatchedMediaKeysApple.defaultInstall);

0 comments on commit 55ddcf0

Please sign in to comment.