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