视频断点播放:h5+jquery

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<script type="text/javascript" src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js" ></script>
	<body>      
	    <video id="myvideo" width="80%" height="80%" controls="controls" poster="img/cars.png">
	    	<source src="mycdn/bfcs.mp4" type="video/mp4">
	    </video>
	    <script type="text/javascript">
	        var video = document.getElementById('myvideo');
	        var currentTime = localStorage.getItem("currentTime");
	        console.log(currentTime);
	        video.addEventListener("loadedmetadata",function(){
	            this.currentTime = currentTime;
	        });
	        video.addEventListener("timeupdate",function(){
	            var currentTime = Math.floor(video.currentTime);
	            localStorage.setItem("currentTime",currentTime);
	            console.log(localStorage.getItem("currentTime"));
	        });
	    </script> 
	</body>
</html>
posted @ 2021-02-19 11:02  striver-sc  阅读(131)  评论(0编辑  收藏  举报