Skip to content

Instantly share code, notes, and snippets.

@stephenscaff
Created April 20, 2015 20:22
Show Gist options
  • Select an option

  • Save stephenscaff/cfda95b331e8c7030cd8 to your computer and use it in GitHub Desktop.

Select an option

Save stephenscaff/cfda95b331e8c7030cd8 to your computer and use it in GitHub Desktop.
Modernizr test and load for video
// 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