@desynova-digital/player 4.0.1 → 4.0.3
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 +1 -2
- 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
package/utils/index.js
CHANGED
|
@@ -3,51 +3,29 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.deprecatedWarning = deprecatedWarning;
|
|
6
7
|
exports.formatTime = formatTime;
|
|
8
|
+
exports.handleAdjustingVideoAsPerFrame = handleAdjustingVideoAsPerFrame;
|
|
9
|
+
exports.isVideoChild = isVideoChild;
|
|
10
|
+
exports.mediaProperties = void 0;
|
|
7
11
|
exports.mergeAndSortChildren = mergeAndSortChildren;
|
|
8
12
|
exports.secondsToTime = secondsToTime;
|
|
13
|
+
exports.throttle = throttle;
|
|
9
14
|
exports.timeToSeconds = timeToSeconds;
|
|
10
|
-
var _react = require("react");
|
|
11
|
-
function
|
|
12
|
-
function
|
|
13
|
-
function
|
|
15
|
+
var _react = _interopRequireDefault(require("react"));
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
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); }
|
|
18
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
19
|
+
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."); }
|
|
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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
22
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
23
|
+
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; }
|
|
24
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
26
|
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; }
|
|
15
|
-
function _toPropertyKey(
|
|
16
|
-
function _toPrimitive(
|
|
17
|
-
/*
|
|
18
|
-
* merge default children
|
|
19
|
-
* sort them by `order` property
|
|
20
|
-
* filter them by `disabled` property
|
|
21
|
-
*/
|
|
22
|
-
function mergeAndSortChildren(defaultChildren) {
|
|
23
|
-
var _children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
24
|
-
var _parentProps = arguments.length > 2 ? arguments[2] : undefined;
|
|
25
|
-
var defaultOrder = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
26
|
-
/*
|
|
27
|
-
* const children = React.Children.toArray(_children);
|
|
28
|
-
* const parentProps = { ..._parentProps };
|
|
29
|
-
*/
|
|
30
|
-
return _children.filter(function (e) {
|
|
31
|
-
return !e.props.disabled;
|
|
32
|
-
}) // filter the disabled components
|
|
33
|
-
.concat(defaultChildren.filter(function (c) {
|
|
34
|
-
return !find(children, function (component) {
|
|
35
|
-
return isTypeEqual(component, c);
|
|
36
|
-
});
|
|
37
|
-
})).map(function (element) {
|
|
38
|
-
var defaultComponent = find(defaultChildren, function (c) {
|
|
39
|
-
return isTypeEqual(c, element);
|
|
40
|
-
});
|
|
41
|
-
delete parentProps.order;
|
|
42
|
-
var defaultProps = defaultComponent ? defaultComponent.props : {};
|
|
43
|
-
var props = _objectSpread(_objectSpread(_objectSpread({}, parentProps), defaultProps), element.props);
|
|
44
|
-
var e = _react.React.cloneElement(element, props, element.props.children);
|
|
45
|
-
return e;
|
|
46
|
-
}).sort(function (a, b) {
|
|
47
|
-
return (a.props.order || defaultOrder) - (b.props.order || defaultOrder);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
27
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
28
|
+
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); }
|
|
51
29
|
/**
|
|
52
30
|
* @file seconds-to-time.js
|
|
53
31
|
*
|
|
@@ -63,28 +41,53 @@ function mergeAndSortChildren(defaultChildren) {
|
|
|
63
41
|
* @function secondsToTime
|
|
64
42
|
*/
|
|
65
43
|
function secondsToTime() {
|
|
66
|
-
var
|
|
67
|
-
var frameRate = arguments.length > 1 ? arguments[1] :
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var
|
|
80
|
-
var
|
|
81
|
-
|
|
44
|
+
var seconds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
45
|
+
var frameRate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25;
|
|
46
|
+
var initialTimecodeInSeconds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
47
|
+
if (seconds > -1) {
|
|
48
|
+
// Calculate total frames
|
|
49
|
+
var totalFrames = Math.round((seconds + initialTimecodeInSeconds) * frameRate);
|
|
50
|
+
|
|
51
|
+
// Calculate new timecode
|
|
52
|
+
var newSeconds = Math.floor(totalFrames / frameRate);
|
|
53
|
+
var remainderFrames = totalFrames % frameRate;
|
|
54
|
+
|
|
55
|
+
// Calculate fractional frames within the range [0, 1)
|
|
56
|
+
var fractionalFrames = remainderFrames / frameRate;
|
|
57
|
+
var newFF = Math.floor(fractionalFrames * frameRate).toString().padStart(2, '0');
|
|
58
|
+
var newSS = newSeconds % 60;
|
|
59
|
+
var newMM = Math.floor(newSeconds / 60) % 60;
|
|
60
|
+
var newHH = Math.floor(newSeconds / 3600);
|
|
61
|
+
|
|
62
|
+
// Format and return the new timecode
|
|
63
|
+
return "".concat(newHH.toString().padStart(2, '0'), ":").concat(newMM.toString().padStart(2, '0'), ":").concat(newSS.toString().padStart(2, '0'), ":").concat(newFF);
|
|
82
64
|
}
|
|
83
|
-
return
|
|
65
|
+
return '00:00:00:00';
|
|
84
66
|
}
|
|
67
|
+
|
|
68
|
+
// export function secondsToTime(_seconds = 0, frameRate, initialTime) {
|
|
69
|
+
// let time = '00:00:00:00';
|
|
70
|
+
// _seconds = parseFloat(_seconds);
|
|
71
|
+
// if (_seconds > -1) {
|
|
72
|
+
// if (initialTime) {
|
|
73
|
+
// _seconds += initialTime;
|
|
74
|
+
// }
|
|
75
|
+
// const date = new Date(null);
|
|
76
|
+
// const currentFrame = Math.round((_seconds * frameRate) % frameRate);
|
|
77
|
+
// const paddedFrame = currentFrame < 10 ? `0${currentFrame}` : currentFrame;
|
|
78
|
+
// date.setSeconds(_seconds);
|
|
79
|
+
// const timeString = date.toISOString().substr(11, 8);
|
|
80
|
+
// const timeWithFrame = `${timeString}:${paddedFrame}`;
|
|
81
|
+
// time = timeWithFrame;
|
|
82
|
+
// }
|
|
83
|
+
|
|
84
|
+
// return time;
|
|
85
|
+
// }
|
|
86
|
+
|
|
85
87
|
function timeToSeconds() {
|
|
86
88
|
var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '00:00:00:00';
|
|
87
89
|
var frameRate = arguments.length > 1 ? arguments[1] : undefined;
|
|
90
|
+
if (!time) return 0;
|
|
88
91
|
var timeObj = time.split(':'); // split it at the colons
|
|
89
92
|
|
|
90
93
|
// minutes are worth 60 seconds. Hours are worth 60 minutes.
|
|
@@ -141,4 +144,100 @@ function formatTime() {
|
|
|
141
144
|
// Check if leading zero is need for seconds
|
|
142
145
|
s = s < 10 ? "0".concat(s) : s;
|
|
143
146
|
return h + m + s;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/*
|
|
150
|
+
* Check if the element belongs to a video element
|
|
151
|
+
* only accept <source />, <track />,
|
|
152
|
+
* <MyComponent isVideoChild />
|
|
153
|
+
* elements
|
|
154
|
+
*/
|
|
155
|
+
function isVideoChild(c) {
|
|
156
|
+
if (c.props && c.props.isVideoChild) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
return c.type === 'source' || c.type === 'track';
|
|
160
|
+
}
|
|
161
|
+
var find = function find(elements, func) {
|
|
162
|
+
return elements.filter(func)[0];
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// check if two components are the same type
|
|
166
|
+
var isTypeEqual = function isTypeEqual(component1, component2) {
|
|
167
|
+
var type1 = component1.type;
|
|
168
|
+
var type2 = component2.type;
|
|
169
|
+
if (typeof type1 === 'string' || typeof type2 === 'string') {
|
|
170
|
+
return type1 === type2;
|
|
171
|
+
}
|
|
172
|
+
if (typeof type1 === 'function' && typeof type2 === 'function') {
|
|
173
|
+
return type1.displayName === type2.displayName;
|
|
174
|
+
}
|
|
175
|
+
return false;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/*
|
|
179
|
+
* merge default children
|
|
180
|
+
* sort them by `order` property
|
|
181
|
+
* filter them by `disabled` property
|
|
182
|
+
*/
|
|
183
|
+
function mergeAndSortChildren(defaultChildren, _children, _parentProps) {
|
|
184
|
+
var defaultOrder = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
185
|
+
var children = _react["default"].Children.toArray(_children);
|
|
186
|
+
var parentProps = _objectSpread({}, _parentProps);
|
|
187
|
+
return children.filter(function (e) {
|
|
188
|
+
return !e.props.disabled;
|
|
189
|
+
}) // filter the disabled components
|
|
190
|
+
.concat(defaultChildren.filter(function (c) {
|
|
191
|
+
return !find(children, function (component) {
|
|
192
|
+
return isTypeEqual(component, c);
|
|
193
|
+
});
|
|
194
|
+
})).map(function (element) {
|
|
195
|
+
var defaultComponent = find(defaultChildren, function (c) {
|
|
196
|
+
return isTypeEqual(c, element);
|
|
197
|
+
});
|
|
198
|
+
delete parentProps.order;
|
|
199
|
+
var defaultProps = defaultComponent ? defaultComponent.props : {};
|
|
200
|
+
var props = _objectSpread(_objectSpread(_objectSpread({}, parentProps), defaultProps), element.props);
|
|
201
|
+
var e = /*#__PURE__*/_react["default"].cloneElement(element, props, element.props.children);
|
|
202
|
+
return e;
|
|
203
|
+
}).sort(function (a, b) {
|
|
204
|
+
return (a.props.order || defaultOrder) - (b.props.order || defaultOrder);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Temporary utility for generating the warnings
|
|
210
|
+
*/
|
|
211
|
+
function deprecatedWarning(oldMethodCall, newMethodCall) {
|
|
212
|
+
// eslint-disable-next-line no-console
|
|
213
|
+
console.warn("WARNING: ".concat(oldMethodCall, " will be deprecated soon!\n Please use ").concat(newMethodCall, " instead."));
|
|
214
|
+
}
|
|
215
|
+
function throttle(callback, limit) {
|
|
216
|
+
var _arguments = arguments;
|
|
217
|
+
var wait = false;
|
|
218
|
+
return function () {
|
|
219
|
+
if (!wait) {
|
|
220
|
+
callback.apply(void 0, _toConsumableArray(_arguments));
|
|
221
|
+
wait = true;
|
|
222
|
+
setTimeout(function () {
|
|
223
|
+
wait = false;
|
|
224
|
+
}, limit);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
var mediaProperties = exports.mediaProperties = ['error', 'src', 'srcObject', 'currentSrc', 'crossOrigin', 'networkState', 'preload', 'buffered', 'readyState', 'seeking', 'currentTime', 'duration', 'paused', 'defaultPlaybackRate', 'playbackRate', 'played', 'seekable', 'ended', 'autoplay', 'loop', 'mediaGroup', 'controller', 'controls', 'volume', 'muted', 'defaultMuted', 'audioTracks', 'videoTracks', 'textTracks', 'width', 'height', 'videoWidth', 'videoHeight', 'poster'];
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
*
|
|
232
|
+
* @param {Number} currentTime current time of video
|
|
233
|
+
* @returns adjusting the current time to the nearest frame
|
|
234
|
+
*/
|
|
235
|
+
function handleAdjustingVideoAsPerFrame(currentTime) {
|
|
236
|
+
var frameRate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25;
|
|
237
|
+
var frameDuration = 1 / frameRate;
|
|
238
|
+
var milliSeconds = currentTime - Math.floor(currentTime);
|
|
239
|
+
var frameNumber = Math.round(milliSeconds / frameDuration);
|
|
240
|
+
var updatedMilliseconds = frameNumber * frameDuration;
|
|
241
|
+
var adjustedTimeInSeconds = Math.trunc(currentTime) + updatedMilliseconds;
|
|
242
|
+
return adjustedTimeInSeconds;
|
|
144
243
|
}
|