排队播放两个视频 [英] Playing two videos in queue

查看:72
本文介绍了排队播放两个视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <视频宽度="320" height ="240"自动播放循环>< source src ="movie1.mp4" type ="video/mp4">< source src ="movie2.mp4" type ="video/mpr">您的浏览器不支持视频标签.</video> 

上面的代码将一遍又一遍地播放 movie1.mp4 .我想要实现的是依次播放这两个视频.我的意思是在播放 movie1.mp4 之后,接下来将播放 movie2.mp4 .

如何实现?

解决方案

您可以通过以下方法对此进行归档:

 < 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");函数run(){video_count ++;如果(video_count == 4)video_count = 1;var nextVideo ="app/video" + video_count +.mp4";videoPlayer.src = nextVideo;videoPlayer.play();}; 

参考

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

解决方案

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

这篇关于排队播放两个视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