Created
December 7, 2011 11:46
-
-
Save sirbrad/1442523 to your computer and use it in GitHub Desktop.
Code for when working with HTML5 Video
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
// Below code relies on Modernizr to do element support checks. | |
// Check format browser supports | |
(function format(){ | |
return { | |
ogg: !!Modernizr.video.ogg, | |
webm: !!Modernizr.video.webm, | |
mp4: !!Modernizr.video.h264 | |
} | |
}()); | |
// Check for HTML5 video support and set type attributes | |
if (!!Modernizr.video) { | |
if (format.ogg) { | |
ext = '.ogv'; | |
player.setAttribute('type', "video/ogg; codecs='theora, vorbis'") | |
} else if (format.mp4) { | |
ext = '.mp4'; | |
player.setAttribute('type', "video/mp4; codecs='avc1.42E01E, mp4a.40.2'"); | |
} else if (format.webm) { | |
ext = '.webm'; | |
player.setAttribute('type', "video/; codecs='vp8, vorbis'"); | |
} | |
} else { | |
ext = '.swf'; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment