JavaScript实现视频轮流播放
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Video.js 7.4.1</title>
</head>
<body>
<div style="margin:10%">
<video id="myVideo" controls="controls" autoplay="autoplay" style="width:873px;height:453px" muted>
<source id="myVideo1" src="~/Areas/trailer.mp4" type="video/mp4" />
</video>
</div>
<script>
var md = document.getElementsByTagName("video")[0];
var s = Array('/Areas/movie1.MP4', '/Areas/trailer.mp4');//路径
var s1 = 0;
md.addEventListener("ended", function () {//属性返回音频/视频是否已结束。
console.log("结束");
md.load();//重新加载视频元素。
document.getElementById('myVideo1').src = '' + s[s1] + '';//清空路径
s1++;
if (s1 == s.length) {
s1 = 0;
}
})
</script>
</body>
</html>
效果图