videojs-mobile-ui 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/README.md +10 -2
- package/dist/videojs-mobile-ui.cjs.js +55 -28
- package/dist/videojs-mobile-ui.css +1 -1
- package/dist/videojs-mobile-ui.es.js +55 -28
- package/dist/videojs-mobile-ui.js +55 -28
- package/dist/videojs-mobile-ui.min.js +2 -2
- package/docs/api/TouchOverlay.html +964 -0
- package/docs/api/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/api/fonts/OpenSans-Bold-webfont.svg +1830 -0
- package/docs/api/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/api/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/api/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
- package/docs/api/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/api/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/api/fonts/OpenSans-Italic-webfont.svg +1830 -0
- package/docs/api/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/api/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/api/fonts/OpenSans-Light-webfont.svg +1831 -0
- package/docs/api/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/api/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/api/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
- package/docs/api/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/api/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/api/fonts/OpenSans-Regular-webfont.svg +1831 -0
- package/docs/api/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/api/global.html +957 -0
- package/docs/api/index.html +159 -0
- package/docs/api/plugin.js.html +221 -0
- package/docs/api/scripts/linenumber.js +25 -0
- package/docs/api/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/api/scripts/prettify/lang-css.js +2 -0
- package/docs/api/scripts/prettify/prettify.js +28 -0
- package/docs/api/styles/jsdoc-default.css +358 -0
- package/docs/api/styles/prettify-jsdoc.css +111 -0
- package/docs/api/styles/prettify-tomorrow.css +132 -0
- package/docs/api/touchOverlay.js.html +211 -0
- package/index.html +185 -92
- package/package.json +10 -13
- package/src/plugin.js +59 -34
- package/test/plugin.test.js +46 -1
package/src/plugin.js
CHANGED
|
@@ -9,12 +9,15 @@ const defaults = {
|
|
|
9
9
|
enterOnRotate: true,
|
|
10
10
|
exitOnRotate: true,
|
|
11
11
|
lockOnRotate: true,
|
|
12
|
-
|
|
12
|
+
lockToLandscapeOnEnter: false,
|
|
13
|
+
iOS: false,
|
|
14
|
+
disabled: false
|
|
13
15
|
},
|
|
14
16
|
touchControls: {
|
|
15
17
|
seekSeconds: 10,
|
|
16
18
|
tapTimeout: 300,
|
|
17
|
-
disableOnEnd: false
|
|
19
|
+
disableOnEnd: false,
|
|
20
|
+
disabled: false
|
|
18
21
|
}
|
|
19
22
|
};
|
|
20
23
|
|
|
@@ -28,7 +31,7 @@ const screen = window.screen;
|
|
|
28
31
|
const getOrientation = () => {
|
|
29
32
|
if (screen) {
|
|
30
33
|
// Prefer the string over angle, as 0° can be landscape on some tablets
|
|
31
|
-
const orientationString = (screen.orientation || {}).type || screen.mozOrientation || screen.msOrientation || ''.split('-');
|
|
34
|
+
const orientationString = ((screen.orientation || {}).type || screen.mozOrientation || screen.msOrientation || '').split('-')[0];
|
|
32
35
|
|
|
33
36
|
if (orientationString === 'landscape' || orientationString === 'portrait') {
|
|
34
37
|
return orientationString;
|
|
@@ -62,36 +65,45 @@ const registerPlugin = videojs.registerPlugin || videojs.plugin;
|
|
|
62
65
|
const onPlayerReady = (player, options) => {
|
|
63
66
|
player.addClass('vjs-mobile-ui');
|
|
64
67
|
|
|
65
|
-
if (options.
|
|
66
|
-
|
|
68
|
+
if (options.fullscreen.iOS) {
|
|
69
|
+
videojs.log.warn('videojs-mobile-ui: `fullscreen.iOS` is deprecated. Use Video.js option `preferFullWindow` instead.');
|
|
70
|
+
if (videojs.browser.IS_IOS && videojs.browser.IOS_VERSION > 9 &&
|
|
71
|
+
!player.el_.ownerDocument.querySelector('.bc-iframe')) {
|
|
72
|
+
player.tech_.el_.setAttribute('playsinline', 'playsinline');
|
|
73
|
+
player.tech_.supportsFullScreen = function() {
|
|
74
|
+
return false;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
67
77
|
}
|
|
68
78
|
|
|
69
|
-
if (options.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return false;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
79
|
+
if (!options.touchControls.disabled) {
|
|
80
|
+
|
|
81
|
+
if (options.touchControls.disableOnEnd || typeof player.endscreen === 'function') {
|
|
82
|
+
player.addClass('vjs-mobile-ui-disable-end');
|
|
83
|
+
}
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
// Insert before the control bar
|
|
86
|
+
let controlBarIdx;
|
|
87
|
+
const versionParts = videojs.VERSION.split('.');
|
|
88
|
+
const major = parseInt(versionParts[0], 10);
|
|
89
|
+
const minor = parseInt(versionParts[1], 10);
|
|
90
|
+
|
|
91
|
+
// Video.js < 7.7.0 doesn't account for precedding components that don't have elements
|
|
92
|
+
if (major < 7 || (major === 7 && minor < 7)) {
|
|
93
|
+
controlBarIdx = Array.prototype.indexOf.call(
|
|
94
|
+
player.el_.children,
|
|
95
|
+
player.getChild('ControlBar').el_
|
|
96
|
+
);
|
|
97
|
+
} else {
|
|
98
|
+
controlBarIdx = player.children_.indexOf(player.getChild('ControlBar'));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
player.touchOverlay = player.addChild('TouchOverlay', options.touchControls, controlBarIdx);
|
|
92
102
|
}
|
|
93
103
|
|
|
94
|
-
|
|
104
|
+
if (options.fullscreen.disabled) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
95
107
|
|
|
96
108
|
let locked = false;
|
|
97
109
|
|
|
@@ -101,7 +113,7 @@ const onPlayerReady = (player, options) => {
|
|
|
101
113
|
if (currentOrientation === 'landscape' && options.fullscreen.enterOnRotate) {
|
|
102
114
|
if (player.paused() === false) {
|
|
103
115
|
player.requestFullscreen();
|
|
104
|
-
if (options.fullscreen.lockOnRotate &&
|
|
116
|
+
if ((options.fullscreen.lockOnRotate || options.fullscreen.lockToLandscapeOnEnter) &&
|
|
105
117
|
screen.orientation && screen.orientation.lock) {
|
|
106
118
|
screen.orientation.lock('landscape').then(() => {
|
|
107
119
|
locked = true;
|
|
@@ -134,15 +146,21 @@ const onPlayerReady = (player, options) => {
|
|
|
134
146
|
}
|
|
135
147
|
}
|
|
136
148
|
|
|
137
|
-
player.on('
|
|
138
|
-
if (
|
|
149
|
+
player.on('fullscreenchange', _ => {
|
|
150
|
+
if (player.isFullscreen() && options.fullscreen.lockToLandscapeOnEnter && getOrientation() === 'portrait') {
|
|
151
|
+
screen.orientation.lock('landscape').then(()=>{
|
|
152
|
+
locked = true;
|
|
153
|
+
}).catch((e) => {
|
|
154
|
+
videojs.log('Browser refused orientation lock:', e);
|
|
155
|
+
});
|
|
156
|
+
} else if (!player.isFullscreen() && locked) {
|
|
139
157
|
screen.orientation.unlock();
|
|
140
158
|
locked = false;
|
|
141
159
|
}
|
|
142
160
|
});
|
|
143
161
|
|
|
144
|
-
player.on('
|
|
145
|
-
if (
|
|
162
|
+
player.on('ended', _ => {
|
|
163
|
+
if (locked === true) {
|
|
146
164
|
screen.orientation.unlock();
|
|
147
165
|
locked = false;
|
|
148
166
|
}
|
|
@@ -161,17 +179,24 @@ const onPlayerReady = (player, options) => {
|
|
|
161
179
|
* Enables the display regardless of user agent, for testing purposes
|
|
162
180
|
* @param {Object} [options.fullscreen={}]
|
|
163
181
|
* Fullscreen options.
|
|
182
|
+
* @param {boolean} [options.fullscreen.disabled=false]
|
|
183
|
+
* If true no fullscreen handling except the *deprecated* iOS fullwindow hack
|
|
164
184
|
* @param {boolean} [options.fullscreen.enterOnRotate=true]
|
|
165
185
|
* Whether to go fullscreen when rotating to landscape
|
|
166
186
|
* @param {boolean} [options.fullscreen.exitOnRotate=true]
|
|
167
187
|
* Whether to leave fullscreen when rotating to portrait (if not locked)
|
|
168
188
|
* @param {boolean} [options.fullscreen.lockOnRotate=true]
|
|
169
189
|
* Whether to lock orientation when rotating to landscape
|
|
190
|
+
* Unlocked when exiting fullscreen or on 'ended
|
|
191
|
+
* @param {boolean} [options.fullscreen.lockToLandscapeOnEnter=false]
|
|
192
|
+
* Whether to always lock orientation to landscape on fullscreen mode
|
|
170
193
|
* Unlocked when exiting fullscreen or on 'ended'
|
|
171
194
|
* @param {boolean} [options.fullscreen.iOS=false]
|
|
172
|
-
* Whether to disable iOS's native fullscreen so controls can work
|
|
195
|
+
* Deprecated: Whether to disable iOS's native fullscreen so controls can work
|
|
173
196
|
* @param {Object} [options.touchControls={}]
|
|
174
197
|
* Touch UI options.
|
|
198
|
+
* @param {boolean} [options.touchControls.disabled=false]
|
|
199
|
+
* If true no touch controls are added.
|
|
175
200
|
* @param {int} [options.touchControls.seekSeconds=10]
|
|
176
201
|
* Number of seconds to seek on double-tap
|
|
177
202
|
* @param {int} [options.touchControls.tapTimeout=300]
|
package/test/plugin.test.js
CHANGED
|
@@ -62,6 +62,24 @@ QUnit.test('inserts element before control bar', function(assert) {
|
|
|
62
62
|
);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
QUnit.test('does not insert if disabled', function(assert) {
|
|
66
|
+
|
|
67
|
+
this.player.mobileUi({
|
|
68
|
+
forceForTesting: true,
|
|
69
|
+
touchControls: {
|
|
70
|
+
disabled: true
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
this.clock.tick(1);
|
|
75
|
+
|
|
76
|
+
assert.strictEqual(
|
|
77
|
+
this.player.touchOverlay,
|
|
78
|
+
undefined,
|
|
79
|
+
'TouchOverlay should not be present'
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
65
83
|
QUnit.test('iOS event listeners', function(assert) {
|
|
66
84
|
|
|
67
85
|
const oldBrowser = videojs.browser;
|
|
@@ -118,7 +136,7 @@ QUnit[testOrSkip]('Android event listeners', function(assert) {
|
|
|
118
136
|
assert.strictEqual(
|
|
119
137
|
typeof window.screen.orientation.onchange,
|
|
120
138
|
'function',
|
|
121
|
-
'screen.orientation.onchange is used for
|
|
139
|
+
'screen.orientation.onchange is used for android'
|
|
122
140
|
);
|
|
123
141
|
|
|
124
142
|
this.player.dispose();
|
|
@@ -133,3 +151,30 @@ QUnit[testOrSkip]('Android event listeners', function(assert) {
|
|
|
133
151
|
|
|
134
152
|
videojs.browser = oldBrowser;
|
|
135
153
|
});
|
|
154
|
+
|
|
155
|
+
QUnit[testOrSkip]('Android event listeners skipped if disabled', function(assert) {
|
|
156
|
+
|
|
157
|
+
const oldBrowser = videojs.browser;
|
|
158
|
+
|
|
159
|
+
videojs.browser = videojs.mergeOptions(videojs.browser, {
|
|
160
|
+
IS_IOS: false,
|
|
161
|
+
IS_ANDROID: true
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
this.player.mobileUi({
|
|
165
|
+
forceForTesting: true,
|
|
166
|
+
fullscreen: {
|
|
167
|
+
disabled: true
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
this.clock.tick(1);
|
|
172
|
+
|
|
173
|
+
assert.notStrictEqual(
|
|
174
|
+
typeof window.screen.orientation.onchange,
|
|
175
|
+
'function',
|
|
176
|
+
'screen.orientation.onchange skipped for android'
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
videojs.browser = oldBrowser;
|
|
180
|
+
});
|