<video id=video controls mute></video>
<script>
let source = new MediaSource,
buffer = MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');
(xhr = new XMLHttpRequest).open('get', 'frag_bunny.mp4');
xhr.responseType = 'arraybuffer';
xhr.onload = _ => {
buffer.onupdateend = _ => {
source.endOfStream();
video.src = URL.createObjectURL(source);
video.muted = true;
video.play();
};
buffer.appendBuffer(xhr.response);
}
xhr.send();
</script>
The code is not working. I really need your help
I am looking for a solution in which it is possible to preload a video file to the buffer. At the same time, change the src attribute of the video when the video is in the buffer. That is, upload a video and then insert or change the src attribute of the current video in the document. Is it possible to implement such a thing?