@desynova-digital/player 3.13.21 → 3.13.23

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.
@@ -12,10 +12,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
12
12
  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); }
13
13
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
14
14
  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."); }
15
- 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); }
16
15
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
17
16
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
17
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
18
+ 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."); }
19
+ 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); }
18
20
  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; }
21
+ 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; } }
22
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
23
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
24
  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); } }
21
25
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -55,6 +59,37 @@ var Shortcut = exports["default"] = /*#__PURE__*/function (_Component) {
55
59
  var _this;
56
60
  _classCallCheck(this, Shortcut);
57
61
  _this = _callSuper(this, Shortcut, [props, context]);
62
+ _defineProperty(_assertThisInitialized(_this), "segmentShift", function (direction) {
63
+ var _this$props = _this.props,
64
+ leftMarker = _this$props.playerSelectedMarker.leftMarker,
65
+ onTagClick = _this$props.onTagClick;
66
+ var _this$props2 = _this.props,
67
+ actions = _this$props2.actions,
68
+ _this$props2$markers = _slicedToArray(_this$props2.markers, 1),
69
+ values = _this$props2$markers[0].values;
70
+ var newIndex;
71
+ if (direction === 'backward') {
72
+ newIndex = values.findIndex(function (item) {
73
+ return item.in_time === leftMarker;
74
+ }) - 1;
75
+ }
76
+ if (direction === 'forward') {
77
+ newIndex = values.findIndex(function (item) {
78
+ return item.in_time === leftMarker;
79
+ }) + 1;
80
+ }
81
+ if (leftMarker > -1 && newIndex < values.length && direction === 'forward' || leftMarker > -1 && newIndex > -1 && direction === 'backward') {
82
+ var _values$newIndex, _values$newIndex2, _values$newIndex3;
83
+ actions.seek((_values$newIndex = values[newIndex]) === null || _values$newIndex === void 0 ? void 0 : _values$newIndex.start_time);
84
+ 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]);
85
+ }
86
+ });
87
+ _defineProperty(_assertThisInitialized(_this), "debounceSegmentShiftForward", (0, _lodash.debounce)(function () {
88
+ _this.segmentShift('forward');
89
+ }, 0));
90
+ _defineProperty(_assertThisInitialized(_this), "debounceSegmentShiftBackward", (0, _lodash.debounce)(function () {
91
+ _this.segmentShift('backward');
92
+ }, 0));
58
93
  _defineProperty(_assertThisInitialized(_this), "debounceKeyFunc", (0, _lodash.debounce)(function (keyCode) {
59
94
  _this.handleKeyMovement(keyCode);
60
95
  }));
