我有许多视频在同一个 HTML5 视频播放器中一一播放
HTML
<video id="homevideo" width="100%" autoplay autobuffer>
<source src="app/video1.mp4" type='video/mp4' />
</video>
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);
如果我在玩之前发出警报,它就会起作用。但是没有警报就不会。初始化第二个视频播放:
videoPlayer.src = nextVideo;
alert("a");
videoPlayer.play();