<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>
上面是我的原碼
可列印頁面
<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>
上面是我的原碼
轉貼於:
[url]http://home.kimo.com.tw/yhw-yhw/html/music.html[/url]
*********************************************************************
<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>
*********************************************************************
由於 HTML 的 embed 標籤並無此參數 , 所以必須要使用 JavaScript
我雖然不會寫 JavaScript ...@@ll....
但是還看得懂 , 稍微解釋一下吧 !
[b]song = new Array(10);//Array(0)到Array(9)[/b]
=> 就是宣告 song 為從 0 到 9 的陣列
(兩條斜線後面是註解行 , 瀏覽器不會執行)
[b]song[0][/b] 到 [b]song[9][/b]
=> 儲存十首歌曲的 URL
[b]singer[/b]
=> 一樣宣告為陣列 , 儲存十首歌曲的歌名以及資訊
[b]now=new Date();[/b]
=> 宣告 now 為儲存時間的變數
[b]index=Math.floor(now.getSeconds()*10/60);[/b]
=> 先用 [b]now.getseconds()[/b] 取得系統時間的秒數 ,
除以 10 再乘以 60 , 再用 math.floor() 取[b]最大整數值[/b] (小於或等於)
[b]document.write("<center><font size='2'>"+singer[index]+"</font><br>")[/b]
=> 先在網頁上顯示[b]歌曲的歌名以及資訊[/b]
[b]document.write("<EMBED src="+song[index]+".mid
align="baseline" border="0" width="165" height="17" autostart="True" shuffle="Ture"
controls="SMALLCONSOLE" loop="TRUE"></center>")[/b]
=> 最後用 embed 標籤在網頁上撥放音樂 ~~~
如果你只要撥放歌曲 , 並不要顯示歌名
可以將 Script 簡化如下 :
[b]<script language="JavaScript">
song = new Array([color=red]10[/color]);
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[[color=red]9[/color]]="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]+"[color=blue].mid[/color]
align="baseline" border="0" width="165" height="17" autostart="True" shuffle="Ture"
controls="SMALLCONSOLE" loop="TRUE"></p><br>")
</script>[/b]
*********************************************************
([color=red]紅色[/color]的部分可以根據你有幾首歌來修改 , URL 改成自己的歌曲路徑就可以
, 記得陣列數為 10 就是從 0 到 9 , 陣列數 9 就是從 0 到 8 , 以此類推....)
([color=blue]藍色[/color]的部分是歌曲的副檔名 , 如果是 *.wma 的話要改成 [color=blue].wma[/color])