-lsf

h5视频配置

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>视频播放</title>
</head>

<body>
<button onclick="getCurTime()" type="button">获得当前时间的位置</button>
<button onclick="setCurTime()" type="button">将时间位置设置为 5 秒</button>
<br />
<video width="500" height="300" controls="controls" id="video1">
    <source src="1110.mp4" type="video/mp4" />//图片地址
</video>
<div id="a">
试看结束!
</div>
</body>
<script>
myVid=document.getElementById("video1");
/*myVid.onplay = function()
{
    alert(1);
    
   if(myVid.currentTime=="5"){
   myVid.pause();
   }
};*/
//播放时间显示
myVid.ontimeupdate = function (){
var vTime = myVid.currentTime;
vTime=Math.floor(vTime);
//时间限制
if(vTime>=5){
    myVid.style.display="none";
    document.getElementById("a").style.display="block";
myVid.pause();
}
};
function getCurTime()
{     
  alert(myVid.currentTime);
myVid.pause();
}
function setCurTime()
{
  myVid.currentTime=5;
}
window.onload=function(){
document.getElementById("a").style.display="none";
}
</script>
</html>

分类:

技术点:

相关文章:

  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2021-05-06
  • 2021-09-22
  • 2021-07-06
猜你喜欢
  • 2021-12-04
  • 2022-02-06
  • 2022-01-07
  • 2021-10-25
  • 2021-12-02
  • 2021-06-16
  • 2022-12-23
相关资源
相似解决方案