设置video js多视频连续播放
代码如下:
var vList = ['http://vjs.zencdn.net/v/oceans.mp4', 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4']; // 初始化播放列表
var vLen = vList.length; // 播放列表的长度
var curr = 0; // 当前播放的视频
var video = document.getElementById("example_video_1");
/*
var video = document.createElement("VIDEO");
video.setAttribute("width", "100%");
video.setAttribute("height", "500");
video.setAttribute("id", "example_video_1");
video.setAttribute("class", "video-js vjs-default-skin");
video.setAttribute("preload", "none");
video.setAttribute("poster", "video//demo.jpg");
video.setAttribute("data-setup", "{}");
video.setAttribute("controls", "yes");
document.getElementById("playervideo").appendChild(video);
*/
//document.body.appendChild(video);
video.addEventListener('ended', play);
play();
function play(e) {
video.src = vList[curr];
video.load();
video.play();
curr++;
if(curr >= vLen){
curr = 0; // 播放完了,重新播放
}
}