Blame view

sources/apps/files_videoviewer/mediaelement/src/js/me-featuredetection.js 3.01 KB
03e52840d   Kload   Init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  // necessary detection (fixes for <IE9)
  mejs.MediaFeatures = {
  	init: function() {
  		var
  			t = this,
  			d = document,
  			nav = mejs.PluginDetector.nav,
  			ua = mejs.PluginDetector.ua.toLowerCase(),
  			i,
  			v,
  			html5Elements = ['source','track','audio','video'];
  
  		// detect browsers (only the ones that have some kind of quirk we need to work around)
  		t.isiPad = (ua.match(/ipad/i) !== null);
  		t.isiPhone = (ua.match(/iphone/i) !== null);
  		t.isiOS = t.isiPhone || t.isiPad;
  		t.isAndroid = (ua.match(/android/i) !== null);
  		t.isBustedAndroid = (ua.match(/android 2\.[12]/) !== null);
  		t.isIE = (nav.appName.toLowerCase().indexOf("microsoft") != -1);
  		t.isChrome = (ua.match(/chrome/gi) !== null);
  		t.isFirefox = (ua.match(/firefox/gi) !== null);
  		t.isWebkit = (ua.match(/webkit/gi) !== null);
  		t.isGecko = (ua.match(/gecko/gi) !== null) && !t.isWebkit;
  		t.isOpera = (ua.match(/opera/gi) !== null);
  		t.hasTouch = ('ontouchstart' in window);
  		
  		// borrowed from Modernizr
  		t.svg = !! document.createElementNS &&
  				!! document.createElementNS('http://www.w3.org/2000/svg','svg').createSVGRect;
  
  		// create HTML5 media elements for IE before 9, get a <video> element for fullscreen detection
  		for (i=0; i<html5Elements.length; i++) {
  			v = document.createElement(html5Elements[i]);
  		}
  		
  		t.supportsMediaTag = (typeof v.canPlayType !== 'undefined' || t.isBustedAndroid);
  
  		// detect native JavaScript fullscreen (Safari/Firefox only, Chrome still fails)
  		
  		// iOS
  		t.hasSemiNativeFullScreen = (typeof v.webkitEnterFullscreen !== 'undefined');
  		
  		// Webkit/firefox
  		t.hasWebkitNativeFullScreen = (typeof v.webkitRequestFullScreen !== 'undefined');
  		t.hasMozNativeFullScreen = (typeof v.mozRequestFullScreen !== 'undefined');
  		
  		t.hasTrueNativeFullScreen = (t.hasWebkitNativeFullScreen || t.hasMozNativeFullScreen);
  		t.nativeFullScreenEnabled = t.hasTrueNativeFullScreen;
  		if (t.hasMozNativeFullScreen) {
  			t.nativeFullScreenEnabled = v.mozFullScreenEnabled;
  		}
  		
  		
  		if (this.isChrome) {
  			t.hasSemiNativeFullScreen = false;
  		}
  		
  		if (t.hasTrueNativeFullScreen) {
  			t.fullScreenEventName = (t.hasWebkitNativeFullScreen) ? 'webkitfullscreenchange' : 'mozfullscreenchange';
  			
  			
  			t.isFullScreen = function() {
  				if (v.mozRequestFullScreen) {
  					return d.mozFullScreen;
  				} else if (v.webkitRequestFullScreen) {
  					return d.webkitIsFullScreen;
  				}
  			}
  					
  			t.requestFullScreen = function(el) {
  		
  				if (t.hasWebkitNativeFullScreen) {
  					el.webkitRequestFullScreen();
  				} else if (t.hasMozNativeFullScreen) {
  					el.mozRequestFullScreen();
  				}
  			}
  			
  			t.cancelFullScreen = function() {				
  				if (t.hasWebkitNativeFullScreen) {
  					document.webkitCancelFullScreen();
  				} else if (t.hasMozNativeFullScreen) {
  					document.mozCancelFullScreen();
  				}
  			}	
  			
  		}
  		
  		
  		// OS X 10.5 can't do this even if it says it can :(
  		if (t.hasSemiNativeFullScreen && ua.match(/mac os x 10_5/i)) {
  			t.hasNativeFullScreen = false;
  			t.hasSemiNativeFullScreen = false;
  		}
  		
  	}
  };
  mejs.MediaFeatures.init();