videojs / mux.js

Lightweight utilities for inspecting and manipulating video container formats.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Basic Transmuxer Test issue if segments more then 3

ipnet-me opened this issue · comments

Hello,

I am trying very basic example player from your docs.

https://github.com/videojs/mux.js/#basic-usage

It working perfect with 3 segments, but If I add 4 or more segments I got error.

Uncaught (in promise) DOMException: Failed to execute 'appendBuffer' on 'SourceBuffer': This SourceBuffer is still processing an 'appendBuffer' or 'remove' operation.

I can't find issue, anyone can help me?

Thanks

segments.zip

this is video segments I am trying to play

I got it myself

just changed function

   function appendNextSegment(){
        // reset the 'data' event listener to just append (moof/mdat) boxes to the Source Buffer
        transmuxer.off('data');
        transmuxer.on('data', (segment) =>{
            sourceBuffer.appendBuffer(new Uint8Array(segment.data));
        })

        if (segments.length == 0){
            // notify MSE that we have no more segments to append.
            mediaSource.endOfStream();
        }
        
        if(segments.length>0){
            fetch(segments.shift()).then((response)=>{
                return response.arrayBuffer();
            }).then((response)=>{
                transmuxer.push(new Uint8Array(response));
                transmuxer.flush();
            })
        }

    }