Adding Music to your Web Site 
by Richard Weers

Adding music (or sound) to your homepage is simpler than adding animation yet there are some complications. I have found that the success of adding music (or sound) to your page depends to some extent on the Internet server on which the page is placed and which browser you use to access the page. Netscape Navigator and Microsoft Internet Explorer are the two major browsers that are widely used today. I will limit my discussion not only to these two browsers but also to versions 3.0x . These versions support and allow for background music and sound to be loaded and played by themselves after the page and graphics have been loaded.

 To add music so Netscape Navigator can recognize and play it we must use the <EMBED>tag, which was originated by Netscape and allows different data (sound) types to be placed or "embedded" into an HTML document. To place a MIDI file named "OurMusic.mid" into an HTML document that will be recognized by Netscape Navigator we use the <EMBED> tag as follows:

 <EMBED SRC="programs/MyMusic.mid" HIDDEN=TRUE AUTOSTART=TRUE>
 
 

  • SRC="MyMusic.mid" means this is the name and location of the MIDI file you want to be download. 
  • HIDDEN=TRUE means the music player will not be seen. 
  • AUTOSTART=TRUE means the music will start automatically.
<EMBED SRC="program/OurMusic.mid" HEIGHT=2 WIDTH=0 STARTTIME=00:15>
 
 
  • HEIGHT=2 WIDTH=0 means the music player is not hidden and designates the size of the music console. 
  • STARTTIME=00:15 means the sound file will begin at 15 seconds (this is implemented only on Windows 95, NT or Macintosh)
To add music so Microsoft Internet Explorer can recognize and play it we must use the <BGSOUND> tag, which will also allow different data (sound) types to be placed into an HTML document. It has fewer attributes than the <EMBED> tag and is used as follows:

 <BGSOUND SRC="OurMusic.mid" LOOP=INFINITE>

  • SRC="OurMusic.mid" means this is the name and location of the MIDI file you want to be downloaded. You will note in this example "program" was not included. This means the MIDI file is not located in a separate file but is contained in the same file as the page which calls for it.

  •  

     

  • LOOP=INFINITE means the music file plays continuously. This of course could become very annoying depending upon the music or sound being played.
<BGSOUND SRC="OurMusic.mid" LOOP=2>
 
 
  • LOOP=2 means the music file will play twice and then stop.
Where do you get MIDI files? One site with many classical MIDI files is: http://www.dtx.net/~raborn/ (The Classical MIDI Connection). By using a search engine you will find many sites that have MIDI and other sound files.

 While the examples above have used a MIDI file, which is a universal music encoding scheme (Musical Instrument Digital Interface), Netscape Navigator and Internet Explorer Versions 3.0x also recognize and can handle other sound format files e.g. WAV (Waveform Audio) files which are the native format for PC's and the AU (Audio) files which are the native format for most UNIX workstations.

 As mentioned at the beginning of this article, one of the problems I have encountered in adding music to a homepage concerns the internet servers on which the homepage resides. I have access to three servers and have recently tested the same pages with the same HTML code on each of the servers. The result was that the pages with the same code did not respond the same with each of the two browsers on all of the servers. 

An example that will provide background music without a problem using either Netscape Navigator or Microsoft Internet Explorer is http://lonestar.texas.net/~weersrg/arts.htm

 Richard Weers is an artist and one of the assistant webmasters for the Alamo PC home page. You can find out even more about Richard by visiting his home page at http://lonestar.texas.net/~weersrg