Including sound in your Web pages can be tricky, but there are two tags that allow you to do it:
The <embed /> tag is a general tag first implemented by Netscape to add many types of media into your Web page. You can embed many different objects that are supported by browser plug ins. In fact, if the browser recognizes the MIME type of the object, then you can embed nearly anything. The most common things to embed are movies and sound files.
When using the <embed /> tag to include music on your Web site, the one required attribute is src. This attribute defines the name and path to the file to be played. You need to make sure that the file you would like to play is on the Web server, and the path to it is accurate.
The other attributes you should know when using the <embed /> tag to play music are hidden, autostart, and loop. Hidden is used as a stand alone attribute and tells the browser to show nothing to the reader when playing the music. Without this attribute, the browser might show a control panel to allow your readers to adjust the volume of the sound or start and stop the music. Autostart and loop can be either true or false.
If you would like to have the file hello.mid played once with no control panel, you would add a tag to the BODY of your document that looks like:
<embed src="hello.mid" hidden autostart="true" loop="false" />
If you would like the file music.au played infinitely with a control panel displayed, you would add a tag to the body of your document that looks like
<embed src="music.au" loop="true" />
I strongly recommend you don't use this tag. It is not a part of the XHTML specification and it may not be supported in future versions of IE.
The <bgsound /> tag is only supported by Internet Explorer, other browsers simply ignore this tag. When your Web page is downloaded, this tag will then download and play the indicated sound file as background for your Web page.
This tag requires the src attribute to indicate the path and file to be played. Internet Explorer recognizes three sound file types: wav, au, and mid.
The only other attribute for the <bgsound /> tag is the loop attribute. This tells the browser how many times to play the indicated sound file. If you would like it to loop for as long as the reader is on the page, you would make the loop "infinite".
If you would like to have the file hello.mid played twice, you would add a tag to the body of your document that looks like:
<bgsound src="hello.mid" loop="2" />
If you would like the file music.au to play continuously, you would add a tag to the body of your document that looks like:
<bgsound src="music.au " loop="infinite" />
Tips for Using Sound
One thing to keep in mind when using sound files on your Web pages is that some people would rather listen to music of their own choice rather than yours. I would recommend not using the hidden attribute on <embed /> tags, as this allows your readers to choose if they want the sound on or not.