annotate johndyer-mediaelement-13fa20a/src/js/me-featuredetection.js @ 25:4a4bd554b4c1 tip

Closing this sub branch.
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Mon, 25 Mar 2013 14:02:54 +0000
parents 032bc65ebafc
children
rev   line source
gyorgy@0 1 // necessary detection (fixes for <IE9)
gyorgy@0 2 mejs.MediaFeatures = {
gyorgy@0 3 init: function() {
gyorgy@0 4 var
gyorgy@0 5 nav = mejs.PluginDetector.nav,
gyorgy@0 6 ua = mejs.PluginDetector.ua.toLowerCase(),
gyorgy@0 7 i,
gyorgy@0 8 v,
gyorgy@0 9 html5Elements = ['source','track','audio','video'];
gyorgy@0 10
gyorgy@0 11 // detect browsers (only the ones that have some kind of quirk we need to work around)
gyorgy@0 12 this.isiPad = (ua.match(/ipad/i) !== null);
gyorgy@0 13 this.isiPhone = (ua.match(/iphone/i) !== null);
gyorgy@0 14 this.isAndroid = (ua.match(/android/i) !== null);
gyorgy@0 15 this.isBustedAndroid = (ua.match(/android 2\.[12]/) !== null);
gyorgy@0 16 this.isIE = (nav.appName.toLowerCase().indexOf("microsoft") != -1);
gyorgy@0 17 this.isChrome = (ua.match(/chrome/gi) !== null);
gyorgy@0 18 this.isFirefox = (ua.match(/firefox/gi) !== null);
gyorgy@0 19
gyorgy@0 20 // create HTML5 media elements for IE before 9, get a <video> element for fullscreen detection
gyorgy@0 21 for (i=0; i<html5Elements.length; i++) {
gyorgy@0 22 v = document.createElement(html5Elements[i]);
gyorgy@0 23 }
gyorgy@0 24
gyorgy@0 25 this.supportsMediaTag = (typeof v.canPlayType !== 'undefined' || this.isBustedAndroid);
gyorgy@0 26
gyorgy@0 27 // detect native JavaScript fullscreen (Safari only, Chrome fails)
gyorgy@0 28 this.hasNativeFullScreen = (typeof v.webkitRequestFullScreen !== 'undefined');
gyorgy@0 29 if (this.isChrome) {
gyorgy@0 30 this.hasNativeFullScreen = false;
gyorgy@0 31 }
gyorgy@0 32 // OS X 10.5 can't do this even if it says it can :(
gyorgy@0 33 if (this.hasNativeFullScreen && ua.match(/mac os x 10_5/i)) {
gyorgy@0 34 this.hasNativeFullScreen = false;
gyorgy@0 35 }
gyorgy@0 36 }
gyorgy@0 37 };
gyorgy@0 38 mejs.MediaFeatures.init();