首页 > 代码库 > HTML5实现两个视频循环播放!

HTML5实现两个视频循环播放!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>循环播放</title>
</head>
<script type="text/javascript">
    window.onload = function(){
        var index = 0;
        var video = document.getElementById("videoID");
            video.onended = function() 
            {
                if(index){
                    index = 0;
                    video.src="222.mp4";
                }else{
                    index = 1;
                    video.src="221.mp4";
                }        
            };
    }
    
</script>
<body>
<video id="videoID" src="222.mp4" autoplay controls="controls" ></video>
</body>

HTML5实现两个视频循环播放!