Created
April 20, 2015 20:22
-
-
Save stephenscaff/cfda95b331e8c7030cd8 to your computer and use it in GitHub Desktop.
Modernizr test and load for video
This file contains hidden or 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
| // Exclude the iPad | |
| Modernizr.addTest('ipad', function () { | |
| return !!navigator.userAgent.match(/iPad/i); | |
| }); | |
| // Exclude the iPhone | |
| Modernizr.addTest('iphone', function () { | |
| return !!navigator.userAgent.match(/iPhone/i); | |
| }); | |
| // Exclude the iPod touch | |
| Modernizr.addTest('ipod', function () { | |
| return !!navigator.userAgent.match(/iPod/i); | |
| }); | |
| // Exclude android phones and tablets | |
| Modernizr.addTest('android', function () { | |
| return !!navigator.userAgent.match(/android/i); | |
| }); | |
| // Add a test to Modernizr combining all platforms | |
| Modernizr.addTest('excludedplatforms', function () { | |
| return (Modernizr.ipad || Modernizr.ipod || Modernizr.iphone || Modernizr.android); | |
| }); | |
| // Specified platforms won't be able to play background video, | |
| // But we serve them a nice extensible background image (see CSS). | |
| if (!Modernizr.excludedplatforms) { | |
| Modernizr.load({ | |
| // If the platform can play any of these video types… | |
| test: Modernizr.video.webm || Modernizr.video.h264 || Modernizr.video.ogg, | |
| // We load the jQuery plugin with a few functions | |
| yep: ['/js/bgvideo.min.js'], | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment