First, create LiveAudio embeds for all of the sounds you want to be played. In the case of my little app, you need two music files and one AU file. There are two special parameters that these embeds need, HIDDEN and NAME:
<EMBED SRC = "classic.mid" HIDDEN = TRUE CONTROLS = console VOLUME = 100 LOOP = FALSE AUTOSTART = FALSE NAME = "classic" MASTERSOUND>The HIDDEN parameter does just what it says; it hides the LiveAudio control. The name parameter is important because when you start/pause/stop the sound, you need to refer to it by name. (Note: Embeds are also indexed as arrays, but its more convenient do control them with names and it's also the method Netscape recommends.) You can add as many embeds as you want, just give them all different names; prefererably descriptive ones. I named my app's controls classic, jazz, and click. Now to control the embed, just use these three commands:
document.embed_name.play([true/false]); <-- Play Sound document.embed_name.stop(); <-- Stop Sound document.embed_name.pause(); <-- Toggle PauseWhere embed_name is the name of the embed you want to control. The true/false parameter in play() determines whether or not the sound should be repeated. Just so you know, these functions are not defined by any script, they are defined by the plugin. No extra code is needed to control the sounds, that's the whole essence of LiveConnect. Finally, as a "saftey precaution" add this if statement to make sure the sounds are loaded before an attempt at playing them is made:
Note: Below are a few more functions that you can use to control LiveAudio, though some of them will only work on the Win 95 and Mac platforms.
|setvol(in percent)||Sets the volume of the specified embed in percent.|
|start_time(in seconds)||Sets the point at which the embed should start in seconds.|
|end_time(in seconds)||Sets the point at which the embed should end in seconds.|
|fade_to(in percent)||Sets the percent that the embed should fade to.|