一段简易代码,当然你也可以保存在服务器,加上视频ID,等等,自由发挥吧
下面代码是保存在本地。。。
<div class="div">
<video class="video000" id="myvideo" controls="controls" style="width: 6rem;height: 200px;">
<source src="12.mp4" type="video/mp4"></source>
</video>
</div>
<script type="text/javascript">
var video = document.getElementsByTagName('video')[0];
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>
评论 (0)