Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

414 LESSON 14: Integrating Multimedia: Video and Sound


Table 14.5 lists the attributes of the <audio> tag.

TABLE 14.5 <audio> Attributes
Attribute Description
src The URL for the audio to be played.
controls Boolean attribute that indicates that the browser should supply its own con-
trols for the file. The default is to leave out the controls.
autoplay Boolean attribute that indicates that the audio should play immediately when
the page loads.
loop Boolean attribute. If present, the audio will loop when it reaches the end,
replaying until the user manually stops the file from playing.
mediagroup Groups media elements with an implicit media controller.
muted Boolean attribute. If present, the audio file will be silent.
preload Boolean attribute. If present, the browser will begin downloading the video
as soon as the page loads to get it ready to play. Ignored if autoplay is
present.

To provide background music for the page, you can add the autoplay and loop attributes
to the tag. Chances are, if you use autoplay, or even worse, autoplay and loop without
also providing controls for the audio, your users will leave in a hurry.

Flash Audio Players


Embedding Flash audio players is the same as embedding Flash video players in a page.
You can use the <object> tag, nested <object> tags, or SWFObject to embed your Flash

FIGURE 14.15
An embedded
audio player.
Free download pdf