Embedding Sound in Web Pages, Part I: Audio Control Example - Doc JavaScript | WebReference

Embedding Sound in Web Pages, Part I: Audio Control Example - Doc JavaScript

Audio Control Example

Let's look at an example that demonstrates many of the LiveAudio and ActiveMovie methods. The following form lets you set several properties of the LiveAudio plug-in and ActiveMovie Control:

Sound card enabled:

The code is shown on the next page. The script is fairly straightforward. Let's take one function to demonstrate the principles of object referencing:

function playIt() {
  if (!audioEnabled) return;
  if (IEsound) document.audiopanel.play()
  else if (NSsound) document.audiopanel.play(true);
  timerID = setTimeout("showPosition()", 1000);

Explorer plays a sound track by the play() method, while Navigator does it with the play() one. Differences stem from the fact that Navigator uses the LiveAudio plug-in, while Explorer uses the ActiveMovie Control, as explained earlier in this column. On both browsers, an object is referenced as document.audiopanel, where audiopanel is the value of the <EMBED> tag's NAME attribute. The function state() prints the state of the sound control, and the last line of the playIt() function invokes the setInterval() function to update the position of the track every 1000 ms.

Notice that the Explorer' ActiveMovie Control supports several features that Navigator does not. For example, Explorer lets you read the current playing position along the track, the audio file name, and if the sound card is enabled. Compare the feature table of LiveAudio with that of ActiveMovie Control, and you will find many more such features.


Created: May 31, 1998
Revised: May 16, 1999

URL: http://www.webreference.com/js/column20/liveaudioexample.html