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>