Home > Back-end >  Js write music player initialization time display is nan, click on the following piece when time is
Js write music player initialization time display is nan, click on the following piece when time is

Time:09-25


Window. The onl oad=function ()
{
The function getTime () {
SetTimeout (function () {
Var duration=$(" # audio_src ") [0]. Duration;
If (isNaN (duration)) {
GetTime ();
}
The else {
Var music_time0=Math. Floor ($(" # audio_src ") [0]. Duration).
Var music_time=formatSeconds (music_time0);
$(" # time2 "). The HTML (music_time);
}
}, 10);
}
GetTime ();
Var lyric=[
{
"Name" : "confessions balloons,"
'img' : 'picture/img1. JPG,
'audio_src' : 'music/confessions balloon. Mp3,
'content':"00:00.00]告白气球\n[00:04.55]词:方文山 曲:周杰伦\n[00:09.23]演唱:周杰伦\n[00:13.67]我爱歌词网 www.5ilrc.com\n[00:22.92]塞纳河畔 左岸的咖啡\n[00:26.04]我手一杯 品尝你的美\n[00:28.95]留下唇印的嘴\n[00:31.98]\n[00:33.67]花店玫瑰 名字写错谁\n[00:36.76]告白气球 风吹到对街\n[00:39.61]微笑在天上飞\n[00:42.67]\n[00:43.07]你说你有点难追 想让我知难而退\n[00:48.98]礼物不需挑最贵 只要香榭的落叶\n[00:54.38]营造浪漫的约会 不害怕搞砸一切\n[00:59.69]拥有你就拥有 全世界\n[01:04.26]\n[01:04.54]亲爱的 爱上你 从那天起\n[01:10.98]甜蜜的很轻易\n[01:14.96]亲爱的 别任性 你的眼睛\n[01:21.76]在说我愿意\n[01:25.68]\n[01:30.54]LRC编辑:Love QQ:8178617\n[01:44.12]\n[01:48.18]塞纳河畔 左岸的咖啡\n[01:51.36]我手一杯 品尝你的美\n[01:54.31]留下唇印的嘴\n[01:57.44]\n[01:59.09]花店玫瑰 名字写错谁\n[02:01.71]告白气球 风吹到对街\n[02:04.78]微笑在天上飞\n[02:07.97]\n[02:08.31]你说你有点难追 想让我知难而退\n[02:14.33]礼物不需挑最贵 只要香榭的落叶\n[02:19.62]营造浪漫的约会 不害怕搞砸一切\n[02:25.01]拥有你就拥有 全世界\n[02:29.60]\n[02:29.90]亲爱的 爱上你 从那天起\n[02:36.48]甜蜜的很轻易\n[02:40.44]亲爱的 别任性 你的眼睛\n[02:47.09]在说我愿意\n[02:50.80]\n[02:51.29]亲爱的 爱上你 恋爱日记\n[02:57.70]飘香水的回忆\n[03:01.53]一整瓶 的梦境 全都有你\n[03:08.39]搅拌在一起\n[03:12.34]亲爱的别任性 你的眼睛\n[03:20.33]在说我愿意"
},
{
'name' : "idle away one's",
'img' : 'picture/img1. JPG,
'audio_src' : 'music/idle away one's. Mp3,
'content' : "00:01onsaturday (UK time). 92] lyrics for"
}
]
Var play_btn=document. GetElementById (" play_btn ");
Var prev_btn=document. GetElementById (" prev_btn ");
Var next_btn=document. GetElementById (" next_btn ");
Var audio=document. GetElementsByTagName (" audio ") [0];
Var initTime=document. GetElementsByTagName (" time ") [0];
Var time=document. GetElementsByTagName (" time ") [1].
Var progress_bar=document. GetElementById (" progress_bar ");
Var progress_cube=document. GetElementById (" progress_cube ");
Var vol_bar=document. GetElementById (" vol_bar ");
Var vol_cube=document. GetElementById (" vol_cube ");
Var lyric_con=document. GetElementById (" lyric_con ");
Var lyric_txt=document. GetElementById (" lyric_txt ");
Var photo_pic=document. GetElementById (" photo_pic ");
Var icon1=document. GetElementById (" icon1 ");
Var icon2=document. GetElementById (" icon2 ");
Var lyric_tit=document. GetElementById (" lyric_tit ");
Var list_con=document. GetElementById (" list_con ");
Var list_item=list_con. GetElementsByTagName (" p ");
Var songIndex=0;
Var container=document. GetElementById (" container ");
Var obj.
The function config ()
{
Enclosing play_mark=true;
This. Duration=audio. Duration;
Enclosing play_btn="& amp; # xe60e; ";
This. Vol.=audio volume;
This. The timer=null;
Enclosing rotateSum=0;
Enclosing icon1=icon1. InnerHTML;
Enclosing icon2=icon2. InnerHTML;
This. Icon1_co=icon1. Style. Color;
Enclosing endplay_btn="& amp; # xe60c; ";
Enclosing endicon1=icon1. InnerHTML;
Enclosing endicon2="& amp; # xe674; ";
}

Obj=new config ();
//list control

Var allSong="";
For (var song=0; Song{
AllSong +="& lt; P>" + lyric [song]. Name + "& lt;/p>"
}
List_con. InnerHTML=allSong;
List_con. Style. Height=lyric. Length * 30 + "px";
For (var listIndex=0; ListIndex{
List_item [listIndex] index=listIndex;
List_item [listIndex] onclick=function (ev)
{
Var ev=ev | | window. The event;
Ev. StopPropagation ();
SongIndex=this. The index;
Change_music ();
}
}
List_con. Style. The display="none";
List. The onclick=function ()
{
If (list_con. Style. The display=="none")
{
List_con. Style. The display="block";
}
The else {
List_con. Style. The display="none";
}
}
//the song
Next_btn. Onclick=function () {
SongIndex++;
Change_music ();
}
Prev_btn. Onclick=function () {
SongIndex -;
Change_music ();
}
The function change_music ()
{
ClearInterval (obj. Timer);
If (songIndex>=lyric. Length)
{songIndex=0}
Else if (songIndex<0)
{songIndex=lyric. Length}
Obj=new config ();
Iconinit ();
AudioInit ();
PlayedTime ();
Lyric_ctrl ();
}
//initialize the total length, volume, etc.
The function audioInit ()
{

Time. InnerHTML=format (audio. Duration).
Audio. Volume=0.5;
Play_btn. InnerHTML=obj. Play_btn;
Vol_cube. Style. Left=audio. Volume * vol_bar offsetWidth + "px";
Lyric_tit. The innerText=lyric [songIndex]. Name;
Photo_pic. Style. Background="url (" + lyric [songIndex]. Img +") ";
audio.src=https://bbs.csdn.net/topics/lyric [songIndex] audio_src;
Progress_cube. Style. Left=0;

}

AudioInit ();
//play time
Audio. AddEventListener (" timeupdate ", function ()
{
PlayedTime ();

}
)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related