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