获取音乐文件的播放时间及当前进度
程序员文章站
2022-06-26 08:37:27
首先将以下代码加入网页中: function currentposi...
首先将以下代码加入网页中:
<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;
}
<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;
}
上一篇: Word宽屏模式如何变为窄屏模式回到自己熟悉的界面
下一篇: 1ting的歌词同步,所用到的代码