- Tips and Tricks -

Using Embedded Sounds and LiveAudio

September 20, 1996

In Netscape 2.0, you could only play sounds by sending them to a helper application. Using the LiveConnect feature of Netscape 3.0 and the LiveAudio plug-in (included with Netscape 3.0) you can use sounds from JavaScript in a more transparent way. See the example for a quick look at this technique, explained fully in the rest of this article.

NOTE: This example will work only in Netscape 3.0 (beta 6 or later), and only if you have the LiveAudio plug-in installed. You'll also need a computer with sound capability (such as a PC with sound card) to try the example.

Using the <EMBED> Tag

To use a sound in your web page with LiveAudio, use the <EMBED> tag to embed the sound. LiveAudio works with the common sound formats (.wav, .au, .aif). The <EMBED> tag for a sound can include the following attributes: NOTE: The MASTERSOUND attribute must be included for a sound to be controlled with JavaScript.

The Sound Object

When you embed a sound in your document with the <EMBED> tag, it is made available as a sound object, a child of the document object. The sound object's name is what you specified in the NAME attribute. The sound object has a variety of methods you can use from JavaScript: In addition, you can use the following methods, which return a value:

Example: Using Embedded Sounds

As an example of embedded sounds with the LiveAudio plug-in, I've written a quick script which plays a sound repeatedly and allows you to control it, using JavaScript event handlers. Follow this link to see this example in action or view its source.
michael moncur ... [email protected]