Created
March 23, 2010 19:38
-
-
Save imlucas/341559 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Clean way of testing for HTML5 audio support for jQuery. | |
* | |
* Example: | |
* if(jQuery.support.audio.mp3){ | |
* alert('Thanks guy. Enjoy the mp3 party in your browser.'); | |
* } else { | |
* alert('MP3 native playback not supported.'); | |
* } | |
* | |
*/ | |
(function() { | |
var a = document.createElement("audio"); | |
function t(m){ | |
return (a && jQuery.isFunction(a.canPlayType) && a.canPlayType(m) != "" && a.canPlayType(m) != "no"); | |
}; | |
jQuery.extend(jQuery.support, {audio:{mp3: t('audio/mpeg'), aac: t('audio/aac'), ogg: t('audio/ogg')}}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment