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.