首先将以下代码加入网页中:
<spanid="Text"></span>
functionCurrentPosition(){
if(document.winplayer.PlayState!=2)return;
cPos.style.pixelLeft=ToBarPosition(document.winplayer.CurrentPosition);
Text.innerHTML=ToPosition(winplayer.currentposition)+"/"+ToPosition(winplayer.Duration);
}
//保留两个小数
functionformat2(str)
{
str=Math.round(parseFloat(str)*100)/100
returnstr
}
functionToPosition(pos)
{
varlevelt;
levelt=((cmaxX-cminX)*pos)/document.winplayer.Duration;
levelt=(parseInt(levelt)+cminX)/60;
levelt=format2(levelt);
returnlevelt;
}
//以上是时间转换函数,如5.34,这后面的0.34相当于60*0.34=20秒,改进后的函数如下:
functionToPosition(pos)
{
varlevelt;
levelt=((cmaxX-cminX)*pos)/document.winplayer.Duration;
levelt=(parseInt(levelt)+cminX)/60;
levelt=parseInt(levelt)+":"+parseInt((format2(levelt)-parseInt(levelt))*60);
returnlevelt;
}