@desynova-digital/player 3.9.7 → 3.9.9
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/Manager.js +26 -50
- package/actions/player.js +58 -89
- package/actions/video.js +70 -69
- package/colors.js +13 -13
- package/components/AudioMeter.js +138 -182
- package/components/BigPlayButton.js +48 -72
- package/components/ImageViewer.js +120 -165
- package/components/MarkerBar.js +64 -75
- package/components/Menu.js +30 -57
- package/components/Player.js +239 -357
- package/components/PlayerHeader.js +213 -348
- package/components/Playlist.js +50 -89
- package/components/PointersBar.js +131 -203
- package/components/PosterImage.js +12 -22
- package/components/SDOutline.js +32 -54
- package/components/Shortcut.js +135 -140
- package/components/Slider.js +85 -128
- package/components/TagsBar.js +45 -62
- package/components/Video.js +479 -655
- package/components/control-bar/AudioTracksMenuButton.js +63 -86
- package/components/control-bar/CameraButton.js +65 -76
- package/components/control-bar/CommentsButton.js +97 -136
- package/components/control-bar/ControlBar.js +171 -164
- package/components/control-bar/EditorControlMenuButton.js +180 -280
- package/components/control-bar/ForwardControl.js +7 -11
- package/components/control-bar/ForwardReplayControl.js +41 -55
- package/components/control-bar/FullscreenToggle.js +48 -67
- package/components/control-bar/PlayToggle.js +39 -54
- package/components/control-bar/ReplayControl.js +7 -11
- package/components/control-bar/SettingsMenuButton.js +19 -29
- package/components/control-bar/SubtitleLanguagesMenuButton.js +90 -119
- package/components/control-bar/SubtitleMovementMenu.js +128 -0
- package/components/control-bar/VolumeMenuButton.js +71 -96
- package/components/control-bar/ZoomMenuButton.js +57 -81
- package/components/marking-controls/MarkInControl.js +49 -65
- package/components/marking-controls/MarkOutControl.js +53 -69
- package/components/marking-controls/MarkingAddButton.js +41 -54
- package/components/marking-controls/MarkingControl.js +58 -107
- package/components/marking-controls/MarkingDeleteButton.js +39 -51
- package/components/marking-controls/MarkingDuration.js +23 -56
- package/components/marking-controls/MarkingPreview.js +39 -51
- package/components/progress-bar/AudioWaveform.js +48 -64
- package/components/progress-bar/LoadProgressBar.js +14 -37
- package/components/progress-bar/MouseTimeDisplay.js +14 -30
- package/components/progress-bar/PlayProgressBar.js +23 -41
- package/components/progress-bar/ProgressControl.js +82 -141
- package/components/progress-bar/SeekBar.js +101 -169
- package/components/progress-bar/Timeline.js +57 -81
- package/components/settings-menu-control/PlaybackRateControl.js +70 -115
- package/components/settings-menu-control/SafeAreaControl.js +49 -65
- package/components/settings-menu-control/SettingsMenu.js +26 -50
- package/components/time-controls/CurrentTimeDisplay.js +15 -34
- package/components/time-controls/DurationDisplay.js +14 -33
- package/components/time-controls/TimeDivider.js +12 -28
- package/components/volume-control/VolumeBar.js +84 -118
- package/components/volume-control/VolumeControl.js +7 -23
- package/components/volume-control/VolumeLevel.js +19 -36
- package/components/zoom-control/ZoomBar.js +79 -111
- package/components/zoom-control/ZoomLevel.js +24 -36
- package/index.js +204 -149
- package/package.json +5 -1
- package/reducers/index.js +12 -14
- package/reducers/operation.js +14 -14
- package/reducers/player.js +40 -42
- package/utils/browser.js +10 -5
- package/utils/dom.js +4 -15
- package/utils/fullscreen.js +24 -24
- package/utils/index.js +35 -46
package/components/Shortcut.js
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _propTypes = require("prop-types");
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
17
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
-
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
function
|
|
22
|
-
|
|
18
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
19
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
23
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
24
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
25
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
26
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
27
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
28
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
29
|
var propTypes = {
|
|
24
30
|
clickable: _propTypes.PropTypes.bool,
|
|
25
31
|
dblclickable: _propTypes.PropTypes.bool,
|
|
@@ -33,7 +39,6 @@ var propTypes = {
|
|
|
33
39
|
frameRate: _propTypes.PropTypes.number,
|
|
34
40
|
playerType: _propTypes.PropTypes.oneOf(['dubbing_review', 'clipping_default', 'default', 'tagging', 'qc', 'subtitle', 'snp_edit', 'archive', 'restore', 'clipping', 'storyboard', 'panel'])
|
|
35
41
|
};
|
|
36
|
-
|
|
37
42
|
var defaultProps = {
|
|
38
43
|
clickable: true,
|
|
39
44
|
dblclickable: true,
|
|
@@ -41,21 +46,21 @@ var defaultProps = {
|
|
|
41
46
|
player: {},
|
|
42
47
|
shortcuts: []
|
|
43
48
|
};
|
|
44
|
-
|
|
45
|
-
var Shortcut = function (_Component) {
|
|
49
|
+
var Shortcut = /*#__PURE__*/function (_Component) {
|
|
46
50
|
_inherits(Shortcut, _Component);
|
|
47
|
-
|
|
51
|
+
var _super = _createSuper(Shortcut);
|
|
48
52
|
function Shortcut(props, context) {
|
|
53
|
+
var _this;
|
|
49
54
|
_classCallCheck(this, Shortcut);
|
|
50
|
-
|
|
51
|
-
var _this = _possibleConstructorReturn(this, (Shortcut.__proto__ || Object.getPrototypeOf(Shortcut)).call(this, props, context));
|
|
52
|
-
|
|
55
|
+
_this = _super.call(this, props, context);
|
|
53
56
|
_this.intervalRewind = null;
|
|
54
57
|
_this.defaultShortcuts = [{
|
|
55
|
-
keyCode: 32,
|
|
58
|
+
keyCode: 32,
|
|
59
|
+
// spacebar
|
|
56
60
|
handle: _this.togglePlay
|
|
57
61
|
}, {
|
|
58
|
-
keyCode: 75,
|
|
62
|
+
keyCode: 75,
|
|
63
|
+
// k
|
|
59
64
|
handle: function handle(player, actions) {
|
|
60
65
|
actions.pause({
|
|
61
66
|
action: 'pause',
|
|
@@ -68,21 +73,24 @@ var Shortcut = function (_Component) {
|
|
|
68
73
|
actions.handleVideoRewind(false);
|
|
69
74
|
}
|
|
70
75
|
}, {
|
|
71
|
-
keyCode: 70,
|
|
76
|
+
keyCode: 70,
|
|
77
|
+
// f
|
|
72
78
|
handle: _this.toggleFullscreen
|
|
73
79
|
}, {
|
|
74
|
-
keyCode: 37,
|
|
80
|
+
keyCode: 37,
|
|
81
|
+
// Left arrow
|
|
75
82
|
handle: function handle(player, actions, frameRate) {
|
|
76
83
|
if (!player.hasStarted) {
|
|
77
84
|
return;
|
|
78
85
|
}
|
|
79
86
|
actions.replay(1 / frameRate, {
|
|
80
|
-
action:
|
|
87
|
+
action: "forward-".concat(1 / frameRate),
|
|
81
88
|
source: 'shortcut'
|
|
82
89
|
}); // Go back 1 frame
|
|
83
90
|
}
|
|
84
91
|
}, {
|
|
85
|
-
keyCode: 37,
|
|
92
|
+
keyCode: 37,
|
|
93
|
+
// Left arrow
|
|
86
94
|
shift: true,
|
|
87
95
|
handle: function handle(player, actions) {
|
|
88
96
|
if (!player.hasStarted) {
|
|
@@ -94,7 +102,8 @@ var Shortcut = function (_Component) {
|
|
|
94
102
|
}); // Go back 1 seconds
|
|
95
103
|
}
|
|
96
104
|
}, {
|
|
97
|
-
keyCode: 74,
|
|
105
|
+
keyCode: 74,
|
|
106
|
+
// j
|
|
98
107
|
handle: function handle(player, actions) {
|
|
99
108
|
actions.changeRate(1.0, {
|
|
100
109
|
action: 'change-rate',
|
|
@@ -103,18 +112,20 @@ var Shortcut = function (_Component) {
|
|
|
103
112
|
actions.handleVideoRewind(true);
|
|
104
113
|
}
|
|
105
114
|
}, {
|
|
106
|
-
keyCode: 39,
|
|
115
|
+
keyCode: 39,
|
|
116
|
+
// Right arrow
|
|
107
117
|
handle: function handle(player, actions, frameRate) {
|
|
108
118
|
if (!player.hasStarted) {
|
|
109
119
|
return;
|
|
110
120
|
}
|
|
111
121
|
actions.forward(1 / frameRate, {
|
|
112
|
-
action:
|
|
122
|
+
action: "forward-".concat(1 / frameRate),
|
|
113
123
|
source: 'shortcut'
|
|
114
124
|
}); // Go forward 1 frame
|
|
115
125
|
}
|
|
116
126
|
}, {
|
|
117
|
-
keyCode: 39,
|
|
127
|
+
keyCode: 39,
|
|
128
|
+
// Right arrow
|
|
118
129
|
shift: true,
|
|
119
130
|
handle: function handle(player, actions) {
|
|
120
131
|
if (!player.hasStarted) {
|
|
@@ -126,7 +137,8 @@ var Shortcut = function (_Component) {
|
|
|
126
137
|
}); // Go forward 1 seconds
|
|
127
138
|
}
|
|
128
139
|
}, {
|
|
129
|
-
keyCode: 76,
|
|
140
|
+
keyCode: 76,
|
|
141
|
+
// l
|
|
130
142
|
handle: function handle(player, actions) {
|
|
131
143
|
if (player.paused && player.playbackRate === 1) {
|
|
132
144
|
actions.play({
|
|
@@ -139,7 +151,8 @@ var Shortcut = function (_Component) {
|
|
|
139
151
|
}
|
|
140
152
|
}
|
|
141
153
|
}, {
|
|
142
|
-
keyCode: 36,
|
|
154
|
+
keyCode: 36,
|
|
155
|
+
// Home
|
|
143
156
|
handle: function handle(player, actions) {
|
|
144
157
|
if (!player.hasStarted) {
|
|
145
158
|
return;
|
|
@@ -147,16 +160,16 @@ var Shortcut = function (_Component) {
|
|
|
147
160
|
actions.seek(0); // Go to beginning of video
|
|
148
161
|
}
|
|
149
162
|
}, {
|
|
150
|
-
keyCode: 73,
|
|
163
|
+
keyCode: 73,
|
|
164
|
+
// I Key
|
|
151
165
|
handle: function handle(player, actions) {
|
|
152
166
|
var _this$props = _this.props,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
167
|
+
markers = _this$props.markers,
|
|
168
|
+
playerType = _this$props.playerType,
|
|
169
|
+
onAddMarker = _this$props.onAddMarker,
|
|
170
|
+
playerReadOnlyMode = _this$props.playerReadOnlyMode,
|
|
171
|
+
disablePlayerActions = _this$props.disablePlayerActions,
|
|
172
|
+
playerSelectedMarker = _this$props.playerSelectedMarker;
|
|
160
173
|
if (playerReadOnlyMode || disablePlayerActions.includes("marking_controls")) {
|
|
161
174
|
return;
|
|
162
175
|
}
|
|
@@ -199,17 +212,17 @@ var Shortcut = function (_Component) {
|
|
|
199
212
|
}
|
|
200
213
|
}
|
|
201
214
|
}, {
|
|
202
|
-
keyCode: 79,
|
|
215
|
+
keyCode: 79,
|
|
216
|
+
// O Key
|
|
203
217
|
handle: function handle(player, actions) {
|
|
204
218
|
var _this$props2 = _this.props,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
219
|
+
markers = _this$props2.markers,
|
|
220
|
+
onMarkerSelect = _this$props2.onMarkerSelect,
|
|
221
|
+
playerType = _this$props2.playerType,
|
|
222
|
+
onAddMarker = _this$props2.onAddMarker,
|
|
223
|
+
playerReadOnlyMode = _this$props2.playerReadOnlyMode,
|
|
224
|
+
disablePlayerActions = _this$props2.disablePlayerActions,
|
|
225
|
+
playerSelectedMarker = _this$props2.playerSelectedMarker;
|
|
213
226
|
if (playerReadOnlyMode || disablePlayerActions.includes("marking_controls")) {
|
|
214
227
|
return;
|
|
215
228
|
}
|
|
@@ -251,13 +264,17 @@ var Shortcut = function (_Component) {
|
|
|
251
264
|
// }
|
|
252
265
|
}
|
|
253
266
|
}
|
|
267
|
+
|
|
254
268
|
if (playerSelectedMarker.leftMarker > -1 && player.currentTime > -1 && playerSelectedMarker.markerCreate && createPoint && player.currentTime > playerSelectedMarker.leftMarker) {
|
|
255
269
|
// actions.handleMarkerPointChange('create');
|
|
256
|
-
onAddMarker(playerSelectedMarker.leftMarker, player.currentTime, '', false, {
|
|
270
|
+
onAddMarker(playerSelectedMarker.leftMarker, player.currentTime, '', false, {
|
|
271
|
+
markerType: 'create'
|
|
272
|
+
});
|
|
257
273
|
}
|
|
258
274
|
}
|
|
259
275
|
}, {
|
|
260
|
-
keyCode: 35,
|
|
276
|
+
keyCode: 35,
|
|
277
|
+
// End
|
|
261
278
|
handle: function handle(player, actions) {
|
|
262
279
|
if (!player.hasStarted) {
|
|
263
280
|
return;
|
|
@@ -266,7 +283,8 @@ var Shortcut = function (_Component) {
|
|
|
266
283
|
actions.seek(player.duration);
|
|
267
284
|
}
|
|
268
285
|
}, {
|
|
269
|
-
keyCode: 38,
|
|
286
|
+
keyCode: 38,
|
|
287
|
+
// Up arrow
|
|
270
288
|
handle: function handle(player, actions) {
|
|
271
289
|
// Increase volume 5%
|
|
272
290
|
var v = player.volume + 0.05;
|
|
@@ -279,7 +297,8 @@ var Shortcut = function (_Component) {
|
|
|
279
297
|
});
|
|
280
298
|
}
|
|
281
299
|
}, {
|
|
282
|
-
keyCode: 40,
|
|
300
|
+
keyCode: 40,
|
|
301
|
+
// Down arrow
|
|
283
302
|
handle: function handle(player, actions) {
|
|
284
303
|
// Decrease volume 5%
|
|
285
304
|
var v = player.volume - 0.05;
|
|
@@ -293,25 +312,23 @@ var Shortcut = function (_Component) {
|
|
|
293
312
|
});
|
|
294
313
|
}
|
|
295
314
|
}, {
|
|
296
|
-
keyCode: 68,
|
|
315
|
+
keyCode: 68,
|
|
316
|
+
// D Key
|
|
297
317
|
handle: function handle(player, actions) {
|
|
298
318
|
var playerSelectedMarker = _this.props.playerSelectedMarker;
|
|
299
|
-
|
|
300
319
|
if ((playerSelectedMarker.leftMarker > -1 || playerSelectedMarker.rightMarker > -1) && playerSelectedMarker.markerType === 'create') {
|
|
301
320
|
var onDeleteMarker = _this.props.onDeleteMarker;
|
|
302
|
-
|
|
303
321
|
actions.handleMarkerPointChange('delete');
|
|
304
322
|
onDeleteMarker();
|
|
305
323
|
}
|
|
306
324
|
}
|
|
307
325
|
}, {
|
|
308
|
-
keyCode: 27,
|
|
326
|
+
keyCode: 27,
|
|
327
|
+
// Escape Key
|
|
309
328
|
handle: function handle(player, actions) {
|
|
310
329
|
var playerSelectedMarker = _this.props.playerSelectedMarker;
|
|
311
|
-
|
|
312
330
|
if (playerSelectedMarker.leftMarker > -1) {
|
|
313
331
|
var onDeleteMarker = _this.props.onDeleteMarker;
|
|
314
|
-
|
|
315
332
|
actions.handleVideoPreview(false);
|
|
316
333
|
actions.handleMarkerPointChange('delete');
|
|
317
334
|
onDeleteMarker();
|
|
@@ -320,42 +337,40 @@ var Shortcut = function (_Component) {
|
|
|
320
337
|
}
|
|
321
338
|
}
|
|
322
339
|
}, {
|
|
323
|
-
keyCode: 77,
|
|
340
|
+
keyCode: 77,
|
|
341
|
+
// M Key
|
|
324
342
|
handle: function handle(player, actions) {
|
|
325
343
|
// Mute Video
|
|
326
344
|
actions.mute(!player.muted);
|
|
327
345
|
}
|
|
328
346
|
}, {
|
|
329
|
-
keyCode: 81,
|
|
347
|
+
keyCode: 81,
|
|
348
|
+
// Q Key
|
|
330
349
|
handle: function handle(player, actions) {
|
|
331
350
|
var leftMarker = _this.props.playerSelectedMarker.leftMarker;
|
|
332
|
-
|
|
333
351
|
if (leftMarker > -1) {
|
|
334
352
|
actions.seek(leftMarker);
|
|
335
353
|
}
|
|
336
354
|
}
|
|
337
355
|
}, {
|
|
338
|
-
keyCode: 87,
|
|
356
|
+
keyCode: 87,
|
|
357
|
+
// W Key
|
|
339
358
|
handle: function handle(player, actions) {
|
|
340
359
|
var rightMarker = _this.props.playerSelectedMarker.rightMarker;
|
|
341
|
-
|
|
342
360
|
if (rightMarker > -1) {
|
|
343
361
|
actions.seek(rightMarker);
|
|
344
362
|
}
|
|
345
363
|
}
|
|
346
364
|
}];
|
|
347
|
-
|
|
348
|
-
_this.
|
|
349
|
-
|
|
350
|
-
_this.
|
|
351
|
-
_this.
|
|
352
|
-
_this.handleClick = _this.handleClick.bind(_this);
|
|
353
|
-
_this.handleDoubleClick = _this.handleDoubleClick.bind(_this);
|
|
365
|
+
_this.shortcuts = _toConsumableArray(_this.defaultShortcuts);
|
|
366
|
+
_this.mergeShortcuts = _this.mergeShortcuts.bind(_assertThisInitialized(_this));
|
|
367
|
+
_this.handleKeyPress = _this.handleKeyPress.bind(_assertThisInitialized(_this));
|
|
368
|
+
_this.handleClick = _this.handleClick.bind(_assertThisInitialized(_this));
|
|
369
|
+
_this.handleDoubleClick = _this.handleDoubleClick.bind(_assertThisInitialized(_this));
|
|
354
370
|
return _this;
|
|
355
371
|
}
|
|
356
|
-
|
|
357
372
|
_createClass(Shortcut, [{
|
|
358
|
-
key:
|
|
373
|
+
key: "componentDidMount",
|
|
359
374
|
value: function componentDidMount() {
|
|
360
375
|
this.mergeShortcuts();
|
|
361
376
|
document.addEventListener('keydown', this.handleKeyPress);
|
|
@@ -363,13 +378,12 @@ var Shortcut = function (_Component) {
|
|
|
363
378
|
document.addEventListener('dblclick', this.handleDoubleClick);
|
|
364
379
|
}
|
|
365
380
|
}, {
|
|
366
|
-
key:
|
|
381
|
+
key: "componentDidUpdate",
|
|
367
382
|
value: function componentDidUpdate(prevProps) {
|
|
368
|
-
var
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
383
|
+
var _this$props3 = this.props,
|
|
384
|
+
shortcuts = _this$props3.shortcuts,
|
|
385
|
+
player = _this$props3.player,
|
|
386
|
+
frameRate = _this$props3.frameRate;
|
|
373
387
|
if (prevProps.shortcuts !== shortcuts) {
|
|
374
388
|
this.mergeShortcuts();
|
|
375
389
|
}
|
|
@@ -380,20 +394,19 @@ var Shortcut = function (_Component) {
|
|
|
380
394
|
}
|
|
381
395
|
}
|
|
382
396
|
}, {
|
|
383
|
-
key:
|
|
397
|
+
key: "componentWillUnmount",
|
|
384
398
|
value: function componentWillUnmount() {
|
|
385
399
|
document.removeEventListener('keydown', this.handleKeyPress);
|
|
386
400
|
document.removeEventListener('click', this.handleClick);
|
|
387
401
|
document.removeEventListener('dblclick', this.handleDoubleClick);
|
|
388
402
|
}
|
|
389
403
|
}, {
|
|
390
|
-
key:
|
|
404
|
+
key: "rewindVideo",
|
|
391
405
|
value: function rewindVideo() {
|
|
392
|
-
var
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
406
|
+
var _this$props4 = this.props,
|
|
407
|
+
player = _this$props4.player,
|
|
408
|
+
actions = _this$props4.actions,
|
|
409
|
+
frameRate = _this$props4.frameRate;
|
|
397
410
|
if (player.currentTime == 0 || !player.rewindActive) {
|
|
398
411
|
clearInterval(this.intervalRewind);
|
|
399
412
|
this.intervalRewind = null;
|
|
@@ -405,43 +418,39 @@ var Shortcut = function (_Component) {
|
|
|
405
418
|
} else {
|
|
406
419
|
var time = 1 / frameRate;
|
|
407
420
|
actions.replay(time, {
|
|
408
|
-
action:
|
|
421
|
+
action: "forward-".concat(1 / frameRate),
|
|
409
422
|
source: 'shortcut'
|
|
410
423
|
});
|
|
411
424
|
}
|
|
412
425
|
}
|
|
413
426
|
|
|
414
427
|
// merge the shortcuts from props
|
|
415
|
-
|
|
416
428
|
}, {
|
|
417
|
-
key:
|
|
429
|
+
key: "mergeShortcuts",
|
|
418
430
|
value: function mergeShortcuts() {
|
|
419
431
|
var shortcuts = this.props.shortcuts;
|
|
420
|
-
|
|
421
432
|
var getShortcutKey = function getShortcutKey(_ref) {
|
|
422
433
|
var _ref$keyCode = _ref.keyCode,
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
return keyCode
|
|
434
|
+
keyCode = _ref$keyCode === void 0 ? 0 : _ref$keyCode,
|
|
435
|
+
_ref$ctrl = _ref.ctrl,
|
|
436
|
+
ctrl = _ref$ctrl === void 0 ? false : _ref$ctrl,
|
|
437
|
+
_ref$shift = _ref.shift,
|
|
438
|
+
shift = _ref$shift === void 0 ? false : _ref$shift,
|
|
439
|
+
_ref$alt = _ref.alt,
|
|
440
|
+
alt = _ref$alt === void 0 ? false : _ref$alt;
|
|
441
|
+
return "".concat(keyCode, ":").concat(ctrl, ":").concat(shift, ":").concat(alt);
|
|
431
442
|
};
|
|
432
443
|
var defaultShortcuts = this.defaultShortcuts.reduce(function (shortcuts, shortcut) {
|
|
433
444
|
return Object.assign(shortcuts, _defineProperty({}, getShortcutKey(shortcut), shortcut));
|
|
434
445
|
}, {});
|
|
435
446
|
var mergedShortcuts = (shortcuts || []).reduce(function (shortcuts, shortcut) {
|
|
436
447
|
var keyCode = shortcut.keyCode,
|
|
437
|
-
|
|
438
|
-
|
|
448
|
+
handle = shortcut.handle;
|
|
439
449
|
if (keyCode && typeof handle === 'function') {
|
|
440
450
|
return Object.assign(shortcuts, _defineProperty({}, getShortcutKey(shortcut), shortcut));
|
|
441
451
|
}
|
|
442
452
|
return shortcuts;
|
|
443
453
|
}, defaultShortcuts);
|
|
444
|
-
|
|
445
454
|
var gradeShortcut = function gradeShortcut(s) {
|
|
446
455
|
var score = 0;
|
|
447
456
|
var ps = ['ctrl', 'shift', 'alt'];
|
|
@@ -452,7 +461,6 @@ var Shortcut = function (_Component) {
|
|
|
452
461
|
});
|
|
453
462
|
return score;
|
|
454
463
|
};
|
|
455
|
-
|
|
456
464
|
this.shortcuts = Object.keys(mergedShortcuts).map(function (key) {
|
|
457
465
|
return mergedShortcuts[key];
|
|
458
466
|
}).sort(function (a, b) {
|
|
@@ -460,7 +468,7 @@ var Shortcut = function (_Component) {
|
|
|
460
468
|
});
|
|
461
469
|
}
|
|
462
470
|
}, {
|
|
463
|
-
key:
|
|
471
|
+
key: "togglePlay",
|
|
464
472
|
value: function togglePlay(player, actions) {
|
|
465
473
|
if (this.intervalRewind) {
|
|
466
474
|
clearInterval(this.intervalRewind);
|
|
@@ -484,7 +492,7 @@ var Shortcut = function (_Component) {
|
|
|
484
492
|
}
|
|
485
493
|
}
|
|
486
494
|
}, {
|
|
487
|
-
key:
|
|
495
|
+
key: "changePlaybackRate",
|
|
488
496
|
value: function changePlaybackRate(player, actions) {
|
|
489
497
|
var playbackRate = player.playbackRate;
|
|
490
498
|
if (playbackRate >= 2) {
|
|
@@ -515,34 +523,30 @@ var Shortcut = function (_Component) {
|
|
|
515
523
|
});
|
|
516
524
|
}
|
|
517
525
|
}, {
|
|
518
|
-
key:
|
|
526
|
+
key: "toggleFullscreen",
|
|
519
527
|
value: function toggleFullscreen(player, actions) {
|
|
520
528
|
var playerType = this.props.playerType;
|
|
521
|
-
|
|
522
529
|
if (playerType !== 'panel') {
|
|
523
530
|
actions.toggleFullscreen(player);
|
|
524
531
|
}
|
|
525
532
|
}
|
|
526
533
|
}, {
|
|
527
|
-
key:
|
|
534
|
+
key: "handleKeyPress",
|
|
528
535
|
value: function handleKeyPress(e) {
|
|
529
|
-
var
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
536
|
+
var _this$props5 = this.props,
|
|
537
|
+
player = _this$props5.player,
|
|
538
|
+
actions = _this$props5.actions,
|
|
539
|
+
frameRate = _this$props5.frameRate;
|
|
534
540
|
if (!player.isActive) {
|
|
535
541
|
return;
|
|
536
542
|
}
|
|
537
543
|
if (document.activeElement && (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA')) {
|
|
538
544
|
return;
|
|
539
545
|
}
|
|
540
|
-
|
|
541
546
|
var keyCode = e.keyCode || e.which;
|
|
542
547
|
var ctrl = e.ctrlKey || e.metaKey;
|
|
543
548
|
var shift = e.shiftKey;
|
|
544
549
|
var alt = e.altKey;
|
|
545
|
-
|
|
546
550
|
var shortcut = this.shortcuts.filter(function (s) {
|
|
547
551
|
if (!s.keyCode || s.keyCode - keyCode !== 0) {
|
|
548
552
|
return false;
|
|
@@ -552,7 +556,6 @@ var Shortcut = function (_Component) {
|
|
|
552
556
|
}
|
|
553
557
|
return true;
|
|
554
558
|
})[0];
|
|
555
|
-
|
|
556
559
|
if (shortcut) {
|
|
557
560
|
shortcut.handle(player, actions, frameRate);
|
|
558
561
|
e.preventDefault();
|
|
@@ -560,9 +563,8 @@ var Shortcut = function (_Component) {
|
|
|
560
563
|
}
|
|
561
564
|
|
|
562
565
|
// only if player is active and player is ready
|
|
563
|
-
|
|
564
566
|
}, {
|
|
565
|
-
key:
|
|
567
|
+
key: "canBeClicked",
|
|
566
568
|
value: function canBeClicked(player, e) {
|
|
567
569
|
if (!player.isActive || e.target.nodeName !== 'VIDEO' || player.readyState !== 4) {
|
|
568
570
|
return false;
|
|
@@ -570,13 +572,12 @@ var Shortcut = function (_Component) {
|
|
|
570
572
|
return true;
|
|
571
573
|
}
|
|
572
574
|
}, {
|
|
573
|
-
key:
|
|
575
|
+
key: "handleClick",
|
|
574
576
|
value: function handleClick(e) {
|
|
575
|
-
var
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
577
|
+
var _this$props6 = this.props,
|
|
578
|
+
player = _this$props6.player,
|
|
579
|
+
actions = _this$props6.actions,
|
|
580
|
+
clickable = _this$props6.clickable;
|
|
580
581
|
if (!this.canBeClicked(player, e) || !clickable) {
|
|
581
582
|
return;
|
|
582
583
|
}
|
|
@@ -584,13 +585,12 @@ var Shortcut = function (_Component) {
|
|
|
584
585
|
// e.preventDefault();
|
|
585
586
|
}
|
|
586
587
|
}, {
|
|
587
|
-
key:
|
|
588
|
+
key: "handleDoubleClick",
|
|
588
589
|
value: function handleDoubleClick(e) {
|
|
589
|
-
var
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
590
|
+
var _this$props7 = this.props,
|
|
591
|
+
player = _this$props7.player,
|
|
592
|
+
actions = _this$props7.actions,
|
|
593
|
+
dblclickable = _this$props7.dblclickable;
|
|
594
594
|
if (!this.canBeClicked(player, e) || !dblclickable) {
|
|
595
595
|
return;
|
|
596
596
|
}
|
|
@@ -602,20 +602,15 @@ var Shortcut = function (_Component) {
|
|
|
602
602
|
* this component dose not render anything
|
|
603
603
|
* it's just for the key down event
|
|
604
604
|
*/
|
|
605
|
-
|
|
606
605
|
}, {
|
|
607
|
-
key:
|
|
606
|
+
key: "render",
|
|
608
607
|
value: function render() {
|
|
609
608
|
return null;
|
|
610
609
|
}
|
|
611
610
|
}]);
|
|
612
|
-
|
|
613
611
|
return Shortcut;
|
|
614
612
|
}(_react.Component);
|
|
615
|
-
|
|
616
|
-
exports.default = Shortcut;
|
|
617
|
-
|
|
618
|
-
|
|
613
|
+
exports["default"] = Shortcut;
|
|
619
614
|
Shortcut.propTypes = propTypes;
|
|
620
615
|
Shortcut.defaultProps = defaultProps;
|
|
621
616
|
Shortcut.displayName = 'Shortcut';
|