videojs-mobile-ui 0.8.0 → 1.0.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.
Files changed (45) hide show
  1. package/README.md +4 -2
  2. package/dist/lang/de.js +3 -0
  3. package/dist/lang/en.js +1 -1
  4. package/dist/lang/it.js +3 -0
  5. package/dist/videojs-mobile-ui.cjs.js +110 -185
  6. package/dist/videojs-mobile-ui.css +2 -2
  7. package/dist/videojs-mobile-ui.es.js +110 -184
  8. package/dist/videojs-mobile-ui.js +117 -231
  9. package/dist/videojs-mobile-ui.min.js +2 -2
  10. package/index.html +1 -7
  11. package/package.json +10 -10
  12. package/src/plugin.css +13 -1
  13. package/src/plugin.js +5 -33
  14. package/src/touchOverlay.js +46 -56
  15. package/CHANGELOG.md +0 -95
  16. package/docs/api/TouchOverlay.html +0 -964
  17. package/docs/api/fonts/OpenSans-Bold-webfont.eot +0 -0
  18. package/docs/api/fonts/OpenSans-Bold-webfont.svg +0 -1830
  19. package/docs/api/fonts/OpenSans-Bold-webfont.woff +0 -0
  20. package/docs/api/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  21. package/docs/api/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  22. package/docs/api/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  23. package/docs/api/fonts/OpenSans-Italic-webfont.eot +0 -0
  24. package/docs/api/fonts/OpenSans-Italic-webfont.svg +0 -1830
  25. package/docs/api/fonts/OpenSans-Italic-webfont.woff +0 -0
  26. package/docs/api/fonts/OpenSans-Light-webfont.eot +0 -0
  27. package/docs/api/fonts/OpenSans-Light-webfont.svg +0 -1831
  28. package/docs/api/fonts/OpenSans-Light-webfont.woff +0 -0
  29. package/docs/api/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  30. package/docs/api/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  31. package/docs/api/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  32. package/docs/api/fonts/OpenSans-Regular-webfont.eot +0 -0
  33. package/docs/api/fonts/OpenSans-Regular-webfont.svg +0 -1831
  34. package/docs/api/fonts/OpenSans-Regular-webfont.woff +0 -0
  35. package/docs/api/global.html +0 -957
  36. package/docs/api/index.html +0 -159
  37. package/docs/api/plugin.js.html +0 -221
  38. package/docs/api/scripts/linenumber.js +0 -25
  39. package/docs/api/scripts/prettify/Apache-License-2.0.txt +0 -202
  40. package/docs/api/scripts/prettify/lang-css.js +0 -2
  41. package/docs/api/scripts/prettify/prettify.js +0 -28
  42. package/docs/api/styles/jsdoc-default.css +0 -358
  43. package/docs/api/styles/prettify-jsdoc.css +0 -111
  44. package/docs/api/styles/prettify-tomorrow.css +0 -132
  45. package/docs/api/touchOverlay.js.html +0 -211
package/src/plugin.js CHANGED
@@ -10,7 +10,6 @@ const defaults = {
10
10
  exitOnRotate: true,
11
11
  lockOnRotate: true,
12
12
  lockToLandscapeOnEnter: false,
13
- iOS: false,
14
13
  disabled: false
15
14
  },
