我正在尝试使用Video.js更改HTML 5视频的来源。
来源正在改变,我可以点击播放,它会播放视频,但我需要视频才能播放。特别是loadedalldata
事件。
我已经阅读了api documentation并且它表明,我所做的事情应该有效(根据我的理解。)。
Javascript:
var player = _V_('video'),
video = [{
"type": "video\/mp4",
"src": "http:\/\/mabuse.dev\/assets\/videos\/testVideo.mp4"
}, {
"type": "video\/webm",
"src": "http:\/\/mabuse.dev\/assets\/videos\/testVideo.webm"
}, {
"type": "video\/ogg",
"src": "http:\/\/mabuse.dev\/assets\/videos\/testVideo.ogv"
}, {
"type": "video\/flv",
"src": "http:\/\/mabuse.dev\/assets\/videos\/testVideo.flv"
}];
/* Add sources to new player */
player.src(video);
/* Remove loader & play video once loaded */
player.on("loadedalldata", function(){
console.log('test');
//app.player.play();
});
HTML:
<video class="video-js" id="video" controls preload="none" width="572" height="356" data-setup="{}"></video>
答案 0 :(得分:1)
尝试收听直接从视频元素发送的类似事件。
document.querySelector("#video").addEventListener("canplaythrough", onLoaded)