<video width="320" height="240" autoplay loop>
<source src="movie1.mp4" type="video/mp4">
<source src="movie2.mp4" type="video/mpr">
Your browser does not support the video tag.
</video>
上面的代码会一遍又一遍地播放movie1.mp4
。我想要实现的是一个接一个地播放这两个视频。我的意思是在玩movie1.mp4
之后,movie2.mp4
将会播放。
如何实现这一目标?
答案 0 :(得分:1)
您可以通过以下方式实现此目的:
<video id="homevideo" width="100%" autoplay onended="run()">
<source src="app/video1.mp4" type='video/mp4'/>
<source src="app/video2.mp4" type='video/mp4'/>
</video>
video_count =1;
videoPlayer = document.getElementById("homevideo");
function run(){
video_count++;
if (video_count == 4) video_count = 1;
var nextVideo = "app/video"+video_count+".mp4";
videoPlayer.src = nextVideo;
videoPlayer.play();
};