From 593eca7bd091b962e7d893864f20fa427e80d08a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Tyczy=C5=84ski?= Date: Wed, 27 Nov 2024 13:18:16 +0100 Subject: [PATCH] fix: Detect smooth codec switch support on Apple devices (#7678) --- externs/managedmediasource.js | 6 ++++++ lib/media/media_source_capabilities.js | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/externs/managedmediasource.js b/externs/managedmediasource.js index cca0dbd843..1c06840f19 100644 --- a/externs/managedmediasource.js +++ b/externs/managedmediasource.js @@ -22,3 +22,9 @@ function ManagedMediaSource() {} * @return {boolean} */ ManagedMediaSource.isTypeSupported = function(type) {}; + +/** + * @constructor + * @extends {SourceBuffer} + */ +function ManagedSourceBuffer() {} diff --git a/lib/media/media_source_capabilities.js b/lib/media/media_source_capabilities.js index b1b7daa334..8f11bb3a2c 100644 --- a/lib/media/media_source_capabilities.js +++ b/lib/media/media_source_capabilities.js @@ -37,9 +37,10 @@ shaka.media.Capabilities = class { * @return {boolean} */ static isChangeTypeSupported() { - return !!window.SourceBuffer && + const sourceBuffer = window.ManagedSourceBuffer || window.SourceBuffer; + return !!sourceBuffer && // eslint-disable-next-line no-restricted-syntax - !!SourceBuffer.prototype && !!SourceBuffer.prototype.changeType; + !!sourceBuffer.prototype && !!sourceBuffer.prototype.changeType; } };