相关疑难解决方法(0)

HTML5视频循环src更改结束播放功能无法正常工作

我在同一个HTML5视频播放器中逐个播放了许多视频

HTML

<video id="homevideo" width="100%" autoplay autobuffer>
    <source src="app/video1.mp4" type='video/mp4' />
</video>
Run Code Online (Sandbox Code Playgroud)

JS

video_count = 1;
videoPlayer = document.getElementById("homevideo");
videoPlayer.addEventListener("ended", function (){
    video_count++;
    if (video_count == 4) video_count = 1;
    var nextVideo = "app/video" + video_count + ".mp4";
    videoPlayer.src = nextVideo;
    videoPlayer.play();
}, false); 
Run Code Online (Sandbox Code Playgroud)

如果我在播放之前发出警报,它就会起作用.但没有警报就没有了.初始化第二个视频播放:

videoPlayer.src = nextVideo;
alert("a");
videoPlayer.play();
Run Code Online (Sandbox Code Playgroud)

javascript html5 html5-video

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

html5 ×1

html5-video ×1

javascript ×1