我在一个页面上有几个 html5 视频。当我第一次进入页面时,它们加载正确 - 我可以看到正确的帧大小,播放视频等。转到另一个页面并返回视频页面后,帧不够高,视频也没有播放,不进入全屏等。
在我看来,这与视频加载有关。我尝试使用 onloadeddata 但没有成功(不过我可能用错了,这里是新手)。
有什么办法可以强制加载视频吗?就像一个循环检查视频是否已加载,如果没有加载它们?
更新:这是代码。
var content = '';
var index;
$.post('api/getVideo.php', {id: id}, function(data) {
//console.log(data);
for (index = 0; index < data.length; index++) {
content = content + '<div class="col-md-6 video-col"> <button id="play" class="full-play-button"><i class="fa fa-play"></i></button>' +
'<video id="video1" class="video-small"> <source src="'+data[index]["Path"] + '"type="video/'+data[index]["Typ"]+'" class="video-file"> </video><h3 class="video-title">'+
data[index]["Tytul"]+'</h3></div>';
}
}, "json");
最佳答案
您的源标记中可能有拼写错误。尝试将“type=video/”更改为“type=video/”。现代浏览器不再需要 type 属性,因此请尝试完全删除 '"type="video/'+data[index]["Typ"]+'。我没有足够的信息来测试您的代码,但看起来像是语法错误。
关于javascript - 如何强制完全加载 html5 视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24693012/