16
15
  touchControls: {
@@ -29,9 +28,9 @@ const screen = window.screen;
29
28
  * @return {string} orientation
30
29
  */
31
30
  const getOrientation = () => {
32
- if (screen) {
31
+ if (window.screen) {
33
32
  // Prefer the string over angle, as 0° can be landscape on some tablets
34
- const orientationString = ((screen.orientation || {}).type || screen.mozOrientation || screen.msOrientation || '').split('-')[0];
33
+ const orientationString = ((window.screen.orientation || {}).type || window.screen.mozOrientation || window.screen.msOrientation || '').split('-')[0];
35
34
 
36
35
  if (orientationString === 'landscape' || orientationString === 'portrait') {
37
36
  return orientationString;
@@ -49,9 +48,6 @@ const getOrientation = () => {
49
48
  return 'portrait';
50
49
  };
51
50
 
52
- // Cross-compatibility for Video.js 5 and 6.
53
- const registerPlugin = videojs.registerPlugin || videojs.plugin;
54
-
55
51
  /**
56
52
  * Add UI and event listeners
57
53
  *
@@ -65,17 +61,6 @@ const registerPlugin = videojs.registerPlugin || videojs.plugin;
65
61
  const onPlayerReady = (player, options) => {
66
62
  player.addClass('vjs-mobile-ui');
67
63
 
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
- }
77
- }
78
-
79
64
  if (!options.touchControls.disabled) {
80
65
 
81
66
  if (options.touchControls.disableOnEnd || typeof player.endscreen === 'function') {
@@ -83,20 +68,7 @@ const onPlayerReady = (player, options) => {
83
68
  }
84
69
 
85
70
  // 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
- }
71
+ const controlBarIdx = player.children_.indexOf(player.getChild('ControlBar'));
100
72
 
101
73
  player.touchOverlay = player.addChild('TouchOverlay', options.touchControls, controlBarIdx);
102
74
  }
@@ -208,13 +180,13 @@ const onPlayerReady = (player, options) => {
208
180
  const mobileUi = function(options = {}) {
209
181
  if (options.forceForTesting || videojs.browser.IS_ANDROID || videojs.browser.IS_IOS) {
210
182
  this.ready(() => {
211
- onPlayerReady(this, videojs.mergeOptions(defaults, options));
183
+ onPlayerReady(this, videojs.obj.merge(defaults, options));
212
184
  });
213
185
  }
214
186
  };
215
187
 
216
188
  // Register the plugin with video.js.
217
- registerPlugin('mobileUi', mobileUi);
189
+ videojs.registerPlugin('mobileUi', mobileUi);
218
190
 
219
191
  // Include the version number.
220
192
  mobileUi.VERSION = VERSION;
@@ -30,6 +30,7 @@ class TouchOverlay extends Component {
30
30
 
31
31
  this.seekSeconds = options.seekSeconds;
32
32
  this.tapTimeout = options.tapTimeout;
33
+ this.taps = 0;
33
34
 
34
35
  // Add play toggle overlay
35
36
  this.addChild('playToggle', {});
@@ -44,6 +45,46 @@ class TouchOverlay extends Component {
44
45
  this.player_.options_.inactivityTimeout = 5000;
45
46
  }
46
47
 
48
+ /**
49
+ * Debounced tap handler.
50
+ * Seeks number of (taps - 1) * configured seconds to skip.
51
+ * One tap is a non-op
52
+ *
53
+ * @param {Event} event
54
+ */
55
+ this.handleTaps_ = videojs.fn.debounce(event => {
56
+ const increment = (this.taps - 1) * this.seekSeconds;
57
+
58
+ this.taps = 0;
59
+ if (increment < 1) {
60
+ return;
61
+ }
62
+
63
+ const rect = this.el_.getBoundingClientRect();
64
+ const x = event.changedTouches[0].clientX - rect.left;
65
+
66
+ // Check if double tap is in left or right area
67
+ if (x < rect.width * 0.4) {
68
+ this.player_.currentTime(Math.max(0, this.player_.currentTime() - increment));
69
+ this.addClass('reverse');
70
+ } else if (x > rect.width - (rect.width * 0.4)) {
71
+ this.player_.currentTime(Math.min(this.player_.duration(), this.player_.currentTime() + increment));
72
+ this.removeClass('reverse');
73
+ } else {
74
+ return;
75
+ }
76
+
77
+ // Remove play toggle if showing
78
+ this.removeClass('show-play-toggle');
79
+
80
+ // Remove and readd class to trigger animation
81
+ this.setAttribute('data-skip-text', `${increment} ${this.localize('seconds')}`);
82
+ this.removeClass('skip');
83
+ window.requestAnimationFrame(() => {
84
+ this.addClass('skip');
85
+ });
86
+ }, this.tapTimeout);
87
+
47
88
  this.enable();
48
89
  }
49
90
 
@@ -78,63 +119,12 @@ class TouchOverlay extends Component {
78
119
 
79
120
  event.preventDefault();
80
121
 
81
- if (this.firstTapCaptured) {
82
- this.firstTapCaptured = false;
83
- if (this.timeout) {
84
- window.clearTimeout(this.timeout);
85
- }
86
- this.handleDoubleTap(event);
87
- } else {
88
- this.firstTapCaptured = true;
89
- this.timeout = window.setTimeout(() => {
90
- this.firstTapCaptured = false;
91
- this.handleSingleTap(event);
92
- }, this.tapTimeout);
122
+ this.taps += 1;
123
+ if (this.taps === 1) {
124
+ this.removeClass('skip');
125
+ this.toggleClass('show-play-toggle');
93
126
  }
94
- }
95
-
96
- /**
97
- * Toggles display of play toggle
98
- *
99
- * @param {Event} event
100
- * The touch event
101
- *
102
- */
103
- handleSingleTap(event) {
104
- this.removeClass('skip');
105
- this.toggleClass('show-play-toggle');
106
- }
107
-
108
- /**
109
- * Seeks by configured number of seconds if left or right part of video double tapped
110
- *
111
- * @param {Event} event
112
- * The touch event
113
- *
114
- */
115
- handleDoubleTap(event) {
116
- const rect = this.el_.getBoundingClientRect();
117
- const x = event.changedTouches[0].clientX - rect.left;
118
-
119
- // Check if double tap is in left or right area
120
- if (x < rect.width * 0.4) {
121
- this.player_.currentTime(Math.max(0, this.player_.currentTime() - this.seekSeconds));
122
- this.addClass('reverse');
123
- } else if (x > rect.width - (rect.width * 0.4)) {
124
- this.player_.currentTime(Math.min(this.player_.duration(), this.player_.currentTime() + this.seekSeconds));
125
- this.removeClass('reverse');
126
- } else {
127
- return;
128
- }
129
-
130
- // Remove play toggle if showing
131
- this.removeClass('show-play-toggle');
132
-
133
- // Remove and readd class to trigger animation
134
- this.removeClass('skip');
135
- window.requestAnimationFrame(() => {
136
- this.addClass('skip');
137
- });
127
+ this.handleTaps_(event);
138
128
  }
139
129
 
140
130
  /**
package/CHANGELOG.md DELETED
@@ -1,95 +0,0 @@
1
- <a name="0.8.0"></a>
2
- # [0.8.0](https://github.com/mister-ben/videojs-mobile-ui/compare/v0.5.3...v0.8.0) (2022-04-13)
3
-
4
- ### Features
5
-
6
- * Add disable options (#33) ([59e5f89](https://github.com/mister-ben/videojs-mobile-ui/commit/59e5f89)), closes [#33](https://github.com/mister-ben/videojs-mobile-ui/issues/33)
7
- * Add option to lock to landscape when entering fullscreen (#49) ([26c58d4](https://github.com/mister-ben/videojs-mobile-ui/commit/26c58d4)), closes [#49](https://github.com/mister-ben/videojs-mobile-ui/issues/49)
8
-
9
- ### Bug Fixes
10
-
11
- * Detect angle correctly where no window.orientation (#17) ([c85ac35](https://github.com/mister-ben/videojs-mobile-ui/commit/c85ac35)), closes [#17](https://github.com/mister-ben/videojs-mobile-ui/issues/17)
12
- * Fix typo in iOS orientation (#27) ([7e05afb](https://github.com/mister-ben/videojs-mobile-ui/commit/7e05afb)), closes [#27](https://github.com/mister-ben/videojs-mobile-ui/issues/27)
13
- * orientation string (#37) ([177f326](https://github.com/mister-ben/videojs-mobile-ui/commit/177f326)), closes [#37](https://github.com/mister-ben/videojs-mobile-ui/issues/37)
14
- * Remove event listeners on player dispose (#21) ([25c8fb1](https://github.com/mister-ben/videojs-mobile-ui/commit/25c8fb1)), closes [#21](https://github.com/mister-ben/videojs-mobile-ui/issues/21)
15
- * Split orientation string ([0eebd64](https://github.com/mister-ben/videojs-mobile-ui/commit/0eebd64))
16
-
17
- ### Chores
18
-
19
- * **deps-dev:** bump karma from 6.3.14 to 6.3.16 (#46) ([7bd42f1](https://github.com/mister-ben/videojs-mobile-ui/commit/7bd42f1)), closes [#46](https://github.com/mister-ben/videojs-mobile-ui/issues/46)
20
- * **deps-dev:** bump karma from 6.3.2 to 6.3.14 (#44) ([ddff196](https://github.com/mister-ben/videojs-mobile-ui/commit/ddff196)), closes [#44](https://github.com/mister-ben/videojs-mobile-ui/issues/44)
21
- * **deps:** bump engine.io from 4.1.1 to 4.1.2 (#39) ([5031c93](https://github.com/mister-ben/videojs-mobile-ui/commit/5031c93)), closes [#39](https://github.com/mister-ben/videojs-mobile-ui/issues/39)
22
- * **deps:** bump follow-redirects from 1.14.0 to 1.14.7 (#41) ([6fcbb49](https://github.com/mister-ben/videojs-mobile-ui/commit/6fcbb49)), closes [#41](https://github.com/mister-ben/videojs-mobile-ui/issues/41)
23
- * **deps:** bump follow-redirects from 1.14.7 to 1.14.8 (#45) ([cf20418](https://github.com/mister-ben/videojs-mobile-ui/commit/cf20418)), closes [#45](https://github.com/mister-ben/videojs-mobile-ui/issues/45)
24
- * **deps:** bump log4js from 6.3.0 to 6.4.0 (#42) ([f9c69ff](https://github.com/mister-ben/videojs-mobile-ui/commit/f9c69ff)), closes [#42](https://github.com/mister-ben/videojs-mobile-ui/issues/42)
25
- * **deps:** bump minimist from 1.2.5 to 1.2.6 (#50) ([6faea79](https://github.com/mister-ben/videojs-mobile-ui/commit/6faea79)), closes [#50](https://github.com/mister-ben/videojs-mobile-ui/issues/50)
26
- * **deps:** bump nanoid from 3.1.22 to 3.2.0 (#43) ([70e3440](https://github.com/mister-ben/videojs-mobile-ui/commit/70e3440)), closes [#43](https://github.com/mister-ben/videojs-mobile-ui/issues/43)
27
- * **deps:** bump shelljs from 0.8.4 to 0.8.5 (#40) ([bf57915](https://github.com/mister-ben/videojs-mobile-ui/commit/bf57915)), closes [#40](https://github.com/mister-ben/videojs-mobile-ui/issues/40)
28
- * make video.js a peer dependency (#51) ([1e1ae5d](https://github.com/mister-ben/videojs-mobile-ui/commit/1e1ae5d)), closes [#51](https://github.com/mister-ben/videojs-mobile-ui/issues/51)
29
- * update dependencies ([6fb5a7b](https://github.com/mister-ben/videojs-mobile-ui/commit/6fb5a7b))
30
- * Update to Node 14 / Generator 8 (#16) ([660dc86](https://github.com/mister-ben/videojs-mobile-ui/commit/660dc86)), closes [#16](https://github.com/mister-ben/videojs-mobile-ui/issues/16)
31
-
32
- <a name="0.7.0"></a>
33
- # [0.7.0](https://github.com/mister-ben/videojs-mobile-ui/compare/v0.6.1...v0.7.0) (2021-11-09)
34
-
35
- ### Features
36
-
37
- * Add disable options (#33) ([59e5f89](https://github.com/mister-ben/videojs-mobile-ui/commit/59e5f89)), closes [#33](https://github.com/mister-ben/videojs-mobile-ui/issues/33)
38
-
39
- ### Bug Fixes
40
-
41
- * orientation string (#37) ([177f326](https://github.com/mister-ben/videojs-mobile-ui/commit/177f326)), closes [#37](https://github.com/mister-ben/videojs-mobile-ui/issues/37)
42
-
43
- ### Chores
44
-
45
- * update dependencies ([6fb5a7b](https://github.com/mister-ben/videojs-mobile-ui/commit/6fb5a7b))
46
-
47
- <a name="0.6.1"></a>
48
- ## [0.6.1](https://github.com/mister-ben/videojs-mobile-ui/compare/v0.6.0...v0.6.1) (2021-08-27)
49
-
50
- ### Bug Fixes
51
-
52
- * Split orientation string ([0eebd64](https://github.com/mister-ben/videojs-mobile-ui/commit/0eebd64))
53
-
54
- <a name="0.6.0"></a>
55
- # 0.6.0 (2021-08-27)
56
-
57
- ### Bug Fixes
58
-
59
- * Detect angle correctly where no window.orientation (#17) ([c85ac35](https://github.com/mister-ben/videojs-mobile-ui/commit/c85ac35)), closes [#17](https://github.com/mister-ben/videojs-mobile-ui/issues/17)
60
- * Fix fullscreen on rotate (#14) ([33093e4](https://github.com/mister-ben/videojs-mobile-ui/commit/33093e4)), closes [#14](https://github.com/mister-ben/videojs-mobile-ui/issues/14)
61
- * Fix typo in iOS orientation (#27) ([7e05afb](https://github.com/mister-ben/videojs-mobile-ui/commit/7e05afb)), closes [#27](https://github.com/mister-ben/videojs-mobile-ui/issues/27)
62
- * Remove event listeners on player dispose (#21) ([25c8fb1](https://github.com/mister-ben/videojs-mobile-ui/commit/25c8fb1)), closes [#21](https://github.com/mister-ben/videojs-mobile-ui/issues/21)
63
-
64
- ### Chores
65
-
66
- * Update to Node 14 / Generator 8 (#16) ([660dc86](https://github.com/mister-ben/videojs-mobile-ui/commit/660dc86)), closes [#16](https://github.com/mister-ben/videojs-mobile-ui/issues/16)
67
-
68
- <a name="0.5.3"></a>
69
- ## [0.5.3](https://github.com/mister-ben/videojs-mobile-ui/compare/v0.5.2...v0.5.3) (2021-05-25)
70
-
71
- ### Bug Fixes
72
-
73
- * Fix fullscreen on rotate (#14) ([33093e4](https://github.com/mister-ben/videojs-mobile-ui/commit/33093e4)), closes [#14](https://github.com/mister-ben/videojs-mobile-ui/issues/14)
74
-
75
- <a name="0.5.2"></a>
76
- ## [0.5.2](https://github.com/mister-ben/videojs-mobile-ui/compare/v0.5.1...v0.5.2) (2021-01-29)
77
-
78
- <a name="0.5.1"></a>
79
- ## [0.5.1](https://github.com/mister-ben/videojs-mobile-ui/compare/v0.5.0...v0.5.1) (2021-01-29)
80
-
81
- <a name="0.5.0"></a>
82
- # 0.5.0 (2021-01-16)
83
-
84
- <a name="0.4.1"></a>
85
- ## [0.4.1](https://github.com/mister-ben/videojs-mobile-ui/compare/v0.4.0...v0.4.1) (2018-04-30)
86
-
87
- <a name="0.4.0"></a>
88
- # [0.4.0](https://github.com/mister-ben/videojs-mobile-ui/compare/v0.3.0...v0.4.0) (2018-04-30)
89
-
90
- <a name="0.3.0"></a>
91
- # [0.3.0](https://github.com/mister-ben/videojs-mobile-ui/compare/v0.2.0...v0.3.0) (2018-04-28)
92
-
93
- <a name="0.2.0"></a>
94
- # 0.2.0 (2018-04-28)
95
-