From a3e32a2dbbac500e974d0a29c4b49dbbf8f98732 Mon Sep 17 00:00:00 2001 From: Sergey Volkov Date: Fri, 10 Jul 2020 21:04:07 +0300 Subject: [PATCH] Fix queue draining fix #3 --- src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index f0538b2..23b5b3c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -60,7 +60,7 @@ export default class VideoConverter { debug.log(` video.readyState=${this.element.readyState}`); const data = this.queue.shift(); if (data) { - this.writeBuffer(data); + this.doAppend(data); } }); this.sourceBuffer.addEventListener('error', () => { @@ -144,7 +144,7 @@ export default class VideoConverter { private writeBuffer(data: Uint8Array): void { if (this.mediaReady) { - if (this.sourceBuffer.updating) { + if (this.sourceBuffer.updating || this.queue.length) { this.queue.push(data); } else { this.doAppend(data); @@ -156,7 +156,7 @@ export default class VideoConverter { if (!this.sourceBuffer.updating) { const d = this.queue.shift(); if (d) { - this.writeBuffer(d); + this.doAppend(d); } } });