Skip to content

Commit

Permalink
fix: Fix MediaCapabilities polyfill on Playstation 4 (shaka-project#4320
Browse files Browse the repository at this point in the history
)

Add Playstation 5 detection to the Media Capabilities Polyfill install method.

Fixes shaka-project#4320
  • Loading branch information
bcupac authored and joeyparrish committed Jul 14, 2022
1 parent a1af9dd commit 0f20944
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/polyfill/media_capabilities.js
Expand Up @@ -37,9 +37,12 @@ shaka.polyfill.MediaCapabilities = class {
// See: https://github.com/shaka-project/shaka-player/issues/3582
// TODO: re-evaluate MediaCapabilities in the future versions of PS5
// Browsers.
// Since MediaCapabilities implementation does not exist in PS4 browsers, we
// should always install polyfill.
let canUseNativeMCap = true;
if (shaka.util.Platform.isApple() ||
shaka.util.Platform.isPS5() ||
shaka.util.Platform.isPS4() ||
shaka.util.Platform.isChromecast()) {
canUseNativeMCap = false;
}
Expand Down
10 changes: 9 additions & 1 deletion lib/util/platform.js
Expand Up @@ -198,7 +198,8 @@ shaka.util.Platform = class {
static isApple() {
return !!navigator.vendor && navigator.vendor.includes('Apple') &&
!shaka.util.Platform.isTizen() &&
!shaka.util.Platform.isEOS();
!shaka.util.Platform.isEOS() &&
!shaka.util.Platform.isPS4();
}

/**
Expand All @@ -214,6 +215,13 @@ shaka.util.Platform = class {
return shaka.util.Platform.userAgentContains_('PlayStation 5');
}

/**
* Check if the current platform is Playstation 4.
*/
static isPS4() {
return shaka.util.Platform.userAgentContains_('PlayStation 4');
}

/**
* Returns a major version number for Safari, or Safari-based iOS browsers.
*
Expand Down

0 comments on commit 0f20944

Please sign in to comment.