Tips & Tricks
Advanced Topics
Adding Sound To Your Page

Enhancing Your Site
With Sound

Sound files can be a nice way to enrich your web site. You can also use sound to add detail or to express a point. You can use music to add a bit of flair, a voice recording to depict a speech or moment in history such as Franklin D. Roosevelt's Pearl Harbor speech.

Sound files come in a variety of formats.
 .WAV are the most common, but only work on PCs, not Mac.
 .AIFF are the most common Mac sound files.
 .MIDI or .MID files are the most common cross platform
      sound files and can be played on both PC and Mac.
      If you're going to use sound on your site, this is the type
      of file we recommend.

Background
Sound

Coding the sound on your web page is fairly easy. But there are some things you need to know.

The <bgsound> tag is often used by programmers, but this tag is only recognized by Microsoft's Internet Explorer. This tag will not work in Netscape or some other internet browsers. The tag looks like this:

<BGSOUND SRC="../img/vivsprng.mid" LOOP="infinite">

You can set the LOOP parameter, to replay the sound file a specified number of times (ie: LOOP="1"), or to continually loop (ie: infinite).


Sound provided by
Vivaldi's Four Seasons
~ Spring Interlude~

 

The EMBED tag is Netscape's way to embed an object, such as a sound file in your web page. This tag uses a few extra parameters as well.

Autostart tells the browser to automatically play the file when the page is loaded.
Loop tells the browser to continually loop the sound file.
Hidden tells the browser to hide the object. If you chose not to use this parameter, you'll see a small block like the one to the left where the embedded object is placed on your page.

<EMBED SRC="../img/vivsprng.mid" HEIGHT="10" WIDTH="10"
AUTOSTART="true" LOOP="true" HIDDEN="true" ALIGN="BOTTOM">


 The Future of Sound

See the Object Command In Action

Many web experts expect both the BGSOUND and EMBED tags to be replaced by the cross browser OBJECT tag. The Object tag is not fully supported by all web browsers yet, but it mostly likely will be soon. It is supported by the new versions of Internet Explorer and Netscape.

If you'd like to see this command in the works, click the earth to the left.


The Usual Reminder

One of the biggest disadvantages to using sound files is the amount of time a browser spends trying to load it. From a design perspective, loading sound on your main home page to enhance your site is often good enough. Adding different sound files on all your web pages might persuade visitors to go else where to find the information they're looking for.

Think of it this way, if you don't want to wait several seconds for a page to load, will someone visiting your site want to wait either?


 Next: Using Programs & Javascripts