首先將以下代碼加入網(wǎng)頁中:
<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) ;
}
//保留兩個小數(shù)
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;
}
//以上是時間轉換函數(shù),如5.34,這后面的0.34相當于60*0.34=20秒,改進后的函數(shù)如下:
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;
}
更多信息請查看IT技術專欄