Site hosted by Angelfire.com: Build your free website today!
Bill Evenski , Wheeler High School

Adding Sounds to Your Pages

 

Links

some sound files sources:

sound america

wav central

find sounds

the free site

boggiejack

some tutorials on adding sound:

adding sounds according to dave

the embed tag

Your assignment:

Today's assignment

directions for this assignment

Internet Explorer only:
the "bgsound" tag


There are two ways to call sound files from your web page one way works exclusively with Internet Explorer and the other way works both with IE and Netscape.

To call a sound file only with IE you would insert the following tag into the <body>.....</body> of the web page. <bgsound src="musicfile.mid" loop="0"> where musicfile.mid would be replaced with any musical file you want. With this format the file would have to be in the same directory as the web page. If, on the other hand, the file was in a directory called audio or sound or whatever, the syntax would be <bgsound src="../sound/musicfile.mid" loop="0">

The loop="0" would cause the file not to play when the page is first loaded. If the number 1, 2 or 3 were placed here, the sound file would self initialize and play that number of times and stop. If the number -1 was placed in the loop= attribute, the file would play continually.

The two main drawbacks to using this method are; it only works with IE and there is no control panel available to the web site visitor. The sound simply does what is defined in the command and the visitor has no control over stopping it or playing it again (unless they hit their browser's stop or reload buttons). They are at the mercy of the web page designer. It's a good idea to give the web site visitor the option of controlling the sound.


Internet Explorer and Netscape
the "embed" tag


To make the sound file available to all visitors and controllable by them with a control console or panel, use the embed tag instead of the bgsound tag. The embed tag can be placed anywhere on the page and a control console will appear at that location in the document. Both Netscape and IE recognize the embed tag. The syntax for the embed tag is as follows
<
embed src="soundfile.mid" height="60" width="144" controls="console" autostart="false" hidden="false">

  • embed tag includes a sound file of your choosing on the page wherever the embed tag is placed.
  • src="soundfile.mid" the name of the sound file goes here
  • height="60" width="144" sets the dimensions of the console to whatever you define.
  • controls="console" must be present for Netscape and it does no harm in IE so be sure to include it.
  • autostart="false" will cause the sound file to initialize (or not) without any web site visitor interaction set to true the sound will start automatically, set to false the sound will not start automatically.
  • hidden="false" will make the control console visible. "true" = invisible will make the console invisible.
  • loop="-1" will make the sound loop indefinitely. To set a limit on how many times the sound plays place any whole number here.

And of course, there's always a text link