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