console
<!DOCTYPE HTML PUBliC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<head>
<Title>tttt</Title>
<Meta http-equiv="pragma" content="no-cache">
<Meta http-equiv="cache-control" content="no-cache">
<Meta http-equiv="expires" content="0">
<Meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<Meta http-equiv="description" content="This is my page">
<Meta charset="utf-8">
</head>
<body>
<div class="container">
<input type="file" ID="file" onchange="playMedia(5,10)">第5秒开始-10秒时暂停
<br >
<br >
<button onclick="setCurrentTime(7)" type="button">从第7秒开始播放</button>
<input type="text" ID="showTime"/>
<br >
<br >
<vIDeo ID="vIDeo1" autoplay="autoplay" controls >
</vIDeo>
</div>
</body>
<script>
var myVID=document.getElementById("vIDeo1");
myVID.addEventListener("timeupdate",timeupdate);
var _endTime;
//视频播放
function playMedia(startTime,endTime){
//设置结束时间
_endTime = endTime;
var file = document.getElementById("file").files[0];
if(!file){
alert("请指定视频路径");
return false;
}
//var url = (window.URL) ? window.URL.createObjectURL(file) : window.webkitURL.createObjectURL(file);
var url = "https://tuzhanai01.oss-cn-shenzhen.aliyuncs.com/captcha-demo-slide//Screen%20Recording%202022-05-26%20at%2011.41.01.mov"
myVID.src = url;
myVID.controls = true;
setTimeout("setCurrentTime('"+startTime+"')",200);
}
//设置视频开始播放事件
function setCurrentTime(startTime){
myVID.currentTime=startTime;
myVID.play();
}
function timeupdate(){
//因为当前的格式是带毫秒的float类型的如:12.231233,所以把他转成String了便于后面分割取秒
var time = myVID.currentTime+"";
debugger;
document.getElementById("showTime").value=time;
var ts = time.substring(0,time.indexOf("."));
if(ts==_endTime){
myVID.pause();
}
}
</script>
</HTML>