Javascript Music Player


  <object id="darkplayer" codeBase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" type="application/x-oleobject" height="0" standby="Loading Microsoft Windows Media Player components..." width="0" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95">
  <param NAME VALUE>
  <param NAME="ShowControls" VALUE="0">
  <param NAME="ShowStatusBar" VALUE="0">
  <param NAME="ShowDisplay" VALUE="0">
  <param NAME="DefaultFrame" VALUE="Slide">
  <param NAME="Autostart" VALUE="1">
  <param NAME="Loop" VALUE="True">
  </object>
  <script language="JavaScript">
  <!--
  var playstate = 1;shuffle = 1; musicid = 1;// set to 0 to always play first song in list
  // set to 1 to randomly choose the first song to play
  songsTitle = new Array();
  songs=new Array();

  songsTitle[0] = "i wanna be sedated - the ramones";
  songsTitle[1] = "close to me - the cure";
  songsTitle[2] = "great romance of the 20th century - tbs";
  songsTitle[3] = "how does it feel - sugarcult";
  songsTitle[4] = "santeria - sublime";
  songsTitle[5] = "rape me - nirvana";
  songsTitle[6] = "sincerely me - new found glory";

  songs[0]="/test/jemapel.mp3";
  songs[1]="/test/a_thousand_miles.mp3";
  songs[2]="/test/Born Too Slow.mp3";
  songs[3]="/test/Holly Valance - Kiss Kiss.mp3";
  songs[4]="/test/hudie.mp3";
  songs[5]="/test/jemapel.mp3";
  songs[6]="/test/Keane - Somewhere Only We Know.mp3";

  function play(id){
   if (playstate == 2) {
    document.darkplayer.Play();
   }
   else {
    var snum = id;
    document.darkplayer.FileName = songs[snum];
    document.darkplayer.scr = songs[snum];
    document.all['musicTitle'].innerHTML = "";
    document.all['musicTitle'].innerHTML = songsTitle[snum];
   }
   playstate = 1;
  }

  function playPrevious(){
   if (musicid - 1 < 0)
    musicid = 0
   else
    musicid --;
   play(musicid);
  }

  function playNext(){
   if (musicid + 1 >= songs.length)
    musicid = songs.length - 1;
   else
    musicid ++;
   play(musicid);
  }
  //-->
  </script>
  <table width=210 height=43 border=0 cellpadding=0 cellspacing=0>
  <tr>
   <td height=5 colspan=8></td>
  </tr>
  <tr>
   <td width=31 height=17 background=images/bgm_00.gif></td>
   <td width=100 height=17 background=images/bgm_01.gif>
   <marquee direction="left" scrollamount=2><Div id="musicTitle">一个家庭主妇永远有做不</Div></marquee>
   </td>
   <td width=2 height=17></td>
   <td width=13 height=17>
   <input type="image" src=images/bgm_02.gif border=0 OnClick="playPrevious();">
   </td>
   <td width=13 height=17>
   <input type="image" src=images/bgm_03.gif border=0 OnClick="play();">
   </td>
   <td width=13 height=17>
   <input type="image" src=images/bgm_04.gif border=0 OnClick="document.darkplayer.Pause(); playstate=2;">
   </td>
   <td width=13 height=17>
   <input type="image" src=images/bgm_05.gif border=0 OnClick="playNext();">
   </td>
   <td width=13 height=17>
   <input type="image" src=images/bgm_06.gif border=0 OnClick="document.darkplayer.Pause(); playstate=2;">
   </td>
   <script language="JavaScript">
   if (shuffle == 1) {
    //var randsg = Math.floor(Math.random()*songs.length);
    musicid = 4;
    document.darkplayer.FileName = songs[musicid];
    document.darkplayer.scr = songs[musicid];
    document.all['musicTitle'].innerHTML = "";
    document.all['musicTitle'].innerHTML = songsTitle[musicid];
   }
   </script>
  </tr>
  <tr>
   <td height=21 colspan=8></td>
  </tr>
  </table>

posted @ 2004-10-27 17:39  活力豆  阅读(644)  评论(0)    收藏  举报