Skip to content

Commit

Permalink
Merge pull request #4 from NetrisTV/master
Browse files Browse the repository at this point in the history
Fix queue draining
  • Loading branch information
horiuchi authored Jul 13, 2020
2 parents 6d84774 + a3e32a2 commit 744eff0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
});
Expand Down

0 comments on commit 744eff0

Please sign in to comment.