@@ -97,9 +132,9 @@ var Shortcut = exports["default"] = /*#__PURE__*/function (_Component) {
97
132
  * 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.
98
133
  */
99
134
  _defineProperty(_assertThisInitialized(_this), "createThreeKeyCombo", function (event, handleKeyMovement, debounceKeyFunc, keyParameter) {
100
- var _this$props = _this.props,
101
- playerReadOnlyMode = _this$props.playerReadOnlyMode,
102
- disablePlayerActions = _this$props.disablePlayerActions;
135
+ var _this$props3 = _this.props,
136
+ playerReadOnlyMode = _this$props3.playerReadOnlyMode,
137
+ disablePlayerActions = _this$props3.disablePlayerActions;
103
138
  if (playerReadOnlyMode || disablePlayerActions.includes('marking_controls')) {
104
139
  return;
105
140
  }
@@ -250,13 +285,13 @@ var Shortcut = exports["default"] = /*#__PURE__*/function (_Component) {
250
285
  keyCode: 73,
251
286
  // I Key
252
287
  handle: function handle(player, actions) {
253
- var _this$props2 = _this.props,
254
- markers = _this$props2.markers,
255
- playerType = _this$props2.playerType,
256
- onAddMarker = _this$props2.onAddMarker,
257
- playerReadOnlyMode = _this$props2.playerReadOnlyMode,
258
- disablePlayerActions = _this$props2.disablePlayerActions,
259
- playerSelectedMarker = _this$props2.playerSelectedMarker;
288
+ var _this$props4 = _this.props,
289
+ markers = _this$props4.markers,
290
+ playerType = _this$props4.playerType,
291
+ onAddMarker = _this$props4.onAddMarker,
292
+ playerReadOnlyMode = _this$props4.playerReadOnlyMode,
293
+ disablePlayerActions = _this$props4.disablePlayerActions,
294
+ playerSelectedMarker = _this$props4.playerSelectedMarker;
260
295
  if (playerReadOnlyMode || disablePlayerActions.includes('marking_controls')) {
261
296
  return;
262
297
  }
@@ -310,14 +345,14 @@ var Shortcut = exports["default"] = /*#__PURE__*/function (_Component) {
310
345
  keyCode: 79,
311
346
  // O Key
312
347
  handle: function handle(player, actions) {
313
- var _this$props3 = _this.props,
314
- markers = _this$props3.markers,
315
- onMarkerSelect = _this$props3.onMarkerSelect,
316
- playerType = _this$props3.playerType,
317
- onAddMarker = _this$props3.onAddMarker,
318
- playerReadOnlyMode = _this$props3.playerReadOnlyMode,
319
- disablePlayerActions = _this$props3.disablePlayerActions,
320
- playerSelectedMarker = _this$props3.playerSelectedMarker;
348
+ var _this$props5 = _this.props,
349
+ markers = _this$props5.markers,
350
+ onMarkerSelect = _this$props5.onMarkerSelect,
351
+ playerType = _this$props5.playerType,
352
+ onAddMarker = _this$props5.onAddMarker,
353
+ playerReadOnlyMode = _this$props5.playerReadOnlyMode,
354
+ disablePlayerActions = _this$props5.disablePlayerActions,
355
+ playerSelectedMarker = _this$props5.playerSelectedMarker;
321
356
  if (playerReadOnlyMode || disablePlayerActions.includes('marking_controls')) {
322
357
  return;
323
358
  }
@@ -472,36 +507,12 @@ var Shortcut = exports["default"] = /*#__PURE__*/function (_Component) {
472
507
  keyCode: 219,
473
508
  //'ctrl + ['
474
509
  ctrl: true,
475
- handle: function handle(player, actions, frameRate, e, markers) {
476
- var _this$props4 = _this.props,
477
- leftMarker = _this$props4.playerSelectedMarker.leftMarker,
478
- onTagClick = _this$props4.onTagClick;
479
- var newIndex = markers.findIndex(function (item) {
480
- return item.in_time === leftMarker;
481
- }) - 1;
482
- if (leftMarker > -1 && newIndex > -1) {
483
- var _markers$newIndex, _markers$newIndex2, _markers$newIndex3;
484
- actions.seek((_markers$newIndex = markers[newIndex]) === null || _markers$newIndex === void 0 ? void 0 : _markers$newIndex.start_time);
485
- onTagClick((_markers$newIndex2 = markers[newIndex]) === null || _markers$newIndex2 === void 0 ? void 0 : _markers$newIndex2.start_time, (_markers$newIndex3 = markers[newIndex]) === null || _markers$newIndex3 === void 0 ? void 0 : _markers$newIndex3.end_time, markers[newIndex]);
486
- }
487
- }
510
+ handle: _this.debounceSegmentShiftBackward
488
511
  }, {
489
512
  keyCode: 221,
490
513
  //'ctrl + ]'
491
514
  ctrl: true,
492
- handle: function handle(player, actions, frameRate, e, markers) {
493
- var _this$props5 = _this.props,
494
- leftMarker = _this$props5.playerSelectedMarker.leftMarker,
495
- onTagClick = _this$props5.onTagClick;
496
- var newIndex = markers.findIndex(function (item) {
497
- return item.in_time === leftMarker;
498
- }) + 1;
499
- if (leftMarker > -1 && newIndex < markers.length) {
500
- var _markers$newIndex4, _markers$newIndex5, _markers$newIndex6;
501
- actions.seek((_markers$newIndex4 = markers[newIndex]) === null || _markers$newIndex4 === void 0 ? void 0 : _markers$newIndex4.start_time);
502
- onTagClick((_markers$newIndex5 = markers[newIndex]) === null || _markers$newIndex5 === void 0 ? void 0 : _markers$newIndex5.start_time, (_markers$newIndex6 = markers[newIndex]) === null || _markers$newIndex6 === void 0 ? void 0 : _markers$newIndex6.end_time, markers[newIndex]);
503
- }
504
- }
515
+ handle: _this.debounceSegmentShiftForward
505
516
  }];
506
517
  _this.shortcuts = _toConsumableArray(_this.defaultShortcuts);
507
518
  _this.isCalled = false;
@@ -1,16 +1,22 @@
1
1
  "use strict";
2
2
 
3
+ 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); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports["default"] = void 0;
7
8
  var _propTypes = require("prop-types");
8
- var _react = _interopRequireDefault(require("react"));
9
- var _styledComponents = _interopRequireDefault(require("styled-components"));
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _components = require("@desynova-digital/components");
10
11
  var _utils = require("../../utils");
11
- var _templateObject;
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
14
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
15
+ 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."); }
16
+ 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); }
17
+ 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; }
18
+ 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; } }
19
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
20
  var propTypes = {
15
21
  player: _propTypes.PropTypes.instanceOf(Object),
16
22
  initialTime: _propTypes.PropTypes.number,
@@ -19,13 +25,47 @@ var propTypes = {
19
25
  var defaultProps = {
20
26
  player: {}
21
27
  };
22
- var VideoCurrentTime = _styledComponents["default"].div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-family: SFUIText-Regular;\n font-size: 12px;\n letter-spacing: -0.6px;\n color: #ffffff;\n min-width: 65px;\n text-align: left;\n"])));
23
28
  function CurrentTimeDisplay(_ref) {
24
29
  var player = _ref.player,
25
30
  initialTime = _ref.initialTime,
26
- frameRate = _ref.frameRate;
31
+ frameRate = _ref.frameRate,
32
+ actions = _ref.actions;
27
33
  var formattedTime = (0, _utils.secondsToTime)(player.currentTime, frameRate, initialTime);
28
- return /*#__PURE__*/_react["default"].createElement(VideoCurrentTime, null, formattedTime);
34
+ var _useState = (0, _react.useState)(formattedTime),
35
+ _useState2 = _slicedToArray(_useState, 2),
36
+ inputValue = _useState2[0],
37
+ setInputValue = _useState2[1];
38
+ var elementRef = (0, _react.useRef)(null);
39
+ var handleKeyPress = function handleKeyPress(event) {
40
+ if (event.key === 'Enter') {
41
+ if (elementRef.current && elementRef.current.checkValidity()) {
42
+ if (isNaN(initialTime)) {
43
+ initialTime = 0;
44
+ }
45
+ var seekSecondsTime = (0, _utils.timeToSeconds)(event.target.value, frameRate) - initialTime;
46
+ actions.seek(seekSecondsTime);
47
+ document.activeElement.blur();
48
+ }
49
+ }
50
+ };
51
+ var onInputFocus = function onInputFocus() {
52
+ actions.pause();
53
+ };
54
+ (0, _react.useEffect)(function () {
55
+ setInputValue(formattedTime);
56
+ }, [player.currentTime]);
57
+ return /*#__PURE__*/_react["default"].createElement(_components.TimeCodeInput, {
58
+ width: "72px",
59
+ elementRef: elementRef,
60
+ inputValue: inputValue,
61
+ onKeyDown: function onKeyDown(e) {
62
+ return handleKeyPress(e);
63
+ },
64
+ onFocus: onInputFocus,
65
+ frameRate: frameRate,
66
+ initialTime: initialTime || 0,
67
+ playerDuration: player.duration || 0
68
+ });
29
69
  }
30
70
  CurrentTimeDisplay.propTypes = propTypes;
31
71
  CurrentTimeDisplay.defaultProps = defaultProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@desynova-digital/player",
3
- "version": "3.13.21",
3
+ "version": "3.13.23",
4
4
  "description": "Video Player Package for Contido Application",
5
5
  "main": "index.js",
6
6
  "scripts": {