Reputation: 884
<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>
The code above will play movie1.mp4
over and over again. What I want to achieve is to play those two videos one after the other. I mean after playing movie1.mp4
, the movie2.mp4
will play next.
How to achieve this?
Upvotes: 1
Views: 2718
Reputation: 330
You can archieve this by doing:
<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();
};
Upvotes: 2