diff --git a/src/controller/buffer-controller.ts b/src/controller/buffer-controller.ts index 71d0b47b022..974425c1105 100644 --- a/src/controller/buffer-controller.ts +++ b/src/controller/buffer-controller.ts @@ -493,15 +493,17 @@ export default class BufferController implements ComponentAPI { // on BUFFER_EOS mark matching sourcebuffer(s) as ended and trigger checkEos() // an undefined data.type will mark all buffers as EOS. protected onBufferEos(event: Events.BUFFER_EOS, data: BufferEOSData) { - for (const type in this.sourceBuffer) { + let ended = true; + this.getSourceBufferTypes().forEach((type) => { + const sb = this.sourceBuffer[type as SourceBufferName]; if (!data.type || data.type === type) { - const sb = this.sourceBuffer[type as SourceBufferName]; if (sb && !sb.ended) { sb.ended = true; logger.log(`[buffer-controller]: ${type} sourceBuffer now EOS`); } } - } + ended = ended && !!(!sb || sb.ended); + }); const endStream = () => { const { mediaSource } = this; @@ -511,7 +513,9 @@ export default class BufferController implements ComponentAPI { // Allow this to throw and be caught by the enqueueing function mediaSource.endOfStream(); }; - this.blockBuffers(endStream); + if (ended) { + this.blockBuffers(endStream); + } } protected onLevelUpdated(