From 8818a026d647b984825c92deacdc0630d6715b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Tue, 28 Feb 2023 20:16:16 +0100 Subject: [PATCH] fix: Reject TS content on Edge (#5043) Fixes https://github.com/shaka-project/shaka-player/issues/4955 --- lib/polyfill/mediasource.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/polyfill/mediasource.js b/lib/polyfill/mediasource.js index 4508185804..5a981e8484 100644 --- a/lib/polyfill/mediasource.js +++ b/lib/polyfill/mediasource.js @@ -61,6 +61,11 @@ shaka.polyfill.MediaSource = class { // Bug filed: https://bugs.webkit.org/show_bug.cgi?id=165342 shaka.polyfill.MediaSource.stubAbort_(); } + } else if (shaka.util.Platform.isEdge()) { + shaka.log.info('Rejecting TS container.'); + // TS content is broken on Edge in general. + // See https://github.com/shaka-project/shaka-player/issues/4955 + shaka.polyfill.MediaSource.rejectContainer_('mp2t'); } else if (shaka.util.Platform.isTizen2() || shaka.util.Platform.isTizen3() || shaka.util.Platform.isTizen4()) { @@ -122,6 +127,23 @@ shaka.polyfill.MediaSource = class { }; } + /** + * Patch |MediaSource.isTypeSupported| to always reject |container|. This is + * used when we know that we are on a platform that does not work well with + * a given container. + * + * @param {string} container + * @private + */ + static rejectContainer_(container) { + const isTypeSupported = MediaSource.isTypeSupported; + + MediaSource.isTypeSupported = (mimeType) => { + const actualContainer = shaka.util.MimeUtils.getContainerType(mimeType); + return actualContainer != container && isTypeSupported(mimeType); + }; + } + /** * Patch |MediaSource.isTypeSupported| to always reject |codec|. This is used * when we know that we are on a platform that does not work well with a given