.
.
[ Home ][ Index ][ Join Club ][ Publish ][ For Sale ]


The HTML Code for the MIDI Music

Different Code for Different Situations
The code you choose will depend on how you want the music to play:
a)  begin playing as soon as the page is opened (automatic).
b)  begin playing when the reader clicks on a button (manual).
c)  begins playing when file is chosen from a drop-down menu.
The code should be copied and pasted into each HTML page using a HTML editor.

The code for Automatic Play (in MS Explorer or Netscape)
The following code was designed to allow MIDI (or MP3 and WAV) files to begin playing as soon as the page is opened as a Background Sound.
It will work with Netscape and MS Internet Explorer..
The MIDI file title is displayed in red (substitute your own files here)
The Parameter Loop=INFINITE means that the tune will play over and over.
You can specify the number of times the tune will play by substituting a number here.
The Parameter LOOP= FALSE means the the tune will play only once.

Your HTML Editor should allow insertion of this code in the "edit source" mode.

Put this code somewhere between the tags <body> and <body/>

<!--START OF SCRIPT -->
<script LANGUAGE="JavaScript">
var MSIE=navigator.userAgent.indexOf("MSIE");
var NETS=navigator.userAgent.indexOf("Netscape");
var OPER=navigator.userAgent.indexOf("Opera");
if((MSIE>-1) || (OPER>-1)) {
document.write("<BGSOUND SRC=ThankYouftm.midLOOP=INFINITE>");
} else {
document.write("<EMBED SRC=ThankYouftm.mid AUTOSTART=TRUE ");
document.write("HIDDEN=true VOLUME=100 LOOP=TRUE>");
}
// End -->
</script>
<!-- END OF SCRIPT -->

MS Browsers Only
When the music will only be played in a MicroSoft browser then instead of the above code you can use the following single line of code. This is recommended for use with the E-dit e-Book compiler that I normally use.
Put this code somewhere between the tags <head> and <head/>

<!--START OF SCRIPT -->
<BGSOUND SRC="ThankYouftm.mid" LOOP="1">
<!-- END OF SCRIPT -->

The code for button linked music
Once you have a button placed on your page you need to highlight the image by clicking on it, then go to Link Properties and place this one line of code.

<a HREF="ThankYouftm.mid"

<body bgsound=C:\mydirectory\MusicFile.mid 
height=60 width=150 autoStart=true>

Web Page Music
The following code can be used if you want visitors to hear background music on you web pages and will work if the visitor is using Netscape or MSIE.
<embed src="mysong.mid" width=200  height=55 autostart=true loop=true>
    <noembed>
 <bgsound src="mysong.mid" loop=infinite>
    </noembed>

Simple Text Link for Music on Demand
This is the simplest form that works but is not so attractive as an button image.
<a href="ThankYouftm.mid"> Click to Hear </a>

The  code for a dropdown menu of sound files
Put this code somewhere between the tags <body> and <body/>
You can change the horizontal position of the drop down box by changing 
"LEFT" to "CENTER" or "RIGHT".  The vertical position can be changed using 
the WYSIWYG editor.
MusicFile.mid - replace these with the names of each MIDI file.
MusicTitle - replace these with the Titles of each MIDI tune.
Copy and paste as many lines as required for all tunes you want in the menu.
Note: the width of the drop down box is influenced by the length of the Music Titles!
So try to keep the titles short and about the same length for neatness.
All MIDI files must be in the same directory as your HTML files.

<!--START OF SCRIPT -->
<FORM METHOD="POST" ENCTYPE="application/x-www-form-urlencoded">
<DIV ALIGN="LEFT"> 
<DIV ALIGN="LEFT">
<P>
<SELECT NAME="list">
<OPTION VALUE>Music&nbsp;</OPTION>
<OPTION VALUE="C:\directory\MusicFile.mid">MusicTitle&nbsp;</OPTION>
<OPTION VALUE="C:\directory\MusicFile.mid">MusicTitle&nbsp;</OPTION>
<OPTION VALUE="C:\directory\MusicFile.mid">MusicTitle&nbsp;</OPTION>
<OPTION VALUE="C:\directory\MusicFile.mid">MusicTitle&nbsp;</OPTION>
<OPTION VALUE="C:\directory\MusicFile.mid">MusicTitle&nbsp;</OPTION>
</SELECT>
<input TYPE="button" VALUE="Play!" 
ONCLICK="top.location.href=this.form.list.options[this.form.list.selectedIndex].value"></P>
</DIV>
<!-- END OF SCRIPT -->

This could be used to give the reader multiple choices for each story theme instead of just one music file of the author's choice.
 
 




Copyright © 2000 Xerostar Holdings. - All Rights Reserved.
Contact - support@midi-ebooks.com Rivervale 6103 
Western Australia Tel: 618 9479 1979  Fax: 618 9478 2349