The HTML Artwork HTML and Sound


Incorporating sound in an HTML document is a complicated task. The classic method is simply to create a link to the sound file. This gives readers complete control over the "display" of the sound file. However, if you wish to have sounds downloaded and played automatically when your document is loaded, a number of options are available. Unfortunately all of these options are browser-specific.


Microsoft Internet Explorer: BGSOUND Tag

This document includes a BGSOUND tag. This is a Microsoft Internet Explorer extension to HTML, and is currently not in any of the standard-track HTML specifications. Two attributes are available with this tag:

SRC
Used to specify the sound file that should be played
LOOP
Used to specify how many times the sound file should be played. Value may be any positive number, -1 (equivalent to INFINITE) or INFINITE .

The tag format is:

         <BGSOUND SRC=soundfile LOOP=n or INFINITE>

The format for sound files used with this tag should be either .wav, .au or .mid (MIDI).


Browsers with JavaScript Support

Include: <BODY onLoad="playMessage()"> in your document if you want the sound to be played automatically while the document is loading. If you want the sound to be played on command, include:

Netscape: EMBED Tag

Netscape supports the EMBED tag for including sounds in a document. The attributes available with EMBED include:

SRC
The URL for the item to be played or displayed.
AUTOSTART
Allowed values: false or true
Determines whether the sound is played automatically, or whether the user must click on a control panel to play it.
VOLUME
Sets the volume level. Value may be between 1 and 100.
LOOP
Set the number of times that an audio object will be played. Value may be set to TRUE, FALSE or a number.
CONTROLS
Sets the control for the object. Defaults to "console"
HEIGHT and WIDTH
Used to set the height and width of the object in pixels. Setting one or the other to 2, and the remaining attribute to 0 will cause te browser to hide (mostly) the console that normally appears with an embedded sound. Eg: WIDTH=0 HEIGHT=2. The default height and width for the sound console seems to be WIDTH=144 HEIGHT=60
<EMBED SRC="Audio/embedsound.au" AUTOSTART=false VOLUME=100 WIDTH=144 HEIGHT=60 CONTROLS=Console>

The following (hopefully almost invisible) EMBED, uses WIDTH=2 and HEIGHT=0 to hide the console.

Now you can see the console, when we set WIDTH=144 and HEIGHT=60


Netscape: NOEMBED Tag

Do you see the "Play a secret message!" sentence following this one? <A HREF=Audio/embedsound.au>Play a secret message!</A> If you didn't, you are viewing this document with a browser that supports the NOEMBED tag. This tag was introduced by Netscape, and is intended to detect the existance of a plug-in with the corresponding EMBED tag. If the plug-in does not exist, the text inside the EMBED tag is displayed. The text is also displayed by browsers that do not support EMBED/NOEMBED, and provides an easy way to set-up an alternate sound or external object access for browsers without built-in support.


[HTML CD Home Page]

Vivian Neou, vivian@catalog.com
Copyright © 1996 Vivian Neou