Linking
to sound file
You can link to a sound file in the same way you link to another Web
page using the <a> anchor tag. Of course, the user must have the
appropriate sound player installed on their computer to be able to play
the file:
<a href="sound.mp3">Play this file</a>
Download the lab files here.
Insert the following code immediately below the last paragraph in raintxt.htm.
<p>Click below to listen to the sounds of <i>Adams &
Davis</i> from last year's folk festival.</p>
<blockquote>
<a href="mountain.mp3">Wild Mountain Thyme Full Clip
(342K - MP3)</a><br>
<a href="mountain.wav">Wild Mountain Thyme Partial Clip
(211K - WAV)</a><br>
<a href="mountain.au">Wild Mountain Thyme Partial Clip
(211K - AU)</a>
Save the file and test the links in the browser.
Embedding
a sound file
Linking to a sound file as in the previous section causes the browser
to open the related application separately. An embedded sound file can
be played from within the Web page. Of course, the user must have the
supporting application installed. Use the <embed> tag to embed
a sound file in a Web page:
<embed src="URL" width="value"
height="value" align="value" autostart="value">
width and height = pixels (size of the control
panel)
align = left, right to wrap text or top, or bottom to align with baseline
autostart = true or false
Edit raintxt.htm and add the following code in the
blockquote. Use the format that is supported by the local system:
<embed src="mountain.mp3" width="145" height="60"
autostart="false">
Save the file and test the embedded sound file in the browser.
Use
<bgsound> tag
You can automatically have the browser play sound in the background
when the page loads using the <bgsound> tag:
<bgsound src="URL" balance="value"
loop="value" volume="value">
balance = defines how the sound should be balanced
between left and right speakers (-10,000 to 10,000)
loop = how many times the clip should play (1,2,3...infinite)
volume = 0 (muted) - 10,000
Edit raintxt.htm and add the following code inthe blockquote.
<bgsound src="mountain.mp3" balance="0" loop="1"
volume="10">
Save the file and test it in the browser.