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

fix: Install polyfills for Comcast X1 devices #7529

Merged
merged 20 commits into from
Nov 4, 2024
Merged
19 changes: 19 additions & 0 deletions externs/comcast.js
tykus160 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @fileoverview Externs for Comcast
*
* @externs
*/


/** @const */
var ServiceManager = {};


/** @type {string} */
ServiceManager.getServiceForJavaScript;
3 changes: 2 additions & 1 deletion lib/polyfill/media_capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions lib/polyfill/mediasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down
27 changes: 16 additions & 11 deletions lib/util/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ shaka.util.Platform = class {
!shaka.util.Platform.isOrange() &&
!shaka.util.Platform.isPS4() &&
!shaka.util.Platform.isAmazonFireTV() &&
!shaka.util.Platform.isWPE() &&
!shaka.util.Platform.isZenterio() &&
!shaka.util.Platform.isSkyQ();
!shaka.util.Platform.isSkyQ() &&
!shaka.util.Platform.isComcastX1();
}

/**
Expand Down Expand Up @@ -354,6 +354,19 @@ shaka.util.Platform = class {
return shaka.util.Platform.userAgentContains_('Sky_STB');
}

/**
* Check if the current platform is Comcast X1.
*/
static isComcastX1() {
const rdk = window.ServiceManager &&
window.ServiceManager.getServiceForJavaScript;
return rdk && shaka.util.Platform.userAgentContains_('WPE') &&
navigator.platform &&
navigator.platform.includes('Linux aarch64') &&
shaka.util.Platform.userAgentContains_('AppleWebKit') &&
shaka.util.Platform.userAgentContains_('Version/8.0');
}

/**
* Check if the current platform is Amazon Fire TV.
* https://developer.amazon.com/docs/fire-tv/identify-amazon-fire-tv-devices.html
Expand All @@ -364,14 +377,6 @@ shaka.util.Platform = class {
return shaka.util.Platform.userAgentContains_('AFT');
}

/**
* Check if the current platform is Comcast X1.
* @return {boolean}
*/
static isWPE() {
return shaka.util.Platform.userAgentContains_('WPE');
}

/**
* Check if the current platform is Deutsche Telecom Zenterio STB.
* @return {boolean}
Expand Down Expand Up @@ -536,7 +541,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;
}
Expand Down
Loading