MidiPlayerとWeb_Jukeがある。前者はJavaスクリプト、後者はPerlで書かれている。一長一短だが基本はおなじである。自動演奏だけのシンプルなJavaスクリプトもある。
・midi形式の曲を登録して、選曲・演奏できる。MidiPlayerをクリックすると180x80のポップアップ・ウィンドウに表示される。
・演奏したい曲は、select.htmのなかのスクリプトに直接書く。qmid:midiファイル名、qname:曲名(演奏画面に表示される)、qtime:演奏時間を秒単位で書く(この間隔で自動的につぎの曲の演奏に移る)
【参考】
・日本のhttp://CGIScriptMarket.com/から無料配布されているWeb_JukeはPerlで書かれており、プラグイン・プレイヤにYamahaを使っている。このサイト(http://www.yamaha.co.jp/xg/)は2004年3月に閉鎖された。ただし、Web_JukeのCGIは問題なく動作する。ただし、演奏開始のたびに「ActiveX・・・」を聞いてくるのが煩わしい。
・MidiPlayerでは、Web_Jukeにはない連続演奏の機能があるのがよい。一方、Web_Jukeでは曲の登録・削除がオンラインでできるので便利である。
・曲のmidiファイルを登録するだけで連続してすべてを演奏するスクリプトはこちらです。
・Javascript Kitサイト(http://www.javascriptkit.com/)から提供されており、個人的に改造し使用できる。
・下記のスクリプトをHEADに書いたHTMLファイルとselect.htmをおなじフォルダーに保存する。
・このままだと演奏のたびにブラウザーがActiveXを使うか?と聞いてわずらわしい。スクリプト部分を別のmidiplayer.jsファイルにおいて呼び出すように改造する。
Copy the below code into the <head> section of your page
<SCRIPT>
/*written by The Omega
// http://www.geocities.com/Area51/Corridor/4381
// the_omega@geocities.com
// You must leave these comments in to use the script
// (hey, I wrote it. Let me have a little credit!)
*/
window.open("select.htm","OmegaMidiPlayerWin","width=180,height=80")
//-->
</SCRIPT>
Copy the below and save it as "select.htm". This file should be placed in the same directory as the images above:
<HTML>
<HEAD>
<BODY onLoad="setdone()">
<SCRIPT>
<!-- written by The Omega
// http://www.geocities.com/Area51/Corridor/4381
// the_omega@geocities.com
// You must leave these comments in to use the script
// (hey, I wrote it. Let me have a little credit!)
var qmid=new Array();
var qname=new Array();
var qtime=new Array();
qtime[0]=.1 // Do NOT change this line
numsongs=3 // Change the 3 to equal the number of songs above
qmid[1]="../midi/90291.mid" // The filename of the first song
qname[1]="90210 Theme" // The name of the first song
qtime[1]=100 // The number of seconds the first song lasts
qmid[2]="../midi/baywatch.mid" // ditto for the second song
qname[2]="Baywatch Theme"
qtime[2]=120
qmid[3]="../midi/chicagobull.mid" // and for the third...
qname[3]="Chicago Bulls Theme"
qtime[3]=60
/* To add more songs, just repeat the above three lines
and increase the number in [brackets] by one each time.
Also, don't forget to update numsongs above! */
function rndsong(){
var today=new Date();
today=today.getTime()/10;
today=(today%numsongs)+1;
location.href="select.htm?"+today+"x0"}
function playsong(today){
window.location.href="select.htm?"+today+"x0"}
function continuous(){
var today=new Date();
today=today.getTime()/10;
today=(today%numsongs)+1;
document.location="select.htm?0x"+today}
function nextsong(){
if(!done){
window.setTimeout("nextsong()",100)}
else{
var today=new Date();
today=today.getTime()/10;
today=(today%numsongs)+1;
document.location="select.htm?"+song2+"x"+today}}
function fastforward(){
if(done)
nextsong()}
function setdone(){
done=true}
done=false;
song1=0;song2=0;
param=location.search;
if(param.length>3){
n=param.substring(1,param.length);
p=n.indexOf("x");
song1=parseInt(n.substring(0,p));
song2=parseInt(n.substring(p+1,n.length))}
player='<CENTER><NOBR><EMBED SRC="'+qmid[song1]+'" WIDTH=144 HEIGHT=60 AUTOSTART=TRUE><BR>';
stopbut='<A HREF="select.htm" onMouseOver=\'window.status="Stop Song";return true\' onMouseOut=\'window.status="";return true\'><IMG SRC="stopsong.gif" WIDTH=15 HEIGHT=13 BORDER=0 ALIGN=RIGHT ALT="Stop Song"></A>';
songname='<FONT SIZE=1>'+qname[song1]+'</FONT></NOBR></CENTER>';
ffbut='<A HREF="javascript:;" onClick="fastforward();return false" onMouseOver=\'window.status="Next Song";return true\' onMouseOut=\'window.status="";return true\'><IMG SRC="nextsong.gif" WIDTH=15 HEIGHT=13 BORDER=0 ALIGN=RIGHT ALT="Next Song"></A>';
cacher='<EMBED SRC="'+qmid[song2]+'" HIDDEN=true AUTOSTART=false>';
if(song2==0){
ffbut='';
cacher=''}
if(song1==0){
player='<CENTER>Loading file<BR>Please wait...<BR><FONT SIZE=2>Script by <A HREF="mailto:the_omega@geocities.com">The Omega</A></CENTER>';
ffbut='';
stopbut='';
songname=''}
if((song1==0)&&(song2==0)){
document.writeln('<FORM NAME="songs"><NOBR>Choose a song:<BR><SELECT NAME="song">')
for(i=1;i<=numsongs;document.writeln("<OPTION>"+qname[i++]));
document.writeln('</SELECT><BR><A HREF="javascript:playsong(document.songs.song.selectedIndex+1);" onClick="playsong(document.songs.song.selectedIndex+1);return false;" onMouseOver=\'window.status="Play Song\";return true\' onMouseOut=\'window.status="";return true\'><IMG SRC="playsong.gif" WIDTH=50 HEIGHT=30 BORDER=0 ALT="Play Song"></A><A HREF="javascript:rndsong();" onClick="rndsong();return false;" onMouseOver=\'window.status="Random Song";return true\' onMouseOut=\'window.status="";return true\'><IMG SRC="randsong.gif" WIDTH=50 HEIGHT=30 BORDER=0 ALT="Random Song"></A><A HREF="javascript:continuous();" onClick="continuous();return false;" onMouseOver=\'window.status="Continous Play";return true\' onMouseOut=\'window.status="";return true\'><IMG SRC="contplay.gif" WIDTH=50 HEIGHT=30 BORDER=0 ALT="Continuous Play"></A></NOBR>')}
else{
document.writeln(player+ffbut+stopbut+cacher+songname)}
if(song2!=0){
window.setTimeout("nextsong()",qtime[song1]*1000)}
//-->
</SCRIPT>
<NOSCRIPT>Sorry, this won't work w/o JavaScript</NOSCRIPT>
</FORM>
</BODY>
</HTML>
<SCRIPT language="JavaScript">
<!--
BGM = new Array(3);
BGM[0]="abe.mid";
BGM[1]="akaikutu.mid";
BGM[2]="aogeba.mid";
maxSound = 30; // 最大サウンド番号
function setBGM()
{
soundNo = Math.floor(Math.random()*maxSound);
document.write("<EMBED SRC='",BGM[soundNo],"' autostart='true' volume='50' width='145' height='50' panel='1' save='true' repeat='true' loop='true' controls='console'>");
}
// -->
</SCRIPT>
<P align="center"><FONT size="+1"><B>著作権消滅曲<BR>
</B></FONT>
<SCRIPT language="JavaScript">
<!--
setBGM();
// -->
</SCRIPT>