Reputation: 2885
I have:
const startVideoListener = eventName => {
const mediaSource = new MediaSource()
const src = URL.createObjectURL(mediaSource)
let sourceBuffer = null
mediaSource.addEventListener('sourceopen', () => {
sourceBuffer = mediaSource.addSourceBuffer('video/webm; codecs=vp9')
})
socket.on(eventName, function (chunk, id) {
if (mediaSource.readyState === 'open') {
count++
if (count === 5) return
console.log({ count })
sourceBuffer.appendBuffer(chunk)
}
})
return src
}
I have a stream that works when all segments come through. One I miss even a single segment (as shown with the 5th segment above) the video breaks and becomes completely unplayable.
Is this a constraint imposed by the format/codec or is there a way to recover from missing segments in a SourceBuffer
or MediaSource
?
I've tried to remove segments and several other things, but there isn't much context in the documentation:
https://developer.mozilla.org/en-US/docs/Web/API/SourceBuffer
Upvotes: 1
Views: 98