我正在尝试使用媒体源 api 流式传输“webm”视频,我正在关注演示代码“ http://html5-demos.appspot.com/static/media-source.html ”。我没有收到任何错误,但没有玩。
这是我的代码
var type=entry.type; // it is always "video/webm"
var video=document.createElement("video");
var mediaSource = new MediaSource();
video.src = window.URL.createObjectURL(mediaSource);
mediaSource.addEventListener('webkitsourceopen', function(e) {
var sourceBuffer = mediaSource.addSourceBuffer(type+';codecs="vorbis,vp8"');
var obj=get({path:entry.path,request:"read"}); // this is my server get
obj.onstarted=function(url){
self.showVideo(video,url);
};
obj.onBlobRecieved=function(chunk){
//chunk is a blob
sourceBuffer.append(new Uint8Array(chunk));
}
obj.oncomplete=function(url){
video.play(); // for testing play on complete
}
},false);
我是调试代码,sourcebuffer总是返回长度0;
如何解决?