var video22 = document.getElementById("video22");var intervalID = null;var time = 0;var speed = 15;
video22.onloadedmetadata = function() { var duration = video22.duration;
intervalID = setInterval(function(){
time++; if (time / speed <= duration){
video22.currentTime = time / speed;
}else{
clearInterval(intervalID);
intervalID = null;
}
},1000 / speed);
};
video22.addEventListener('click', function(){
clearInterval(intervalID);
intervalID = null; this.play();
});想問一下這個如果這個code如果有很多視頻我該如何簡化呢因為這樣有幾個視頻就要幾段這樣的code
1 回答
肥皂起泡泡
TA贡献1829条经验 获得超6个赞
var list=docuemnt.querySeclectotAll("video");
for(var i=0,len=list.length;i<len;i++){
list[i].onloadedmetadata=function(){
.....
}
list[i].addEventListener('click', function(){
...
})
}
这样?
添加回答
举报
0/150
提交
取消