//当目前的播放位置已更改时触发
var chapteridopen="202305124987545454";//该字段为当前视频ID,根据需要自定义,保持唯一性。
var setTimeFlag = 1;//currentTime属性赋值次数 该字段用来记录上次播放进度
myVideo.addEventListener("timeupdate",function(){
if (setTimeFlag == 1){
if (localStorage.getItem('currentTime' +chapteridopen) != null){
var time = localStorage.getItem('currentTime' +chapteridopen);
myVideo.currentTime = time;
lastplayTime=time;
}
setTimeFlag = 2;
}
//获取当前播放位置的秒数,并设置localStorage
var currentTime = myVideo.currentTime;
localStorage.setItem('currentTime' +chapteridopen, currentTime)
});