html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-2.js"></script>
</head>
<body>
<video style="width: 300px; height: 300px;" id="myvideo" width="100%" height="auto" controls="controls" >
你的浏览器不支持HTML5播放此视频
<span style="white-space:pre"> </span><!-- 支持播放的文件格式 -->
<source src="video/first.mp4" type='video/mp4' />
</video>
</video>
<script language="javascript">
$(document).ready(function(){
video.play();
});
//注意这个路径是相对路径
var vList = ['video/first.mp4', 'video/a.mp4']; // 初始化播放列表
var vLen = vList.length;
var curr = 0;
var video = document.getElementById("myvideo");
video.addEventListener('ended', function(){
play();
});
function play() {
console.log("播完了"+vList[curr])
video.src = vList[curr];
video.load();
video.play();
curr++;
if(curr >= vLen){
curr = 0; //重新循环播放
}
}
</script>
</body>
</html>
js:
jquery类库