html5 自定播发器关键编码

日期:2021-02-25 类型:科技新闻 

关键词:制作小程序,小程序商城,扫码点餐小程序,微信小程序开店的步骤,牛刀小程序

网页页面html

拷贝编码
编码以下:

<body style="background-color:#8EEE5EE;">
<section id="skin">
<video id="myMovie" width="640" height="360">
<source src="videos/Introduction.mp4">
</video>
<nav>
<div id="buttons">
<button type="button" id="playButton">Play</button>
</div>
<div id="defaultBar">
<div id="progressBar"></div>
</div>
<div style="clear:both"></div>
</nav>
</section>
</body>

css款式

拷贝编码
编码以下:

body{
text-align:center;
}
header,section,footer,aside,nav,article,hgroup{
display:block;
}
#skin{
width:700px;
margin:10px auto;
padding:5px;
background:red;
border:4px solid black;
border-radius:20px;
}
nav{
margin:5px 0px;
}
#buttons{
float:left;
width:70px;
height:22px;
}
#defaultBar{
position:relative;
float:left;
width:600px;
height:14px;
padding:4px;
border:1px solid black;
background:yellow;
}
/*progressBar在defaultBar內部*/
#progressBar{
position:absolute;
width:0px; /*应用javascript操纵转变*/
height:14px; /*和defaultBar高宽比同样*/
background:blue;
}

javascript编码

拷贝编码
编码以下:

function doFisrt()
{
barSize=600; //留意不必应用px企业,且不必用var,是全局性自变量
myMovie=document.getElementById('myMovie');
playButton=document.getElementById('playButton');
bar=document.getElementById('defaultBar');
progressBar=document.getElementById('progressBar');
playButton.addEventListener('click',playOrPause,false); //第3个主要参数一直false, Register the event handler for the bubbling phase.
bar.addEventListener('click',clickedBar,false);
}
//操纵movie播发和终止
function playOrPause(){
if(!myMovie.paused && !myMovie.ended){
myMovie.pause();
playButton.innerHTML='Play';
window.clearInterval(updatedBar);
}else{
myMovie.play();
playButton.innerHTML='pause';
updatedBar=setInterval(update,500);
}
}
//操纵进度条的动态性显示信息
function update(){
if(!myMovie.ended){
var size=parseInt(myMovie.currentTime*barSize/myMovie.duration);
progressBar.style.width=size+'px';
}else{
progressBar.style.width='0px';
playButton.innerHTML='Play';
window.clearInterval(updatedBar);
}
}
//电脑鼠标点一下进度条操纵方式
function clickedBar(e){
if(!myMovie.paused && !myMovie.ended){
var mouseX=e.pageX-bar.offsetLeft;
var newtime=mouseX*myMovie.duration/barSize; //new starting time
myMovie.currentTime=newtime;
progressBar.style.width=mouseX+'px';
window.clearInterval(updatedBar);
}
}
window.addEventListener('load',doFisrt,false);

好物品啊,摘了编码一部分
上一篇:HTML5比照HTML4的关键更改和改善总结 返回下一篇:没有了