mp3的自動連續播放以及探測是否可以播放、並對可以播放的結果進行儲存

來源:互聯網
上載者:User

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<link href="style/style.css" rel="stylesheet" type="text/css">

<script language="JavaScript">
var state;
var playlist;
var pplay=0;
var flag;
var find=0;
playlist = new Array();

var mp3name='老鼠愛大米';
playlist.push('http://202.206.96.204/homepage/homepageUsers/shipin/sucai/老鼠愛大米.mp3');
playlist.push('http://218.10.236.102/mp3/laosu.mp3');
playlist.push('http://www.korwoo.com.cn/download/songs/dami.mp3');
playlist.push('http://www.daqingit.com/yinyue/mp3/老鼠愛大米.mp3');
playlist.push('http://xxc1212.ahut.edu.cn/mid/4689.mp3');
playlist.push('http://www.klstudio.com/mp3/200492011225.mp3');
playlist.push('http://218.3.124.244/mp3/lsadm.mp3');
playlist.push('http://www.e-city.com.cn/200492011225.mp3');
playlist.push('http://www.panjin.net/df/08/mp3/mouse.mp3');
playlist.push('http://movie.games-daily.com/movie/mouse.mp3');
playlist.push('http://www.bgo.com.cn/class/music/mouselove.mp3');
playlist.push('http://www.00gg.net/photos/forum/楊臣剛-老鼠愛大米.mp3');
playlist.push('http://benhood.nease.net/blog/bg.mp3');
playlist.push('http://www.qiuqian108.com/hghx/%e8%80%81%e9%bc%a0%e7%88%b1%e5%a4%a7%e7%b1%b3%ef%bc%88%e6%9d%a8%e8%87%a3%e5%88%9a%ef%bc%89.mp3');
playlist.push('http://sxz.cslg.cn/cshb/mp3/lsadm.mp3');
playlist.push('http://www.ncdiy.com/news/mp3/ai.mp3');
playlist.push('http://www.webx.cn/mp3/老鼠愛大米.mp3');
playlist.push('http://md.jxufe.edu.cn/mdbbs/UploadFile/2004-10/200410521217630.mp3');
playlist.push('http://edu.tom.com/script/down/laoshuaidami.mp3');
playlist.push('http://218.65.74.218/club/forum/files/369.mp3');
playlist.push('');

//初始化
function playerinit()
{
 player.url=playlist[0];
 play();
 flag=setInterval("check()",10000);
}

//播放
function play()
{
 if (player.controls.isavailable('play'))
 {
  player.controls.play();
  //playerinfo.innerHTML = "正在載入。。。。"+player.url+"請稍侯";
 }
}

//暫停
function pause()
{
 if (player.controls.isavailable('pause'))
 {
  player.controls.pause();
  clearInterval(state);
  playerinfo.innerHTML = "暫停";
 }
}

//停止
function stop()
{
 if (player.controls.isavailable('stop'))
 {
  player.controls.stop();
  clearInterval(state);
  playerinfo.innerHTML = "停止";
 }
}

//前首
function previous()
{
 if (player.controls.isavailable( 'previous' ))
 {
  player.controls.previous();
  playerinfo.innerHTML = "前一首";
 }
}

//後首
function next()
{
 if (player.controls.isavailable( 'next' ))
 {
  player.controls.next();
  playerinfo.innerHTML = "下一首";
 }
}

//?
function step()
{
 if (player.controls.isavailable( 'step' ))
 player.controls.step( 1 );
}

//音量-
function voldown()
{
 if ( player.settings.volume < 5 )
 {
  player.settings.volume = 0;
  playerinfo.innerHTML = "0";
 }
 else
 {
  player.settings.volume -= 5;
  playerinfo.innerHTML = player.settings.volume;
 }
}

//音量+
function volup()
{
 if ( player.settings.volume > 95 )
 {
  player.settings.volume = 100;
  playerinfo.innerHTML = "100";
 }
 else
 {
  player.settings.volume += 5;
  playerinfo.innerHTML = player.settings.volume;
 }
}

//靜音
function mute()
{
 player.settings.mute = !player.settings.mute;
}

//聲道
function balance()
{
 switch (player.settings.balance)
 {
  case 0:
   player.settings.balance = 100;
   playerinfo.innerHTML = '左聲道';
   break;
  case 100:
   player.settings.balance = -100;
   playerinfo.innerHTML = '右聲道';
   break;
  case -100:
   player.settings.balance = 0;
   playerinfo.innerHTML = '全聲道';
   break;
  default :
   player.settings.balance = 0;
   playerinfo.innerHTML = '全聲道';
   break;
 }
}

//更新時間
function updatetime()
{
 playerinfo.innerHTML = player.controls.currentPositionString + " | " + player.currentMedia.durationString;
 setTimeout("updatetime()",1000);
}

function check()
{
 if (find)
 {
  clearTimeout(flag);
  //儲存結果
  return
 }
 if (pplay<playlist.length-1)
  pplay++;
 else
  pplay = 0;
 stop();
 player.url=playlist[pplay];
 play();
}

function GetPage(url)
{
 var xml = new ActiveXObject("Microsoft.XMLHTTP");
 xml.open("GET",url,false);
 xml.send();
 return unescape(xml.ResponseText);
}

</script>
</head>
<body >
<table width="300">
  <tr>
    <td><object id="player" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject" width="300" height="60">
      <param name="autoStart" value="true">
      <param name="balance" value="0">
      <param name="currentPosition" value="0">
      <param name="currentMarker" value="0">
      <param name="enableContextMenu" value="true">
      <param name="enableErrorDialogs" value="false">
      <param name="enabled" value="true">
      <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="uMode" value="none">
      <param name="volume" value="100">
    </object></td>
  </tr>
  <tr>
    <td><span id="playerinfo"></span></td>
  </tr>
</table>
<script language = "JavaScript"  for = player event = playstatechange(newstate)>
switch (newstate){
  case 1:
   playerinfo.innerHTML = "停止";
   break;
  case 2:
   playerinfo.innerHTML = "暫停";
   break;
  case 3:
   find=1;//表示可以收聽
   GetPage('save.asp?mp3name='+mp3name+'&mp3url='+player.url);
   playerinfo.innerHTML = "開始播放" + player.url;
   setTimeout("updatetime()",1000);
   break;
  case 4:
   playerinfo.innerHTML = "4";
   break;
  case 5:
   playerinfo.innerHTML = "5";
   break;
  case 6:
   playerinfo.innerHTML = "正在緩衝...";
   break;
  case 7:
   playerinfo.innerHTML = "7";
   break;
  case 8://完成
   playerinfo.innerHTML = "8";//在這裡播放下一首即可
   break;
  case 9:
   playerinfo.innerHTML = "正在串連"+player.url+"...";
   break;
  case 10:
   playerinfo.innerHTML = "準備就緒";
   playlist.splice(pplay,1);//刪除不能線上播放的
   stop();
   play();
   break;
  case 11:
   playerinfo.innerHTML = "11";
   break;
  default:
   playerinfo.innerHTML = "";
}
</script>

</body>
</html>



相關文章

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

Starter Package

SSD Cloud server and data transfer for only $2.50 a month

Get Started >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。