@desynova-digital/player 4.0.0 → 4.0.2
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 +99 -0
- package/actions/player.js +331 -0
- package/actions/video.js +206 -0
- package/{utils/colors.js → colors.js} +1 -2
- package/{media → components}/AudioMeter.js +96 -109
- package/components/BigPlayButton.js +84 -0
- package/components/ImageViewer.js +272 -0
- package/{control → components}/MarkerBar.js +33 -24
- package/{utils → components}/Menu.js +13 -4
- package/components/Player.js +706 -0
- package/{header/Header.js → components/PlayerHeader.js} +104 -78
- package/components/Playlist.js +95 -0
- package/{control → components}/PointersBar.js +122 -61
- package/components/PosterImage.js +50 -0
- package/{media → components}/SDOutline.js +13 -49
- package/components/Shortcut.js +821 -0
- package/{control → components}/Slider.js +27 -23
- package/components/TagsBar.js +81 -0
- package/components/Video.js +1280 -0
- package/{control → components/control-bar}/AudioTracksMenuButton.js +32 -28
- package/components/control-bar/CameraButton.js +75 -0
- package/components/control-bar/CommentsButton.js +186 -0
- package/components/control-bar/ControlBar.js +266 -0
- package/components/control-bar/EditorControlMenuButton.js +317 -0
- package/components/control-bar/ForwardControl.js +12 -0
- package/components/control-bar/ForwardReplayControl.js +106 -0
- package/{control → components/control-bar}/FullscreenToggle.js +26 -21
- package/components/control-bar/PlayToggle.js +85 -0
- package/components/control-bar/ReplayControl.js +12 -0
- package/components/control-bar/SettingsMenuButton.js +41 -0
- package/components/control-bar/SubtitleLanguagesMenuButton.js +149 -0
- package/components/control-bar/SubtitleMovementMenu.js +140 -0
- package/{control/VolumneMenuButton.js → components/control-bar/VolumeMenuButton.js} +26 -27
- package/components/control-bar/ZoomMenuButton.js +90 -0
- package/{control → components/marking-controls}/MarkInControl.js +32 -25
- package/{control → components/marking-controls}/MarkOutControl.js +35 -26
- package/components/marking-controls/MarkingAddButton.js +79 -0
- package/components/marking-controls/MarkingControl.js +95 -0
- package/components/marking-controls/MarkingDeleteButton.js +70 -0
- package/{control → components/marking-controls}/MarkingDuration.js +12 -5
- package/components/marking-controls/MarkingPreview.js +72 -0
- package/components/progress-bar/AudioWaveform.js +126 -0
- package/components/progress-bar/LoadProgressBar.js +67 -0
- package/components/progress-bar/MouseTimeDisplay.js +36 -0
- package/{control → components/progress-bar}/PlayProgressBar.js +4 -4
- package/components/progress-bar/ProgressControl.js +186 -0
- package/{control → components/progress-bar}/SeekBar.js +113 -72
- package/{control → components/progress-bar}/Timeline.js +43 -32
- package/{control/PlayBackRateControl.js → components/settings-menu-control/PlaybackRateControl.js} +44 -30
- package/components/settings-menu-control/SafeAreaControl.js +81 -0
- package/components/settings-menu-control/SettingsMenu.js +56 -0
- package/components/settings-menu-control/SubtitleControl.js +1 -0
- package/components/time-controls/CurrentTimeDisplay.js +83 -0
- package/{control → components/time-controls}/DurationDisplay.js +8 -15
- package/components/time-controls/TimeDivider.js +25 -0
- package/{control → components/volume-control}/VolumeBar.js +62 -80
- package/components/volume-control/VolumeControl.js +19 -0
- package/{control → components/volume-control}/VolumeLevel.js +2 -3
- package/components/zoom-control/ZoomBar.js +155 -0
- package/components/zoom-control/ZoomLevel.js +55 -0
- package/index.js +198 -1
- package/package.json +5 -8
- package/reducers/index.js +19 -0
- package/reducers/operation.js +35 -0
- package/reducers/player.js +222 -0
- package/utils/browser.js +30 -0
- package/utils/dom.js +93 -0
- package/utils/fullscreen.js +72 -0
- package/utils/index.js +156 -57
- package/Player.js +0 -945
- package/control/AudioTracksMenuButton.jsx +0 -80
- package/control/ControlBar.js +0 -303
- package/control/ControlBar.jsx +0 -264
- package/control/CurrentTimeDisplay.js +0 -34
- package/control/CurrentTimeDisplay.jsx +0 -35
- package/control/DurationDisplay.jsx +0 -48
- package/control/ForwardBackwardControl.js +0 -76
- package/control/ForwardBackwardControl.jsx +0 -79
- package/control/FullscreenToggle.jsx +0 -83
- package/control/MarkInControl.jsx +0 -109
- package/control/MarkOutControl.jsx +0 -131
- package/control/MarkerBar.jsx +0 -107
- package/control/MarkingControl.js +0 -82
- package/control/MarkingControl.jsx +0 -143
- package/control/MarkingPreview.js +0 -49
- package/control/MarkingPreview.jsx +0 -60
- package/control/PlayBackRateControl.jsx +0 -106
- package/control/PlayProgressBar.jsx +0 -92
- package/control/PlayToggle.js +0 -56
- package/control/PlayToggle.jsx +0 -57
- package/control/PointersBar.jsx +0 -286
- package/control/ProgressControl.js +0 -127
- package/control/ProgressControl.jsx +0 -155
- package/control/SeekBar.jsx +0 -229
- package/control/SettingsMenuButton.js +0 -63
- package/control/SettingsMenuButton.jsx +0 -69
- package/control/Slider.jsx +0 -243
- package/control/Timeline.jsx +0 -131
- package/control/VolumeBar.jsx +0 -174
- package/control/VolumeLevel.jsx +0 -66
- package/control/VolumneMenuButton.jsx +0 -111
- package/header/Header.jsx +0 -479
- package/media/AudioMeter.jsx +0 -411
- package/media/SDOutline.jsx +0 -90
- package/media/Video.js +0 -684
- package/media/Video.jsx +0 -714
- package/playlist/Playlist.js +0 -67
- package/playlist/Playlist.jsx +0 -91
- package/playlist/index.js +0 -13
- package/shortcuts/Shortcut.js +0 -662
- package/utils/Menu.jsx +0 -105
|
@@ -0,0 +1,821 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = require("prop-types");
|
|
9
|
+
var _lodash = require("lodash");
|
|
10
|
+
var _hotkeysJs = _interopRequireDefault(require("hotkeys-js"));
|
|
11
|
+
var _utils = require("../utils");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
14
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
15
|
+
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."); }
|
|
16
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
17
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
18
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
19
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20
|
+
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); }
|
|
21
|
+
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; }
|
|
22
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
23
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
24
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
25
|
+
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); } }
|
|
26
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
27
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
28
|
+
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); }
|
|
29
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
30
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
31
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
32
|
+
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); }
|
|
33
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
34
|
+
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; }
|
|
35
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
36
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
37
|
+
var propTypes = {
|
|
38
|
+
clickable: _propTypes.PropTypes.bool,
|
|
39
|
+
dblclickable: _propTypes.PropTypes.bool,
|
|
40
|
+
actions: _propTypes.PropTypes.instanceOf(Object),
|
|
41
|
+
player: _propTypes.PropTypes.instanceOf(Object),
|
|
42
|
+
shortcuts: _propTypes.PropTypes.arrayOf(Object),
|
|
43
|
+
markers: _propTypes.PropTypes.instanceOf(Object),
|
|
44
|
+
onAddMarker: _propTypes.PropTypes.func,
|
|
45
|
+
onDeleteMarker: _propTypes.PropTypes.func,
|
|
46
|
+
onMarkerSelect: _propTypes.PropTypes.func,
|
|
47
|
+
frameRate: _propTypes.PropTypes.number,
|
|
48
|
+
playerType: _propTypes.PropTypes.oneOf(['dubbing_review', 'clipping_default', 'default', 'tagging', 'qc', 'subtitle', 'snp_edit', 'archive', 'restore', 'clipping', 'storyboard', 'panel'])
|
|
49
|
+
};
|
|
50
|
+
var defaultProps = {
|
|
51
|
+
clickable: true,
|
|
52
|
+
dblclickable: true,
|
|
53
|
+
actions: {},
|
|
54
|
+
player: {},
|
|
55
|
+
shortcuts: []
|
|
56
|
+
};
|
|
57
|
+
var Shortcut = exports["default"] = /*#__PURE__*/function (_Component) {
|
|
58
|
+
_inherits(Shortcut, _Component);
|
|
59
|
+
function Shortcut(props, context) {
|
|
60
|
+
var _this;
|
|
61
|
+
_classCallCheck(this, Shortcut);
|
|
62
|
+
_this = _callSuper(this, Shortcut, [props, context]);
|
|
63
|
+
_defineProperty(_assertThisInitialized(_this), "segmentShift", function (direction) {
|
|
64
|
+
var _this$props = _this.props,
|
|
65
|
+
leftMarker = _this$props.playerSelectedMarker.leftMarker,
|
|
66
|
+
onTagClick = _this$props.onTagClick;
|
|
67
|
+
var _this$props2 = _this.props,
|
|
68
|
+
actions = _this$props2.actions,
|
|
69
|
+
_this$props2$markers = _slicedToArray(_this$props2.markers, 1),
|
|
70
|
+
values = _this$props2$markers[0].values;
|
|
71
|
+
var newIndex;
|
|
72
|
+
if (direction === 'backward') {
|
|
73
|
+
newIndex = values.findIndex(function (item) {
|
|
74
|
+
return item.in_time === leftMarker;
|
|
75
|
+
}) - 1;
|
|
76
|
+
}
|
|
77
|
+
if (direction === 'forward') {
|
|
78
|
+
newIndex = values.findIndex(function (item) {
|
|
79
|
+
return item.in_time === leftMarker;
|
|
80
|
+
}) + 1;
|
|
81
|
+
}
|
|
82
|
+
if (leftMarker > -1 && newIndex < values.length && direction === 'forward' || leftMarker > -1 && newIndex > -1 && direction === 'backward') {
|
|
83
|
+
var _values$newIndex, _values$newIndex2, _values$newIndex3;
|
|
84
|
+
actions.seek((_values$newIndex = values[newIndex]) === null || _values$newIndex === void 0 ? void 0 : _values$newIndex.start_time);
|
|
85
|
+
onTagClick((_values$newIndex2 = values[newIndex]) === null || _values$newIndex2 === void 0 ? void 0 : _values$newIndex2.start_time, (_values$newIndex3 = values[newIndex]) === null || _values$newIndex3 === void 0 ? void 0 : _values$newIndex3.end_time, values[newIndex]);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
_defineProperty(_assertThisInitialized(_this), "debounceSegmentShiftForward", (0, _lodash.debounce)(function () {
|
|
89
|
+
_this.segmentShift('forward');
|
|
90
|
+
}, 0));
|
|
91
|
+
_defineProperty(_assertThisInitialized(_this), "debounceSegmentShiftBackward", (0, _lodash.debounce)(function () {
|
|
92
|
+
_this.segmentShift('backward');
|
|
93
|
+
}, 0));
|
|
94
|
+
_defineProperty(_assertThisInitialized(_this), "debounceKeyFunc", (0, _lodash.debounce)(function (keyCode) {
|
|
95
|
+
_this.handleKeyMovement(keyCode);
|
|
96
|
+
}));
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param {number} keyCode the keycode for the specific key's functionality
|
|
100
|
+
* @param {boolean} currentTimeRequired currentTime value required or not to perform key functionality
|
|
101
|
+
*common function to handle the key functionalies. eg-> W Key and Q key functionalities
|
|
102
|
+
*/
|
|
103
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeyMovement", function (keyCode) {
|
|
104
|
+
var _this$props$markers$, _this$props$playerSel, _this$props$player, _this$props$player2;
|
|
105
|
+
if (keyCode === 81 || keyCode === 87) {
|
|
106
|
+
_this.isCalled = true;
|
|
107
|
+
}
|
|
108
|
+
var frameRateNumber = parseInt(_this.props.frameRate);
|
|
109
|
+
var timeAfterOverlap;
|
|
110
|
+
var keyPressHandle = _this.defaultShortcuts.find(function (shortcut) {
|
|
111
|
+
return shortcut.keyCode === keyCode;
|
|
112
|
+
});
|
|
113
|
+
var ans = _this.findAdjacentMarkers((_this$props$markers$ = _this.props.markers[0]) === null || _this$props$markers$ === void 0 ? void 0 : _this$props$markers$.values, (_this$props$playerSel = _this.props.playerSelectedMarker) === null || _this$props$playerSel === void 0 ? void 0 : _this$props$playerSel.data);
|
|
114
|
+
if (((_this$props$player = _this.props.player) === null || _this$props$player === void 0 ? void 0 : _this$props$player.currentTime) >= (ans === null || ans === void 0 ? void 0 : ans.in_time_forward)) {
|
|
115
|
+
timeAfterOverlap = ans.in_time_forward - 1 / frameRateNumber;
|
|
116
|
+
}
|
|
117
|
+
if (((_this$props$player2 = _this.props.player) === null || _this$props$player2 === void 0 ? void 0 : _this$props$player2.currentTime) <= (ans === null || ans === void 0 ? void 0 : ans.out_time_behind)) {
|
|
118
|
+
timeAfterOverlap = ans.out_time_behind + 1 / frameRateNumber;
|
|
119
|
+
}
|
|
120
|
+
if (keyPressHandle) {
|
|
121
|
+
keyPressHandle.handle(_this.props.player, _this.props.actions, {
|
|
122
|
+
timeAfterOverlap: timeAfterOverlap
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
*
|
|
128
|
+
* @param {event} event
|
|
129
|
+
* @param {function} handleKeyMovement function to call Q and W key functionality
|
|
130
|
+
* @param {function} debounceKeyFunc to handle the debounced I and O key functionality
|
|
131
|
+
* @param {string} keyParameter to identify the key combo pressed
|
|
132
|
+
* this function executed the Q and W key functionality first and then performs I and O key functionality provided 3 key combo is still pressed
|
|
133
|
+
* Once we leave the keyCombo isCalled variable is set to false. This ensures that on the next combo press we will again execute Q/W key combo first.
|
|
134
|
+
*/
|
|
135
|
+
_defineProperty(_assertThisInitialized(_this), "createThreeKeyCombo", function (event, handleKeyMovement, debounceKeyFunc, keyParameter) {
|
|
136
|
+
var _this$props3 = _this.props,
|
|
137
|
+
playerReadOnlyMode = _this$props3.playerReadOnlyMode,
|
|
138
|
+
disablePlayerActions = _this$props3.disablePlayerActions;
|
|
139
|
+
if (playerReadOnlyMode || disablePlayerActions.includes('marking_controls')) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (!_this.isCalled) {
|
|
143
|
+
handleKeyMovement();
|
|
144
|
+
}
|
|
145
|
+
if (event.type === 'keydown') {
|
|
146
|
+
debounceKeyFunc();
|
|
147
|
+
_this.isCalled = true;
|
|
148
|
+
}
|
|
149
|
+
if (event.type === 'keyup') {
|
|
150
|
+
_this.isCalled = false;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
_defineProperty(_assertThisInitialized(_this), "threeKeyCombo1", (0, _lodash.debounce)(function (event) {
|
|
154
|
+
return _this.createThreeKeyCombo(event, _this.handleKeyMovement.bind(_assertThisInitialized(_this), 87), _this.debounceKeyFunc.bind(_assertThisInitialized(_this), 79), 'Ctrl + O + Right');
|
|
155
|
+
}, 0, {
|
|
156
|
+
leading: true,
|
|
157
|
+
trailing: true
|
|
158
|
+
}));
|
|
159
|
+
_defineProperty(_assertThisInitialized(_this), "threeKeyCombo2", (0, _lodash.debounce)(function (event) {
|
|
160
|
+
return _this.createThreeKeyCombo(event, _this.handleKeyMovement.bind(_assertThisInitialized(_this), 87), _this.debounceKeyFunc.bind(_assertThisInitialized(_this), 79), 'Ctrl + O + Left');
|
|
161
|
+
}, 0, {
|
|
162
|
+
leading: true,
|
|
163
|
+
trailing: true
|
|
164
|
+
}));
|
|
165
|
+
_defineProperty(_assertThisInitialized(_this), "threeKeyCombo3", (0, _lodash.debounce)(function (event) {
|
|
166
|
+
return _this.createThreeKeyCombo(event, _this.handleKeyMovement.bind(_assertThisInitialized(_this), 81), _this.debounceKeyFunc.bind(_assertThisInitialized(_this), 73), 'Ctrl + I + Right');
|
|
167
|
+
}, 0, {
|
|
168
|
+
leading: true,
|
|
169
|
+
trailing: true
|
|
170
|
+
}));
|
|
171
|
+
_defineProperty(_assertThisInitialized(_this), "threeKeyCombo4", (0, _lodash.debounce)(function (event) {
|
|
172
|
+
return _this.createThreeKeyCombo(event, _this.handleKeyMovement.bind(_assertThisInitialized(_this), 81), _this.debounceKeyFunc.bind(_assertThisInitialized(_this), 73), 'Ctrl + I + Left');
|
|
173
|
+
}, 0, {
|
|
174
|
+
leading: true,
|
|
175
|
+
trailing: true
|
|
176
|
+
}));
|
|
177
|
+
_this.intervalRewind = null;
|
|
178
|
+
_this.defaultShortcuts = [{
|
|
179
|
+
keyCode: 32,
|
|
180
|
+
// spacebar
|
|
181
|
+
handle: _this.togglePlay
|
|
182
|
+
}, {
|
|
183
|
+
keyCode: 75,
|
|
184
|
+
// k
|
|
185
|
+
handle: function handle(player, actions) {
|
|
186
|
+
actions.pause({
|
|
187
|
+
action: 'pause',
|
|
188
|
+
source: 'shortcut'
|
|
189
|
+
});
|
|
190
|
+
actions.changeRate(1.0, {
|
|
191
|
+
action: 'fast-forward',
|
|
192
|
+
source: 'shortcut'
|
|
193
|
+
});
|
|
194
|
+
actions.handleVideoRewind(false);
|
|
195
|
+
}
|
|
196
|
+
}, {
|
|
197
|
+
keyCode: 70,
|
|
198
|
+
// f
|
|
199
|
+
handle: _this.toggleFullscreen
|
|
200
|
+
}, {
|
|
201
|
+
keyCode: 37,
|
|
202
|
+
// Left arrow
|
|
203
|
+
handle: function handle(player, actions, frameRate) {
|
|
204
|
+
var leftMarker = _this.props.playerSelectedMarker.leftMarker;
|
|
205
|
+
if (!player.hasStarted && !(leftMarker > -1)) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
actions.replay(1 / frameRate, {
|
|
209
|
+
action: "forward-".concat(1 / frameRate),
|
|
210
|
+
source: 'shortcut'
|
|
211
|
+
}); // Go back 1 frame
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
keyCode: 37,
|
|
215
|
+
// Left arrow
|
|
216
|
+
shift: true,
|
|
217
|
+
handle: function handle(player, actions) {
|
|
218
|
+
if (!player.hasStarted) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
actions.replay(1, {
|
|
222
|
+
action: 'replay-1',
|
|
223
|
+
source: 'shortcut'
|
|
224
|
+
}); // Go back 1 seconds
|
|
225
|
+
}
|
|
226
|
+
}, {
|
|
227
|
+
keyCode: 74,
|
|
228
|
+
// j
|
|
229
|
+
handle: function handle(player, actions) {
|
|
230
|
+
actions.changeRate(1.0, {
|
|
231
|
+
action: 'change-rate',
|
|
232
|
+
source: 'shortcut'
|
|
233
|
+
});
|
|
234
|
+
actions.handleVideoRewind(true);
|
|
235
|
+
}
|
|
236
|
+
}, {
|
|
237
|
+
keyCode: 39,
|
|
238
|
+
// Right arrow
|
|
239
|
+
handle: function handle(player, actions, frameRate) {
|
|
240
|
+
var leftMarker = _this.props.playerSelectedMarker.leftMarker;
|
|
241
|
+
if (!player.hasStarted && !(leftMarker > -1)) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
actions.forward(1 / frameRate, {
|
|
245
|
+
action: "forward-".concat(1 / frameRate),
|
|
246
|
+
source: 'shortcut'
|
|
247
|
+
}); // Go forward 1 frame
|
|
248
|
+
}
|
|
249
|
+
}, {
|
|
250
|
+
keyCode: 39,
|
|
251
|
+
// Right arrow
|
|
252
|
+
shift: true,
|
|
253
|
+
handle: function handle(player, actions) {
|
|
254
|
+
if (!player.hasStarted) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
actions.forward(1, {
|
|
258
|
+
action: 'forward-1',
|
|
259
|
+
source: 'shortcut'
|
|
260
|
+
}); // Go forward 1 seconds
|
|
261
|
+
}
|
|
262
|
+
}, {
|
|
263
|
+
keyCode: 76,
|
|
264
|
+
// l
|
|
265
|
+
handle: function handle(player, actions) {
|
|
266
|
+
var disablePlayerActions = _this.props.disablePlayerActions;
|
|
267
|
+
if (disablePlayerActions.includes('playback_rate')) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (player.paused && player.playbackRate === 1) {
|
|
271
|
+
actions.play({
|
|
272
|
+
action: 'play',
|
|
273
|
+
source: 'shortcut'
|
|
274
|
+
});
|
|
275
|
+
actions.handleVideoRewind(false);
|
|
276
|
+
} else {
|
|
277
|
+
_this.changePlaybackRate(player, actions);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}, {
|
|
281
|
+
keyCode: 36,
|
|
282
|
+
// Home
|
|
283
|
+
handle: function handle(player, actions) {
|
|
284
|
+
if (!player.hasStarted) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
actions.seek(0); // Go to beginning of video
|
|
288
|
+
}
|
|
289
|
+
}, {
|
|
290
|
+
keyCode: 73,
|
|
291
|
+
// I Key
|
|
292
|
+
handle: function handle(player, actions) {
|
|
293
|
+
var _this$props4 = _this.props,
|
|
294
|
+
markers = _this$props4.markers,
|
|
295
|
+
playerType = _this$props4.playerType,
|
|
296
|
+
onAddMarker = _this$props4.onAddMarker,
|
|
297
|
+
playerReadOnlyMode = _this$props4.playerReadOnlyMode,
|
|
298
|
+
disablePlayerActions = _this$props4.disablePlayerActions,
|
|
299
|
+
playerSelectedMarker = _this$props4.playerSelectedMarker,
|
|
300
|
+
frameRate = _this$props4.frameRate;
|
|
301
|
+
if (playerReadOnlyMode || disablePlayerActions.includes('marking_controls')) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
var currentAdjustedTime = (0, _utils.handleAdjustingVideoAsPerFrame)(player.currentTime, frameRate);
|
|
305
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
306
|
+
args[_key - 2] = arguments[_key];
|
|
307
|
+
}
|
|
308
|
+
var isOverLapTime = args[0].timeAfterOverlap;
|
|
309
|
+
if (isOverLapTime) {
|
|
310
|
+
onAddMarker(args[0].timeAfterOverlap, playerSelectedMarker.rightMarker, 'update');
|
|
311
|
+
} else {
|
|
312
|
+
if (playerType !== 'panel') {
|
|
313
|
+
var createPoint = true;
|
|
314
|
+
if (markers && markers.length && markers[0].values && markers[0].values.length) {
|
|
315
|
+
var markerArr = markers[0].values;
|
|
316
|
+
if (Object.keys(player.selectedMarker).length) {
|
|
317
|
+
markerArr = markerArr.filter(function (marker) {
|
|
318
|
+
return marker.start_time !== player.selectedMarker.leftMarker && marker.end_time !== player.selectedMarker.rightMarker;
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
markerArr.filter(function (marker) {
|
|
322
|
+
if (currentAdjustedTime >= marker.start_time && currentAdjustedTime <= marker.end_time || playerSelectedMarker.leftMarker > -1 && currentAdjustedTime > marker.start_time && playerSelectedMarker.leftMarker < marker.start_time || playerSelectedMarker.leftMarker > -1 && currentAdjustedTime < marker.start_time && playerSelectedMarker.leftMarker > marker.end_time) {
|
|
323
|
+
createPoint = false;
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
if (!createPoint && playerSelectedMarker.markerType === 'update' && currentAdjustedTime > player.selectedMarker.leftMarker && currentAdjustedTime < player.selectedMarker.rightMarker) {
|
|
328
|
+
createPoint = true;
|
|
329
|
+
}
|
|
330
|
+
if (createPoint) {
|
|
331
|
+
if (playerSelectedMarker.rightMarker < 0 || playerSelectedMarker.rightMarker > -1 && currentAdjustedTime < playerSelectedMarker.rightMarker) {
|
|
332
|
+
// actions.handleMarkerPointChange(
|
|
333
|
+
// player.markerType !== 'update' ? 'add' : 'update',
|
|
334
|
+
// 'left',
|
|
335
|
+
// currentAdjustedTime
|
|
336
|
+
// );
|
|
337
|
+
var data = {
|
|
338
|
+
markerType: playerSelectedMarker.data && Object.keys(playerSelectedMarker.data).length ? 'update' : 'add',
|
|
339
|
+
markerPos: 'left',
|
|
340
|
+
currentTime: currentAdjustedTime
|
|
341
|
+
};
|
|
342
|
+
onAddMarker(currentAdjustedTime, -1, '', true, data);
|
|
343
|
+
if (playerSelectedMarker.leftMarker > -1 && playerSelectedMarker.rightMarker > -1 && (!playerSelectedMarker.markerCreate || playerSelectedMarker.markerType === 'update' || playerSelectedMarker.data && Object.keys(playerSelectedMarker.data).length)) {
|
|
344
|
+
onAddMarker(currentAdjustedTime, playerSelectedMarker.rightMarker, 'update');
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}, {
|
|
352
|
+
keyCode: 79,
|
|
353
|
+
// O Key
|
|
354
|
+
handle: function handle(player, actions) {
|
|
355
|
+
var _this$props5 = _this.props,
|
|
356
|
+
markers = _this$props5.markers,
|
|
357
|
+
onMarkerSelect = _this$props5.onMarkerSelect,
|
|
358
|
+
playerType = _this$props5.playerType,
|
|
359
|
+
onAddMarker = _this$props5.onAddMarker,
|
|
360
|
+
playerReadOnlyMode = _this$props5.playerReadOnlyMode,
|
|
361
|
+
disablePlayerActions = _this$props5.disablePlayerActions,
|
|
362
|
+
playerSelectedMarker = _this$props5.playerSelectedMarker,
|
|
363
|
+
frameRate = _this$props5.frameRate;
|
|
364
|
+
if (playerReadOnlyMode || disablePlayerActions.includes('marking_controls')) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
var currentAdjustedTime = (0, _utils.handleAdjustingVideoAsPerFrame)(player.currentTime, frameRate);
|
|
368
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
369
|
+
args[_key2 - 2] = arguments[_key2];
|
|
370
|
+
}
|
|
371
|
+
var isOverLapTime = args[0].timeAfterOverlap;
|
|
372
|
+
if (isOverLapTime) {
|
|
373
|
+
var data = {
|
|
374
|
+
markerType: playerSelectedMarker.data && Object.keys(playerSelectedMarker.data).length ? 'update' : 'add',
|
|
375
|
+
markerPos: 'right',
|
|
376
|
+
currentTime: args[0].timeAfterOverlap
|
|
377
|
+
};
|
|
378
|
+
onAddMarker(playerSelectedMarker.leftMarker, args[0].timeAfterOverlap, 'update', false, data);
|
|
379
|
+
} else {
|
|
380
|
+
var createPoint = true;
|
|
381
|
+
if (playerType !== 'panel') {
|
|
382
|
+
if (markers && markers.length && markers[0].values && markers[0].values.length) {
|
|
383
|
+
var markerArr = markers[0].values;
|
|
384
|
+
if (Object.keys(player.selectedMarker).length) {
|
|
385
|
+
markerArr = markerArr.filter(function (marker) {
|
|
386
|
+
return marker.start_time !== player.selectedMarker.leftMarker && marker.end_time !== player.selectedMarker.rightMarker;
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
markerArr.filter(function (marker) {
|
|
390
|
+
if (currentAdjustedTime >= marker.start_time && currentAdjustedTime <= marker.end_time || playerSelectedMarker.leftMarker > -1 && currentAdjustedTime > marker.start_time && playerSelectedMarker.leftMarker < marker.start_time || playerSelectedMarker.leftMarker > -1 && currentAdjustedTime < marker.start_time && playerSelectedMarker.leftMarker > marker.end_time) {
|
|
391
|
+
createPoint = false;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
if (!createPoint && playerSelectedMarker.markerType === 'update' && currentAdjustedTime > player.selectedMarker.leftMarker && currentAdjustedTime < player.selectedMarker.rightMarker) {
|
|
396
|
+
createPoint = true;
|
|
397
|
+
}
|
|
398
|
+
if (createPoint && playerSelectedMarker.leftMarker > -1 && currentAdjustedTime > playerSelectedMarker.leftMarker) {
|
|
399
|
+
// actions.handleMarkerPointChange(
|
|
400
|
+
// markerType: player.markerType !== 'update' ? 'add' : 'update',
|
|
401
|
+
// markerPos: 'right',
|
|
402
|
+
// currentTime: currentAdjustedTime
|
|
403
|
+
// );
|
|
404
|
+
var _data = {
|
|
405
|
+
markerType: playerSelectedMarker.data && Object.keys(playerSelectedMarker.data).length ? 'update' : 'add',
|
|
406
|
+
markerPos: 'right',
|
|
407
|
+
currentTime: currentAdjustedTime
|
|
408
|
+
};
|
|
409
|
+
if (playerSelectedMarker.leftMarker > -1 && playerSelectedMarker.rightMarker > -1 && (!playerSelectedMarker.markerCreate || playerSelectedMarker.markerType === 'update' || playerSelectedMarker.data && Object.keys(playerSelectedMarker.data).length)) {
|
|
410
|
+
onAddMarker(playerSelectedMarker.leftMarker, currentAdjustedTime, 'update', false, _data);
|
|
411
|
+
}
|
|
412
|
+
//Commented for CN-632.
|
|
413
|
+
// if (player.controlType === 'default') {
|
|
414
|
+
// onMarkerSelect(player.leftMarker, currentAdjustedTime);
|
|
415
|
+
// }
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
if (playerSelectedMarker.leftMarker > -1 && currentAdjustedTime > -1 && playerSelectedMarker.markerCreate && createPoint && currentAdjustedTime > playerSelectedMarker.leftMarker) {
|
|
419
|
+
// actions.handleMarkerPointChange('create');
|
|
420
|
+
onAddMarker(playerSelectedMarker.leftMarker, currentAdjustedTime, '', false, {
|
|
421
|
+
markerType: 'create'
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}, {
|
|
427
|
+
keyCode: 35,
|
|
428
|
+
// End
|
|
429
|
+
handle: function handle(player, actions) {
|
|
430
|
+
if (!player.hasStarted) {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
// Go to end of video
|
|
434
|
+
actions.seek(player.duration);
|
|
435
|
+
}
|
|
436
|
+
}, {
|
|
437
|
+
keyCode: 38,
|
|
438
|
+
// Up arrow
|
|
439
|
+
handle: function handle(player, actions) {
|
|
440
|
+
// Increase volume 5%
|
|
441
|
+
var v = player.volume + 0.05;
|
|
442
|
+
if (v > 1) {
|
|
443
|
+
v = 1;
|
|
444
|
+
}
|
|
445
|
+
actions.changeVolume(v, {
|
|
446
|
+
action: 'volume-up',
|
|
447
|
+
source: 'shortcut'
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}, {
|
|
451
|
+
keyCode: 40,
|
|
452
|
+
// Down arrow
|
|
453
|
+
handle: function handle(player, actions) {
|
|
454
|
+
// Decrease volume 5%
|
|
455
|
+
var v = player.volume - 0.05;
|
|
456
|
+
if (v < 0) {
|
|
457
|
+
v = 0;
|
|
458
|
+
}
|
|
459
|
+
var action = v > 0 ? 'volume-down' : 'volume-off';
|
|
460
|
+
actions.changeVolume(v, {
|
|
461
|
+
action: action,
|
|
462
|
+
source: 'shortcut'
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}, {
|
|
466
|
+
keyCode: 68,
|
|
467
|
+
// D Key
|
|
468
|
+
handle: function handle(player, actions) {
|
|
469
|
+
var playerSelectedMarker = _this.props.playerSelectedMarker;
|
|
470
|
+
if ((playerSelectedMarker.leftMarker > -1 || playerSelectedMarker.rightMarker > -1) && playerSelectedMarker.markerType === 'create') {
|
|
471
|
+
var onDeleteMarker = _this.props.onDeleteMarker;
|
|
472
|
+
actions.handleMarkerPointChange('delete');
|
|
473
|
+
onDeleteMarker();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}, {
|
|
477
|
+
keyCode: 27,
|
|
478
|
+
// Escape Key
|
|
479
|
+
handle: function handle(player, actions) {
|
|
480
|
+
var playerSelectedMarker = _this.props.playerSelectedMarker;
|
|
481
|
+
if (playerSelectedMarker.leftMarker > -1) {
|
|
482
|
+
var onDeleteMarker = _this.props.onDeleteMarker;
|
|
483
|
+
actions.handleVideoPreview(false);
|
|
484
|
+
actions.handleMarkerPointChange('delete');
|
|
485
|
+
onDeleteMarker();
|
|
486
|
+
} else {
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}, {
|
|
491
|
+
keyCode: 77,
|
|
492
|
+
// M Key
|
|
493
|
+
handle: function handle(player, actions) {
|
|
494
|
+
// Mute Video
|
|
495
|
+
actions.mute(!player.muted);
|
|
496
|
+
}
|
|
497
|
+
}, {
|
|
498
|
+
keyCode: 81,
|
|
499
|
+
// Q Key
|
|
500
|
+
handle: function handle(player, actions) {
|
|
501
|
+
var leftMarker = _this.props.playerSelectedMarker.leftMarker;
|
|
502
|
+
if (leftMarker > -1) {
|
|
503
|
+
actions.seek(leftMarker);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}, {
|
|
507
|
+
keyCode: 87,
|
|
508
|
+
// W Key
|
|
509
|
+
handle: function handle(player, actions) {
|
|
510
|
+
var rightMarker = _this.props.playerSelectedMarker.rightMarker;
|
|
511
|
+
if (rightMarker > -1) {
|
|
512
|
+
actions.seek(rightMarker);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}, {
|
|
516
|
+
keyCode: 219,
|
|
517
|
+
//'ctrl + ['
|
|
518
|
+
ctrl: true,
|
|
519
|
+
handle: _this.debounceSegmentShiftBackward
|
|
520
|
+
}, {
|
|
521
|
+
keyCode: 221,
|
|
522
|
+
//'ctrl + ]'
|
|
523
|
+
ctrl: true,
|
|
524
|
+
handle: _this.debounceSegmentShiftForward
|
|
525
|
+
}];
|
|
526
|
+
_this.shortcuts = _toConsumableArray(_this.defaultShortcuts);
|
|
527
|
+
_this.isCalled = false;
|
|
528
|
+
_this.mergeShortcuts = _this.mergeShortcuts.bind(_assertThisInitialized(_this));
|
|
529
|
+
_this.handleKeyPress = _this.handleKeyPress.bind(_assertThisInitialized(_this));
|
|
530
|
+
_this.handleClick = _this.handleClick.bind(_assertThisInitialized(_this));
|
|
531
|
+
_this.handleDoubleClick = _this.handleDoubleClick.bind(_assertThisInitialized(_this));
|
|
532
|
+
return _this;
|
|
533
|
+
}
|
|
534
|
+
_createClass(Shortcut, [{
|
|
535
|
+
key: "componentDidMount",
|
|
536
|
+
value: function componentDidMount() {
|
|
537
|
+
this.mergeShortcuts();
|
|
538
|
+
(0, _hotkeysJs["default"])('w+right,right+w', {
|
|
539
|
+
keyup: true,
|
|
540
|
+
keydown: true
|
|
541
|
+
}, this.threeKeyCombo1);
|
|
542
|
+
(0, _hotkeysJs["default"])('w+left,left+w', {
|
|
543
|
+
keyup: true,
|
|
544
|
+
keydown: true
|
|
545
|
+
}, this.threeKeyCombo2);
|
|
546
|
+
(0, _hotkeysJs["default"])('q+right,right+q', {
|
|
547
|
+
keyup: true,
|
|
548
|
+
keydown: true
|
|
549
|
+
}, this.threeKeyCombo3);
|
|
550
|
+
(0, _hotkeysJs["default"])('q+left,left+q', {
|
|
551
|
+
keyup: true,
|
|
552
|
+
keydown: true
|
|
553
|
+
}, this.threeKeyCombo4);
|
|
554
|
+
document.addEventListener('keydown', this.handleKeyPress);
|
|
555
|
+
document.addEventListener('click', this.handleClick);
|
|
556
|
+
document.addEventListener('dblclick', this.handleDoubleClick);
|
|
557
|
+
}
|
|
558
|
+
}, {
|
|
559
|
+
key: "findAdjacentMarkers",
|
|
560
|
+
value: function findAdjacentMarkers(markers, selectedMarker) {
|
|
561
|
+
if (markers) {
|
|
562
|
+
var index = markers === null || markers === void 0 ? void 0 : markers.findIndex(function (marker) {
|
|
563
|
+
return marker.in_time === selectedMarker.in_time && marker.out_time === selectedMarker.out_time;
|
|
564
|
+
});
|
|
565
|
+
if (index !== -1) {
|
|
566
|
+
var adjacentMarkerForward = markers[index + 1];
|
|
567
|
+
var adjacentMarkerBehind = markers[index - 1];
|
|
568
|
+
var result = {
|
|
569
|
+
in_time_forward: adjacentMarkerForward ? adjacentMarkerForward.in_time : undefined,
|
|
570
|
+
out_time_behind: adjacentMarkerBehind ? adjacentMarkerBehind.out_time : undefined
|
|
571
|
+
};
|
|
572
|
+
return result;
|
|
573
|
+
}
|
|
574
|
+
} else {
|
|
575
|
+
return undefined;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}, {
|
|
579
|
+
key: "componentDidUpdate",
|
|
580
|
+
value: function componentDidUpdate(prevProps) {
|
|
581
|
+
var _this$props6 = this.props,
|
|
582
|
+
shortcuts = _this$props6.shortcuts,
|
|
583
|
+
player = _this$props6.player,
|
|
584
|
+
frameRate = _this$props6.frameRate;
|
|
585
|
+
if (prevProps.shortcuts !== shortcuts) {
|
|
586
|
+
this.mergeShortcuts();
|
|
587
|
+
}
|
|
588
|
+
if (player.rewindActive !== prevProps.player.rewindActive) {
|
|
589
|
+
if (!this.intervalRewind) {
|
|
590
|
+
this.intervalRewind = setInterval(this.rewindVideo.bind(this), 1000 / frameRate);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}, {
|
|
595
|
+
key: "componentWillUnmount",
|
|
596
|
+
value: function componentWillUnmount() {
|
|
597
|
+
_hotkeysJs["default"].unbind('q+right,right+q');
|
|
598
|
+
_hotkeysJs["default"].unbind('w+right,right+w');
|
|
599
|
+
_hotkeysJs["default"].unbind('w+left,left+w');
|
|
600
|
+
_hotkeysJs["default"].unbind('w+left,left+w');
|
|
601
|
+
document.removeEventListener('keydown', this.handleKeyPress);
|
|
602
|
+
document.removeEventListener('click', this.handleClick);
|
|
603
|
+
document.removeEventListener('dblclick', this.handleDoubleClick);
|
|
604
|
+
}
|
|
605
|
+
}, {
|
|
606
|
+
key: "rewindVideo",
|
|
607
|
+
value: function rewindVideo() {
|
|
608
|
+
var _this$props7 = this.props,
|
|
609
|
+
player = _this$props7.player,
|
|
610
|
+
actions = _this$props7.actions,
|
|
611
|
+
frameRate = _this$props7.frameRate;
|
|
612
|
+
if (player.currentTime == 0 || !player.rewindActive) {
|
|
613
|
+
clearInterval(this.intervalRewind);
|
|
614
|
+
this.intervalRewind = null;
|
|
615
|
+
actions.pause({
|
|
616
|
+
action: 'pause',
|
|
617
|
+
source: 'shortcut'
|
|
618
|
+
});
|
|
619
|
+
actions.handleVideoRewind(false);
|
|
620
|
+
} else {
|
|
621
|
+
var time = 1 / frameRate;
|
|
622
|
+
actions.replay(time, {
|
|
623
|
+
action: "forward-".concat(1 / frameRate),
|
|
624
|
+
source: 'shortcut'
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// merge the shortcuts from props
|
|
630
|
+
}, {
|
|
631
|
+
key: "mergeShortcuts",
|
|
632
|
+
value: function mergeShortcuts() {
|
|
633
|
+
var shortcuts = this.props.shortcuts;
|
|
634
|
+
var getShortcutKey = function getShortcutKey(_ref) {
|
|
635
|
+
var _ref$keyCode = _ref.keyCode,
|
|
636
|
+
keyCode = _ref$keyCode === void 0 ? 0 : _ref$keyCode,
|
|
637
|
+
_ref$ctrl = _ref.ctrl,
|
|
638
|
+
ctrl = _ref$ctrl === void 0 ? false : _ref$ctrl,
|
|
639
|
+
_ref$shift = _ref.shift,
|
|
640
|
+
shift = _ref$shift === void 0 ? false : _ref$shift,
|
|
641
|
+
_ref$alt = _ref.alt,
|
|
642
|
+
alt = _ref$alt === void 0 ? false : _ref$alt;
|
|
643
|
+
return "".concat(keyCode, ":").concat(ctrl, ":").concat(shift, ":").concat(alt);
|
|
644
|
+
};
|
|
645
|
+
var defaultShortcuts = this.defaultShortcuts.reduce(function (shortcuts, shortcut) {
|
|
646
|
+
return Object.assign(shortcuts, _defineProperty({}, getShortcutKey(shortcut), shortcut));
|
|
647
|
+
}, {});
|
|
648
|
+
var mergedShortcuts = (shortcuts || []).reduce(function (shortcuts, shortcut) {
|
|
649
|
+
var keyCode = shortcut.keyCode,
|
|
650
|
+
handle = shortcut.handle;
|
|
651
|
+
if (keyCode && typeof handle === 'function') {
|
|
652
|
+
return Object.assign(shortcuts, _defineProperty({}, getShortcutKey(shortcut), shortcut));
|
|
653
|
+
}
|
|
654
|
+
return shortcuts;
|
|
655
|
+
}, defaultShortcuts);
|
|
656
|
+
var gradeShortcut = function gradeShortcut(s) {
|
|
657
|
+
var score = 0;
|
|
658
|
+
var ps = ['ctrl', 'shift', 'alt'];
|
|
659
|
+
ps.forEach(function (key) {
|
|
660
|
+
if (s[key]) {
|
|
661
|
+
score++;
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
return score;
|
|
665
|
+
};
|
|
666
|
+
this.shortcuts = Object.keys(mergedShortcuts).map(function (key) {
|
|
667
|
+
return mergedShortcuts[key];
|
|
668
|
+
}).sort(function (a, b) {
|
|
669
|
+
return gradeShortcut(b) - gradeShortcut(a);
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
}, {
|
|
673
|
+
key: "togglePlay",
|
|
674
|
+
value: function togglePlay(player, actions) {
|
|
675
|
+
if (this.intervalRewind) {
|
|
676
|
+
clearInterval(this.intervalRewind);
|
|
677
|
+
this.intervalRewind = null;
|
|
678
|
+
}
|
|
679
|
+
actions.handleVideoRewind(false);
|
|
680
|
+
if (player.paused) {
|
|
681
|
+
actions.play({
|
|
682
|
+
action: 'play',
|
|
683
|
+
source: 'shortcut'
|
|
684
|
+
});
|
|
685
|
+
} else {
|
|
686
|
+
actions.pause({
|
|
687
|
+
action: 'pause',
|
|
688
|
+
source: 'shortcut'
|
|
689
|
+
});
|
|
690
|
+
actions.changeRate(1.0, {
|
|
691
|
+
action: 'fast-forward',
|
|
692
|
+
source: 'shortcut'
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}, {
|
|
697
|
+
key: "changePlaybackRate",
|
|
698
|
+
value: function changePlaybackRate(player, actions) {
|
|
699
|
+
var playbackRate = player.playbackRate;
|
|
700
|
+
if (playbackRate >= 2) {
|
|
701
|
+
playbackRate = 4;
|
|
702
|
+
} else if (playbackRate >= 1.5) {
|
|
703
|
+
playbackRate = 2;
|
|
704
|
+
} else if (playbackRate >= 1) {
|
|
705
|
+
playbackRate = 1.5;
|
|
706
|
+
} else if (playbackRate >= 0.5) {
|
|
707
|
+
playbackRate = 1.0;
|
|
708
|
+
}
|
|
709
|
+
/*
|
|
710
|
+
* else if (playbackRate >= 1.25) {
|
|
711
|
+
* playbackRate = 1.5;
|
|
712
|
+
* } else if (playbackRate >= 1.0) {
|
|
713
|
+
* playbackRate = 1.25;
|
|
714
|
+
* }
|
|
715
|
+
* else if (playbackRate >= 0.5) {
|
|
716
|
+
* playbackRate = 1.0;
|
|
717
|
+
* }
|
|
718
|
+
* else if (playbackRate >= 0.25) {
|
|
719
|
+
* playbackRate = 0.5;
|
|
720
|
+
* } else if (playbackRate >= 0) {
|
|
721
|
+
* playbackRate = 0.25;
|
|
722
|
+
* }
|
|
723
|
+
*/
|
|
724
|
+
actions.changeRate(playbackRate, {
|
|
725
|
+
action: 'fast-forward',
|
|
726
|
+
source: 'shortcut'
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
}, {
|
|
730
|
+
key: "toggleFullscreen",
|
|
731
|
+
value: function toggleFullscreen(player, actions) {
|
|
732
|
+
var playerType = this.props.playerType;
|
|
733
|
+
if (playerType !== 'panel') {
|
|
734
|
+
actions.toggleFullscreen(player);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}, {
|
|
738
|
+
key: "handleKeyPress",
|
|
739
|
+
value: function handleKeyPress(e) {
|
|
740
|
+
var _this$props8 = this.props,
|
|
741
|
+
player = _this$props8.player,
|
|
742
|
+
actions = _this$props8.actions,
|
|
743
|
+
frameRate = _this$props8.frameRate,
|
|
744
|
+
markers = _this$props8.markers;
|
|
745
|
+
if (!player.isActive) {
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
if (document.activeElement && (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') || document.activeElement.className === 'notranslate public-DraftEditor-content') {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
var keyCode = e.keyCode || e.which;
|
|
752
|
+
var ctrl = e.ctrlKey || e.metaKey;
|
|
753
|
+
var shift = e.shiftKey;
|
|
754
|
+
var alt = e.altKey;
|
|
755
|
+
var shortcut = this.shortcuts.filter(function (s) {
|
|
756
|
+
if (!s.keyCode || s.keyCode - keyCode !== 0) {
|
|
757
|
+
return false;
|
|
758
|
+
}
|
|
759
|
+
if (s.ctrl !== undefined && s.ctrl !== ctrl || s.shift !== undefined && s.shift !== shift || s.alt !== undefined && s.alt !== alt) {
|
|
760
|
+
return false;
|
|
761
|
+
}
|
|
762
|
+
return true;
|
|
763
|
+
})[0];
|
|
764
|
+
if (shortcut) {
|
|
765
|
+
var _markers$;
|
|
766
|
+
shortcut.handle(player, actions, frameRate, e, (_markers$ = markers[0]) === null || _markers$ === void 0 ? void 0 : _markers$.values);
|
|
767
|
+
e.preventDefault();
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// only if player is active and player is ready
|
|
772
|
+
}, {
|
|
773
|
+
key: "canBeClicked",
|
|
774
|
+
value: function canBeClicked(player, e) {
|
|
775
|
+
if (!player.isActive || e.target.nodeName !== 'VIDEO' || player.readyState !== 4) {
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
return true;
|
|
779
|
+
}
|
|
780
|
+
}, {
|
|
781
|
+
key: "handleClick",
|
|
782
|
+
value: function handleClick(e) {
|
|
783
|
+
var _this$props9 = this.props,
|
|
784
|
+
player = _this$props9.player,
|
|
785
|
+
actions = _this$props9.actions,
|
|
786
|
+
clickable = _this$props9.clickable;
|
|
787
|
+
if (!this.canBeClicked(player, e) || !clickable) {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
this.togglePlay(player, actions);
|
|
791
|
+
// e.preventDefault();
|
|
792
|
+
}
|
|
793
|
+
}, {
|
|
794
|
+
key: "handleDoubleClick",
|
|
795
|
+
value: function handleDoubleClick(e) {
|
|
796
|
+
var _this$props10 = this.props,
|
|
797
|
+
player = _this$props10.player,
|
|
798
|
+
actions = _this$props10.actions,
|
|
799
|
+
dblclickable = _this$props10.dblclickable;
|
|
800
|
+
if (!this.canBeClicked(player, e) || !dblclickable) {
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
this.toggleFullscreen(player, actions);
|
|
804
|
+
// e.preventDefault();
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
/*
|
|
808
|
+
* this component dose not render anything
|
|
809
|
+
* it's just for the key down event
|
|
810
|
+
*/
|
|
811
|
+
}, {
|
|
812
|
+
key: "render",
|
|
813
|
+
value: function render() {
|
|
814
|
+
return null;
|
|
815
|
+
}
|
|
816
|
+
}]);
|
|
817
|
+
return Shortcut;
|
|
818
|
+
}(_react.Component);
|
|
819
|
+
Shortcut.propTypes = propTypes;
|
|
820
|
+
Shortcut.defaultProps = defaultProps;
|
|
821
|
+
Shortcut.displayName = 'Shortcut';
|