From e7892d9f797c0b4b682b375075beaeba97b11f1e Mon Sep 17 00:00:00 2001 From: Martin <901824+martinstark@users.noreply.github.com> Date: Wed, 8 Mar 2023 15:26:18 +0100 Subject: [PATCH] fix: prevent bad calls to MediaSource.endOfStream --- lib/media/media_source_engine.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index 5ed1e5eecfb..7a2acdc0e2f 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -1056,8 +1056,10 @@ shaka.media.MediaSourceEngine = class { async endOfStream(reason) { await this.enqueueBlockingOperation_(() => { // If endOfStream() has already been called on the media source, - // don't call it again. - if (this.ended()) { + // don't call it again. Also do not call if readyState is + // 'closed' (not attached to video element) since it is not a + // valid operation. + if (this.ended() || this.mediaSource_.readyState === 'closed') { return; } // Tizen won't let us pass undefined, but it will let us omit the