@@ -2,13 +2,15 @@ importScripts("../third_party/mp4boxjs/mp4box.all.min.js");
22
33// Wraps an MP4Box File as a WritableStream underlying sink.
44class MP4FileSink {
5+ #onEndOfStream = null ;
56 #setStatus = null ;
67 #file = null ;
78 #offset = 0 ;
89
9- constructor ( file , setStatus ) {
10+ constructor ( file , onEndOfStream , setStatus ) {
1011 this . #file = file ;
1112 this . #setStatus = setStatus ;
13+ this . #onEndOfStream = onEndOfStream ;
1214 }
1315
1416 write ( chunk ) {
@@ -28,6 +30,7 @@ class MP4FileSink {
2830 close ( ) {
2931 this . #setStatus( "fetch" , "Done" ) ;
3032 this . #file. flush ( ) ;
33+ this . #onEndOfStream( ) ;
3134 }
3235}
3336
@@ -39,7 +42,7 @@ class MP4Demuxer {
3942 #setStatus = null ;
4043 #file = null ;
4144
42- constructor ( uri , { onConfig, onChunk, setStatus} ) {
45+ constructor ( uri , { onConfig, onChunk, onEndOfStream , setStatus} ) {
4346 this . #onConfig = onConfig ;
4447 this . #onChunk = onChunk ;
4548 this . #setStatus = setStatus ;
@@ -51,7 +54,7 @@ class MP4Demuxer {
5154 this . #file. onSamples = this . #onSamples. bind ( this ) ;
5255
5356 // Fetch the file and pipe the data through.
54- const fileSink = new MP4FileSink ( this . #file, setStatus ) ;
57+ const fileSink = new MP4FileSink ( this . #file, onEndOfStream , setStatus ) ;
5558 fetch ( uri ) . then ( response => {
5659 // highWaterMark should be large enough for smooth streaming, but lower is
5760 // better for memory usage.
0 commit comments