Audio Controls (for Netscape 3,4, and IE 4)

Audio controls are quite simple - once you know what the commands are. The easiest way I've found to do it is by using the EMBED tag to load the audio file (wav, au, midi etc.). Then using the appropriate commands you can either play or stop the file.

So first, here's the embed tag (it's pretty self-explanitory):


The code to make Netscape 3 or Netscape 4 play this file is:

If you want the file to loop, you have to use .play(true)

And the code for Internet Explorer 4 is very similar:

In IE the file will loop depending on the LOOP property in the EMBED tag.

Finally, the code to stop playing the file is the same across all the browsers:


View audio1.html for an example (this example only works if your browser is properly configured for audio playback)

Audio Error Checking

There's a whole slew of things to consider when implementing audio into your page. Not all versions of Netscape 3 and 4 have audio capabilities, and they'll give an error when it reads the EMBED tag. And if the files haven't loaded yet and you try to play them, they'll give some other error. And if you use IE 4 and try to start a file while another one is playing or if you execute an audio command from an HREF tag it won't do anything,... blah, blah, blah.

But don't worry, on the following example I've done most of the error checking you could possibly need, and you'll probably be able to just cut and paste what you need. I've included a lot of remarks to explain what I'm doing, so I think you'll be able to follow through it.

View audio2.html for an example with multiple sounds and audio error checking. View Source Code

Home Next Lesson: Changing Content
copyright 1998 Dan Steinman