HTML and CSS Reference
In-Depth Information
Embedding Audio in Your Pages
The nice thing about embedding audio is that it's similar to embedding video. HTML5
provides an <audio> tag that works almost identically to the <video> tag. The <embed>
tag can also be used with audio, but you should use the <audio> and <object> tags
Four main file formats and codecs are used for audio on the Web: MP3, Ogg Vorbis,
AAC, and WAV. MP3 is supported natively by Safari and Chrome and can be played
using Flash-based players. The WAV format is supported by Firefox, Safari, and Opera.
Ogg Vorbis, the open format, is supported by Firefox and Chrome. AAC is the format
used by iTunes when you rip CDs. It is supported natively by Safari and also by Flash.
Your best bet for reaching the largest audience is to use the <audio> tag with MP3 files
for browsers that support it, including mobile browsers that support HTML5 but not
Flash, and then use a Flash-based player to play the MP3 files for those users whose
browsers do not support HTML5 or don't support the MP3 format.
The <audio> Tag
The <audio> tag is similar to the <video> tag. It attempts to use the native capabilities of
the browser to play an audio file. Its attributes are the same as those <video> tag, except
that the height and width attributes are not used. Here's an example of the <audio> tag:
<audio src=”song.mp3” controls>
If the browser is capable of playing the video at the URL specified in the src attribute, it
will present the audio, which you can use to control playback. The audio player appears
in Figure 12.15.
FIGURE 12.15
An embedded
audio player.
Search WWH ::

Custom Search