ptg16476052
Embedding Audio in Your Pages 413
14
<a href="http://get.adobe.com/flashplayer/>Get Flash.
In this case, browsers that support the native tag will use it. Then Internet Explorer will use the nested tag. Finally, other browsers will use the inner
The nice thing about embedding audio is that it’s similar to embedding video. HTML5 provides an tag that works almost identically to the tag. The tag can also be used with audio, but you should use the and tags instead.
Four main file formats and codecs are used for audio on the Web: MP3, Ogg Vorbis, AAC, and WAV. MP3 is supported natively by Internet Explorer 9+, Firefox, Opera, iOS, Android, Safari, and Chrome and can be played using Flash-based players. The WAV format is supported by all browsers except Internet Explorer. Ogg Vorbis, the open format, is supported by Firefox, Opera, Android, and Chrome. AAC is the format used by iTunes when you rip CDs. It is supported natively by all browsers but Firefox and also by Flash. Firefox only supports it in an MP4 container.
Your best bet for reaching the largest audience is to use the 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 tag is similar to the tag. It attempts to use the native capabilities of the browser to play an audio file. Its attributes are the same as the tag, except that the height and width attributes are not used. Here’s an example of the tag:
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 14.1 5.