@desynova-digital/player 3.13.15 → 3.13.17

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.
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports["default"] = void 0;
8
7
  var _react = require("react");
9
8
  var _propTypes = require("prop-types");
10
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ var _lodash = require("lodash");
10
+ var _hotkeysJs = _interopRequireDefault(require("hotkeys-js"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
11
13
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
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."); }
13
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); }
@@ -17,8 +19,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
17
19
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
20
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
19
21
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
20
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
21
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
22
22
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
23
23
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
24
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -26,6 +26,9 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
26
26
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
27
27
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
28
28
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
29
+ 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; }
30
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
31
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
29
32
  var propTypes = {
30
33
  clickable: _propTypes.PropTypes.bool,
31
34
  dblclickable: _propTypes.PropTypes.bool,
@@ -53,6 +56,75 @@ var Shortcut = /*#__PURE__*/function (_Component) {
53
56
  var _this;
54
57
  _classCallCheck(this, Shortcut);
55
58
  _this = _super.call(this, props, context);
59
+ _defineProperty(_assertThisInitialized(_this), "debounceKeyFunc", (0, _lodash.debounce)(function (keyCode) {
60
+ _this.handleKeyMovement(keyCode);
61
+ }));
62
+ /**
63
+ *
64
+ * @param {number} keyCode the keycode for the specific key's functionality
65
+ * @param {boolean} currentTimeRequired currentTime value required or not to perform key functionality
66
+ *common function to handle the key functionalies. eg-> W Key and Q key functionalities
67
+ */
68
+ _defineProperty(_assertThisInitialized(_this), "handleKeyMovement", function (keyCode) {
69
+ var currentTimeRequired = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
70
+ var keyPressHandle = _this.defaultShortcuts.find(function (shortcut) {
71
+ return shortcut.keyCode === keyCode;
72
+ });
73
+ if (keyPressHandle) {
74
+ var currentTime = currentTimeRequired ? _this.props.player.currentTime : undefined;
75
+ keyPressHandle.handle(_this.props.player, _this.props.actions, currentTime);
76
+ }
77
+ });
78
+ /**
79
+ *
80
+ * @param {event} event
81
+ * @param {function} handleKeyMovement function to call Q and W key functionality
82
+ * @param {function} debounceKeyFunc to handle the debounced I and O key functionality
83
+ * @param {string} keyParameter to identify the key combo pressed
84
+ * 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
85
+ * 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.
86
+ */
87
+ _defineProperty(_assertThisInitialized(_this), "createThreeKeyCombo", function (event, handleKeyMovement, debounceKeyFunc, keyParameter) {
88
+ console.log("".concat(keyParameter, " arrow key pressed"));
89
+ if (!_this.state.isCalled) {
90
+ handleKeyMovement();
91
+ }
92
+ if (event.type === 'keydown') {
93
+ debounceKeyFunc();
94
+ _this.setState({
95
+ isCalled: true
96
+ });
97
+ }
98
+ if (event.type === 'keyup') {
99
+ _this.setState({
100
+ isCalled: false
101
+ });
102
+ }
103
+ });
104
+ _defineProperty(_assertThisInitialized(_this), "threeKeyCombo1", (0, _lodash.debounce)(function (event) {
105
+ return _this.createThreeKeyCombo(event, _this.handleKeyMovement.bind(_assertThisInitialized(_this), 87, false), _this.debounceKeyFunc.bind(_assertThisInitialized(_this), 79), 'Ctrl + O + Right');
106
+ }, 0, {
107
+ leading: true,
108
+ trailing: true
109
+ }));
110
+ _defineProperty(_assertThisInitialized(_this), "threeKeyCombo2", (0, _lodash.debounce)(function (event) {
111
+ return _this.createThreeKeyCombo(event, _this.handleKeyMovement.bind(_assertThisInitialized(_this), 87, false), _this.debounceKeyFunc.bind(_assertThisInitialized(_this), 79), 'Ctrl + O + Left');
112
+ }, 0, {
113
+ leading: true,
114
+ trailing: true
115
+ }));
116
+ _defineProperty(_assertThisInitialized(_this), "threeKeyCombo3", (0, _lodash.debounce)(function (event) {
117
+ return _this.createThreeKeyCombo(event, _this.handleKeyMovement.bind(_assertThisInitialized(_this), 81, false), _this.debounceKeyFunc.bind(_assertThisInitialized(_this), 73), 'Ctrl + I + Right');
118
+ }, 0, {
119
+ leading: true,
120
+ trailing: true
121
+ }));
122
+ _defineProperty(_assertThisInitialized(_this), "threeKeyCombo4", (0, _lodash.debounce)(function (event) {
123
+ return _this.createThreeKeyCombo(event, _this.handleKeyMovement.bind(_assertThisInitialized(_this), 81, false), _this.debounceKeyFunc.bind(_assertThisInitialized(_this), 73), 'Ctrl + I + Left');
124
+ }, 0, {
125
+ leading: true,
126
+ trailing: true
127
+ }));
56
128
  _this.intervalRewind = null;
57
129
  _this.defaultShortcuts = [{
58
130
  keyCode: 32,
@@ -80,7 +152,8 @@ var Shortcut = /*#__PURE__*/function (_Component) {
80
152
  keyCode: 37,
81
153
  // Left arrow
82
154
  handle: function handle(player, actions, frameRate) {
83
- if (!player.hasStarted) {
155
+ var leftMarker = _this.props.playerSelectedMarker.leftMarker;
156
+ if (!player.hasStarted && !(leftMarker > -1)) {
84
157
  return;
85
158
  }
86
159
  actions.replay(1 / frameRate, {
@@ -115,7 +188,8 @@ var Shortcut = /*#__PURE__*/function (_Component) {
115
188
  keyCode: 39,
116
189
  // Right arrow
117
190
  handle: function handle(player, actions, frameRate) {
118
- if (!player.hasStarted) {
191
+ var leftMarker = _this.props.playerSelectedMarker.leftMarker;
192
+ if (!player.hasStarted && !(leftMarker > -1)) {
119
193
  return;
120
194
  }
121
195
  actions.forward(1 / frameRate, {
@@ -361,8 +435,55 @@ var Shortcut = /*#__PURE__*/function (_Component) {
361
435
  actions.seek(rightMarker);
362
436
  }
363
437
  }
438
+ }, {
439
+ keyCode: 219,
440
+ //'ctrl + ['
441
+ ctrl: true,
442
+ handle: function handle(player, actions, frameRate, e, markers) {
443
+ var _this$props3 = _this.props,
444
+ leftMarker = _this$props3.playerSelectedMarker.leftMarker,
445
+ _this$props3$playerSe = _this$props3.playerSelectedMarker,
446
+ _this$props3$playerSe2 = _this$props3$playerSe === void 0 ? {} : _this$props3$playerSe,
447
+ _this$props3$playerSe3 = _this$props3$playerSe2.data,
448
+ _this$props3$playerSe4 = _this$props3$playerSe3 === void 0 ? {} : _this$props3$playerSe3,
449
+ uniqueKey = _this$props3$playerSe4.uniqueKey,
450
+ onTagClick = _this$props3.onTagClick;
451
+ var newIndex = markers.findIndex(function (item) {
452
+ return item.uniqueKey === uniqueKey;
453
+ }) - 1;
454
+ if (leftMarker > -1 && newIndex > -1) {
455
+ var _markers$newIndex, _markers$newIndex2, _markers$newIndex3;
456
+ actions.seek((_markers$newIndex = markers[newIndex]) === null || _markers$newIndex === void 0 ? void 0 : _markers$newIndex.start_time);
457
+ 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]);
458
+ }
459
+ }
460
+ }, {
461
+ keyCode: 221,
462
+ //'ctrl + ]'
463
+ ctrl: true,
464
+ handle: function handle(player, actions, frameRate, e, markers) {
465
+ var _this$props4 = _this.props,
466
+ leftMarker = _this$props4.playerSelectedMarker.leftMarker,
467
+ _this$props4$playerSe = _this$props4.playerSelectedMarker,
468
+ _this$props4$playerSe2 = _this$props4$playerSe === void 0 ? {} : _this$props4$playerSe,
469
+ _this$props4$playerSe3 = _this$props4$playerSe2.data,
470
+ _this$props4$playerSe4 = _this$props4$playerSe3 === void 0 ? {} : _this$props4$playerSe3,
471
+ uniqueKey = _this$props4$playerSe4.uniqueKey,
472
+ onTagClick = _this$props4.onTagClick;
473
+ var newIndex = markers.findIndex(function (item) {
474
+ return item.uniqueKey === uniqueKey;
475
+ }) + 1;
476
+ if (leftMarker > -1 && newIndex < markers.length) {
477
+ var _markers$newIndex4, _markers$newIndex5, _markers$newIndex6;
478
+ actions.seek((_markers$newIndex4 = markers[newIndex]) === null || _markers$newIndex4 === void 0 ? void 0 : _markers$newIndex4.start_time);
479
+ 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]);
480
+ }
481
+ }
364
482
  }];
365
483
  _this.shortcuts = _toConsumableArray(_this.defaultShortcuts);
484
+ _this.state = {
485
+ isCalled: false
486
+ };
366
487
  _this.mergeShortcuts = _this.mergeShortcuts.bind(_assertThisInitialized(_this));
367
488
  _this.handleKeyPress = _this.handleKeyPress.bind(_assertThisInitialized(_this));
368
489
  _this.handleClick = _this.handleClick.bind(_assertThisInitialized(_this));
@@ -373,6 +494,22 @@ var Shortcut = /*#__PURE__*/function (_Component) {
373
494
  key: "componentDidMount",
374
495
  value: function componentDidMount() {
375
496
  this.mergeShortcuts();
497
+ (0, _hotkeysJs["default"])('ctrl+i+left', {
498
+ keyup: true,
499
+ keydown: true
500
+ }, this.threeKeyCombo4);
501
+ (0, _hotkeysJs["default"])('ctrl+i+right', {
502
+ keyup: true,
503
+ keydown: true
504
+ }, this.threeKeyCombo3);
505
+ (0, _hotkeysJs["default"])('ctrl+o+left', {
506
+ keyup: true,
507
+ keydown: true
508
+ }, this.threeKeyCombo2);
509
+ (0, _hotkeysJs["default"])('ctrl+o+right', {
510
+ keyup: true,
511
+ keydown: true
512
+ }, this.threeKeyCombo1);
376
513
  document.addEventListener('keydown', this.handleKeyPress);
377
514
  document.addEventListener('click', this.handleClick);
378
515
  document.addEventListener('dblclick', this.handleDoubleClick);
@@ -380,10 +517,10 @@ var Shortcut = /*#__PURE__*/function (_Component) {
380
517
  }, {
381
518
  key: "componentDidUpdate",
382
519
  value: function componentDidUpdate(prevProps) {
383
- var _this$props3 = this.props,
384
- shortcuts = _this$props3.shortcuts,
385
- player = _this$props3.player,
386
- frameRate = _this$props3.frameRate;
520
+ var _this$props5 = this.props,
521
+ shortcuts = _this$props5.shortcuts,
522
+ player = _this$props5.player,
523
+ frameRate = _this$props5.frameRate;
387
524
  if (prevProps.shortcuts !== shortcuts) {
388
525
  this.mergeShortcuts();
389
526
  }
@@ -396,6 +533,10 @@ var Shortcut = /*#__PURE__*/function (_Component) {
396
533
  }, {
397
534
  key: "componentWillUnmount",
398
535
  value: function componentWillUnmount() {
536
+ _hotkeysJs["default"].unbind('ctrl+i+left');
537
+ _hotkeysJs["default"].unbind('ctrl+i+right');
538
+ _hotkeysJs["default"].unbind('ctrl+o+left');
539
+ _hotkeysJs["default"].unbind('ctrl+o+right');
399
540
  document.removeEventListener('keydown', this.handleKeyPress);
400
541
  document.removeEventListener('click', this.handleClick);
401
542
  document.removeEventListener('dblclick', this.handleDoubleClick);
@@ -403,10 +544,10 @@ var Shortcut = /*#__PURE__*/function (_Component) {
403
544
  }, {
404
545
  key: "rewindVideo",
405
546
  value: function rewindVideo() {
406
- var _this$props4 = this.props,
407
- player = _this$props4.player,
408
- actions = _this$props4.actions,
409
- frameRate = _this$props4.frameRate;
547
+ var _this$props6 = this.props,
548
+ player = _this$props6.player,
549
+ actions = _this$props6.actions,
550
+ frameRate = _this$props6.frameRate;
410
551
  if (player.currentTime == 0 || !player.rewindActive) {
411
552
  clearInterval(this.intervalRewind);
412
553
  this.intervalRewind = null;
@@ -535,10 +676,11 @@ var Shortcut = /*#__PURE__*/function (_Component) {
535
676
  }, {
536
677
  key: "handleKeyPress",
537
678
  value: function handleKeyPress(e) {
538
- var _this$props5 = this.props,
539
- player = _this$props5.player,
540
- actions = _this$props5.actions,
541
- frameRate = _this$props5.frameRate;
679
+ var _this$props7 = this.props,
680
+ player = _this$props7.player,
681
+ actions = _this$props7.actions,
682
+ frameRate = _this$props7.frameRate,
683
+ markers = _this$props7.markers;
542
684
  if (!player.isActive) {
543
685
  return;
544
686
  }
@@ -559,7 +701,8 @@ var Shortcut = /*#__PURE__*/function (_Component) {
559
701
  return true;
560
702
  })[0];
561
703
  if (shortcut) {
562
- shortcut.handle(player, actions, frameRate);
704
+ var _markers$;
705
+ shortcut.handle(player, actions, frameRate, e, (_markers$ = markers[0]) === null || _markers$ === void 0 ? void 0 : _markers$.values);
563
706
  e.preventDefault();
564
707
  }
565
708
  }
@@ -576,10 +719,10 @@ var Shortcut = /*#__PURE__*/function (_Component) {
576
719
  }, {
577
720
  key: "handleClick",
578
721
  value: function handleClick(e) {
579
- var _this$props6 = this.props,
580
- player = _this$props6.player,
581
- actions = _this$props6.actions,
582
- clickable = _this$props6.clickable;
722
+ var _this$props8 = this.props,
723
+ player = _this$props8.player,
724
+ actions = _this$props8.actions,
725
+ clickable = _this$props8.clickable;
583
726
  if (!this.canBeClicked(player, e) || !clickable) {
584
727
  return;
585
728
  }
@@ -589,10 +732,10 @@ var Shortcut = /*#__PURE__*/function (_Component) {
589
732
  }, {
590
733
  key: "handleDoubleClick",
591
734
  value: function handleDoubleClick(e) {
592
- var _this$props7 = this.props,
593
- player = _this$props7.player,
594
- actions = _this$props7.actions,
595
- dblclickable = _this$props7.dblclickable;
735
+ var _this$props9 = this.props,
736
+ player = _this$props9.player,
737
+ actions = _this$props9.actions,
738
+ dblclickable = _this$props9.dblclickable;
596
739
  if (!this.canBeClicked(player, e) || !dblclickable) {
597
740
  return;
598
741
  }
@@ -552,13 +552,17 @@ var Video = /*#__PURE__*/function (_Component) {
552
552
  key: "seek",
553
553
  value: function seek(time) {
554
554
  try {
555
- var updatedTime = this.handleAdjustingVideoAsPerFrame(time);
555
+ var updatedTime = 0;
556
+ if (time < 0) {
557
+ updatedTime = 0;
558
+ } else {
559
+ updatedTime = time > this.video.duration ? this.video.duration : this.handleAdjustingVideoAsPerFrame(time);
560
+ }
556
561
  this.video.currentTime = updatedTime;
557
562
  } catch (e) {
558
563
  // console.log(e, 'Video is not ready.')
559
564
  }
560
565
  }
561
-
562
566
  // jump forward x seconds
563
567
  }, {
564
568
  key: "forward",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@desynova-digital/player",
3
- "version": "3.13.15",
3
+ "version": "3.13.17",
4
4
  "description": "Video Player Package for Contido Application",
5
5
  "main": "index.js",
6
6
  "scripts": {