From 899f4894dbb98e9473cf57e5891f49a798e1c38e Mon Sep 17 00:00:00 2001 From: kixelated Date: Wed, 25 Oct 2023 11:51:41 +0900 Subject: [PATCH] Temporary fix to disable MSE audio. (#68) --- lib/playback/index.ts | 5 +++++ lib/playback/mse/segment.ts | 4 ++++ lib/playback/mse/source.ts | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/lib/playback/index.ts b/lib/playback/index.ts index 036d57b..842e998 100644 --- a/lib/playback/index.ts +++ b/lib/playback/index.ts @@ -75,6 +75,11 @@ export class Player { throw new Error(`expected CMAF track`) } + if (isAudioTrack(track) && this.#backend instanceof MSE) { + // TODO temporary hack to disable audio in MSE + continue + } + inits.add(track.init_track) tracks.push(track) } diff --git a/lib/playback/mse/segment.ts b/lib/playback/mse/segment.ts index 0cfb767..699cc9f 100644 --- a/lib/playback/mse/segment.ts +++ b/lib/playback/mse/segment.ts @@ -73,6 +73,10 @@ export class Segment { mdat.write(stream) } + if (stream.buffer.byteLength == 0) { + return this.done + } + this.source.initialize(this.init) this.source.append(stream.buffer) diff --git a/lib/playback/mse/source.ts b/lib/playback/mse/source.ts index 22b95ba..e99273b 100644 --- a/lib/playback/mse/source.ts +++ b/lib/playback/mse/source.ts @@ -45,6 +45,10 @@ export class Source { // Append the segment data to the buffer. append(data: Uint8Array | ArrayBuffer) { + if (data.byteLength == 0) { + throw new Error("empty append") + } + this.queue.push({ kind: "data", data: data,