@desynova-digital/player 3.9.7 → 4.0.1

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 (130) hide show
  1. package/Player.js +945 -0
  2. package/control/AudioTracksMenuButton.js +91 -0
  3. package/control/AudioTracksMenuButton.jsx +80 -0
  4. package/control/ControlBar.js +303 -0
  5. package/control/ControlBar.jsx +264 -0
  6. package/control/CurrentTimeDisplay.js +34 -0
  7. package/control/CurrentTimeDisplay.jsx +35 -0
  8. package/control/DurationDisplay.js +38 -0
  9. package/control/DurationDisplay.jsx +48 -0
  10. package/control/ForwardBackwardControl.js +76 -0
  11. package/control/ForwardBackwardControl.jsx +79 -0
  12. package/control/FullscreenToggle.js +82 -0
  13. package/control/FullscreenToggle.jsx +83 -0
  14. package/control/MarkInControl.js +124 -0
  15. package/control/MarkInControl.jsx +109 -0
  16. package/control/MarkOutControl.js +137 -0
  17. package/control/MarkOutControl.jsx +131 -0
  18. package/control/MarkerBar.js +127 -0
  19. package/control/MarkerBar.jsx +107 -0
  20. package/control/MarkingControl.js +82 -0
  21. package/control/MarkingControl.jsx +143 -0
  22. package/control/MarkingDuration.js +44 -0
  23. package/control/MarkingPreview.js +49 -0
  24. package/control/MarkingPreview.jsx +60 -0
  25. package/control/PlayBackRateControl.js +106 -0
  26. package/control/PlayBackRateControl.jsx +106 -0
  27. package/control/PlayProgressBar.js +61 -0
  28. package/control/PlayProgressBar.jsx +92 -0
  29. package/control/PlayToggle.js +56 -0
  30. package/control/PlayToggle.jsx +57 -0
  31. package/control/PointersBar.js +231 -0
  32. package/control/PointersBar.jsx +286 -0
  33. package/control/ProgressControl.js +127 -0
  34. package/control/ProgressControl.jsx +155 -0
  35. package/control/SeekBar.js +204 -0
  36. package/control/SeekBar.jsx +229 -0
  37. package/control/SettingsMenuButton.js +63 -0
  38. package/control/SettingsMenuButton.jsx +69 -0
  39. package/control/Slider.js +274 -0
  40. package/control/Slider.jsx +243 -0
  41. package/control/Timeline.js +118 -0
  42. package/control/Timeline.jsx +131 -0
  43. package/control/VolumeBar.js +198 -0
  44. package/control/VolumeBar.jsx +174 -0
  45. package/control/VolumeLevel.js +61 -0
  46. package/control/VolumeLevel.jsx +66 -0
  47. package/control/VolumneMenuButton.js +112 -0
  48. package/control/VolumneMenuButton.jsx +111 -0
  49. package/header/Header.js +309 -0
  50. package/header/Header.jsx +479 -0
  51. package/index.js +9 -151
  52. package/media/AudioMeter.js +381 -0
  53. package/media/AudioMeter.jsx +411 -0
  54. package/media/SDOutline.js +82 -0
  55. package/media/SDOutline.jsx +90 -0
  56. package/media/Video.js +684 -0
  57. package/media/Video.jsx +714 -0
  58. package/package.json +5 -1
  59. package/playlist/Playlist.js +67 -0
  60. package/playlist/Playlist.jsx +91 -0
  61. package/playlist/index.js +13 -0
  62. package/shortcuts/Shortcut.js +662 -0
  63. package/utils/Menu.js +50 -0
  64. package/utils/Menu.jsx +105 -0
  65. package/{colors.js → utils/colors.js} +13 -13
  66. package/utils/dom.js +6 -16
  67. package/utils/index.js +52 -122
  68. package/Manager.js +0 -124
  69. package/actions/player.js +0 -375
  70. package/actions/video.js +0 -230
  71. package/components/AudioMeter.js +0 -414
  72. package/components/BigPlayButton.js +0 -110
  73. package/components/ImageViewer.js +0 -318
  74. package/components/MarkerBar.js +0 -138
  75. package/components/Menu.js +0 -77
  76. package/components/Player.js +0 -821
  77. package/components/PlayerHeader.js +0 -472
  78. package/components/Playlist.js +0 -133
  79. package/components/PointersBar.js +0 -299
  80. package/components/PosterImage.js +0 -61
  81. package/components/SDOutline.js +0 -68
  82. package/components/Shortcut.js +0 -621
  83. package/components/Slider.js +0 -317
  84. package/components/TagsBar.js +0 -100
  85. package/components/Video.js +0 -1431
  86. package/components/control-bar/AudioTracksMenuButton.js +0 -113
  87. package/components/control-bar/CameraButton.js +0 -88
  88. package/components/control-bar/CommentsButton.js +0 -216
  89. package/components/control-bar/ControlBar.js +0 -260
  90. package/components/control-bar/EditorControlMenuButton.js +0 -412
  91. package/components/control-bar/ForwardControl.js +0 -17
  92. package/components/control-bar/ForwardReplayControl.js +0 -122
  93. package/components/control-bar/FullscreenToggle.js +0 -101
  94. package/components/control-bar/PlayToggle.js +0 -98
  95. package/components/control-bar/ReplayControl.js +0 -17
  96. package/components/control-bar/SettingsMenuButton.js +0 -43
  97. package/components/control-bar/SubtitleLanguagesMenuButton.js +0 -174
  98. package/components/control-bar/VolumeMenuButton.js +0 -134
  99. package/components/control-bar/ZoomMenuButton.js +0 -116
  100. package/components/marking-controls/MarkInControl.js +0 -140
  101. package/components/marking-controls/MarkOutControl.js +0 -155
  102. package/components/marking-controls/MarkingAddButton.js +0 -94
  103. package/components/marking-controls/MarkingControl.js +0 -135
  104. package/components/marking-controls/MarkingDeleteButton.js +0 -84
  105. package/components/marking-controls/MarkingDuration.js +0 -77
  106. package/components/marking-controls/MarkingPreview.js +0 -86
  107. package/components/progress-bar/AudioWaveform.js +0 -144
  108. package/components/progress-bar/LoadProgressBar.js +0 -90
  109. package/components/progress-bar/MouseTimeDisplay.js +0 -53
  110. package/components/progress-bar/PlayProgressBar.js +0 -79
  111. package/components/progress-bar/ProgressControl.js +0 -222
  112. package/components/progress-bar/SeekBar.js +0 -261
  113. package/components/progress-bar/Timeline.js +0 -134
  114. package/components/settings-menu-control/PlaybackRateControl.js +0 -147
  115. package/components/settings-menu-control/SafeAreaControl.js +0 -92
  116. package/components/settings-menu-control/SettingsMenu.js +0 -68
  117. package/components/settings-menu-control/SubtitleControl.js +0 -1
  118. package/components/time-controls/CurrentTimeDisplay.js +0 -53
  119. package/components/time-controls/DurationDisplay.js +0 -51
  120. package/components/time-controls/TimeDivider.js +0 -41
  121. package/components/volume-control/VolumeBar.js +0 -216
  122. package/components/volume-control/VolumeControl.js +0 -35
  123. package/components/volume-control/VolumeLevel.js +0 -78
  124. package/components/zoom-control/ZoomBar.js +0 -189
  125. package/components/zoom-control/ZoomLevel.js +0 -68
  126. package/reducers/index.js +0 -23
  127. package/reducers/operation.js +0 -36
  128. package/reducers/player.js +0 -222
  129. package/utils/browser.js +0 -29
  130. package/utils/fullscreen.js +0 -73
