-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathbrowser.js
More file actions
57 lines (43 loc) · 1.39 KB
/
browser.js
File metadata and controls
57 lines (43 loc) · 1.39 KB
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
function addBrowserFunctions(AblePlayer) {
AblePlayer.prototype.isIOS = function(version) {
// return true if this is iOS
// if version is provided check for a particular version
var userAgent, iOS;
userAgent = navigator.userAgent.toLowerCase();
iOS = /ipad|iphone|ipod/.exec(userAgent);
if (iOS) {
if (typeof version !== 'undefined') {
if (userAgent.indexOf('os ' + version) !== -1) {
// this is the target version of iOS
return true;
} else {
return false;
}
} else {
// no version was specified
return true;
}
} else {
// this is not iOS
return false;
}
};
AblePlayer.prototype.browserSupportsVolume = function() {
// To test whether the browser supports changing the volume,
// create a new audio element and try setting the volume to something other than 1.
// Then, retrieve the current setting to see if it preserved it.
// This doesn't work in iOS by design: https://developer.apple.com/documentation/avfoundation/avplayer/volume
var audio, testVolume;
if (this.isIOS()) {
return false;
}
testVolume = 0.9; // any value between 0.1 and 0.9
audio = new Audio();
audio.volume = testVolume;
return ( audio.volume === testVolume );
};
AblePlayer.prototype.nativeFullscreenSupported = function () {
return document.fullscreenEnabled || document.webkitFullscreenEnabled;
};
}
export default addBrowserFunctions;