Skip to content

Instantly share code, notes, and snippets.

@Nutrox
Created February 5, 2011 03:16
Show Gist options
  • Save Nutrox/812170 to your computer and use it in GitHub Desktop.
Save Nutrox/812170 to your computer and use it in GitHub Desktop.
JavaScript - HTML5/MP4 Media Detection
o = document.createElement( "audio" );
if( o.canPlayType ) {
audioAvailable = o.canPlayType( 'audio/mp4; codecs="mp4a"' ) == "probably";
}
o = document.createElement( "video" );
if( o.canPlayType ) {
videoAvailable = o.canPlayType( 'video/mp4; codecs="avc1,mp4a"' ) == "probably";
}
// NOTE: The codecs must be double-quoted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment