Looking through the JavaScript library, I noticed that there
are a few scripts for random images but none for midi files.
To remedy this, I have editted one of the random JPEG image
scripts and turned it into a script that randomly selects midi
files.
Here is the script:
<SCRIPT LANGUAGE="JavaScript">
<!-- // start of script
// Original code by Joe Burns.
// Modified by Kurt A for JPEG files.
// Further modified by Steve Commisso for midi files.
// This script places a random midi file depending on the seconds.
// You may distribute freely as long as you keep this heading.
var dt = new Date();
var hr = dt.getSeconds();
if (hr<=1) hr=1;
else if (hr<=2) hr=2;
else if (hr<=3) hr=3;
else if (hr<=4) hr=1;
else if (hr<=5) hr=2;
else if (hr<=6) hr=3;
else if (hr<=7) hr=1;
else if (hr<=8) hr=2;
else if (hr<=9) hr=3;
else if (hr<=10) hr=1;
else if (hr<=11) hr=2;
else if (hr<=12) hr=3;
else if (hr<=13) hr=1;
else if (hr<=14) hr=2;
else if (hr<=15) hr=3;
else if (hr<=16) hr=1;
else if (hr<=17) hr=2;
else if (hr<=18) hr=3;
else if (hr<=19) hr=1;
else if (hr<=20) hr=2;
else if (hr<=21) hr=3;
else if (hr<=22) hr=1;
else if (hr<=23) hr=2;
else if (hr<=24) hr=3;
else if (hr<=25) hr=1;
else if (hr<=26) hr=2;
else if (hr<=27) hr=3;
else if (hr<=28) hr=1;
else if (hr<=29) hr=2;
else if (hr<=30) hr=3;
else if (hr<=31) hr=1;
else if (hr<=32) hr=2;
else if (hr<=33) hr=3;
else if (hr<=34) hr=1;
else if (hr<=35) hr=2;
else if (hr<=36) hr=3;
else if (hr<=37) hr=1;
else if (hr<=38) hr=2;
else if (hr<=39) hr=3;
else if (hr<=40) hr=1;
else if (hr<=41) hr=2;
else if (hr<=42) hr=3;
else if (hr<=43) hr=1;
else if (hr<=44) hr=2;
else if (hr<=45) hr=3;
else if (hr<=46) hr=1;
else if (hr<=47) hr=2;
else if (hr<=48) hr=3;
else if (hr<=49) hr=1;
else if (hr<=50) hr=2;
else if (hr<=51) hr=3;
else if (hr<=52) hr=1;
else if (hr<=53) hr=2;
else if (hr<=54) hr=3;
else if (hr<=55) hr=1;
else if (hr<=56) hr=2;
else if (hr<=57) hr=3;
else if (hr<=58) hr=1;
else if (hr<=59) hr=2;
else if (hr<=60) hr=3;
// Right now, this script is set up for three different midi files. If you want more
// or less, just change the 'hr' values (except the ones in parenthesis) after
each
// 'else if' to suit your needs.
// Remember to rename your midi files to the numbers in the 'hr' values!
var msg="<EMBED HEIGHT=2 WIDTH=2 AUTOSTART=true LOOP=true SRC="+hr+".mid>";
document.write(msg);
<!-- end -->
</SCRIPT>
Notice that the hr value in parentheses represents the seconds
that are taken from your computer and the hr value out of the
parentheses represents the assigned value for your midi file name.
As you may know by the "1, 2, 3..." pattern, I made this script to
run for three different midi files. To change this, simply change the
assigned midi file names to suit the number of midi files you will be
using (Ex. For 4 midi files, use a pattern of "1, 2, 3, 4...").
To use this script, cut and paste the script above at the bottom of
your HTML file.
Script by: Steve Commisso.