@desynova-digital/player 4.0.1 → 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.
Files changed (111) hide show
  1. package/Manager.js +99 -0
  2. package/actions/player.js +331 -0
  3. package/actions/video.js +206 -0
  4. package/{utils/colors.js → colors.js} +1 -2
  5. package/{media → components}/AudioMeter.js +96 -109
  6. package/components/BigPlayButton.js +84 -0
  7. package/components/ImageViewer.js +272 -0
  8. package/{control → components}/MarkerBar.js +33 -24
  9. package/{utils → components}/Menu.js +13 -4
  10. package/components/Player.js +706 -0
  11. package/{header/Header.js → components/PlayerHeader.js} +104 -78
  12. package/components/Playlist.js +95 -0
  13. package/{control → components}/PointersBar.js +122 -61
  14. package/components/PosterImage.js +50 -0
  15. package/{media → components}/SDOutline.js +13 -49
  16. package/components/Shortcut.js +821 -0
  17. package/{control → components}/Slider.js +27 -23
  18. package/components/TagsBar.js +81 -0
  19. package/components/Video.js +1280 -0
  20. package/{control → components/control-bar}/AudioTracksMenuButton.js +32 -28
  21. package/components/control-bar/CameraButton.js +75 -0
  22. package/components/control-bar/CommentsButton.js +186 -0
  23. package/components/control-bar/ControlBar.js +266 -0
  24. package/components/control-bar/EditorControlMenuButton.js +317 -0
  25. package/components/control-bar/ForwardControl.js +12 -0
  26. package/components/control-bar/ForwardReplayControl.js +106 -0
  27. package/{control → components/control-bar}/FullscreenToggle.js +26 -21
  28. package/components/control-bar/PlayToggle.js +85 -0
  29. package/components/control-bar/ReplayControl.js +12 -0
  30. package/components/control-bar/SettingsMenuButton.js +41 -0
  31. package/components/control-bar/SubtitleLanguagesMenuButton.js +149 -0
  32. package/components/control-bar/SubtitleMovementMenu.js +140 -0
  33. package/{control/VolumneMenuButton.js → components/control-bar/VolumeMenuButton.js} +26 -27
  34. package/components/control-bar/ZoomMenuButton.js +90 -0
  35. package/{control → components/marking-controls}/MarkInControl.js +32 -25
  36. package/{control → components/marking-controls}/MarkOutControl.js +35 -26
  37. package/components/marking-controls/MarkingAddButton.js +79 -0
  38. package/components/marking-controls/MarkingControl.js +95 -0
  39. package/components/marking-controls/MarkingDeleteButton.js +70 -0
  40. package/{control → components/marking-controls}/MarkingDuration.js +12 -5
  41. package/components/marking-controls/MarkingPreview.js +72 -0
  42. package/components/progress-bar/AudioWaveform.js +126 -0
  43. package/components/progress-bar/LoadProgressBar.js +67 -0
  44. package/components/progress-bar/MouseTimeDisplay.js +36 -0
  45. package/{control → components/progress-bar}/PlayProgressBar.js +4 -4
  46. package/components/progress-bar/ProgressControl.js +186 -0
  47. package/{control → components/progress-bar}/SeekBar.js +113 -72
  48. package/{control → components/progress-bar}/Timeline.js +43 -32
  49. package/{control/PlayBackRateControl.js → components/settings-menu-control/PlaybackRateControl.js} +44 -30
  50. package/components/settings-menu-control/SafeAreaControl.js +81 -0
  51. package/components/settings-menu-control/SettingsMenu.js +56 -0
  52. package/components/settings-menu-control/SubtitleControl.js +1 -0
  53. package/components/time-controls/CurrentTimeDisplay.js +83 -0
  54. package/{control → components/time-controls}/DurationDisplay.js +8 -15
  55. package/components/time-controls/TimeDivider.js +25 -0
  56. package/{control → components/volume-control}/VolumeBar.js +62 -80
  57. package/components/volume-control/VolumeControl.js +19 -0
  58. package/{control → components/volume-control}/VolumeLevel.js +2 -3
  59. package/components/zoom-control/ZoomBar.js +155 -0
  60. package/components/zoom-control/ZoomLevel.js +55 -0
  61. package/index.js +198 -1
  62. package/package.json +5 -8
  63. package/reducers/index.js +19 -0
  64. package/reducers/operation.js +35 -0
  65. package/reducers/player.js +222 -0
  66. package/utils/browser.js +30 -0
  67. package/utils/dom.js +1 -2
  68. package/utils/fullscreen.js +72 -0
  69. package/utils/index.js +156 -57
  70. package/Player.js +0 -945
  71. package/control/AudioTracksMenuButton.jsx +0 -80
  72. package/control/ControlBar.js +0 -303
  73. package/control/ControlBar.jsx +0 -264
  74. package/control/CurrentTimeDisplay.js +0 -34
  75. package/control/CurrentTimeDisplay.jsx +0 -35
  76. package/control/DurationDisplay.jsx +0 -48
  77. package/control/ForwardBackwardControl.js +0 -76
  78. package/control/ForwardBackwardControl.jsx +0 -79
  79. package/control/FullscreenToggle.jsx +0 -83
  80. package/control/MarkInControl.jsx +0 -109
  81. package/control/MarkOutControl.jsx +0 -131
  82. package/control/MarkerBar.jsx +0 -107
  83. package/control/MarkingControl.js +0 -82
  84. package/control/MarkingControl.jsx +0 -143
  85. package/control/MarkingPreview.js +0 -49
  86. package/control/MarkingPreview.jsx +0 -60
  87. package/control/PlayBackRateControl.jsx +0 -106
  88. package/control/PlayProgressBar.jsx +0 -92
  89. package/control/PlayToggle.js +0 -56
  90. package/control/PlayToggle.jsx +0 -57
  91. package/control/PointersBar.jsx +0 -286
  92. package/control/ProgressControl.js +0 -127
  93. package/control/ProgressControl.jsx +0 -155
  94. package/control/SeekBar.jsx +0 -229
  95. package/control/SettingsMenuButton.js +0 -63
  96. package/control/SettingsMenuButton.jsx +0 -69
  97. package/control/Slider.jsx +0 -243
  98. package/control/Timeline.jsx +0 -131
  99. package/control/VolumeBar.jsx +0 -174
  100. package/control/VolumeLevel.jsx +0 -66
  101. package/control/VolumneMenuButton.jsx +0 -111
  102. package/header/Header.jsx +0 -479
  103. package/media/AudioMeter.jsx +0 -411
  104. package/media/SDOutline.jsx +0 -90
  105. package/media/Video.js +0 -684
  106. package/media/Video.jsx +0 -714
  107. package/playlist/Playlist.js +0 -67
  108. package/playlist/Playlist.jsx +0 -91
  109. package/playlist/index.js +0 -13
  110. package/shortcuts/Shortcut.js +0 -662
  111. package/utils/Menu.jsx +0 -105
