HTML5播放列表播放2个视频,4或5怎么样? [英] HTML5 Playlist plays 2 videos, How about 4 or 5?
问题描述
我可以使用Apple的代码顺序播放两个视频(并且没有停顿!)(参见第2-4节)......
I'm able to get two videos to play sequentially, (and without pause!) with this code from Apple, (see section 2-4)...
...但是完全失去了如何玩第3或第5个视频。麻烦的是我是一个Javascript noob :-(所以如果你想出来的话请尽可能多地分享你的代码。
...Yet completely lost as to how to play a 3rd or 5th video. Trouble is I'm a Javascript noob :-(, so if you figure this out please share as much of your code as possible.
推荐答案
第一个视频结束=>开始第二个视频
第二个视频结束=>开始第三个视频
第三个视频结束=>开始第四个视频
第四个视频结束=>开始第一个视频
The first video's ended => Start second video
The second video's ended => Start third video
The third video's ended => Start fourth video
The fourth video's ended => Start first video
它只是重新定义结束
事件处理程序不间断... < br>
您也可以使用从0开始的变量。每次增加它并将SRC设置为i%video_count
It's just redefining the ended
event handler nonstop...
You could also use a variable starting at 0. increment it each time and set SRC to i%video_count
var i = 0;
var sources = ["http://www.a.com/blargh.m4v", "http://www.b.com/blargh.m4v"];
videoElement.addEventListener('ended', function(){
videoElement.src = sources[(++i)%sources.length];
videoElement.load();
videoElement.play();
}, false);
...上面的代码假定视频已经在播放,就像你一样我们的例子
...The above code assumes the video is already playing onload, like your example
这篇关于HTML5播放列表播放2个视频,4或5怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!