<!doctype html>
<html>
<head>
<title>Sequential Movies</title>
<script type="text/javascript">
// listener function changes src
function myNewSrc() {
var myVideo = document.getElementsByTagName('video')[0];
myVideo.src = "2.m4v";
myVideo.load();
myVideo.play();
myVideo.addEventListener('ended', myAddListener, false);
}
// add a listener function to the ended event
function myAddListener(){
var myVideo = document.getElementsByTagName('video')[0];
myVideo.src = "1.m4v";
myVideo.load();
myVideo.play();
myVideo.addEventListener('ended', myNewSrc, false);
}
</script>
</head>
<body onload="myAddListener()">
<video controls
src="1.m4v">
</video>
</body>
</html>
看来问题是video1可以切换到video2,但video2不能切换回video1。如何编写脚本来循环 1 > 2 > 1 > 2 > 1 > 2 > 1?是否可以切换三个以上的视频源?我不知道底部链接在说什么,但它似乎对我有用。