Chapter 5
<param name="movie" value="flash/player.swf?soundFile=audio/Townsville.mp3">
<p>Download this delightful tune in either
<a href="audio/Townsville.mp3">MP3</a> or
<a href="audio/Townsville.ogg">Ogg Vorbis</a> format.</p>
</object>
</audio>
You can find a number of Flash-based media players online, many of them free of charge. Just load up the
search engine of your choice and hunt down a player you like. Whatever Flash player you use will have its
own parameters for embedding in a web page so just follow the instructions that come with it.
This fallback content is not a fallback for browsers that support the audio element but not the particular
audio format. If you use an audio element and only offer MP3, for example, browsers that can’t play MP3
audio won’t fall back to the Flash player; they will still attempt to play the embedded MP3 and just fail
silently.
Apple’s Safari browser relies on the QuickTime application to process and play media
data. This is no problem for Safari on Mac OS X because QuickTime is already part of
OS X right out of the box. But Safari on Windows requires the QuickTime plug-in for
Windows in order to play embedded media, so it’s not much different than using Flash
(though the Flash plug-in is probably more ubiquitous on Windows computers). If Safari
on Windows lacks the QuickTime plug-in, it can still fall back to Flash, and if it lacks
Flash, it can fall back to the download links. This is a perfect example of graceful
degradation.
Required Attributes
The audio element doesn’t require any attributes, though it should carry a src attribute if it doesn’t contain
any source elements. If one or more child source elements are present, you should omit the src attribute
from the audio element. An audio element with no attributes is technically valid, but it won’t do anything
without a media source. Even with no media source, the element still exists in the document and
JavaScript can manipulate the object (dynamically adding a media source, for instance).
Optional Attributes
src: Specifies the URL where the audio file or stream resides on a web server.
controls: A Boolean attribute that, when present, invokes the browser’s standard player
interface, typically including a play/pause button, volume control, a seek bar with a position
indicator, and the media length or time remaining.
preload: Suggests to a browser that it may preload the audio data before a user initiates
playback. The attribute accepts the values auto (the user-agent, depending on its settings, can
preload the audio; this is the default), metadata (load only the audio file’s metadata, such as title,
artist, track length, etc.), or none (don’t preload any data). The attribute with an empty value is
equivalent to auto.