Skip to content

Instantly share code, notes, and snippets.

@imlucas
Created March 23, 2010 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imlucas/341559 to your computer and use it in GitHub Desktop.
Save imlucas/341559 to your computer and use it in GitHub Desktop.
/**
* 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