<!--文件命名为music.htm-->
<body style="margin:0"> <div style="display:none"> <OBJECT ID="player" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject" Standby="Loading.... Microsoft Windows Media Player" width="0" height="0" style="position:relative;top=1;width:100%;height:100%;"> <param name="autoStart" value="true"> <param name="balance" value="0"> <param name="baseURL" value=""> <param name="currentPosition" value="0"> <param name="currentMarker" value="0"> <param name="enableContextMenu" value="false"> <param name="enableErrorDialogs" value="false"> <param name="fullScreen" value="false"> <param name="invokeURLs" value="false"> <param name="mute" value="false"> <param name="playCount" value="1"> <param name="rate" value="1"> <param name="stretchToFit" value="true"> <param name="uiMode" value="none"> <param name="volume" value="80"> </OBJECT> </div> <script language="javascript"> var i,t=null,tidTLab=null; var n = new Array(); var myPlayer = document.getElementById("player") n[0] = " http://www.ytblog.net/blog_musfile/313634577.wma"; n[1] = " http://www.cs37zx.com/zongwu/dianjiao/images/完美.mp3"; n[2] = " http://music.bsdcn.net/music/为什么相爱的人不能在一起.wma"; n[3] = " http://www.casterdance.com/movie/music/3just_one_last_dance.mp3"; n[4] = " http://218.85.138.147/media/music/audio/200604/haizi.mp3"; function act(s) { switch(s){ case 1: myPlayer.controls.play(); break; case 2: myPlayer.controls.stop(); break; } tidTLab=setInterval('msg()',1000); } function stop(){myPlayer.controls.stop();msg();} function pre() { i-=1; if(i<0){alert("这已是第一首歌");clearInterval(tidTLab);} else{ myPlayer.controls.stop(); myPlayer.URL=n[i]; myPlayer.controls.play(); tidTLab=setInterval('msg()',1000); } } function next() { i+=1; if(i>=n.length){ myPlayer.controls.stop(); clearInterval(tidTLab); } else{ myPlayer.URL=n[i]; myPlayer.controls.play(); tidTLab=setInterval('msg()',1000); } } function init(){i=0;myPlayer.URL=n[0];myPlayer.controls.play();tidTLab=setInterval('msg()',1000);} init(); function msg() { if(i<n.length){ stime.innerHTML=" <input type=button disabled value='"+myPlayer.controls.currentPositionString + " | " + myPlayer.currentMedia.durationString + " | 第" + (i+1)+"/"+n.length+"首'>";} if(myPlayer.PlayState==1 && i<n.length){next();clearInterval(tidTLab);} } </script> <input name="pre" type="button" value="上一首" οnclick="pre(0)"> <input name="play" type="button" value="播放" οnclick="act(1)"> <input name="stop" type="button" value="停止" οnclick="act(2)"> <input name="next" type="button" value="下一首" οnclick="next(1)"> <div id="stime" style="z-index:-1;position:absolute"></div> </body> |
网页实现歌曲连播(Js+MediaPlayer)
最新推荐文章于 2023-02-28 19:45:54 发布