From 2b2df4b2e24bc04709b44251e80df0890114a286 Mon Sep 17 00:00:00 2001 From: Iragne Date: Mon, 4 Nov 2024 15:11:50 +0100 Subject: [PATCH] fix: Install polyfills for Comcast X1 devices (#7529) Close https://github.com/shaka-project/shaka-player/issues/7522 --- lib/polyfill/media_capabilities.js | 3 ++- lib/polyfill/mediasource.js | 12 ++++++++++++ lib/util/platform.js | 6 +++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/polyfill/media_capabilities.js b/lib/polyfill/media_capabilities.js index d5702f9a95..058622e4f5 100644 --- a/lib/polyfill/media_capabilities.js +++ b/lib/polyfill/media_capabilities.js @@ -61,7 +61,8 @@ shaka.polyfill.MediaCapabilities = class { shaka.util.Platform.isWebOS() || shaka.util.Platform.isTizen() || shaka.util.Platform.isEOS() || - shaka.util.Platform.isHisense()) { + shaka.util.Platform.isHisense() || + shaka.util.Platform.isComcastX1()) { canUseNativeMCap = false; } if (canUseNativeMCap && navigator.mediaCapabilities) { diff --git a/lib/polyfill/mediasource.js b/lib/polyfill/mediasource.js index d459a260e2..9d28141299 100644 --- a/lib/polyfill/mediasource.js +++ b/lib/polyfill/mediasource.js @@ -87,6 +87,18 @@ shaka.polyfill.MediaSource = class { // the player from trying to play opus on Tizen, we will override media // source to always reject opus content. shaka.polyfill.MediaSource.rejectCodec_('opus'); + } else if (shaka.util.Platform.isComcastX1()) { + // XOne look to be like safari 8 which do not correctly + // implement abort() on SourceBuffer. + // Calling abort() before appending a segment causes that segment to be + // incomplete in the buffer. + // Bug filed: https://bugs.webkit.org/show_bug.cgi?id=165342 + shaka.polyfill.MediaSource.stubAbort_(); + // If you remove up to a keyframe, Webkit 601.x.x incorrectly will also + // remove that keyframe and the content up to the next. + // Offsetting the end of the removal range seems to help. + // Bug filed: https://bugs.webkit.org/show_bug.cgi?id=177884 + shaka.polyfill.MediaSource.patchRemovalRange_(); } else { shaka.log.info('Using native MSE as-is.'); } diff --git a/lib/util/platform.js b/lib/util/platform.js index 2bdb8daee9..500ea247b1 100644 --- a/lib/util/platform.js +++ b/lib/util/platform.js @@ -300,7 +300,7 @@ shaka.util.Platform = class { !shaka.util.Platform.isOrange() && !shaka.util.Platform.isPS4() && !shaka.util.Platform.isAmazonFireTV() && - !shaka.util.Platform.isWPE() && + !shaka.util.Platform.isComcastX1() && !shaka.util.Platform.isZenterio() && !shaka.util.Platform.isSkyQ(); } @@ -368,7 +368,7 @@ shaka.util.Platform = class { * Check if the current platform is Comcast X1. * @return {boolean} */ - static isWPE() { + static isComcastX1() { return shaka.util.Platform.userAgentContains_('WPE'); } @@ -536,7 +536,7 @@ shaka.util.Platform = class { Platform.isPS5() || Platform.isAmazonFireTV() || Platform.isEOS() || Platform.isAPL() || Platform.isVirginMedia() || Platform.isOrange() || - Platform.isWPE() || Platform.isChromecast() || + Platform.isComcastX1() || Platform.isChromecast() || Platform.isHisense() || Platform.isZenterio()) { return true; }