From 05a1abcc0ad0f25a28b3da65d01d30fda6b3aec4 Mon Sep 17 00:00:00 2001 From: Martin <901824+martinstark@users.noreply.github.com> Date: Wed, 8 Mar 2023 13:39:43 +0100 Subject: [PATCH] fix: mitigate uncaught type error in media_source_engine --- lib/media/media_source_engine.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index bab68e038e..5ed1e5eecf 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -391,7 +391,22 @@ shaka.media.MediaSourceEngine = class { } } const type = mimeType + this.config_.sourceBufferExtraFeatures; - const sourceBuffer = this.mediaSource_.addSourceBuffer(type); + + this.destroyer_.ensureNotDestroyed(); + + let sourceBuffer; + + try { + sourceBuffer = this.mediaSource_.addSourceBuffer(type); + } catch (exception) { + throw new shaka.util.Error( + shaka.util.Error.Severity.CRITICAL, + shaka.util.Error.Category.MEDIA, + shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW, + exception, + 'The mediaSource_ status was' + this.mediaSource_.readyState + + 'expected \'open\''); + } this.eventManager_.listen( sourceBuffer, 'error',