Read the Previous Page

Page 2



Creating Web Pages

By Bob Pajot


Welcome to the new Millenium or is it Millennium, or, is that still to come next year? Well whatever, this is the first Web Editing installment for the year 2000.

In this issue I will discuss some of the ways that you can add sound into your web page.

I’m sure that you have all visited sites where all of a sudden music will start playing in the background. Have you ever wondered how that happens? To a certain extent, it depends which Browser you use. Netscape and Internet Explorer each have certain html tags that are specific to them only. Reproducing sound is one such area.

Both browsers allow the playing of both MIDI and Wav files by clicking on a link to the appropriate file with the use of the "HREF" tag. When this link is accessed your browser will load a "PLUGIN" that will play either a .wav or a .mid file. Normally a graphic representation of the player will be displayed and allow you to pause, stop and restart the playing of the file but you can also request that the player stay hidden. Here you see the default player that is loaded in Netscape. If the file being played is a WAV file you can also adjust the volume with the slider control.
 
Here is the html code to play a file called "pianoman.mid"
<a href="pianoman.mid">Click here to play pianoman.mid </a>
The following would play a file called "chainsaw.wav"
<a href="chainsaw.wav">Click here to play chainsaw.wav </a>
 

If you would like to autostart the sound file, then you need to get Browser specific.
Internet Explorer uses the <BGSOUND>(background sound)  tag: Here is the format.
<BGSOUND SRC=your_file.mid LOOP=1>
             LOOP can be specified as any positive number, infinite, or -1 which equals infinite. 

If you are writing the code for a Netscape Browser you need to use <EMBED> in a similar way.
<EMBED SRC=your_file.mid LOOP=1>

Note: The differences between the two browsers can be a real headache. You should use both 
<EMBED> and <BGSOUND> tags to make sure that visitors get background sound. 

Internet Explorer does not support the <EMBED> tag directly, but it does support plugins that are installed by Netscape. The users of Internet Explorer 3.0 or higher will hear the sound from <EMBED> if they also have Netscape 3.0 installed in their machine. In this case, if there are both tags in the documents, Explorer identifies the <BGSOUND> tag as active but will report an error when it finds the <EMBED> tag. This is a disadvantage of putting both tags together. 

The sound will play but an error message will be displayed and will look something like:
DEBUG or  Midi Error  "unable to start midi"  OK                           
or "Unable to start  playing midi sound"   OK

The code to autostart the above file and loop through it twice would be.

<BGSOUND SRC=pianoman.mid LOOP=2> for Internet Explorer or
<EMBED SRC=pianoman.mid LOOP=2> for Netscape

Similarly to autostart a WAV file.

<BGSOUND SRC=chainsaw.mid LOOP=2> for Internet Explorer or
<EMBED SRC= chainsaw.mid LOOP=2> for Netscape

The following code will ensure that the music will start in either Internet Explorer or Netscape and will also allow users of older browsers that do not recognize either tag to play the music by letting them click on the text link. (the text will only display in browsers that don’t recognize the tag. The height/width dimensions specify how large the image of the player is to be. 

bgsound src="pianoman.mid" loop="1"> <embed src="pianoman.mid"  height=60 width=145  autostart="true" loop="1"> <noembed>Your browser doesn't support EMBED, but you can still listen to the background sound of this page by<a href="music/decoratd.mid"> clicking here.</a></noembed>

Try this out next time you create your own web page. You can find midi and wave files all over the Internet. We have links to a few sites on our links page.

There are also other methods to add sound which we may get into later.


Read the Next Page
Return To WPCUG Homepage
 
 

What do you think of having "The TXT" on-line? E-mail Bob Pajot

E-mail me at webeditor@wpcug.com