How to Use Javascript to Control LiveAudio
by Stephen Wilson, Professor, Conceptual Design, Art Dept, SFSU
LiveAudio is Netscape Navigator's method for inline sound. It requires Netscape Navigator 3.0 or higher. Microsoft Internet Explorer 3.0 or higher may support some features of LiveAudio. LiveAudio can be used without Javascript by employing new HTML tags. Those are explained in a companion Web page on using LiveAudio.
This documents shows simple ways of using Javascript to create interactive web pages that use sound. It assumes you have a basic familiarity with Javascript. For introductory materials on Javascript see our how to guide on Javascript.
Several Javascript extensions control sound. You can start,stop, and pause a sound. You can also change its volume and looping characteristics. The script below demonstrates the basic play, stop, and pause commands. In this example the functions are linked to html buttons; they could be attached to html links or to imageMaps. For example, you could create your own custom gif image to serve as a control panel by designating parts of the image a client side imagemap that activated Javascript functions.
To activate a sound you, must first load it using the EMBED tag. The sound must be given a name with the NAME option within the EMBED structure so the scripts can refer to it. Then the example creates simple functions that play, stop, and pause the sound.
Demo of using simple buttons to start, stop, pause, and continue sound
This section illustrates simple use of Javascript functions that control the playing, stopping, and pausing of liveaudion inline sound. Each button has a an onClick handler that calls simple functions to activate sound control. The illustration shows that you can also use normal html hyperlinks to call these functions.