Skip to content

Commit

Permalink
Update media capability polyfill to account for Playstation 5 (#3808)
Browse files Browse the repository at this point in the history
Add Playstation 5 detection to the Media Capabilities Polyfill install method.

Fixes #3582

Co-authored-by: Dan Sparacio <[email protected]>
  • Loading branch information
littlespex and dsparacio authored Dec 16, 2021
1 parent 3a9139e commit 1d54965
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 1d54965

Please sign in to comment.