【軟體】我想在網頁隨機播放音樂,有人知道參數嗎





winiori
2003-11-05, 02:51 PM
<p align="center"><embed src="music\music.m3u"
align="baseline" border="0" width="165" height="17" autostart="True" shuffle="Ture"
controls="SMALLCONSOLE" loop="TRUE"><br>
上面是我的原碼




senliou
2003-11-06, 12:56 AM
轉貼於:
http://home.kimo.com.tw/yhw-yhw/html/music.html

*********************************************************************
<script language="JavaScript">

song = new Array(10);//Array(0)到Array(9)

song[0]="http://home.kimo.com.tw/yhw-yhw/Midi/feel";
song[1]="http://home.kimo.com.tw/yhw-yhw/Midi/01051";
song[2]="http://home.kimo.com.tw/yhw-yhw/Midi/moon";
song[3]="http://home.kimo.com.tw/yhw-yhw/Midi/lover";
song[4]="http://home.kimo.com.tw/yhw-yhw/Midi/alwayson";
song[5]="http://home.kimo.com.tw/yhw-yhw/Midi/CantHelpFallingInLove";
song[6]="http://home.kimo.com.tw/yhw-yhw/Midi/CarelessWhisper";
song[7]="http://home.kimo.com.tw/yhw-yhw/Midi/DustInTheWind";
song[8]="http://home.kimo.com.tw/yhw-yhw/Midi/IAlwaysLoveYou";
song[9]="http://home.kimo.com.tw/yhw-yhw/Midi/I'llBeThere";

singer = new Array(10);
singer[0]="現在撥放的歌是 心動";
singer[1]="現在撥放的歌是 廣島之戀";
singer[2]="現在撥放的歌是 月亮代表我的心";
singer[3]="現在撥放的歌是 梁祝";
singer[4]="現在撥放的歌是 Always on my mind";
singer[5]="現在撥放的歌是 Cant Help Falling In Love";
singer[6]="現在撥放的歌是 Careless Whisper";
singer[7]="現在撥放的歌是 Dust In The Wind";
singer[8]="現在撥放的歌是 I Always Love You";
singer[9]="現在撥放的歌是 I Be There";
now=new Date();
index=Math.floor(now.getSeconds()*10/60);
document.write("<center><font size='2'>"+singer[index]+"</font><br>")

document.write("<EMBED src="+song[index]+".mid
align="baseline" border="0" width="165" height="17" autostart="True" shuffle="Ture"
controls="SMALLCONSOLE" loop="TRUE"></center>")
</script>

*********************************************************************

senliou
2003-11-06, 01:45 AM
由於 HTML 的 embed 標籤並無此參數 , 所以必須要使用 JavaScript

我雖然不會寫 JavaScript ...@@ll....
但是還看得懂 , 稍微解釋一下吧 !

song = new Array(10);//Array(0)到Array(9)
=> 就是宣告 song 為從 0 到 9 的陣列
(兩條斜線後面是註解行 , 瀏覽器不會執行)

song[0] 到 song[9]
=> 儲存十首歌曲的 URL

singer
=> 一樣宣告為陣列 , 儲存十首歌曲的歌名以及資訊

now=new Date();
=> 宣告 now 為儲存時間的變數

index=Math.floor(now.getSeconds()*10/60);
=> 先用 now.getseconds() 取得系統時間的秒數 ,
除以 10 再乘以 60 , 再用 math.floor() 取最大整數值 (小於或等於)

document.write("<center><font size='2'>"+singer[index]+"</font><br>")
=> 先在網頁上顯示歌曲的歌名以及資訊

document.write("<EMBED src="+song[index]+".mid
align="baseline" border="0" width="165" height="17" autostart="True" shuffle="Ture"
controls="SMALLCONSOLE" loop="TRUE"></center>")

=> 最後用 embed 標籤在網頁上撥放音樂 ~~~

senliou
2003-11-06, 01:54 AM
如果你只要撥放歌曲 , 並不要顯示歌名
可以將 Script 簡化如下 :

<script language="JavaScript">

song = new Array(10);

song[0]="http://home.kimo.com.tw/XXXXXXX/Midi/feel";
song[1]="http://home.kimo.com.tw/XXXXXXX/Midi/01051";
song[2]="http://home.kimo.com.tw/XXXXXXX/Midi/moon";
song[3]="http://home.kimo.com.tw/XXXXXXX/Midi/lover";
song[4]="http://home.kimo.com.tw/XXXXXXX/Midi/alwayson";
song[5]="http://home.kimo.com.tw/XXXXXXX/Midi/CanInLove";
song[6]="http://home.kimo.com.tw/XXXXXXX/Midi/CarelessWhisper";
song[7]="http://home.kimo.com.tw/XXXXXXX/Midi/DustInTheWind";
song[8]="http://home.kimo.com.tw/XXXXXXX/Midi/IAlwaysLoveYou";
song[9]="http://home.kimo.com.tw/XXXXXXX/Midi/I'llBeThere";

now=new Date();
index=Math.floor(now.getSeconds()*10/60);

document.write("<p align="center"><EMBED src="+song[index]+".mid
align="baseline" border="0" width="165" height="17" autostart="True" shuffle="Ture"
controls="SMALLCONSOLE" loop="TRUE"></p><br>")
</script>

*********************************************************

(紅色的部分可以根據你有幾首歌來修改 , URL 改成自己的歌曲路徑就可以
, 記得陣列數為 10 就是從 0 到 9 , 陣列數 9 就是從 0 到 8 , 以此類推....)

(藍色的部分是歌曲的副檔名 , 如果是 *.wma 的話要改成 .wma)