If you hit the reload button you will see this script in action. Since it is random you may hear the same midi twice in a row. Remember to insert your own midi file names where is says "your midi here". Place this in the head of your page.
Here is the code, just copy and paste:
<script language="JavaScript" type="text/javascript">
//!--- hide script from old browsers
var numimage = 9
day = new Date()
z = day.getTime()
x = parseInt(((z - (parseInt(z/1000,10) * 1000))/10)/100*nummidi + 1,10)
if (x == (1)){
image=("your midi here")
}
if (x == (2)){
image=("your midi here")
}
if (x == (3)){
image=("your midi here")
}
if (x == (4)){
image=("your midi here")
}
if (x == (5)){
image=("your midi here")
}
if (x == (6)){
image=("your midi here")
}
if (x == (7)){
image=("your midi here")
}
if (x == (8)){
image=("your midi here")
}
if (x == (9)){
image=("your midi here")
}
// end hiding --->
</script>
</head>
<body>
<TABLE BORDER="12" CELLSPACING="4" CELLPADDING="4">
<TR>
<TD>
<script language="JavaScript" type="text/javascript">
//!--- hide script from old browsers
document.write('<EMBED SRC= "'+ midi +'" WIDTH="145" HEIGHT="60"
AUTOSTART="TRUE" LOOP="TRUE" VOLUME="MAX" ALIGN="CENTER">')
// end hiding --->
</SCRIPT>
</TD>
</TR>
</TABLE>
Notice how the head tag ends and then the rest of the code goes into the body. If you view the source code in your browser, "midi" is changed to reflect the actual midi file which is playing.
I have put the code for a visable control panel in this script. The table tags, width, height, are all optional.
Autostart=True means the midi starts automatically. Set to false and the user would have to start the midi.
Loop=true means the midi will play over and over. Set to false and the midi would play once, then stop.
If you were to actually embed the player, and make it invisable, users will not be able to turn off the music without leaving the page. Showing the control panel on your page allows the user to stop the music at anytime. Remember, your favorite tune may not be music to their ears!
All graphics were made by Cathyland. Want to see more? Visit the Graphics Page.
For more javascripts visit the Javascript Page.