Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: only polyfill MCap for non Android-based Cast devices. #4170

Merged
merged 1 commit into from Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions lib/polyfill/media_capabilities.js
Expand Up @@ -24,8 +24,8 @@ shaka.polyfill.MediaCapabilities = class {
* @export
*/
static install() {
// Since MediaCapabilities is not fully supported on Chromecast yet, we
// should always install polyfill for Chromecast.
// Since MediaCapabilities is not fully supported on some Chromecast yet,
// we should always install polyfill for all Chromecast not Android-based.
// TODO: re-evaluate MediaCapabilities in the future versions of Chromecast.
// Since MediaCapabilities implementation is buggy in Apple browsers, we
// should always install polyfill for Apple browsers.
Expand All @@ -37,10 +37,16 @@ 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.
if (!shaka.util.Platform.isChromecast() &&
!shaka.util.Platform.isApple() &&
!shaka.util.Platform.isPS5() &&
navigator.mediaCapabilities) {
let canUseNativeMCap = true;
if (shaka.util.Platform.isApple() ||
shaka.util.Platform.isPS5() ||
shaka.util.Platform.isChromecast()) {
canUseNativeMCap = false;
}
if (shaka.util.Platform.isAndroidCastDevice()) {
canUseNativeMCap = true;
}
if (canUseNativeMCap && navigator.mediaCapabilities) {
shaka.log.info(
'MediaCapabilities: Native mediaCapabilities support found.');
return;
Expand Down
10 changes: 10 additions & 0 deletions lib/util/platform.js
Expand Up @@ -163,6 +163,16 @@ shaka.util.Platform = class {
return shaka.util.Platform.userAgentContains_('CrKey');
}

/**
* Check if the current platform is a Android-based Cast devices.
*
* @return {boolean}
*/
static isAndroidCastDevice() {
return shaka.util.Platform.isChromecast() &&
shaka.util.Platform.userAgentContains_('Android');
}

/**
* Check if the current platform is Google Chrome.
*
Expand Down