Lesson Six

Sound files in files of the formats .mp3 and .wav can be played by visitors to a Web page if the file is coded into it as follows:-

If you include more than one sound file you will find that they all try to play at the same time, but it is possible to use JavaScript to hide them behind buttons: a piece of program code can then post the html for a particular sound file into the body of the page when it is actually wanted. To mark the point where the replacement html is to be added in, the paragraph tag preceding the original sound file has to be given a name to identify it. If you just copy the script code in the head part of this page and the button code at the bottom, you should be able to tie your own sound files into your own pages. Note: Explorer and Firefox automatically stops the sound file that's playing when you start another one going, but Opera does not: they play through each other instead.

As with photographs, you will need to copy your sound files into the same folder as your Web pages so that the browser can find them.