Re: [mediacapture-record] Add method MediaRecorder.restart considering this use case. (#178)

Few issues in your code.
First, you must ensure that the format coming out of the recorder is a container supported by MSE (Firefox only supports mp4 and webm). Ogg isn't a supported type with MSE (that's by spec)

Second, your code will call sendToAnotherClient whenever new data is available, which will ultimately call sourceBuffer.appendBuffer(). This will likely error too after the 2nd call to sendToAnotherClient.

Per spec, appendBuffer is an asynchronous operation and the events update, updateend will be fired on the source buffer once the operation is complete.
You *must* wait for that event to have been fired before you can call appendBuffer again, otherwise you will cause an error to be thrown.
https://w3c.github.io/media-source/#sourcebuffer-prepare-append
"If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps."
the updating attribute is set to true when you call appendBuffer and it goes back to being false once the updateend event is fired.

-- 
GitHub Notification of comment by jyavenard
Please view or discuss this issue at https://github.com/w3c/mediacapture-record/issues/178#issuecomment-566769157 using your GitHub account

Received on Tuesday, 17 December 2019 22:03:00 UTC