The following is the snippet of code I'm using to test this. (I am using the jQuery library).
audio_elements = $('audio');This assumes that there is only one audio element on the page (in my case I dynamically insert one). If the volume property exists, I assume that the element can be used to playback Ogg Vorbis files.
if('volume' in audio_elements[0] ) {
// processing here
}
There may also need to be a check that the browser actually has the codec installed. (Add a comment if this is the case, and I'll update this post when I work out how).
Update (19 Nov 2008): A better way is to add a check for the Mozilla browser into the test. At the moment, Safari has the audio tag, but only supports media types that work in Quicktime.
if('volume' in audio_elements[0] && $.browser.mozilla)A new function has been added to the HTML5 draft spec - canPlayType() - that gets around these problems.
No comments:
Post a Comment