Mitzrah's Get IT Right Column!!
Random MIDI Selector/Player
Updated : Friday, August 07, 1998

Mitzrah's Get IT Right Column!

Ramdomly selecting a MIDI and playing it. Totally independent of browser type, as long as it supports JAVA, it will be played. Let's assume you have the following:

You can fill up your JAVAscript as follows.

This is the JAVA script, please copy and paste the JAVA script BEFORE your </HEAD> tag:


<script language="JavaScript">

var nummidi = 3
day = new Date()
seed = day.getTime()
ran = parseInt(((seed - (parseInt(seed/1000,10) * 1000))/10)/100*nummidi + 1,10)

if (ran == (1))
midi=("1.mid")

if (ran == (2))
midi=("2.mid")

if (ran == (3))
midi=("3.mid")

browserName = navigator.appName
browserVer = parseInt(navigator.appVersion)

if (browserName == "Netscape"){
    document.write('<EMBED SRC= "' + midi + '" AUTOSTART="TRUE" LOOP="1" HIDDEN="TRUE" VOLUME="100%">');
}
else{
    document.write('<BGSOUND SRC= "' + midi + '" LOOP="1" VOLUME="100%">');
}

// --></script>


Erm.. that's it, you now know how to make midi files play, you can also use .wav files, but hey, they are pretty big!

Additional things you should know:

  1. You can change the "TRUE" or "FALSE" parameters to suite your needs.
  2. You can add controls="smallconsole" to the <EMBED> tag to show the small console with the play and stop buttons. If you choose to use this, please remove the HIDDEN="TRUE" tag.
  3. You can also specify the size of your console like if you want the volume, stop and play buttons you add the following to the <EMBED> tag : width="190"  height="20" controls="smallconsole"
  4. You can change loop="true/infinite" to loop="#" where # is any number you like. Hint: Some visitors do not like the same thing playing over and over and over. Some web masters say that MIDI is a turn off and should be abandoned.

MIDI Links:

This is my MIDI collection - All are high quality MIDIs which I often use!
http://www.midifarm.com - A lot of MIDIs can be found here.
http://www.midi.com - Also a great number of MIDI files here!

Notes from Alex:

If you found my tutorial helpful, please drop a note by my guestbook! So I know that you have dropped by and benefitted from my efforts, it took me quite sometime to get these tutorial up! Click on home and then SIGN GUESTBOOK! I will also visit your homepage at GeoCities and sign your guestbook if you sign mine!

[ Emiri Nakayama | Sailor Mars, Rei | About Me | Photo Gallery ]
[ WWW Resources | HTML Tutorials | Hints & Tips | Banner Exchange ]
[ Awards | Win My Award | Home | Links | Change Music | E-Mail Me ]

Back to where you came from!

LinkExchange Network
LinkExchange Member Free Home Pages at GeoCities