Skip to content

Commit

Permalink
fix: Fix MediaCapabilities polyfill on Playstation 5 (shaka-project#3808
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#3582

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>
Change-Id: Ied871f73f0ad4f2d1f95f91158907179ee52ddea
  • Loading branch information
2 people authored and joeyparrish committed Jan 5, 2022
1 parent f647ba6 commit 41f3db2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/polyfill/media_capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ shaka.polyfill.MediaCapabilities = class {
// See: https://github.com/google/shaka-player/issues/3530
// TODO: re-evaluate MediaCapabilities in the future versions of Apple
// Browsers.
// Since MediaCapabilities implementation is buggy in PS5 browsers, we
// should always install polyfill for PS5 browsers.
// See: https://github.com/google/shaka-player/issues/3582
// TODO: re-evaluate MediaCapabilities in the future versions of PS5
// Browsers.
if (!shaka.util.Platform.isChromecast() &&
!shaka.util.Platform.isApple() &&
!shaka.util.Platform.isPS5() &&
navigator.mediaCapabilities) {
shaka.log.debug(
'MediaCapabilities: Native mediaCapabilities support found.');
Expand Down Expand Up @@ -149,7 +155,7 @@ shaka.polyfill.MediaCapabilities = class {
sessionTypes: mediaCapkeySystemConfig.sessionTypes,
};

// Only add the audio video capablities if they have valid data.
// Only add the audio video capabilities if they have valid data.
// Otherwise the query will fail.
if (audioCapabilities.length) {
mediaKeySystemConfig.audioCapabilities = audioCapabilities;
Expand Down
14 changes: 13 additions & 1 deletion lib/util/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ shaka.util.Platform = class {
!shaka.util.Platform.isEdge();
}


/**
* Check if the current platform is from Apple.
*
Expand All @@ -179,6 +178,19 @@ shaka.util.Platform = class {
&& !shaka.util.Platform.isTizen();
}

/**
* Check if the current platform is Playstation 5.
*
* Returns true on Playstation 5 browsers.
*
* Returns false for Playstation 5 browsers
*
* @return {boolean}
*/
static isPS5() {
return shaka.util.Platform.userAgentContains_('PlayStation 5');
}

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

0 comments on commit 41f3db2

Please sign in to comment.