I have two videos: v11.webm and v12.webm.
What I want is that these two videos should work without problems.
I follow the api application of the media source to add data to the source buffer.
I mean the demo in this link
I modified this example and removed some of the fragmentation of the video, and also tried to add data to the source buffer file.
My code is as follows:
<script> var video = document.querySelector('video'); window.MediaSource = window.MediaSource || window.WebKitMediaSource; if (!!!window.MediaSource) { alert('MediaSource API is not available'); } var mediaSource = new MediaSource(); video.src = window.URL.createObjectURL(mediaSource); mediaSource.addEventListener('webkitsourceopen', function(e) { var sourceBuffer = mediaSource.addSourceBuffer('video/webm; codecs="vorbis,vp8"'); for(i=1;i<=2;i++) { (function(i){ GET('v1'+i+'.webm', function(uInt8Array) { var file = new Blob([uInt8Array], {type: 'video/webm'}); var reader = new FileReader(); reader.onload = function(e) { sourceBuffer.append(new Uint8Array(e.target.result)); }; reader.readAsArrayBuffer(file); }); })(i); } }, false); mediaSource.addEventListener('webkitsourceended', function(e) { logger.log('mediaSource readyState: ' + this.readyState); }, false); function GET(url, callback) { </script>
Currently, the code does not work as desired.
There is an inconsistent mix of v11.webm and v12.webm files.
It works without a glitch.
javascript api html5 video streaming
Pankaj khurana
source share