@@ -1,821 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _extends = Object.assign || 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; };
8
-
9
- var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
10
-
11
- var _propTypes = require('prop-types');
12
-
13
- var _react = require('react');
14
-
15
- var _react2 = _interopRequireDefault(_react);
16
-
17
- var _styledComponents = require('styled-components');
18
-
19
- var _styledComponents2 = _interopRequireDefault(_styledComponents);
20
-
21
- var _reactDom = require('react-dom');
22
-
23
- var _Manager = require('../Manager');
24
-
25
- var _Manager2 = _interopRequireDefault(_Manager);
26
-
27
- var _Video = require('./Video');
28
-
29
- var _Video2 = _interopRequireDefault(_Video);
30
-
31
- var _ImageViewer = require('./ImageViewer');
32
-
33
- var _ImageViewer2 = _interopRequireDefault(_ImageViewer);
34
-
35
- var _Shortcut = require('./Shortcut');
36
-
37
- var _Shortcut2 = _interopRequireDefault(_Shortcut);
38
-
39
- var _ControlBar = require('./control-bar/ControlBar');
40
-
41
- var _ControlBar2 = _interopRequireDefault(_ControlBar);
42
-
43
- var _ProgressControl = require('./progress-bar/ProgressControl');
44
-
45
- var _ProgressControl2 = _interopRequireDefault(_ProgressControl);
46
-
47
- var _PlayerHeader = require('./PlayerHeader');
48
-
49
- var _PlayerHeader2 = _interopRequireDefault(_PlayerHeader);
50
-
51
- var _Playlist = require('./Playlist');
52
-
53
- var _Playlist2 = _interopRequireDefault(_Playlist);
54
-
55
- var _AudioMeter = require('./AudioMeter');
56
-
57
- var _AudioMeter2 = _interopRequireDefault(_AudioMeter);
58
-
59
- var _utils = require('../utils');
60
-
61
- var _fullscreen = require('../utils/fullscreen');
62
-
63
- var _fullscreen2 = _interopRequireDefault(_fullscreen);
64
-
65
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
66
-
67
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
68
-
69
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
70
-
71
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
72
-
73
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
74
-
75
- var propTypes = {
76
- store: _propTypes.PropTypes.instanceOf(Object),
77
- width: _propTypes.PropTypes.oneOfType([_propTypes.PropTypes.string, _propTypes.PropTypes.number]),
78
- height: _propTypes.PropTypes.oneOfType([_propTypes.PropTypes.string, _propTypes.PropTypes.number]),
79
- frameRate: _propTypes.PropTypes.number,
80
- initialTime: _propTypes.PropTypes.number,
81
- audioSrc: _propTypes.PropTypes.string,
82
- fluid: _propTypes.PropTypes.bool,
83
- muted: _propTypes.PropTypes.bool,
84
- playsInline: _propTypes.PropTypes.bool,
85
- aspectRatio: _propTypes.PropTypes.string,
86
- videoId: _propTypes.PropTypes.string,
87
- startTime: _propTypes.PropTypes.number,
88
- loop: _propTypes.PropTypes.bool,
89
- autoPlay: _propTypes.PropTypes.bool,
90
- src: _propTypes.PropTypes.string,
91
- poster: _propTypes.PropTypes.string,
92
- preload: _propTypes.PropTypes.oneOf(['auto', 'metadata', 'none']),
93
- videoDetails: _propTypes.PropTypes.instanceOf(Object),
94
- rightSection: _propTypes.PropTypes.node,
95
- onPlayerClose: _propTypes.PropTypes.func,
96
- onCommentsAdd: _propTypes.PropTypes.func,
97
- onLoadStart: _propTypes.PropTypes.func,
98
- onWaiting: _propTypes.PropTypes.func,
99
- onCanPlay: _propTypes.PropTypes.func,
100
- onCanPlayThrough: _propTypes.PropTypes.func,
101
- onPlaying: _propTypes.PropTypes.func,
102
- onEnded: _propTypes.PropTypes.func,
103
- onSeeking: _propTypes.PropTypes.func,
104
- onSeeked: _propTypes.PropTypes.func,
105
- onPlay: _propTypes.PropTypes.func,
106
- onPause: _propTypes.PropTypes.func,
107
- onProgress: _propTypes.PropTypes.func,
108
- onDurationChange: _propTypes.PropTypes.func,
109
- onError: _propTypes.PropTypes.func,
110
- onSuspend: _propTypes.PropTypes.func,
111
- onAbort: _propTypes.PropTypes.func,
112
- onEmptied: _propTypes.PropTypes.func,
113
- onStalled: _propTypes.PropTypes.func,
114
- onLoadedMetadata: _propTypes.PropTypes.func,
115
- onLoadedData: _propTypes.PropTypes.func,
116
- onTimeUpdate: _propTypes.PropTypes.func,
117
- onRateChange: _propTypes.PropTypes.func,
118
- onVolumeChange: _propTypes.PropTypes.func,
119
- onAddMarker: _propTypes.PropTypes.func,
120
- onMarkerSelect: _propTypes.PropTypes.func,
121
- onTagClick: _propTypes.PropTypes.func,
122
- onDeleteMarker: _propTypes.PropTypes.func,
123
- onEditAction: _propTypes.PropTypes.func,
124
- onPlayerChange: _propTypes.PropTypes.func,
125
- fileType: _propTypes.PropTypes.oneOf(['video', 'image', 'audio']),
126
- playerType: _propTypes.PropTypes.oneOf(['dubbing_review', 'clipping_default', 'default', 'tagging', 'qc', 'subtitle', 'snp_edit', 'archive', 'restore', 'clipping', 'storyboard', 'panel']),
127
- assetType: _propTypes.PropTypes.oneOf(['fc', 'rc']),
128
- controlType: _propTypes.PropTypes.oneOf(['default', 'advanced']),
129
- markers: _propTypes.PropTypes.instanceOf(Array),
130
- playlist: _propTypes.PropTypes.instanceOf(Array),
131
- playlistClick: _propTypes.PropTypes.func,
132
- transcriptArr: _propTypes.PropTypes.instanceOf(Array),
133
- tagsMarker: _propTypes.PropTypes.instanceOf(Array)
134
- };
135
-
136
- var defaultProps = {
137
- fluid: true,
138
- muted: false,
139
- playsInline: false,
140
- aspectRatio: 'auto',
141
- playerType: 'default',
142
- controlType: 'default',
143
- width: null,
144
- height: null,
145
- frameRate: 25,
146
- initialTime: 35990,
147
- audioSrc: '',
148
- videoId: '',
149
- startTime: 0,
150
- loop: false,
151
- autoPlay: false,
152
- src: '',
153
- poster: '',
154
- preload: 'auto',
155
- videoDetails: {
156
- title: 'Opposition making fuss about Rupee weakening'
157
- },
158
- assetType: 'fc',
159
- onPlayerClose: null,
160
- onLoadStart: null,
161
- onWaiting: null,
162
- onCanPlay: null,
163
- onCanPlayThrough: null,
164
- onPlaying: null,
165
- onEnded: null,
166
- onSeeking: null,
167
- onSeeked: null,
168
- onPlay: null,
169
- onPause: null,
170
- onProgress: null,
171
- onDurationChange: null,
172
- onError: null,
173
- onSuspend: null,
174
- onAbort: null,
175
- onEmptied: null,
176
- onStalled: null,
177
- onLoadedMetadata: null,
178
- onLoadedData: null,
179
- onTimeUpdate: null,
180
- onRateChange: null,
181
- onVolumeChange: null
182
- };
183
-
184
- var PlayerBlock = _styledComponents2.default.div.withConfig({
185
- displayName: 'Player__PlayerBlock',
186
- componentId: 'sc-1xon7ai-0'
187
- })(['height:100%;']);
188
-
189
- var PlayerContainer = _styledComponents2.default.div.withConfig({
190
- displayName: 'Player__PlayerContainer',
191
- componentId: 'sc-1xon7ai-1'
192
- })(['display:flex;justify-content:flex-start;background:#000000;.left-video-section{width:', ';position:relative;}.audio-meter-block{position:relative;width:0px;display:none;&.qc{width:70px;display:block;}}.right-video-section{width:', ';position:relative;}'], function (props) {
193
- if (props.hasRightSection) {
194
- return '63.67%';
195
- } else {
196
- return '100%';
197
- }
198
- }, function (props) {
199
- if (props.playerType === 'qc') {
200
- return 'calc(36.33% - 70px)';
201
- } else {
202
- return '36.33%';
203
- }
204
- });
205
-
206
- var AudioMeterBlock = (0, _styledComponents2.default)('div').withConfig({
207
- displayName: 'Player__AudioMeterBlock',
208
- componentId: 'sc-1xon7ai-2'
209
- })(['width:', ';height:', ';position:absolute;bottom:', ';left:', ';padding:', ';box-sizing:border-box;background:', ';border-radius:', ';display:', ';margin:', ';transition:all 0.1s ease-in-out;-moz-transition:all 0.1s ease-in-out;-webkit-transition:all 0.1s ease-in-out;-ms-transition:all 0.1s ease-in-out;-o-transition:all 0.1s ease-in-out;'], function (props) {
210
- return !props.active ? '50px' : '55px';
211
- }, function (props) {
212
- return !props.active ? '50px !important' : 'calc(100% - 40px)';
213
- }, function (props) {
214
- return !props.active ? '5px' : '0px';
215
- }, function (props) {
216
- return !props.active ? '5px' : '0px';
217
- }, function (props) {
218
- return !props.active ? '5px' : '0px';
219
- }, function (props) {
220
- return !props.active ? 'rgba(243, 243, 243, 0.5)' : 'rgba(0, 0, 0, 1)';
221
- }, function (props) {
222
- return !props.active ? '5px' : '0px';
223
- }, function (props) {
224
- return !props.active ? 'block' : 'inline-block';
225
- }, function (props) {
226
- return !props.active ? '0' : '20px 0';
227
- });
228
-
229
- var ControlContainer = _styledComponents2.default.div.withConfig({
230
- displayName: 'Player__ControlContainer',
231
- componentId: 'sc-1xon7ai-3'
232
- })(['']);
233
-
234
- var Player = function (_Component) {
235
- _inherits(Player, _Component);
236
-
237
- function Player(props) {
238
- _classCallCheck(this, Player);
239
-
240
- var _this = _possibleConstructorReturn(this, (Player.__proto__ || Object.getPrototypeOf(Player)).call(this, props));
241
-
242
- _this.controlsHideTimer = null;
243
- _this.meterHeight = 40;
244
- _this.video = null; // the Video component
245
- _this.manager = new _Manager2.default(props.store);
246
- _this.actions = _this.manager.getActions();
247
- _this.manager.subscribeToPlayerStateChange(_this.handleStateChange.bind(_this));
248
- _this.handleResize = _this.handleResize.bind(_this);
249
- _this.getChildren = _this.getChildren.bind(_this);
250
- _this.handleFullScreenChange = _this.handleFullScreenChange.bind(_this);
251
- _this.handleFocus = _this.handleFocus.bind(_this);
252
- _this.handleBlur = _this.handleBlur.bind(_this);
253
- _this.actions.handlePlayerType(props.playerType);
254
- _this.actions.handleControlType(props.controlType);
255
- return _this;
256
- }
257
-
258
- _createClass(Player, [{
259
- key: 'componentDidMount',
260
- value: function componentDidMount() {
261
- this.handleResize();
262
- window.addEventListener('resize', this.handleResize);
263
-
264
- _fullscreen2.default.addEventListener(this.handleFullScreenChange);
265
- /*
266
- * const { player } = this.manager.getState();
267
- * this.actions.toggleFullscreen(player);
268
- */
269
- }
270
-
271
- // shouldComponentUpdate(nextProps) {
272
- // // Rendering the component only if passed props value is changed
273
-
274
- // const replacerFunc = () => {
275
- // const visited = new WeakSet();
276
- // return (key, value) => {
277
- // if (typeof value === 'object' && value !== null) {
278
- // if (visited.has(value)) {
279
- // return;
280
- // }
281
- // visited.add(value);
282
- // }
283
- // return value;
284
- // };
285
- // };
286
-
287
- // if ( JSON.stringify(nextProps, replacerFunc()) !== JSON.stringify(this.props, replacerFunc()) ) {
288
- // return true;
289
- // } else {
290
- // return false;
291
- // }
292
- // }
293
-
294
- }, {
295
- key: 'shouldComponentUpdate',
296
- value: function shouldComponentUpdate(nextProps, nextState) {
297
- if (_.isEqual(nextProps, this.props)) {
298
- return false;
299
- }
300
- return true;
301
- }
302
- }, {
303
- key: 'componentDidUpdate',
304
- value: function componentDidUpdate() {
305
- this.handleResize();
306
- }
307
- }, {
308
- key: 'componentWillUnmount',
309
- value: function componentWillUnmount() {
310
- // Remove event listener
311
- window.removeEventListener('resize', this.handleResize);
312
- _fullscreen2.default.removeEventListener(this.handleFullScreenChange);
313
- if (this.controlsHideTimer) {
314
- window.clearTimeout(this.controlsHideTimer);
315
- }
316
- }
317
- }, {
318
- key: 'onTagsReset',
319
- value: function onTagsReset() {
320
- this.actions.handleVideoPreview(false);
321
- this.actions.handleMarkerPointChange('delete');
322
- }
323
- }, {
324
- key: 'onSegmentClick',
325
- value: function onSegmentClick(start_time, end_time, seek) {
326
- this.actions.handleMarkerUpdate(start_time, end_time);
327
- seek ? this.actions.pause() : this.actions.play();
328
- this.actions.handleVideoRewind(false);
329
- this.actions.seek(start_time);
330
- this.actions.handleVideoPreview(true);
331
- }
332
- }, {
333
- key: 'getDefaultChildren',
334
- value: function getDefaultChildren(props, fullProps) {
335
- var _this2 = this;
336
-
337
- return [_react2.default.createElement(_PlayerHeader2.default, _extends({
338
- ref: function ref(c) {
339
- _this2._playerHeader = c;
340
- },
341
- key: 'video-header',
342
- order: 1
343
- }, fullProps)), _react2.default.createElement(_Video2.default, _extends({
344
- ref: function ref(c) {
345
- _this2.video = c;
346
- _this2.manager.video = _this2.video;
347
- },
348
- key: 'video',
349
- order: 2
350
- }, fullProps)), _react2.default.createElement(_ProgressControl2.default, _extends({
351
- ref: function ref(c) {
352
- _this2._progressControl = c;
353
- }
354
- }, this.props, {
355
- key: 'progress-control',
356
- order: 3
357
- })), _react2.default.createElement(_ControlBar2.default, _extends({
358
- ref: function ref(c) {
359
- _this2._controlBar = c;
360
- },
361
- key: 'control-bar',
362
- order: 4
363
- }, this.props)), _react2.default.createElement(_Shortcut2.default, _extends({ key: 'shortcut', order: 99.0 }, props, { frameRate: fullProps.frameRate }))];
364
- }
365
- }, {
366
- key: 'getImageChildren',
367
- value: function getImageChildren(props, fullProps) {
368
- var _this3 = this;
369
-
370
- return [_react2.default.createElement(_PlayerHeader2.default, _extends({
371
- ref: function ref(c) {
372
- _this3._playerHeader = c;
373
- },
374
- key: 'video-header',
375
- order: 1
376
- }, fullProps)), _react2.default.createElement(_ImageViewer2.default, _extends({
377
- ref: function ref(c) {
378
- _this3.video = c;
379
- _this3.manager.video = _this3.video;
380
- },
381
- key: 'image',
382
- order: 0.0
383
- }, fullProps)),
384
- /*
385
- * <ControlBar
386
- * ref={(c) => {
387
- * this._controlBar = c;
388
- * }}
389
- * key="control-bar"
390
- * order={2}
391
- * {...this.props}
392
- * />,
393
- */
394
- _react2.default.createElement(_Shortcut2.default, _extends({ key: 'shortcut', order: 99.0 }, props))];
395
- }
396
- }, {
397
- key: 'getAdvancedChildren',
398
- value: function getAdvancedChildren(props, fullProps) {
399
- var _this4 = this;
400
-
401
- return [_react2.default.createElement(_PlayerHeader2.default, _extends({
402
- ref: function ref(c) {
403
- _this4._playerHeader = c;
404
- },
405
- key: 'video-header',
406
- order: 1
407
- }, fullProps)), _react2.default.createElement(_Video2.default, _extends({
408
- ref: function ref(c) {
409
- _this4.video = c;
410
- _this4.manager.video = _this4.video;
411
- },
412
- key: 'video',
413
- order: 0.0
414
- }, fullProps)), _react2.default.createElement(_ControlBar2.default, _extends({
415
- ref: function ref(c) {
416
- _this4._controlBar = c;
417
- },
418
- key: 'control-bar',
419
- order: 2
420
- }, this.props)), _react2.default.createElement(_Shortcut2.default, _extends({ key: 'shortcut', order: 99.0 }, props, { frameRate: fullProps.frameRate }))];
421
- }
422
- }, {
423
- key: 'getChildren',
424
- value: function getChildren(props, position) {
425
- if (position === 'left') {
426
- var _propsWithoutChildren = _extends({}, props, {
427
- children: null
428
- });
429
- var _children = [];
430
- var _defaultChildren = [];
431
- switch (props.fileType) {
432
- case 'image':
433
- _defaultChildren = this.getImageChildren();
434
- break;
435
- default:
436
- _defaultChildren = props.controlType === 'advanced' && !props.player.isFullscreen ? this.getAdvancedChildren(_propsWithoutChildren, props) : this.getDefaultChildren(_propsWithoutChildren, props);
437
- }
438
- return (0, _utils.mergeAndSortChildren)(_defaultChildren, _children, _propsWithoutChildren);
439
- }
440
- var propsWithoutChildren = _extends({}, props, {
441
- children: null
442
- });
443
- var children = [];
444
- var defaultChildren = props.controlType === 'advanced' ? this.getAdvancedChildren(propsWithoutChildren, props) : this.getDefaultChildren(propsWithoutChildren, props);
445
- return (0, _utils.mergeAndSortChildren)(defaultChildren, children, propsWithoutChildren);
446
- }
447
- /*
448
- * get redux state
449
- * { player, operation }
450
- */
451
-
452
- }, {
453
- key: 'getState',
454
- value: function getState() {
455
- return this.manager.getState();
456
- }
457
-
458
- // get playback rate
459
-
460
- }, {
461
- key: 'play',
462
-
463
-
464
- // play the video
465
- value: function play() {
466
- this.video.play();
467
- }
468
-
469
- // pause the video
470
-
471
- }, {
472
- key: 'pause',
473
- value: function pause() {
474
- this.video.pause();
475
- }
476
-
477
- // Change the video source and re-load the video:
478
-
479
- }, {
480
- key: 'load',
481
- value: function load() {
482
- this.video.load();
483
- }
484
-
485
- // Add a new text track to the video
486
-
487
- }, {
488
- key: 'addTextTrack',
489
- value: function addTextTrack() {
490
- var _video;
491
-
492
- (_video = this.video).addTextTrack.apply(_video, arguments);
493
- }
494
-
495
- // Check if your browser can play different types of video:
496
-
497
- }, {
498
- key: 'canPlayType',
499
- value: function canPlayType() {
500
- var _video2;
501
-
502
- (_video2 = this.video).canPlayType.apply(_video2, arguments);
503
- }
504
-
505
- // seek video by time
506
-
507
- }, {
508
- key: 'seek',
509
- value: function seek(time) {
510
- this.video.seek(time);
511
- }
512
-
513
- // jump forward x seconds
514
-
515
- }, {
516
- key: 'forward',
517
- value: function forward(seconds) {
518
- this.video.forward(seconds);
519
- }
520
-
521
- // jump back x seconds
522
-
523
- }, {
524
- key: 'replay',
525
- value: function replay(seconds) {
526
- this.video.replay(seconds);
527
- }
528
-
529
- // enter or exist full screen
530
-
531
- }, {
532
- key: 'toggleFullscreen',
533
- value: function toggleFullscreen() {
534
- this.video.toggleFullscreen();
535
- }
536
-
537
- // subscribe to player state change
538
-
539
- }, {
540
- key: 'subscribeToStateChange',
541
- value: function subscribeToStateChange(listener) {
542
- return this.manager.subscribeToPlayerStateChange(listener);
543
- }
544
-
545
- // player resize
546
-
547
- }, {
548
- key: 'handleResize',
549
- value: function handleResize() {
550
- var _manager$getState = this.manager.getState(),
551
- player = _manager$getState.player;
552
-
553
- var leftSectionRef = this._leftSectionRef;
554
- var rightSectionRef = this._rightSectionRef;
555
- var audioMeterBlock = this._audioMeterBlock;
556
- var playerHeader = (0, _reactDom.findDOMNode)(this._playerHeader);
557
- var video = (0, _reactDom.findDOMNode)(this.video);
558
- var progressControl = (0, _reactDom.findDOMNode)(this._progressControl);
559
- var controlBar = (0, _reactDom.findDOMNode)(this._controlBar);
560
- var playlist = (0, _reactDom.findDOMNode)(this._playlist);
561
- var playerContainer = (0, _reactDom.findDOMNode)(this._playerContainer);
562
- var _props = this.props,
563
- controlType = _props.controlType,
564
- playerType = _props.playerType,
565
- fileType = _props.fileType;
566
-
567
- var height = 0;
568
- [].concat(_toConsumableArray(leftSectionRef.children)).forEach(function (child) {
569
- return height += child.offsetHeight;
570
- });
571
- if (rightSectionRef) {
572
- rightSectionRef.style.height = height + 'px';
573
- }
574
- if (audioMeterBlock) {
575
- audioMeterBlock.style.height = video.offsetHeight + 'px';
576
- audioMeterBlock.style.top = playerHeader.offsetHeight + 'px';
577
- this.meterHeight = video.offsetHeight;
578
- }
579
- if (playlist) {
580
- if (fileType === 'image') {
581
- playlist.style.height = 'calc(100% - ' + (playerHeader.offsetHeight + video.offsetHeight) + 'px)';
582
- } else {
583
- playlist.style.height = 'calc(100% - ' + (playerHeader.offsetHeight + video.offsetHeight + progressControl.offsetHeight + controlBar.offsetHeight) + 'px)';
584
- }
585
- }
586
- var videoHeight = window.innerHeight;
587
- var videoWidth = window.innerWidth;
588
- if (playerType === 'panel') {
589
- videoHeight = window.innerHeight;
590
- videoWidth = videoHeight * (16 / 9);
591
- if (videoWidth > window.innerWidth) {
592
- videoWidth = window.innerWidth;
593
- videoHeight = videoWidth * (9 / 16);
594
- }
595
- video.style.paddingTop = '0';
596
- video.style.width = videoWidth + 'px';
597
- video.style.height = videoHeight + 'px';
598
- video.style.margin = '0 auto';
599
- video.classList.add('ratio-border');
600
- } else if (window.innerHeight < 1024 && (playerContainer.offsetHeight > window.innerHeight || window.innerHeight > playerContainer.offsetHeight)) {
601
- var playlistMinHeight = 150;
602
- if (controlType === 'default') {
603
- if (fileType === 'image') {
604
- videoHeight = window.innerHeight - playlistMinHeight - playerHeader.offsetHeight;
605
- } else {
606
- videoHeight = window.innerHeight - playlistMinHeight - playerHeader.offsetHeight - progressControl.offsetHeight - controlBar.offsetHeight;
607
- }
608
- } else {
609
- videoHeight = window.innerHeight - playerHeader.offsetHeight - controlBar.offsetHeight - this._advancedControl.offsetHeight - 30;
610
- }
611
- videoWidth = videoHeight * (16 / 9);
612
- if (videoWidth > leftSectionRef.offsetWidth) {
613
- videoWidth = leftSectionRef.offsetWidth;
614
- videoHeight = videoWidth * (9 / 16);
615
- }
616
- video.style.paddingTop = '0';
617
- video.style.width = videoWidth + 'px';
618
- video.style.height = videoHeight + 'px';
619
- video.style.margin = '0 auto';
620
- video.classList.add('ratio-border');
621
- } else if (window.innerHeight >= 900) {
622
- video.style.paddingTop = '56.25%';
623
- video.style.width = 'auto';
624
- video.style.height = 'auto';
625
- video.classList.remove('ratio-border');
626
- }
627
- if (player.isFullscreen && progressControl) {
628
- videoHeight = window.innerHeight - playerHeader.offsetHeight - progressControl.offsetHeight - controlBar.offsetHeight;
629
- videoWidth = videoHeight * (16 / 9);
630
- if (videoWidth > window.innerWidth) {
631
- videoWidth = window.innerWidth;
632
- videoHeight = videoWidth * (9 / 16);
633
- }
634
- video.style.paddingTop = '0';
635
- video.style.width = videoWidth + 'px';
636
- video.style.height = videoHeight + 'px';
637
- video.style.margin = '0 auto';
638
- video.classList.add('ratio-border');
639
- }
640
- // this.video.handleResize();
641
- }
642
- }, {
643
- key: 'handleFullScreenChange',
644
- value: function handleFullScreenChange() {
645
- this.actions.handleFullscreenChange(_fullscreen2.default.isFullscreen);
646
- }
647
- }, {
648
- key: 'handleStateChange',
649
- value: function handleStateChange(state, prevState) {
650
- if (state.isFullscreen !== prevState.isFullscreen) {
651
- this.handleResize();
652
- }
653
- this.forceUpdate(); // re-render
654
- }
655
- }, {
656
- key: 'handleFocus',
657
- value: function handleFocus() {
658
- this.actions.activate(true);
659
- }
660
- }, {
661
- key: 'handleBlur',
662
- value: function handleBlur() {
663
- this.actions.activate(false);
664
- }
665
- }, {
666
- key: 'render',
667
- value: function render() {
668
- var _this5 = this;
669
-
670
- var _manager$getState2 = this.manager.getState(),
671
- player = _manager$getState2.player;
672
-
673
- var props = _extends({}, this.props, {
674
- player: player,
675
- actions: this.actions,
676
- manager: this.manager,
677
- store: this.manager.store,
678
- video: this.video ? this.video.video : null
679
- });
680
- var childrensLeft = this.getChildren(props, 'left');
681
- var _props2 = this.props,
682
- rightSection = _props2.rightSection,
683
- playerType = _props2.playerType;
684
-
685
-
686
- return _react2.default.createElement(
687
- PlayerBlock,
688
- {
689
- ref: function ref(c) {
690
- _this5.manager.rootElement = c;
691
- },
692
- role: 'region',
693
- onFocus: this.handleFocus,
694
- onBlur: this.handleBlur,
695
- tabIndex: '-1'
696
- },
697
- _react2.default.createElement(
698
- PlayerContainer,
699
- _extends({
700
- ref: function ref(playerContainer) {
701
- _this5._playerContainer = playerContainer;
702
- }
703
- }, props, {
704
- hasRightSection: !!rightSection
705
- }),
706
- _react2.default.createElement(
707
- 'div',
708
- {
709
- className: 'left-video-section',
710
- ref: function ref(leftSectionRef) {
711
- _this5._leftSectionRef = leftSectionRef;
712
- }
713
- },
714
- childrensLeft
715
- ),
716
- _react2.default.createElement(
717
- 'div',
718
- {
719
- className: 'audio-meter-block ' + playerType,
720
- ref: function ref(audioMeterBlock) {
721
- _this5._audioMeterBlock = audioMeterBlock;
722
- }
723
- },
724
- _react2.default.createElement(
725
- AudioMeterBlock,
726
- {
727
- onClick: function onClick() {
728
- _this5.meterBlockClick();
729
- },
730
- role: 'presentation',
731
- active: true
732
- },
733
- _react2.default.createElement(_AudioMeter2.default, { player: props.player, height: this.meterHeight })
734
- )
735
- ),
736
- rightSection ? _react2.default.createElement(
737
- 'div',
738
- {
739
- className: 'right-video-section',
740
- ref: function ref(rightSectionRef) {
741
- _this5._rightSectionRef = rightSectionRef;
742
- }
743
- },
744
- rightSection
745
- ) : null
746
- ),
747
- props.controlType === 'advanced' ? _react2.default.createElement(
748
- ControlContainer,
749
- {
750
- ref: function ref(advancedControl) {
751
- _this5._advancedControl = advancedControl;
752
- }
753
- },
754
- _react2.default.createElement(_ProgressControl2.default, _extends({}, props, { key: 'progress-control', order: 1 }))
755
- ) : _react2.default.createElement(_Playlist2.default, _extends({
756
- ref: function ref(c) {
757
- _this5._playlist = c;
758
- },
759
- key: 'playlist',
760
- order: 5
761
- }, this.props))
762
- );
763
- }
764
- }, {
765
- key: 'playbackRate',
766
- get: function get() {
767
- return this.video.playbackRate;
768
- }
769
-
770
- /*
771
- * set playback rate
772
- * speed of video
773
- */
774
- ,
775
- set: function set(rate) {
776
- this.video.playbackRate = rate;
777
- }
778
- }, {
779
- key: 'muted',
780
- get: function get() {
781
- return this.video.muted;
782
- },
783
- set: function set(val) {
784
- this.video.muted = val;
785
- }
786
- }, {
787
- key: 'volume',
788
- get: function get() {
789
- return this.video.volume;
790
- },
791
- set: function set(val) {
792
- this.video.volume = val;
793
- }
794
-
795
- // video width
796
-
797
- }, {
798
- key: 'videoWidth',
799
- get: function get() {
800
- return this.video.videoWidth;
801
- }
802
-
803
- // video height
804
-
805
- }, {
806
- key: 'videoHeight',
807
- get: function get() {
808
- return this.video.videoHeight;
809
- }
810
- }]);
811
-
812
- return Player;
813
- }(_react.Component);
814
-
815
- exports.default = Player;
816
-
817
-
818
- Player.contextTypes = { store: _propTypes.PropTypes.instanceOf(Object) };
819
- Player.propTypes = propTypes;
820
- Player.defaultProps = defaultProps;
821
- Player.displayName = 'Player';