Playing two videos in queue

那年仲夏 提交于 2019-12-11 12:13:11

问题


<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?


回答1:


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();
   };

Reference



来源:https://stackoverflow.com/questions/31201252/playing-two-videos-in-queue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!