HTML and CSS Reference
In-Depth Information
Table 9-3. Audio Format Support for the audio Element in Different Browsers
Format
IE
Firefox
Chrome
Opera
Safari
MP3
9+
3.5+ 11
3.0+
-
3.1+
WAV
-
3.5+
3.0+
10.5+
3.1+
Ogg Vorbis
-
3.5+
3.0+
10.5+
3.1+
The basic use of the audio element is straightforward (Listing 9-19).
Listing 9-19. Basic Audio Embedding in (X)HTML5
<audio src="valerie.mp3">
</audio>
Beyond the src attribute that specifies the source URL of the audio content to play, there are further attributes for
automatic playing ( autoplay="autoplay" ), control buttons ( controls="controls" ), repeating ( loop="loop" ), and
loading at page load ( preload="preload" ). The last one is ignored if autoplay is present.
To achieve a higher level of accessibility, alternate content should be provided (Listing 9-20).
Listing 9-20. Alternate Content for Audio
<audio src="valerie.mp3" controls="controls">
<p><a href="valerie.mp3">Valerie by Joy</a></p>
</audio>
Since certain formats supported by a browser cannot be played in another, the audio element allows multiple
source declarations that link to different audio files. Listing 9-21 shows an example.
Listing 9-21. Multiple Source Declaration for Different Formats
<audio controls="controls">
<source src="valerie.mp3" type="audio/mpeg" />
<source src="valerie.ogg" type="audio/ogg" />
<p><a href="valerie.mp3">Valerie by Joy</a></p>
</audio>
Browsers can play the first supported format from the different audio formats.
Video
For many years, publishing videos was possible through general object embedding only. Because of the variety of
video and audio codecs and the varying browser support, there is still no ultimate solution for publishing videos on
the Web.
11 To avoid patent issues, Firefox has no native MP3 support, and relies on a decoder from the OS.
 
 
Search WWH ::




Custom Search