Here's my code:
<audio controls preload="auto">
<source src="audio/batcat.mp3" />
Your browser doesn't play MP3s. <a href="audio/batcat.mp3">Download the audio instead.</a>
</audio>
In Chrome & IE9, the browser displays the native audio player.
In Firefox, I would expect it to show the fallback text and the link. Instead, it shows an ugly grey box with an X in the middle and doesn't show the fallback content.
Is this a Firefox bug, or am I doing something wrong?
Are browser makers actually saying include every possible format, or don't use the element at all. That seems a bit harsh.
EDIT The answer to the above question is "yes" apparently. All I can say to that is :(
You're right. This is because each browser supports different "codecs." Originally, HTML5 was going to have a single codec, but the browser vendors could not agree on which one (patent-encumbered vs. open source) so that requirement was dropped.
For example, for video, IE and Safari support H264 (MP4), Chrome, FF, and Opera WebM/Ogg. To ensure it works in all browsers, you can supply multiple source elements and encode your video three times. Mp4 first, WebM or Ogg second (browsers that support video will try each source element until they find one they can play. Note: currently there is a "bug" on the iPad where it can only play the first source element)
You can even embed a Flash object for your fallback so your video will also work in older versions of IE (<9). You'll end up with something like this:
If you want to show a link to the file if the browser cannot play the MP3 file, you can use a little bit of JavaScript code to test if the browser can handle the MP3 format and show a link to a file instead of the video instead. The JavaScript method to call is canPlayType.
Alternatively, (for video only, I think) you can use services like vid.ly (http://m.vid.ly/user/) that serve up the right files from the cloud.