diff --git a/src/reader.ts b/src/reader.ts index 0f859f7..c9bd2a3 100644 --- a/src/reader.ts +++ b/src/reader.ts @@ -54,6 +54,7 @@ export class Reader { } } + this.source.onread?.({ start, end }); const bytesPromise = this.source._read(start, end); const loadingSegment: LoadingSegment = { start, end, promise: bytesPromise }; this.loadingSegments.push(loadingSegment); diff --git a/src/source.ts b/src/source.ts index dde1ab0..9357b76 100644 --- a/src/source.ts +++ b/src/source.ts @@ -12,6 +12,8 @@ export abstract class Source { _getSize() { return this._sizePromise ??= this._retrieveSize(); } + + onread: ((range: { start: number; end: number }) => unknown) | null = null; } /** @public */ diff --git a/todo.txt b/todo.txt index 1100ef6..ddfc2ea 100644 --- a/todo.txt +++ b/todo.txt @@ -3,6 +3,5 @@ - Add the new audio codecs to muxers - Mov muxer!!! Only mov can hold PCM audio, MP4 cannot - A stream source?? Or like a callback-driven source -- onRead callback for Source - onHeader, etc callbacks for Matroska - https://github.com/Vanilagy/mp4-muxer/issues/83 tell him it's possible now \ No newline at end of file