@@ -0,0 +1,1280 @@
1
+ "use strict";
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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _propTypes = require("prop-types");
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
+ var _hls = _interopRequireDefault(require("hls.js"));
12
+ var _Manager = _interopRequireDefault(require("../Manager"));
13
+ var _utils = require("../utils");
14
+ var _BigPlayButton = _interopRequireDefault(require("./BigPlayButton"));
15
+ var _PosterImage = _interopRequireDefault(require("./PosterImage"));
16
+ var _SDOutline = _interopRequireDefault(require("./SDOutline"));
17
+ var _components = require("@desynova-digital/components/components");
18
+ var _templateObject, _templateObject2;
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
20
+ 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); }
21
+ 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; }
22
+ 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; }
23
+ 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; }
24
+ 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; }
25
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
26
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27
+ 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); } }
28
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
29
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
30
+ 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); }
31
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
32
+ 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); }
33
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
34
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
36
+ 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); }
37
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
38
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
39
+ var propTypes = {
40
+ actions: _propTypes.PropTypes.instanceOf(Object),
41
+ player: _propTypes.PropTypes.instanceOf(Object),
42
+ startTime: _propTypes.PropTypes.number,
43
+ loop: _propTypes.PropTypes.bool,
44
+ muted: _propTypes.PropTypes.bool,
45
+ autoPlay: _propTypes.PropTypes.bool,
46
+ playsInline: _propTypes.PropTypes.bool,
47
+ src: _propTypes.PropTypes.string,
48
+ poster: _propTypes.PropTypes.string,
49
+ className: _propTypes.PropTypes.string,
50
+ fileType: _propTypes.PropTypes.oneOf(['video', 'image', 'audio']),
51
+ preload: _propTypes.PropTypes.oneOf(['auto', 'metadata', 'none']),
52
+ crossOrigin: _propTypes.PropTypes.string,
53
+ fluid: _propTypes.PropTypes.bool,
54
+ children: _propTypes.PropTypes.arrayOf(_propTypes.PropTypes.element),
55
+ store: _propTypes.PropTypes.instanceOf(Object),
56
+ width: _propTypes.PropTypes.number,
57
+ activeTrackIndex: _propTypes.PropTypes.number,
58
+ height: _propTypes.PropTypes.number,
59
+ videoId: _propTypes.PropTypes.string,
60
+ onLoadStart: _propTypes.PropTypes.func,
61
+ onWaiting: _propTypes.PropTypes.func,
62
+ onCanPlay: _propTypes.PropTypes.func,
63
+ onCanPlayThrough: _propTypes.PropTypes.func,
64
+ onPlaying: _propTypes.PropTypes.func,
65
+ onEnded: _propTypes.PropTypes.func,
66
+ onSeeking: _propTypes.PropTypes.func,
67
+ onSeeked: _propTypes.PropTypes.func,
68
+ onPlay: _propTypes.PropTypes.func,
69
+ onPause: _propTypes.PropTypes.func,
70
+ onProgress: _propTypes.PropTypes.func,
71
+ onDurationChange: _propTypes.PropTypes.func,
72
+ onError: _propTypes.PropTypes.func,
73
+ onSuspend: _propTypes.PropTypes.func,
74
+ onAbort: _propTypes.PropTypes.func,
75
+ onEmptied: _propTypes.PropTypes.func,
76
+ onStalled: _propTypes.PropTypes.func,
77
+ onLoadedMetadata: _propTypes.PropTypes.func,
78
+ onLoadedData: _propTypes.PropTypes.func,
79
+ onTimeUpdate: _propTypes.PropTypes.func,
80
+ onRateChange: _propTypes.PropTypes.func,
81
+ onVolumeChange: _propTypes.PropTypes.func,
82
+ onResize: _propTypes.PropTypes.func,
83
+ aspectRatio: _propTypes.PropTypes.string,
84
+ onPlayerClose: _propTypes.PropTypes.func,
85
+ userEmail: _propTypes.PropTypes.string,
86
+ playerSelectedMarker: _propTypes.PropTypes.instanceOf(Object),
87
+ theme: _propTypes.PropTypes.string
88
+ };
89
+ var defaultProps = {
90
+ startTime: 0,
91
+ loop: false,
92
+ muted: false,
93
+ autoPlay: false,
94
+ playsInline: false,
95
+ preload: 'auto',
96
+ aspectRatio: 'auto',
97
+ crossOrigin: 'anonymous',
98
+ theme: 'dark'
99
+ };
100
+ var SubTitleSection = _styledComponents["default"].div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n font-family: SFUIText-Regular;\n font-size: 16px;\n bottom: 20px;\n width: 100%;\n display: flex;\n justify-content: center;\n text-align: center;\n color: #ffffff;\n height: 90%;\n align-items: center;\n\n .subtitleContainer {\n border-radius: 4px;\n width: fit-content;\n background: #000000;\n opacity: 0.9;\n padding: ", ";\n line-height: 20px;\n position: absolute;\n\n em {\n font-style: italic; /* Override the font style for <em> tags inside elements with the class .someClass */\n }\n\n strong{\n font-weight: bold; \n }\n \n }\n .longSubtitleStyles {\n overflow-y: auto;\n height: fit-content;\n max-height: 70px;\n max-width: 75%;\n width: fit-content;\n }\n"])), function (props) {
101
+ return props.currentSubtitleObj && props.currentSubtitleObj.line1 ? '8px 10px' : '0px';
102
+ });
103
+ var VideoBlock = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n &.video-react-player-block {\n position: relative;\n transition: all 0.1s ease-in-out;\n -moz-transition: all 0.1s ease-in-out;\n -webkit-transition: all 0.1s ease-in-out;\n -ms-transition: all 0.1s ease-in-out;\n -o-transition: all 0.1s ease-in-out;\n video {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n right: 0;\n bottom: 0;\n }\n .audio-tracks {\n position: relative;\n display: flex;\n background: rgba(0, 0, 0, 0.5);\n color: #fff;\n z-index: 10;\n position: absolute;\n width: 100%;\n bottom: 0;\n p {\n cursor: pointer;\n padding: 10px;\n }\n }\n .loader-container {\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n position: absolute;\n z-index: 10;\n background: rgba(0, 0, 0, 0.5);\n }\n }\n &.ratio-border {\n border: 1px solid rgba(255, 255, 255, 0.5);\n &:after {\n content: '16:9 Safe Area';\n position: absolute;\n color: #fff;\n font-family: SFUIText-Regular;\n font-size: 12px;\n transform: rotate(-90deg);\n top: 20%;\n left: -50px;\n }\n }\n"])));
104
+ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
105
+ _inherits(Video, _Component);
106
+ function Video(props) {
107
+ var _this;
108
+ _classCallCheck(this, Video);
109
+ _this = _callSuper(this, Video, [props]);
110
+ _this.state = {
111
+ audioTracks: [],
112
+ isM3U8: false,
113
+ watermark: {
114
+ color: 'rgb(255, 255, 255)',
115
+ position: 'absolute',
116
+ 'font-family': 'SFUIText-Regular',
117
+ 'text-shadow': '0 0 4px rgb(0 0 0 / 50%)',
118
+ 'font-size': '12px',
119
+ opacity: '0.6',
120
+ display: 'block',
121
+ top: '0px',
122
+ left: '0px'
123
+ },
124
+ watermarkInterval: -1,
125
+ isBuffering: false,
126
+ currentSubtitleObj: {}
127
+ };
128
+ _this.video = null; // the html5 video
129
+ _this.manager = new _Manager["default"](props.store);
130
+ _this.getStyle = _this.getStyle.bind(_assertThisInitialized(_this));
131
+ _this.getChildren = _this.getChildren.bind(_assertThisInitialized(_this));
132
+ _this.play = _this.play.bind(_assertThisInitialized(_this));
133
+ _this.pause = _this.pause.bind(_assertThisInitialized(_this));
134
+ _this.seek = _this.seek.bind(_assertThisInitialized(_this));
135
+ _this.forward = _this.forward.bind(_assertThisInitialized(_this));
136
+ _this.replay = _this.replay.bind(_assertThisInitialized(_this));
137
+ _this.toggleFullscreen = _this.toggleFullscreen.bind(_assertThisInitialized(_this));
138
+ _this.getProperties = _this.getProperties.bind(_assertThisInitialized(_this));
139
+ _this.renderChildren = _this.renderChildren.bind(_assertThisInitialized(_this));
140
+ _this.handleLoadStart = _this.handleLoadStart.bind(_assertThisInitialized(_this));
141
+ _this.handleCanPlay = _this.handleCanPlay.bind(_assertThisInitialized(_this));
142
+ _this.handleCanPlayThrough = _this.handleCanPlayThrough.bind(_assertThisInitialized(_this));
143
+ _this.handlePlay = _this.handlePlay.bind(_assertThisInitialized(_this));
144
+ _this.handlePlaying = _this.handlePlaying.bind(_assertThisInitialized(_this));
145
+ _this.handlePause = _this.handlePause.bind(_assertThisInitialized(_this));
146
+ _this.handleEnded = _this.handleEnded.bind(_assertThisInitialized(_this));
147
+ _this.handleWaiting = _this.handleWaiting.bind(_assertThisInitialized(_this));
148
+ _this.handleSeeking = _this.handleSeeking.bind(_assertThisInitialized(_this));
149
+ _this.handleSeeked = _this.handleSeeked.bind(_assertThisInitialized(_this));
150
+ _this.handleFullscreenChange = _this.handleFullscreenChange.bind(_assertThisInitialized(_this));
151
+ _this.handleError = _this.handleError.bind(_assertThisInitialized(_this));
152
+ _this.handleSuspend = _this.handleSuspend.bind(_assertThisInitialized(_this));
153
+ _this.handleAbort = _this.handleAbort.bind(_assertThisInitialized(_this));
154
+ _this.handleEmptied = _this.handleEmptied.bind(_assertThisInitialized(_this));
155
+ _this.handleStalled = _this.handleStalled.bind(_assertThisInitialized(_this));
156
+ _this.handleLoadedMetaData = _this.handleLoadedMetaData.bind(_assertThisInitialized(_this));
157
+ _this.handleLoadedData = _this.handleLoadedData.bind(_assertThisInitialized(_this));
158
+ _this.handleTimeUpdate = _this.handleTimeUpdate.bind(_assertThisInitialized(_this));
159
+ _this.handleRateChange = _this.handleRateChange.bind(_assertThisInitialized(_this));
160
+ _this.handleVolumeChange = _this.handleVolumeChange.bind(_assertThisInitialized(_this));
161
+ _this.handleDurationChange = _this.handleDurationChange.bind(_assertThisInitialized(_this));
162
+ _this.handleProgress = (0, _utils.throttle)(_this.handleProgress.bind(_assertThisInitialized(_this)), 250);
163
+ _this.handleKeypress = _this.handleKeypress.bind(_assertThisInitialized(_this));
164
+ _this.audioVisualizer = _this.audioVisualizer.bind(_assertThisInitialized(_this));
165
+ _this.checkWatermark = _this.checkWatermark.bind(_assertThisInitialized(_this));
166
+ return _this;
167
+ }
168
+ _createClass(Video, [{
169
+ key: "componentDidMount",
170
+ value: function componentDidMount() {
171
+ var src = this.props.src;
172
+ var isM3U8 = src.split('.').pop() === 'm3u8' ? true : false;
173
+ this.setState({
174
+ isM3U8: isM3U8
175
+ });
176
+ if (_hls["default"].isSupported() && isM3U8) {
177
+ var _this$manager$getStat = this.manager.getState(),
178
+ HLSConfig = _this$manager$getStat.player.HLSConfig;
179
+ this.hls = new _hls["default"](HLSConfig);
180
+ this.setupHLS(src);
181
+ } else {
182
+ this.video.src = src;
183
+ }
184
+ this.forceUpdate(); // make sure the children can get the video property
185
+ var watermarkInterval = setInterval(this.checkWatermark, 20000);
186
+ this.setState({
187
+ watermarkInterval: watermarkInterval
188
+ });
189
+ }
190
+ }, {
191
+ key: "componentWillUnmount",
192
+ value: function componentWillUnmount() {
193
+ var _this$state = this.state,
194
+ isM3U8 = _this$state.isM3U8,
195
+ watermarkInterval = _this$state.watermarkInterval;
196
+ if (_hls["default"].isSupported() && isM3U8) {
197
+ this.hls.detachMedia();
198
+ } else {
199
+ this.video.src = '';
200
+ }
201
+ clearInterval(watermarkInterval);
202
+ }
203
+
204
+ /**
205
+ * This function is triggered on interval to shuffle the position of watermark on Player area
206
+ */
207
+ }, {
208
+ key: "checkWatermark",
209
+ value: function checkWatermark() {
210
+ var watermark = this.state.watermark;
211
+ var _this$props = this.props,
212
+ onPlayerClose = _this$props.onPlayerClose,
213
+ userEmail = _this$props.userEmail;
214
+ var watermark_text = document.querySelector('#watermark-text');
215
+ var video_player = null;
216
+ var watermark_dimension = null;
217
+ var text_css = null;
218
+ var bool_text = false;
219
+ if (!watermark_text) {
220
+ onPlayerClose();
221
+ } else {
222
+ video_player = document.querySelector('.video-react-player-block').getBoundingClientRect();
223
+ watermark_dimension = watermark_text.getBoundingClientRect();
224
+ text_css = watermark_text.style;
225
+ bool_text = text_css.position !== 'absolute' || text_css.opacity !== '0.6' || text_css['font-family'] !== 'SFUIText-Regular' && text_css['font-family'] !== '"SFUIText-Regular"';
226
+ bool_text = bool_text || text_css.display !== 'block';
227
+ bool_text = bool_text || text_css.top !== watermark.top;
228
+ bool_text = bool_text || text_css.left !== watermark.left;
229
+ bool_text = bool_text || text_css.length !== 9 || text_css['font-size'] !== '12px';
230
+ bool_text = bool_text || text_css.color !== 'rgb(255, 255, 255)';
231
+ bool_text = bool_text || userEmail !== watermark_text.innerText;
232
+ if (bool_text) {
233
+ onPlayerClose();
234
+ }
235
+ }
236
+ watermark.left = (Math.random() * (video_player.width - watermark_dimension.width)).toFixed(0) + 'px';
237
+ watermark.top = (Math.random() * (video_player.height - watermark_dimension.height)).toFixed(0) + 'px';
238
+ this.setState({
239
+ watermark: watermark
240
+ });
241
+ }
242
+ }, {
243
+ key: "setupHLS",
244
+ value: function setupHLS(src) {
245
+ var _this2 = this;
246
+ var _this$props2 = this.props,
247
+ actions = _this$props2.actions,
248
+ activeTrackIndex = _this$props2.activeTrackIndex;
249
+ var self = this;
250
+ // bind them together
251
+ this.hls.attachMedia(this.video);
252
+ this.hls.on(_hls["default"].Events.MEDIA_ATTACHED, function () {
253
+ self.hls.loadSource(src);
254
+ });
255
+ this.hls.on(_hls["default"].Events.MANIFEST_PARSED, function (event, data) {
256
+ actions.handleAudioTracks(data.audioTracks);
257
+ });
258
+ this.hls.once(_hls["default"].Events.AUDIO_TRACK_LOADED, function (event, data) {
259
+ var trackIndex = activeTrackIndex || 0;
260
+ actions.handleAudioTrackChange(self.props.player.audioTracksArr[trackIndex]);
261
+ });
262
+ this.hls.on(_hls["default"].Events.ERROR, function (event, data) {
263
+ // eslint-disable-next-line no-console
264
+ console.log('HLS.Events.ERROR: ', event, data);
265
+ if (data.fatal) {
266
+ switch (data.type) {
267
+ case _hls["default"].ErrorTypes.NETWORK_ERROR:
268
+ // try to recover network error
269
+ _this2.hls.startLoad();
270
+ break;
271
+ case _hls["default"].ErrorTypes.MEDIA_ERROR:
272
+ _this2.hls.recoverMediaError();
273
+ break;
274
+ default:
275
+ // cannot recover
276
+ _this2.hls.destroy();
277
+ break;
278
+ }
279
+ } else if (data.details === 'internalException' && data.type === 'otherError' || data.details === 'bufferStalledError' && data.type === 'mediaError') {
280
+ _this2.hls.startLoad();
281
+ }
282
+ });
283
+ }
284
+ }, {
285
+ key: "getDefaultChildren",
286
+ value: function getDefaultChildren(props) {
287
+ return [/*#__PURE__*/_react["default"].createElement(_PosterImage["default"], _extends({
288
+ key: "poster-image",
289
+ order: 1.0
290
+ }, props)), /*#__PURE__*/_react["default"].createElement(_SDOutline["default"], _extends({
291
+ key: "sd-outline",
292
+ order: 2.0
293
+ }, props)), /*#__PURE__*/_react["default"].createElement(_BigPlayButton["default"], _extends({
294
+ key: "big-play-button",
295
+ order: 5.0
296
+ }, props))];
297
+ }
298
+ }, {
299
+ key: "getChildren",
300
+ value: function getChildren(props) {
301
+ var propsWithoutChildren = _objectSpread(_objectSpread({}, props), {}, {
302
+ children: null
303
+ });
304
+ var children = this.props.children;
305
+ var childs = _react["default"].Children.toArray(children).filter(function (e) {
306
+ return !(0, _utils.isVideoChild)(e);
307
+ });
308
+ var defaultChildren = this.getDefaultChildren(propsWithoutChildren, props);
309
+ return (0, _utils.mergeAndSortChildren)(defaultChildren, childs, propsWithoutChildren);
310
+ }
311
+ }, {
312
+ key: "setWidthOrHeight",
313
+ value: function setWidthOrHeight(style, name, value) {
314
+ var styleVal;
315
+ if (typeof value === 'string') {
316
+ if (value === 'auto') {
317
+ styleVal = 'auto';
318
+ } else if (value.match(/\d+%/)) {
319
+ styleVal = value;
320
+ }
321
+ } else if (typeof value === 'number') {
322
+ styleVal = "".concat(value, "px");
323
+ }
324
+ Object.assign(style, _defineProperty({}, name, styleVal));
325
+ }
326
+ }, {
327
+ key: "getStyle",
328
+ value: function getStyle() {
329
+ var fluid = this.props.fluid;
330
+ var _this$manager$getStat2 = this.manager.getState(),
331
+ player = _this$manager$getStat2.player;
332
+ var style = {};
333
+ var _this$props3 = this.props,
334
+ aspectRatio = _this$props3.aspectRatio,
335
+ width = _this$props3.width,
336
+ height = _this$props3.height;
337
+ /*
338
+ * The aspect ratio is either used directly
339
+ * or to calculate width and height.
340
+ */
341
+ if (player.videoWidth) {
342
+ // Otherwise try to get the aspect ratio from the video metadata
343
+ aspectRatio = '16:9';
344
+ // aspectRatio = `${player.videoWidth}:${player.videoHeight}`;
345
+ } else {
346
+ // Or use a default. The video element's is 2:1, but 16:9 is more common.
347
+ aspectRatio = '16:9';
348
+ }
349
+
350
+ // Get the ratio as a decimal we can use to calculate dimensions
351
+ var ratioParts = aspectRatio.split(':');
352
+ var ratioMultiplier = ratioParts[1] / ratioParts[0];
353
+ if (height !== undefined) {
354
+ // Or calulate the width from the aspect ratio if a height has been set
355
+ width = height / ratioMultiplier;
356
+ } else {
357
+ // Or use the video's metadata, or use the video el's default of 300
358
+ width = player.videoWidth || 400;
359
+ height = width * ratioMultiplier;
360
+ }
361
+ if (fluid) {
362
+ style.paddingTop = "".concat(ratioMultiplier * 100, "%");
363
+ } else {
364
+ // If Width contains 'auto', set 'auto' in style
365
+ this.setWidthOrHeight(style, 'width', width);
366
+ this.setWidthOrHeight(style, 'height', height);
367
+ }
368
+ style.width = '100%';
369
+ return style;
370
+ }
371
+
372
+ // get all video properties
373
+ }, {
374
+ key: "getProperties",
375
+ value: function getProperties() {
376
+ var _this3 = this;
377
+ if (!this.video) {
378
+ return null;
379
+ }
380
+ return _utils.mediaProperties.reduce(function (properties, key) {
381
+ properties[key] = _this3.video[key];
382
+ return properties;
383
+ }, {});
384
+ }
385
+
386
+ // get playback rate
387
+ }, {
388
+ key: "playbackRate",
389
+ get: function get() {
390
+ return this.video.playbackRate;
391
+ }
392
+
393
+ /*
394
+ * set playback rate
395
+ * speed of video
396
+ */,
397
+ set: function set(rate) {
398
+ this.video.playbackRate = rate;
399
+ }
400
+ }, {
401
+ key: "muted",
402
+ get: function get() {
403
+ return this.video.muted;
404
+ },
405
+ set: function set(val) {
406
+ this.video.muted = val;
407
+ }
408
+ }, {
409
+ key: "volume",
410
+ get: function get() {
411
+ return this.video.volume;
412
+ },
413
+ set: function set(val) {
414
+ if (val > 1) {
415
+ val = 1;
416
+ }
417
+ if (val < 0) {
418
+ val = 0;
419
+ }
420
+ this.video.volume = val;
421
+ }
422
+
423
+ // video width
424
+ }, {
425
+ key: "videoWidth",
426
+ get: function get() {
427
+ return this.video.videoWidth;
428
+ }
429
+
430
+ // video height
431
+ }, {
432
+ key: "videoHeight",
433
+ get: function get() {
434
+ return this.video.videoHeight;
435
+ }
436
+ }, {
437
+ key: "UNSAFE_componentWillReceiveProps",
438
+ value: function UNSAFE_componentWillReceiveProps(newProps) {
439
+ var _this$props4 = this.props,
440
+ src = _this$props4.src,
441
+ activeAudio = _this$props4.player.activeAudio,
442
+ currentSubtitleObj = _this$props4.currentSubtitleObj,
443
+ markers = _this$props4.markers;
444
+ if (newProps.src !== src) {
445
+ var isM3U8 = this.state.isM3U8;
446
+ if (_hls["default"].isSupported() && isM3U8) {
447
+ this.hls.detachMedia();
448
+ } else {
449
+ this.video.src = '';
450
+ }
451
+ var m3u8 = newProps.src.split('.').pop() === 'm3u8' ? true : false;
452
+ this.setState({
453
+ isM3U8: m3u8
454
+ });
455
+ if (_hls["default"].isSupported() && m3u8) {
456
+ var _this$manager$getStat3 = this.manager.getState(),
457
+ HLSConfig = _this$manager$getStat3.player.HLSConfig;
458
+ this.hls = new _hls["default"](HLSConfig);
459
+ this.setupHLS(newProps.src);
460
+ } else {
461
+ this.video.src = newProps.src;
462
+ }
463
+ this.forceUpdate(); // make sure the children can get the video property
464
+ }
465
+ if (newProps.player.activeAudio && activeAudio && activeAudio.id !== newProps.player.activeAudio.id) {
466
+ this.hls.audioTrack = newProps.player.activeAudio.id;
467
+ }
468
+ if (newProps.subtitleObj && newProps.subtitleObj.field && JSON.stringify(newProps.subtitleObj) !== JSON.stringify(currentSubtitleObj)) {
469
+ if (newProps.subtitleObj && newProps.subtitleObj.field && !newProps.subtitleObj.field.line1) {
470
+ this.setState({
471
+ currentSubtitleObj: {}
472
+ });
473
+ } else if (newProps.subtitleObj && newProps.subtitleObj.field && newProps.subtitleObj.field.line1) {
474
+ var style = this.getSubtitleStyle(newProps.subtitleObj.field);
475
+ this.setState({
476
+ currentSubtitleObj: {
477
+ charactername: newProps.subtitleObj.field.charactername,
478
+ line1: newProps.subtitleObj.field.line1,
479
+ line2: newProps.subtitleObj.field.line2,
480
+ start_time: newProps.subtitleObj.field.in_time,
481
+ end_time: newProps.subtitleObj.field.out_time,
482
+ style: style
483
+ }
484
+ });
485
+ }
486
+ }
487
+ if (newProps.markers.length && markers.length && newProps.markers[0].values.length !== markers[0].values.length) {
488
+ this.displaySubtitle(newProps.markers);
489
+ }
490
+ if (newProps.subtitleReadOnly && newProps.subtitleDataList) {
491
+ this.displaySubtitle(newProps.subtitleDataList);
492
+ }
493
+ }
494
+
495
+ // play the video
496
+ }, {
497
+ key: "play",
498
+ value: function play() {
499
+ var promise = this.video.play();
500
+ if (promise !== undefined) {
501
+ promise["catch"](function () {}).then(function () {});
502
+ }
503
+ }
504
+
505
+ // pause the video
506
+ }, {
507
+ key: "pause",
508
+ value: function pause() {
509
+ var promise = this.video.pause();
510
+ if (promise !== undefined) {
511
+ promise["catch"](function () {}).then(function () {});
512
+ }
513
+ }
514
+
515
+ // Change the video source and re-load the video:
516
+ }, {
517
+ key: "load",
518
+ value: function load() {
519
+ this.video.load();
520
+ }
521
+
522
+ // Add a new text track to the video
523
+ }, {
524
+ key: "addTextTrack",
525
+ value: function addTextTrack() {
526
+ var _this$video;
527
+ (_this$video = this.video).addTextTrack.apply(_this$video, arguments);
528
+ }
529
+
530
+ // Check if your browser can play different types of video:
531
+ }, {
532
+ key: "canPlayType",
533
+ value: function canPlayType() {
534
+ var _this$video2;
535
+ (_this$video2 = this.video).canPlayType.apply(_this$video2, arguments);
536
+ }
537
+
538
+ // toggle play
539
+ }, {
540
+ key: "togglePlay",
541
+ value: function togglePlay() {
542
+ if (this.video.paused) {
543
+ this.play();
544
+ } else {
545
+ this.pause();
546
+ }
547
+ }
548
+
549
+ // seek video by time
550
+ }, {
551
+ key: "seek",
552
+ value: function seek(time) {
553
+ try {
554
+ var updatedTime = 0;
555
+ var frameRate = this.props.frameRate;
556
+ if (time < 0) {
557
+ updatedTime = 0;
558
+ } else {
559
+ updatedTime = time > this.video.duration ? this.video.duration : (0, _utils.handleAdjustingVideoAsPerFrame)(time, frameRate);
560
+ }
561
+ this.video.currentTime = updatedTime;
562
+ } catch (e) {
563
+ // console.log(e, 'Video is not ready.')
564
+ }
565
+ }
566
+ // jump forward x seconds
567
+ }, {
568
+ key: "forward",
569
+ value: function forward(seconds) {
570
+ this.seek(this.video.currentTime + seconds);
571
+ }
572
+
573
+ // jump back x seconds
574
+ }, {
575
+ key: "replay",
576
+ value: function replay(seconds) {
577
+ this.forward(-seconds);
578
+ }
579
+
580
+ // enter or exist full screen
581
+ }, {
582
+ key: "toggleFullscreen",
583
+ value: function toggleFullscreen() {
584
+ var _this$props5 = this.props,
585
+ player = _this$props5.player,
586
+ actions = _this$props5.actions;
587
+ actions.toggleFullscreen(player);
588
+ }
589
+
590
+ /*
591
+ * Fired when the user agent
592
+ * begins looking for media data
593
+ */
594
+ }, {
595
+ key: "handleLoadStart",
596
+ value: function handleLoadStart() {
597
+ var _this$props6 = this.props,
598
+ actions = _this$props6.actions,
599
+ onLoadStart = _this$props6.onLoadStart,
600
+ fileType = _this$props6.fileType;
601
+ if (fileType === 'audio') {
602
+ this.audioVisualizer();
603
+ }
604
+ actions.handleLoadStart(this.getProperties());
605
+ if (onLoadStart) {
606
+ onLoadStart.apply(void 0, arguments);
607
+ }
608
+ }
609
+
610
+ /*
611
+ * A handler for events that
612
+ * signal that waiting has ended
613
+ */
614
+ }, {
615
+ key: "handleCanPlay",
616
+ value: function handleCanPlay() {
617
+ var _this$props7 = this.props,
618
+ actions = _this$props7.actions,
619
+ onCanPlay = _this$props7.onCanPlay;
620
+ actions.handleCanPlay(this.getProperties());
621
+ if (onCanPlay) {
622
+ onCanPlay.apply(void 0, arguments);
623
+ }
624
+ }
625
+
626
+ /*
627
+ * A handler for events that
628
+ * signal that waiting has ended
629
+ */
630
+ }, {
631
+ key: "handleCanPlayThrough",
632
+ value: function handleCanPlayThrough() {
633
+ var _this$props8 = this.props,
634
+ actions = _this$props8.actions,
635
+ onCanPlayThrough = _this$props8.onCanPlayThrough;
636
+ actions.handleCanPlayThrough(this.getProperties());
637
+ if (onCanPlayThrough) {
638
+ onCanPlayThrough.apply(void 0, arguments);
639
+ }
640
+ }
641
+
642
+ /*
643
+ * A handler for events that
644
+ * signal that waiting has ended
645
+ */
646
+ }, {
647
+ key: "handlePlaying",
648
+ value: function handlePlaying() {
649
+ var _this$props9 = this.props,
650
+ actions = _this$props9.actions,
651
+ onPlaying = _this$props9.onPlaying;
652
+ actions.handlePlaying(this.getProperties());
653
+ if (onPlaying) {
654
+ onPlaying.apply(void 0, arguments);
655
+ }
656
+ }
657
+
658
+ // Fired whenever the media has been started
659
+ }, {
660
+ key: "handlePlay",
661
+ value: function handlePlay() {
662
+ var _this$props10 = this.props,
663
+ actions = _this$props10.actions,
664
+ onPlay = _this$props10.onPlay;
665
+ actions.handlePlay(this.getProperties());
666
+ if (onPlay) {
667
+ onPlay.apply(void 0, arguments);
668
+ }
669
+ }
670
+
671
+ // Fired whenever the media has been paused
672
+ }, {
673
+ key: "handlePause",
674
+ value: function handlePause() {
675
+ var _this$props11 = this.props,
676
+ actions = _this$props11.actions,
677
+ onPause = _this$props11.onPause;
678
+ actions.handlePause(this.getProperties());
679
+ if (onPause) {
680
+ onPause.apply(void 0, arguments);
681
+ }
682
+ }
683
+
684
+ /*
685
+ * Fired when the duration of
686
+ * the media resource is first known or changed
687
+ */
688
+ }, {
689
+ key: "handleDurationChange",
690
+ value: function handleDurationChange() {
691
+ var _this$props12 = this.props,
692
+ actions = _this$props12.actions,
693
+ onDurationChange = _this$props12.onDurationChange;
694
+ actions.handleDurationChange(this.getProperties());
695
+ if (onDurationChange) {
696
+ onDurationChange.apply(void 0, arguments);
697
+ }
698
+ }
699
+
700
+ /*
701
+ * Fired while the user agent
702
+ * is downloading media data
703
+ */
704
+ }, {
705
+ key: "handleProgress",
706
+ value: function handleProgress() {
707
+ var _this$props13 = this.props,
708
+ actions = _this$props13.actions,
709
+ onProgress = _this$props13.onProgress;
710
+ if (this.video) {
711
+ actions.handleProgressChange(this.getProperties());
712
+ }
713
+ if (onProgress) {
714
+ onProgress.apply(void 0, arguments);
715
+ }
716
+ }
717
+ }, {
718
+ key: "getSubtitleStyle",
719
+ value: function getSubtitleStyle(data) {
720
+ var style = {};
721
+ style.top = data && data.text_position === 'text_position_top' ? '0px' : '';
722
+ style.bottom = data && data.text_position === 'text_position_bottom' ? '0px' : '';
723
+ style.left = data && data.text_alignment === 'text_aligned_left' ? '0px' : '';
724
+ style.right = data && data.text_alignment === 'text_aligned_right' ? '0px' : '';
725
+ return style;
726
+ }
727
+ }, {
728
+ key: "displaySubtitle",
729
+ value: function displaySubtitle(marker) {
730
+ var _this$props14 = this.props,
731
+ markers = _this$props14.markers,
732
+ resetSubtitleData = _this$props14.resetSubtitleData,
733
+ subtitleReadOnly = _this$props14.subtitleReadOnly,
734
+ subtitleDataList = _this$props14.subtitleDataList;
735
+ var currentSubtitleObj = this.state.currentSubtitleObj;
736
+ if (resetSubtitleData) {
737
+ resetSubtitleData();
738
+ }
739
+ var currentTime = this.video.currentTime;
740
+ var currentMarker = marker || markers;
741
+ if (subtitleReadOnly) {
742
+ currentMarker = marker || subtitleDataList;
743
+ }
744
+ if (currentMarker && currentMarker[0] && currentMarker[0].name === 'Subtitle') {
745
+ var values = currentMarker[0].values;
746
+ var currentValue = values.filter(function (ele) {
747
+ return ele.start_time <= currentTime && ele.end_time >= currentTime;
748
+ });
749
+ var style = this.getSubtitleStyle(currentValue[0]);
750
+ var currentLine1 = currentSubtitleObj && currentSubtitleObj.line1 || '';
751
+ var propsLine1 = currentValue[0] && currentValue[0].line1 || '';
752
+ if (currentValue && currentValue.length && (currentSubtitleObj.start_time === currentValue[0].start_time || currentSubtitleObj.end_time === currentValue[0].end_time) && currentLine1 === propsLine1 || Object.keys(currentSubtitleObj).length && currentValue.length && currentSubtitleObj.start_time && currentValue.length === currentSubtitleObj.start_time.length && currentSubtitleObj.end_time && currentValue.length === currentSubtitleObj.end_time.length && currentLine1 === propsLine1) {
753
+ return;
754
+ } else {
755
+ this.setState({
756
+ currentSubtitleObj: {
757
+ charactername: currentValue[0] && currentValue[0].charactername || '',
758
+ line1: currentValue[0] && currentValue[0].line1 || '',
759
+ line2: currentValue[0] && currentValue[0].line2 || '',
760
+ start_time: currentValue[0] && currentValue[0].start_time || 0,
761
+ end_time: currentValue[0] && currentValue[0].end_time || 0,
762
+ style: style
763
+ }
764
+ });
765
+ }
766
+ }
767
+ }
768
+
769
+ /*
770
+ * Fired when the end of the media resource
771
+ * is reached (currentTime == duration)
772
+ */
773
+ }, {
774
+ key: "handleEnded",
775
+ value: function handleEnded() {
776
+ var _this$props15 = this.props,
777
+ loop = _this$props15.loop,
778
+ player = _this$props15.player,
779
+ actions = _this$props15.actions,
780
+ onEnded = _this$props15.onEnded;
781
+ if (loop) {
782
+ this.seek(0);
783
+ this.play();
784
+ } else if (!player.paused) {
785
+ this.pause();
786
+ }
787
+ actions.handleEnd(this.getProperties());
788
+ if (onEnded) {
789
+ onEnded.apply(void 0, arguments);
790
+ }
791
+ }
792
+
793
+ // Fired whenever the media begins waiting
794
+ }, {
795
+ key: "handleWaiting",
796
+ value: function handleWaiting() {
797
+ var _this$props16 = this.props,
798
+ actions = _this$props16.actions,
799
+ onWaiting = _this$props16.onWaiting;
800
+ actions.handleWaiting(this.getProperties());
801
+ if (onWaiting) {
802
+ onWaiting.apply(void 0, arguments);
803
+ }
804
+ }
805
+
806
+ /*
807
+ * Fired whenever the player
808
+ * is jumping to a new time
809
+ */
810
+ }, {
811
+ key: "handleSeeking",
812
+ value: function handleSeeking() {
813
+ var _this$props17 = this.props,
814
+ actions = _this$props17.actions,
815
+ onSeeking = _this$props17.onSeeking;
816
+ actions.handleSeeking(this.getProperties());
817
+ if (onSeeking) {
818
+ onSeeking.apply(void 0, arguments);
819
+ }
820
+ }
821
+
822
+ /*
823
+ * Fired when the player has
824
+ * finished jumping to a new time
825
+ */
826
+ }, {
827
+ key: "handleSeeked",
828
+ value: function handleSeeked() {
829
+ var _this$props18 = this.props,
830
+ actions = _this$props18.actions,
831
+ onSeeked = _this$props18.onSeeked;
832
+ actions.handleSeeked(this.getProperties());
833
+ if (onSeeked) {
834
+ onSeeked.apply(void 0, arguments);
835
+ }
836
+ }
837
+
838
+ // Handle Fullscreen Change
839
+ }, {
840
+ key: "handleFullscreenChange",
841
+ value: function handleFullscreenChange() {}
842
+
843
+ /*
844
+ * Fires when the browser is
845
+ * intentionally not getting media data
846
+ */
847
+ }, {
848
+ key: "handleSuspend",
849
+ value: function handleSuspend() {
850
+ var _this$props19 = this.props,
851
+ actions = _this$props19.actions,
852
+ onSuspend = _this$props19.onSuspend;
853
+ actions.handleSuspend(this.getProperties());
854
+ if (onSuspend) {
855
+ onSuspend.apply(void 0, arguments);
856
+ }
857
+ }
858
+
859
+ // Fires when the loading of an audio/video is aborted
860
+ }, {
861
+ key: "handleAbort",
862
+ value: function handleAbort() {
863
+ var _this$props20 = this.props,
864
+ actions = _this$props20.actions,
865
+ onAbort = _this$props20.onAbort;
866
+ actions.handleAbort(this.getProperties());
867
+ if (onAbort) {
868
+ onAbort.apply(void 0, arguments);
869
+ }
870
+ }
871
+
872
+ // Fires when the current playlist is empty
873
+ }, {
874
+ key: "handleEmptied",
875
+ value: function handleEmptied() {
876
+ var _this$props21 = this.props,
877
+ actions = _this$props21.actions,
878
+ onEmptied = _this$props21.onEmptied;
879
+ actions.handleEmptied(this.getProperties());
880
+ if (onEmptied) {
881
+ onEmptied.apply(void 0, arguments);
882
+ }
883
+ }
884
+
885
+ /*
886
+ * Fires when the browser is trying to
887
+ * get media data, but data is not available
888
+ */
889
+ }, {
890
+ key: "handleStalled",
891
+ value: function handleStalled() {
892
+ var _this$props22 = this.props,
893
+ actions = _this$props22.actions,
894
+ onStalled = _this$props22.onStalled;
895
+ actions.handleStalled(this.getProperties());
896
+ if (onStalled) {
897
+ onStalled.apply(void 0, arguments);
898
+ }
899
+ }
900
+
901
+ /*
902
+ * Fires when the browser has loaded
903
+ * meta data for the audio/video
904
+ */
905
+ }, {
906
+ key: "handleLoadedMetaData",
907
+ value: function handleLoadedMetaData() {
908
+ var _this$props23 = this.props,
909
+ actions = _this$props23.actions,
910
+ onLoadedMetadata = _this$props23.onLoadedMetadata,
911
+ startTime = _this$props23.startTime;
912
+ if (startTime && startTime > 0) {
913
+ this.video.currentTime = startTime;
914
+ }
915
+ actions.handleLoadedMetaData(this.getProperties());
916
+ if (onLoadedMetadata) {
917
+ onLoadedMetadata.apply(void 0, arguments);
918
+ }
919
+ }
920
+
921
+ /*
922
+ * Fires when the browser has loaded
923
+ * the current frame of the audio/video
924
+ */
925
+ }, {
926
+ key: "handleLoadedData",
927
+ value: function handleLoadedData() {
928
+ var _this$props24 = this.props,
929
+ actions = _this$props24.actions,
930
+ onLoadedData = _this$props24.onLoadedData;
931
+ actions.handleLoadedData(this.getProperties());
932
+ if (onLoadedData) {
933
+ onLoadedData.apply(void 0, arguments);
934
+ }
935
+ }
936
+
937
+ /*
938
+ * Fires when the current
939
+ * playback position has changed
940
+ */
941
+ }, {
942
+ key: "handleTimeUpdate",
943
+ value: function handleTimeUpdate() {
944
+ var _this$props25 = this.props,
945
+ previewActive = _this$props25.player.previewActive,
946
+ actions = _this$props25.actions,
947
+ onTimeUpdate = _this$props25.onTimeUpdate,
948
+ rightMarker = _this$props25.playerSelectedMarker.rightMarker;
949
+ actions.handleTimeUpdate(this.getProperties());
950
+ if (previewActive && this.video.currentTime >= rightMarker) {
951
+ this.video.pause();
952
+ actions.seek(rightMarker);
953
+ actions.handleVideoPreview(false);
954
+ }
955
+ if (onTimeUpdate) {
956
+ onTimeUpdate.apply(void 0, arguments);
957
+ }
958
+ this.displaySubtitle();
959
+ }
960
+
961
+ /**
962
+ * Fires when the playing speed of the audio/video is changed
963
+ */
964
+ }, {
965
+ key: "handleRateChange",
966
+ value: function handleRateChange() {
967
+ var _this$props26 = this.props,
968
+ actions = _this$props26.actions,
969
+ onRateChange = _this$props26.onRateChange;
970
+ actions.handleRateChange(this.getProperties());
971
+ if (onRateChange) {
972
+ onRateChange.apply(void 0, arguments);
973
+ }
974
+ }
975
+
976
+ // Fires when the volume has been changed
977
+ }, {
978
+ key: "handleVolumeChange",
979
+ value: function handleVolumeChange() {
980
+ var _this$props27 = this.props,
981
+ actions = _this$props27.actions,
982
+ onVolumeChange = _this$props27.onVolumeChange;
983
+ actions.handleVolumeChange(this.getProperties());
984
+ if (onVolumeChange) {
985
+ onVolumeChange.apply(void 0, arguments);
986
+ }
987
+ }
988
+
989
+ /*
990
+ * Fires when an error occurred
991
+ * during the loading of an audio/video
992
+ */
993
+ }, {
994
+ key: "handleError",
995
+ value: function handleError() {
996
+ var _this$props28 = this.props,
997
+ actions = _this$props28.actions,
998
+ onError = _this$props28.onError;
999
+ actions.handleError(this.getProperties());
1000
+ if (onError) {
1001
+ onError.apply(void 0, arguments);
1002
+ }
1003
+ }
1004
+ }, {
1005
+ key: "handleKeypress",
1006
+ value: function handleKeypress() {}
1007
+ }, {
1008
+ key: "audioVisualizer",
1009
+ value: function audioVisualizer() {
1010
+ // getting audio nodes
1011
+ var context = new AudioContext({
1012
+ latencyHint: 'interactive',
1013
+ sampleRate: 44100
1014
+ });
1015
+ var src = context.createMediaElementSource(this.video);
1016
+ var analyser = context.createAnalyser();
1017
+
1018
+ //visualising audio nodes on canvas
1019
+ var canvas = this.canvas;
1020
+ canvas.width = this.playerBlock.offsetWidth;
1021
+ canvas.height = this.playerBlock.offsetHeight;
1022
+ var ctx = canvas.getContext('2d');
1023
+ src.connect(analyser);
1024
+ analyser.connect(context.destination);
1025
+ analyser.fftSize = 256;
1026
+ var bufferLength = analyser.frequencyBinCount;
1027
+ var dataArray = new Uint8Array(bufferLength);
1028
+ var WIDTH = canvas.width;
1029
+ var HEIGHT = canvas.height;
1030
+ var barWidth = WIDTH / bufferLength * 1;
1031
+ var barHeight;
1032
+ var x = 0;
1033
+ function renderFrame() {
1034
+ requestAnimationFrame(renderFrame);
1035
+ x = 0;
1036
+ analyser.getByteFrequencyData(dataArray);
1037
+ ctx.fillStyle = '#000';
1038
+ ctx.fillRect(0, 0, WIDTH, HEIGHT);
1039
+ for (var i = 0; i < bufferLength; i++) {
1040
+ barHeight = dataArray[i] * 2;
1041
+
1042
+ /*
1043
+ * var r = barHeight + (25 * (i / bufferLength));
1044
+ * var g = 250 * (i / bufferLength);
1045
+ * var b = s50;
1046
+ */
1047
+
1048
+ ctx.fillStyle = '#0c141d'; // 'rgb(' + r + ',' + g + ',' + b + ')';
1049
+ ctx.fillRect(x, HEIGHT - barHeight, barWidth, barHeight);
1050
+ x += barWidth + 3;
1051
+ }
1052
+ }
1053
+ renderFrame();
1054
+ }
1055
+ }, {
1056
+ key: "renderChildren",
1057
+ value: function renderChildren() {
1058
+ var _this4 = this;
1059
+ var props = _objectSpread(_objectSpread({}, this.props), {}, {
1060
+ video: this.video
1061
+ });
1062
+ var children = this.props.children;
1063
+ // to make sure the children can get video property
1064
+ if (!this.video) {
1065
+ return null;
1066
+ }
1067
+
1068
+ // only keep <source />, <track />, <MyComponent isVideoChild /> elements
1069
+ return _react["default"].Children.toArray(children).filter(_utils.isVideoChild).map(function (c) {
1070
+ var cprops;
1071
+ if (typeof c.type === 'string') {
1072
+ // add onError to <source />
1073
+ if (c.type === 'source') {
1074
+ cprops = _objectSpread({}, c.props);
1075
+ var preOnError = cprops.onError;
1076
+ cprops.onError = function () {
1077
+ if (preOnError) {
1078
+ preOnError.apply(void 0, arguments);
1079
+ }
1080
+ _this4.handleError.apply(_this4, arguments);
1081
+ };
1082
+ }
1083
+ } else {
1084
+ cprops = props;
1085
+ }
1086
+ return /*#__PURE__*/_react["default"].cloneElement(c, cprops);
1087
+ });
1088
+ }
1089
+ }, {
1090
+ key: "handleSubtitleContainerClick",
1091
+ value: function handleSubtitleContainerClick() {
1092
+ var _this$props29 = this.props,
1093
+ actions = _this$props29.actions,
1094
+ player = _this$props29.player;
1095
+ if (player.paused) {
1096
+ actions.play();
1097
+ } else {
1098
+ actions.pause();
1099
+ }
1100
+ }
1101
+ }, {
1102
+ key: "handleSubtitleClick",
1103
+ value: function handleSubtitleClick(e) {
1104
+ var _this$props30 = this.props,
1105
+ actions = _this$props30.actions,
1106
+ player = _this$props30.player,
1107
+ onScreenSubtitleClick = _this$props30.onScreenSubtitleClick,
1108
+ controlType = _this$props30.controlType;
1109
+ var currentSubtitleObj = this.state.currentSubtitleObj;
1110
+ if (controlType === 'advanced') {
1111
+ if (onScreenSubtitleClick) {
1112
+ onScreenSubtitleClick(currentSubtitleObj);
1113
+ }
1114
+ actions.pause();
1115
+ } else {
1116
+ if (player.paused) {
1117
+ actions.play();
1118
+ } else {
1119
+ actions.pause();
1120
+ }
1121
+ }
1122
+ actions.handleVideoRewind(false);
1123
+ e.stopPropagation();
1124
+ }
1125
+ }, {
1126
+ key: "render",
1127
+ value: function render() {
1128
+ var _this5 = this;
1129
+ var _this$props31 = this.props,
1130
+ loop = _this$props31.loop,
1131
+ poster = _this$props31.poster,
1132
+ preload = _this$props31.preload,
1133
+ autoPlay = _this$props31.autoPlay,
1134
+ playsInline = _this$props31.playsInline,
1135
+ muted = _this$props31.muted,
1136
+ crossOrigin = _this$props31.crossOrigin,
1137
+ videoId = _this$props31.videoId,
1138
+ fileType = _this$props31.fileType,
1139
+ userEmail = _this$props31.userEmail,
1140
+ theme = _this$props31.theme;
1141
+ var _this$state2 = this.state,
1142
+ isBuffering = _this$state2.isBuffering,
1143
+ watermark = _this$state2.watermark,
1144
+ currentSubtitleObj = _this$state2.currentSubtitleObj;
1145
+ var children = this.getChildren(this.props);
1146
+ return /*#__PURE__*/_react["default"].createElement(VideoBlock, {
1147
+ className: "video-react-player-block",
1148
+ ref: function ref(c) {
1149
+ _this5.playerBlock = c;
1150
+ },
1151
+ style: this.getStyle()
1152
+ }, isBuffering && /*#__PURE__*/_react["default"].createElement("div", {
1153
+ className: "loader-container",
1154
+ onClick: function onClick() {
1155
+ return _this5.togglePlay();
1156
+ }
1157
+ }, /*#__PURE__*/_react["default"].createElement(_components.Loader, {
1158
+ theme: theme,
1159
+ loaderName: "SpinningLoader"
1160
+ })) || null, fileType === 'audio' ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("canvas", {
1161
+ id: "canvas",
1162
+ ref: function ref(c) {
1163
+ _this5.canvas = c;
1164
+ },
1165
+ style: {
1166
+ top: 0,
1167
+ left: 0,
1168
+ position: 'absolute'
1169
+ }
1170
+ }), /*#__PURE__*/_react["default"].createElement("audio", {
1171
+ id: videoId,
1172
+ crossOrigin: "anonymous",
1173
+ ref: function ref(c) {
1174
+ _this5.video = c;
1175
+ },
1176
+ muted: muted,
1177
+ preload: preload,
1178
+ loop: loop,
1179
+ playsInline: playsInline,
1180
+ autoPlay: autoPlay,
1181
+ poster: poster,
1182
+ onLoadStart: this.handleLoadStart,
1183
+ onWaiting: this.handleWaiting,
1184
+ onCanPlay: this.handleCanPlay,
1185
+ onCanPlayThrough: this.handleCanPlayThrough,
1186
+ onPlaying: this.handlePlaying,
1187
+ onEnded: this.handleEnded,
1188
+ onSeeking: this.handleSeeking,
1189
+ onSeeked: this.handleSeeked,
1190
+ onPlay: this.handlePlay,
1191
+ onPause: this.handlePause,
1192
+ onProgress: this.handleProgress,
1193
+ onDurationChange: this.handleDurationChange,
1194
+ onError: this.handleError,
1195
+ onSuspend: this.handleSuspend,
1196
+ onAbort: this.handleAbort,
1197
+ onEmptied: this.handleEmptied,
1198
+ onStalled: this.handleStalled,
1199
+ onLoadedMetadata: this.handleLoadedMetaData,
1200
+ onLoadedData: this.handleLoadedData,
1201
+ onTimeUpdate: this.handleTimeUpdate,
1202
+ onRateChange: this.handleRateChange,
1203
+ onVolumeChange: this.handleVolumeChange
1204
+ }, /*#__PURE__*/_react["default"].createElement("track", {
1205
+ kind: "captions"
1206
+ }), this.renderChildren())) : /*#__PURE__*/_react["default"].createElement("video", {
1207
+ id: videoId,
1208
+ crossOrigin: crossOrigin,
1209
+ ref: function ref(c) {
1210
+ _this5.video = c;
1211
+ },
1212
+ muted: muted,
1213
+ preload: preload,
1214
+ loop: loop,
1215
+ playsInline: playsInline,
1216
+ autoPlay: autoPlay,
1217
+ poster: poster,
1218
+ onLoadStart: this.handleLoadStart,
1219
+ onWaiting: this.handleWaiting,
1220
+ onCanPlay: this.handleCanPlay,
1221
+ onCanPlayThrough: this.handleCanPlayThrough,
1222
+ onPlaying: this.handlePlaying,
1223
+ onEnded: this.handleEnded,
1224
+ onSeeking: this.handleSeeking,
1225
+ onSeeked: this.handleSeeked,
1226
+ onPlay: this.handlePlay,
1227
+ onPause: this.handlePause,
1228
+ onProgress: this.handleProgress,
1229
+ onDurationChange: this.handleDurationChange,
1230
+ onError: this.handleError,
1231
+ onSuspend: this.handleSuspend,
1232
+ onAbort: this.handleAbort,
1233
+ onEmptied: this.handleEmptied,
1234
+ onStalled: this.handleStalled,
1235
+ onLoadedMetadata: this.handleLoadedMetaData,
1236
+ onLoadedData: this.handleLoadedData,
1237
+ onTimeUpdate: this.handleTimeUpdate,
1238
+ onRateChange: this.handleRateChange,
1239
+ onVolumeChange: this.handleVolumeChange
1240
+ }, /*#__PURE__*/_react["default"].createElement("track", {
1241
+ kind: "captions"
1242
+ }), this.renderChildren()), children, /*#__PURE__*/_react["default"].createElement("p", {
1243
+ className: "user-name-wrapper",
1244
+ id: "watermark-text",
1245
+ style: _objectSpread({}, watermark)
1246
+ }, userEmail), /*#__PURE__*/_react["default"].createElement(SubTitleSection, {
1247
+ id: "outer",
1248
+ currentSubtitleObj: currentSubtitleObj,
1249
+ onClick: function onClick() {
1250
+ return _this5.handleSubtitleContainerClick();
1251
+ }
1252
+ }, /*#__PURE__*/_react["default"].createElement("span", {
1253
+ onClick: function onClick(e) {
1254
+ return _this5.handleSubtitleClick(e);
1255
+ },
1256
+ className: "subtitleContainer longSubtitleStyles",
1257
+ style: _objectSpread({}, currentSubtitleObj.style)
1258
+ }, currentSubtitleObj.charactername && /*#__PURE__*/_react["default"].createElement("p", {
1259
+ id: "charactername",
1260
+ dangerouslySetInnerHTML: {
1261
+ __html: currentSubtitleObj.charactername
1262
+ }
1263
+ }) || null, currentSubtitleObj.line1 && /*#__PURE__*/_react["default"].createElement("p", {
1264
+ id: "subtitleLineOne",
1265
+ dangerouslySetInnerHTML: {
1266
+ __html: currentSubtitleObj.line1
1267
+ }
1268
+ }) || null, currentSubtitleObj.line2 && /*#__PURE__*/_react["default"].createElement("p", {
1269
+ id: "subtitleLineTwo",
1270
+ dangerouslySetInnerHTML: {
1271
+ __html: currentSubtitleObj.line2
1272
+ }
1273
+ }) || null)));
1274
+ }
1275
+ }]);
1276
+ return Video;
1277
+ }(_react.Component);
1278
+ Video.propTypes = propTypes;
1279
+ Video.defaultProps = defaultProps;
1280
+ Video.displayName = 'Video';