@atlaskit/media-ui 28.3.3 → 28.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/customMediaPlayer/index.js +1 -1
- package/dist/cjs/customMediaPlayer/mediaPlayer/captionsSelectControls.js +2 -1
- package/dist/cjs/customMediaPlayer/mediaPlayer/mediaPlayer.js +17 -12
- package/dist/cjs/customMediaPlayer/mediaPlayer/mediaPlayerBase.js +311 -213
- package/dist/cjs/customMediaPlayer/mediaPlayer/testHelpers/_MockedMediaProvider.js +153 -0
- package/dist/cjs/customMediaPlayer/mediaPlayer/testHelpers/_helpers.js +22 -0
- package/dist/cjs/customMediaPlayer/mediaPlayer/useTextTracks.js +11 -7
- package/dist/es2019/customMediaPlayer/index.js +1 -1
- package/dist/es2019/customMediaPlayer/mediaPlayer/captionsSelectControls.js +2 -1
- package/dist/es2019/customMediaPlayer/mediaPlayer/mediaPlayer.js +17 -11
- package/dist/es2019/customMediaPlayer/mediaPlayer/mediaPlayerBase.js +232 -166
- package/dist/es2019/customMediaPlayer/mediaPlayer/testHelpers/_MockedMediaProvider.js +126 -0
- package/dist/es2019/customMediaPlayer/mediaPlayer/testHelpers/_helpers.js +14 -0
- package/dist/es2019/customMediaPlayer/mediaPlayer/useTextTracks.js +23 -18
- package/dist/esm/customMediaPlayer/index.js +1 -1
- package/dist/esm/customMediaPlayer/mediaPlayer/captionsSelectControls.js +2 -1
- package/dist/esm/customMediaPlayer/mediaPlayer/mediaPlayer.js +16 -11
- package/dist/esm/customMediaPlayer/mediaPlayer/mediaPlayerBase.js +310 -212
- package/dist/esm/customMediaPlayer/mediaPlayer/testHelpers/_MockedMediaProvider.js +146 -0
- package/dist/esm/customMediaPlayer/mediaPlayer/testHelpers/_helpers.js +16 -0
- package/dist/esm/customMediaPlayer/mediaPlayer/useTextTracks.js +11 -7
- package/dist/types/customMediaPlayer/analytics/utils/playbackAttributes.d.ts +1 -1
- package/dist/types/customMediaPlayer/mediaPlayer/mediaPlayer.d.ts +2 -1
- package/dist/types/customMediaPlayer/mediaPlayer/mediaPlayerBase.d.ts +15 -6
- package/dist/types/customMediaPlayer/mediaPlayer/testHelpers/_MockedMediaProvider.d.ts +46 -0
- package/dist/types/customMediaPlayer/mediaPlayer/testHelpers/_helpers.d.ts +2 -0
- package/dist/types-ts4.5/customMediaPlayer/analytics/utils/playbackAttributes.d.ts +1 -1
- package/dist/types-ts4.5/customMediaPlayer/mediaPlayer/mediaPlayer.d.ts +2 -1
- package/dist/types-ts4.5/customMediaPlayer/mediaPlayer/mediaPlayerBase.d.ts +15 -6
- package/dist/types-ts4.5/customMediaPlayer/mediaPlayer/testHelpers/_MockedMediaProvider.d.ts +46 -0
- package/dist/types-ts4.5/customMediaPlayer/mediaPlayer/testHelpers/_helpers.d.ts +2 -0
- package/package.json +4 -3
|
@@ -15,7 +15,6 @@ import SoundIcon from '@atlaskit/icon/core/migration/volume-high--hipchat-outgoi
|
|
|
15
15
|
import VideoHdIcon from '@atlaskit/icon-lab/core/video-hd';
|
|
16
16
|
import VideoHdFilledIcon from '@atlaskit/icon-lab/core/video-hd-filled';
|
|
17
17
|
import DownloadIcon from '@atlaskit/icon/core/migration/download';
|
|
18
|
-
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
19
18
|
import { injectIntl } from 'react-intl-next';
|
|
20
19
|
import { Box, Flex } from '@atlaskit/primitives/compiled';
|
|
21
20
|
import MediaButton from '../../MediaButton';
|
|
@@ -45,10 +44,37 @@ import VideoSkipBackwardTenIcon from '@atlaskit/icon/core/video-skip-backward-te
|
|
|
45
44
|
import { getUserCaptionsLocale, setUserCaptionsLocale, findPreselectedTrackIndex, getUserCaptionsEnabled, setUserCaptionsEnabled } from './captions';
|
|
46
45
|
import { CaptionsUploaderBrowser } from './captions/artifactUploader';
|
|
47
46
|
import CaptionDeleteConfirmationModal from './captions/captionDeleteConfirmationModal';
|
|
48
|
-
const MEDIUM_VIDEO_MAX_WIDTH = 400;
|
|
49
|
-
const SMALL_VIDEO_MAX_WIDTH = 245;
|
|
50
47
|
const MINIMUM_DURATION_BEFORE_SAVING_TIME = 60;
|
|
51
48
|
const VIEWED_TRACKING_SECS = 2;
|
|
49
|
+
export const breakpoints = {
|
|
50
|
+
LARGE_VIDEO_MAX_WIDTH: 570,
|
|
51
|
+
MEDIUM_VIDEO_MAX_WIDTH: 430,
|
|
52
|
+
SMALL_VIDEO_MAX_WIDTH: 260
|
|
53
|
+
};
|
|
54
|
+
const breakpointControls = {
|
|
55
|
+
playPauseButton: () => true,
|
|
56
|
+
volume: () => true,
|
|
57
|
+
fullScreenButton: () => true,
|
|
58
|
+
currentTime: playerWidth => playerWidth > breakpoints.SMALL_VIDEO_MAX_WIDTH,
|
|
59
|
+
captionsControls: playerWidth => playerWidth > breakpoints.MEDIUM_VIDEO_MAX_WIDTH,
|
|
60
|
+
downloadButton: playerWidth => playerWidth > breakpoints.MEDIUM_VIDEO_MAX_WIDTH,
|
|
61
|
+
volumeSlider: playerWidth => playerWidth > breakpoints.MEDIUM_VIDEO_MAX_WIDTH,
|
|
62
|
+
skipButtons: playerWidth => playerWidth > breakpoints.LARGE_VIDEO_MAX_WIDTH,
|
|
63
|
+
speedControls: playerWidth => playerWidth > breakpoints.LARGE_VIDEO_MAX_WIDTH,
|
|
64
|
+
hdButton: playerWidth => playerWidth > breakpoints.LARGE_VIDEO_MAX_WIDTH,
|
|
65
|
+
captionsAdminControls: playerWidth => playerWidth > breakpoints.LARGE_VIDEO_MAX_WIDTH
|
|
66
|
+
};
|
|
67
|
+
const getPlayerSize = playerWidth => {
|
|
68
|
+
if (playerWidth > breakpoints.LARGE_VIDEO_MAX_WIDTH) {
|
|
69
|
+
return 'xlarge';
|
|
70
|
+
} else if (playerWidth > breakpoints.MEDIUM_VIDEO_MAX_WIDTH) {
|
|
71
|
+
return 'large';
|
|
72
|
+
} else if (playerWidth > breakpoints.SMALL_VIDEO_MAX_WIDTH) {
|
|
73
|
+
return 'medium';
|
|
74
|
+
} else {
|
|
75
|
+
return 'small';
|
|
76
|
+
}
|
|
77
|
+
};
|
|
52
78
|
|
|
53
79
|
/* Styles */
|
|
54
80
|
|
|
@@ -78,14 +104,16 @@ class _MediaPlayerBase extends Component {
|
|
|
78
104
|
volume: 1,
|
|
79
105
|
status: 'paused',
|
|
80
106
|
duration: 0,
|
|
81
|
-
isMuted: false
|
|
107
|
+
isMuted: false,
|
|
108
|
+
currentActiveCues: () => undefined
|
|
82
109
|
});
|
|
83
110
|
_defineProperty(this, "wasPlayedOnce", false);
|
|
84
111
|
_defineProperty(this, "lastCurrentTime", 0);
|
|
85
112
|
_defineProperty(this, "timeSaver", new TimeSaver(this.props.lastWatchTimeConfig));
|
|
86
113
|
_defineProperty(this, "state", {
|
|
87
114
|
isFullScreenEnabled: false,
|
|
88
|
-
|
|
115
|
+
playerWidth: 100,
|
|
116
|
+
// initial value for playerSize: 'small', i.e. width < 260px
|
|
89
117
|
playbackSpeed: 1,
|
|
90
118
|
selectedTracksIndex: -1,
|
|
91
119
|
areCaptionsEnabled: false,
|
|
@@ -118,9 +146,11 @@ class _MediaPlayerBase extends Component {
|
|
|
118
146
|
} = this.props;
|
|
119
147
|
const {
|
|
120
148
|
isFullScreenEnabled,
|
|
121
|
-
playerSize,
|
|
122
149
|
playbackSpeed
|
|
123
150
|
} = this.state;
|
|
151
|
+
const {
|
|
152
|
+
playerSize
|
|
153
|
+
} = this;
|
|
124
154
|
fireAnalyticsEvent(createFirstPlayedTrackEvent(type, {
|
|
125
155
|
isAutoPlay,
|
|
126
156
|
isHDAvailable,
|
|
@@ -168,22 +198,25 @@ class _MediaPlayerBase extends Component {
|
|
|
168
198
|
this.timeSaver.defaultTime = 0;
|
|
169
199
|
}
|
|
170
200
|
});
|
|
171
|
-
_defineProperty(this, "
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
201
|
+
_defineProperty(this, "shouldRenderCurrentTime", () => breakpointControls.currentTime(this.state.playerWidth));
|
|
202
|
+
_defineProperty(this, "renderCurrentTime", () => {
|
|
203
|
+
return /*#__PURE__*/React.createElement(CurrentTime, {
|
|
204
|
+
draggable: false,
|
|
205
|
+
"data-testid": "current-time"
|
|
206
|
+
}, formatDuration(this.videoState.currentTime), " / ", formatDuration(this.videoState.duration));
|
|
207
|
+
});
|
|
208
|
+
_defineProperty(this, "shouldRenderHdButton", () => {
|
|
178
209
|
const {
|
|
179
210
|
type,
|
|
180
|
-
isHDAvailable
|
|
211
|
+
isHDAvailable
|
|
212
|
+
} = this.props;
|
|
213
|
+
return !fg('platform_media_disable_video_640p_artifact_usage') && breakpointControls.hdButton(this.state.playerWidth) && type !== 'audio' && !!isHDAvailable;
|
|
214
|
+
});
|
|
215
|
+
_defineProperty(this, "renderHDButton", () => {
|
|
216
|
+
const {
|
|
181
217
|
isHDActive,
|
|
182
218
|
onHDToggleClick
|
|
183
219
|
} = this.props;
|
|
184
|
-
if (type === 'audio' || !isHDAvailable) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
220
|
return /*#__PURE__*/React.createElement(MediaButton, {
|
|
188
221
|
testId: "custom-media-player-hd-button",
|
|
189
222
|
onClick: !!onHDToggleClick ? this.getMediaButtonClickHandler(onHDToggleClick, 'HDButton') : undefined,
|
|
@@ -204,6 +237,7 @@ class _MediaPlayerBase extends Component {
|
|
|
204
237
|
});
|
|
205
238
|
this.createAndFireUIEvent('playbackSpeedChange');
|
|
206
239
|
});
|
|
240
|
+
_defineProperty(this, "shouldRenderSpeedControls", () => breakpointControls.speedControls(this.state.playerWidth));
|
|
207
241
|
_defineProperty(this, "renderSpeedControls", () => {
|
|
208
242
|
const {
|
|
209
243
|
playbackSpeed
|
|
@@ -218,47 +252,46 @@ class _MediaPlayerBase extends Component {
|
|
|
218
252
|
onClick: () => this.createAndFireUIEvent('mediaButtonClick', 'playbackSpeedButton')
|
|
219
253
|
});
|
|
220
254
|
});
|
|
221
|
-
_defineProperty(this, "
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
255
|
+
_defineProperty(this, "shouldRenderVolume", () => breakpointControls.volume(this.state.playerWidth));
|
|
256
|
+
_defineProperty(this, "shouldRenderVolumeSLider", () => breakpointControls.volumeSlider(this.state.playerWidth));
|
|
257
|
+
_defineProperty(this, "renderVolume", () => {
|
|
258
|
+
var _this$actions, _this$actions2;
|
|
259
|
+
const showSlider = this.shouldRenderVolumeSLider();
|
|
260
|
+
return /*#__PURE__*/React.createElement(VolumeWrapper, {
|
|
261
|
+
showSlider: showSlider
|
|
262
|
+
}, /*#__PURE__*/React.createElement(VolumeToggleWrapper, {
|
|
263
|
+
isMuted: this.videoState.isMuted
|
|
264
|
+
}, /*#__PURE__*/React.createElement(MutedIndicator, {
|
|
265
|
+
isMuted: this.videoState.isMuted
|
|
266
|
+
}), /*#__PURE__*/React.createElement(MediaButton, {
|
|
267
|
+
testId: "custom-media-player-volume-toggle-button",
|
|
268
|
+
onClick: this.getMediaButtonClickHandler(((_this$actions = this.actions) === null || _this$actions === void 0 ? void 0 : _this$actions.toggleMute) || (() => undefined), 'muteButton'),
|
|
269
|
+
iconBefore: /*#__PURE__*/React.createElement(SoundIcon, {
|
|
270
|
+
color: "currentColor",
|
|
271
|
+
label: this.props.intl.formatMessage(messages.volumeMuteButtonAria)
|
|
272
|
+
}),
|
|
273
|
+
"aria-pressed": this.videoState.isMuted
|
|
274
|
+
})), showSlider && /*#__PURE__*/React.createElement(VolumeTimeRangeWrapper, {
|
|
275
|
+
"data-testid": "volume-time-range-wrapper"
|
|
276
|
+
}, /*#__PURE__*/React.createElement(VolumeRange, {
|
|
277
|
+
onChange: ((_this$actions2 = this.actions) === null || _this$actions2 === void 0 ? void 0 : _this$actions2.setVolume) || (() => undefined),
|
|
278
|
+
currentVolume: this.videoState.volume,
|
|
279
|
+
isAlwaysActive: true,
|
|
280
|
+
onChanged: this.onVolumeChanged,
|
|
281
|
+
ariaLabel: this.props.intl.formatMessage(messages.volumeLevelControlAria)
|
|
282
|
+
})));
|
|
283
|
+
});
|
|
242
284
|
_defineProperty(this, "toggleFullscreen", () => this.videoWrapperRef.current && toggleFullscreen(this.videoWrapperRef.current));
|
|
243
285
|
_defineProperty(this, "onFullScreenButtonClick", () => {
|
|
244
286
|
this.toggleFullscreen();
|
|
245
287
|
this.createAndFireUIEvent('mediaButtonClick', 'fullScreenButton');
|
|
246
288
|
});
|
|
247
289
|
_defineProperty(this, "onResize", width => {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
});
|
|
252
|
-
} else if (width > SMALL_VIDEO_MAX_WIDTH) {
|
|
253
|
-
this.setState({
|
|
254
|
-
playerSize: 'medium'
|
|
255
|
-
});
|
|
256
|
-
} else {
|
|
257
|
-
this.setState({
|
|
258
|
-
playerSize: 'small'
|
|
259
|
-
});
|
|
260
|
-
}
|
|
290
|
+
this.setState({
|
|
291
|
+
playerWidth: width
|
|
292
|
+
});
|
|
261
293
|
});
|
|
294
|
+
_defineProperty(this, "shouldRenderFullScreenButton", () => breakpointControls.fullScreenButton(this.state.playerWidth));
|
|
262
295
|
_defineProperty(this, "renderFullScreenButton", () => {
|
|
263
296
|
const {
|
|
264
297
|
intl: {
|
|
@@ -285,22 +318,15 @@ class _MediaPlayerBase extends Component {
|
|
|
285
318
|
iconBefore: icon
|
|
286
319
|
});
|
|
287
320
|
});
|
|
288
|
-
_defineProperty(this, "
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
onClick: this.getMediaButtonClickHandler(onDownloadClick, 'downloadButton'),
|
|
298
|
-
iconBefore: /*#__PURE__*/React.createElement(DownloadIcon, {
|
|
299
|
-
color: "currentColor",
|
|
300
|
-
label: "download"
|
|
301
|
-
})
|
|
302
|
-
});
|
|
303
|
-
});
|
|
321
|
+
_defineProperty(this, "shouldRenderDownloadButton", () => breakpointControls.downloadButton(this.state.playerWidth));
|
|
322
|
+
_defineProperty(this, "renderDownloadButton", () => this.props.onDownloadClick && /*#__PURE__*/React.createElement(MediaButton, {
|
|
323
|
+
testId: "custom-media-player-download-button",
|
|
324
|
+
onClick: this.getMediaButtonClickHandler(this.props.onDownloadClick, 'downloadButton'),
|
|
325
|
+
iconBefore: /*#__PURE__*/React.createElement(DownloadIcon, {
|
|
326
|
+
color: "currentColor",
|
|
327
|
+
label: "download"
|
|
328
|
+
})
|
|
329
|
+
}));
|
|
304
330
|
_defineProperty(this, "renderShortcuts", ({
|
|
305
331
|
togglePlayPauseAction,
|
|
306
332
|
toggleMute,
|
|
@@ -337,13 +363,14 @@ class _MediaPlayerBase extends Component {
|
|
|
337
363
|
}
|
|
338
364
|
return shortcuts;
|
|
339
365
|
});
|
|
340
|
-
_defineProperty(this, "
|
|
366
|
+
_defineProperty(this, "shouldRenderPlayPauseButton", () => breakpointControls.playPauseButton(this.state.playerWidth));
|
|
367
|
+
_defineProperty(this, "renderPlayPauseButton", () => {
|
|
341
368
|
const {
|
|
342
369
|
intl: {
|
|
343
370
|
formatMessage
|
|
344
371
|
}
|
|
345
372
|
} = this.props;
|
|
346
|
-
const toggleButtonIcon = isPlaying ? /*#__PURE__*/React.createElement(PauseIcon, {
|
|
373
|
+
const toggleButtonIcon = this.isPlaying ? /*#__PURE__*/React.createElement(PauseIcon, {
|
|
347
374
|
spacing: "spacious",
|
|
348
375
|
color: "currentColor",
|
|
349
376
|
label: formatMessage(messages.pause)
|
|
@@ -353,16 +380,29 @@ class _MediaPlayerBase extends Component {
|
|
|
353
380
|
label: formatMessage(messages.play)
|
|
354
381
|
});
|
|
355
382
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
356
|
-
content: formatMessage(isPlaying ? messages.pause : messages.play),
|
|
383
|
+
content: formatMessage(this.isPlaying ? messages.pause : messages.play),
|
|
357
384
|
position: "top"
|
|
358
385
|
}, /*#__PURE__*/React.createElement(MediaButton, {
|
|
359
386
|
testId: "custom-media-player-play-toggle-button",
|
|
360
|
-
"data-test-is-playing": isPlaying,
|
|
387
|
+
"data-test-is-playing": this.isPlaying,
|
|
361
388
|
iconBefore: toggleButtonIcon,
|
|
362
|
-
onClick: isPlaying ? this.pausePlayByButtonClick : this.startPlayByButtonClick
|
|
389
|
+
onClick: this.isPlaying ? this.pausePlayByButtonClick : this.startPlayByButtonClick
|
|
363
390
|
}));
|
|
364
391
|
});
|
|
365
|
-
_defineProperty(this, "
|
|
392
|
+
_defineProperty(this, "defaultSkipAmount", 10);
|
|
393
|
+
_defineProperty(this, "skipBackward", (skipAmount = this.defaultSkipAmount) => {
|
|
394
|
+
var _this$actions3, _this$props$onTimeCha2, _this$props3;
|
|
395
|
+
const newTime = this.videoState.currentTime - skipAmount;
|
|
396
|
+
(_this$actions3 = this.actions) === null || _this$actions3 === void 0 ? void 0 : _this$actions3.navigate(Math.max(newTime, 0));
|
|
397
|
+
(_this$props$onTimeCha2 = (_this$props3 = this.props).onTimeChanged) === null || _this$props$onTimeCha2 === void 0 ? void 0 : _this$props$onTimeCha2.call(_this$props3);
|
|
398
|
+
});
|
|
399
|
+
_defineProperty(this, "skipForward", (skipAmount = this.defaultSkipAmount) => {
|
|
400
|
+
var _this$actions4, _this$props$onTimeCha3, _this$props4;
|
|
401
|
+
const newTime = this.videoState.currentTime + skipAmount;
|
|
402
|
+
(_this$actions4 = this.actions) === null || _this$actions4 === void 0 ? void 0 : _this$actions4.navigate(Math.min(newTime, this.videoState.duration));
|
|
403
|
+
(_this$props$onTimeCha3 = (_this$props4 = this.props).onTimeChanged) === null || _this$props$onTimeCha3 === void 0 ? void 0 : _this$props$onTimeCha3.call(_this$props4);
|
|
404
|
+
});
|
|
405
|
+
_defineProperty(this, "renderSkipBackwardButton", () => {
|
|
366
406
|
const {
|
|
367
407
|
intl: {
|
|
368
408
|
formatMessage
|
|
@@ -378,10 +418,10 @@ class _MediaPlayerBase extends Component {
|
|
|
378
418
|
LEGACY_fallbackIcon: SkipTenBackwardIcon,
|
|
379
419
|
label: formatMessage(messages.skipBackward)
|
|
380
420
|
}),
|
|
381
|
-
onClick: this.getMediaButtonClickHandler(skipBackward, 'skipBackwardButton')
|
|
421
|
+
onClick: this.getMediaButtonClickHandler(this.skipBackward, 'skipBackwardButton')
|
|
382
422
|
}));
|
|
383
423
|
});
|
|
384
|
-
_defineProperty(this, "renderSkipForwardButton",
|
|
424
|
+
_defineProperty(this, "renderSkipForwardButton", () => {
|
|
385
425
|
const {
|
|
386
426
|
intl: {
|
|
387
427
|
formatMessage
|
|
@@ -397,10 +437,17 @@ class _MediaPlayerBase extends Component {
|
|
|
397
437
|
LEGACY_fallbackIcon: SkipTenForwardIcon,
|
|
398
438
|
label: formatMessage(messages.skipForward)
|
|
399
439
|
}),
|
|
400
|
-
onClick: this.getMediaButtonClickHandler(skipForward, 'skipForwardButton')
|
|
440
|
+
onClick: this.getMediaButtonClickHandler(this.skipForward, 'skipForwardButton')
|
|
401
441
|
}));
|
|
402
442
|
});
|
|
443
|
+
_defineProperty(this, "shouldRenderSkipButtons", () => breakpointControls.skipButtons(this.state.playerWidth));
|
|
444
|
+
_defineProperty(this, "renderSkipButtons", () => {
|
|
445
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
446
|
+
direction: "row"
|
|
447
|
+
}, this.renderSkipBackwardButton(), this.renderSkipForwardButton());
|
|
448
|
+
});
|
|
403
449
|
_defineProperty(this, "renderSpinner", () => /*#__PURE__*/React.createElement(Flex, {
|
|
450
|
+
testId: "spinner",
|
|
404
451
|
direction: "column",
|
|
405
452
|
alignItems: "center",
|
|
406
453
|
justifyContent: "center",
|
|
@@ -410,11 +457,11 @@ class _MediaPlayerBase extends Component {
|
|
|
410
457
|
size: "large"
|
|
411
458
|
})));
|
|
412
459
|
_defineProperty(this, "pause", () => {
|
|
413
|
-
var _this$props$onPause, _this$
|
|
460
|
+
var _this$props$onPause, _this$props5;
|
|
414
461
|
if (this.actions) {
|
|
415
462
|
this.actions.pause();
|
|
416
463
|
}
|
|
417
|
-
(_this$props$onPause = (_this$
|
|
464
|
+
(_this$props$onPause = (_this$props5 = this.props).onPause) === null || _this$props$onPause === void 0 ? void 0 : _this$props$onPause.call(_this$props5);
|
|
418
465
|
});
|
|
419
466
|
_defineProperty(this, "play", () => {
|
|
420
467
|
const {
|
|
@@ -461,9 +508,11 @@ class _MediaPlayerBase extends Component {
|
|
|
461
508
|
} = this.props;
|
|
462
509
|
const {
|
|
463
510
|
isFullScreenEnabled,
|
|
464
|
-
playerSize,
|
|
465
511
|
playbackSpeed
|
|
466
512
|
} = this.state;
|
|
513
|
+
const {
|
|
514
|
+
playerSize
|
|
515
|
+
} = this;
|
|
467
516
|
const {
|
|
468
517
|
status,
|
|
469
518
|
currentTime
|
|
@@ -555,6 +604,84 @@ class _MediaPlayerBase extends Component {
|
|
|
555
604
|
}
|
|
556
605
|
return undefined;
|
|
557
606
|
});
|
|
607
|
+
_defineProperty(this, "shouldRenderCaptionsControls", () => {
|
|
608
|
+
const {
|
|
609
|
+
textTracks
|
|
610
|
+
} = this.props;
|
|
611
|
+
const {
|
|
612
|
+
playerWidth
|
|
613
|
+
} = this.state;
|
|
614
|
+
return breakpointControls.captionsControls(playerWidth) && !!textTracks;
|
|
615
|
+
});
|
|
616
|
+
_defineProperty(this, "renderCaptionsControls", () => {
|
|
617
|
+
const {
|
|
618
|
+
textTracks
|
|
619
|
+
} = this.props;
|
|
620
|
+
const {
|
|
621
|
+
areCaptionsEnabled
|
|
622
|
+
} = this.state;
|
|
623
|
+
return textTracks && /*#__PURE__*/React.createElement(CaptionsSelectControls, {
|
|
624
|
+
textTracks: textTracks,
|
|
625
|
+
onSelected: this.onTextTracksSelected,
|
|
626
|
+
areCaptionsEnabled: !!areCaptionsEnabled,
|
|
627
|
+
onCaptionsEnabledChange: this.onCaptionsEnabledChange,
|
|
628
|
+
selectedTracksIndex: this.resolveSelectedTracksIndex()
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
_defineProperty(this, "shouldRenderCaptionsAdminControls", () => {
|
|
632
|
+
var _this$props$mediaSett;
|
|
633
|
+
const {
|
|
634
|
+
playerWidth
|
|
635
|
+
} = this.state;
|
|
636
|
+
return (!this.props.fileState || this.props.fileState.status !== 'uploading') && breakpointControls.captionsAdminControls(playerWidth) && !!((_this$props$mediaSett = this.props.mediaSettings) !== null && _this$props$mediaSett !== void 0 && _this$props$mediaSett.canUpdateVideoCaptions);
|
|
637
|
+
});
|
|
638
|
+
_defineProperty(this, "renderCaptionsAdminControls", () => {
|
|
639
|
+
const {
|
|
640
|
+
isArtifactUploaderOpen,
|
|
641
|
+
artifactToDelete
|
|
642
|
+
} = this.state;
|
|
643
|
+
const {
|
|
644
|
+
textTracks,
|
|
645
|
+
identifier
|
|
646
|
+
} = this.props;
|
|
647
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CaptionsAdminControls, {
|
|
648
|
+
textTracks: textTracks,
|
|
649
|
+
onUpload: () => this.setState({
|
|
650
|
+
isArtifactUploaderOpen: true
|
|
651
|
+
}),
|
|
652
|
+
onDelete: this.onCaptionDelete
|
|
653
|
+
}), /*#__PURE__*/React.createElement(CaptionsUploaderBrowser, {
|
|
654
|
+
identifier: identifier,
|
|
655
|
+
isOpen: isArtifactUploaderOpen,
|
|
656
|
+
onClose: () => this.setState({
|
|
657
|
+
isArtifactUploaderOpen: false
|
|
658
|
+
}),
|
|
659
|
+
onEnd: (metadata, context) => {
|
|
660
|
+
this.fireCaptionUploadSucceededEvent(context.traceId);
|
|
661
|
+
},
|
|
662
|
+
onError: (err, context) => {
|
|
663
|
+
this.fireCaptionUploadFailedEvent(context.traceId, err);
|
|
664
|
+
}
|
|
665
|
+
}), /*#__PURE__*/React.createElement(CaptionDeleteConfirmationModal, {
|
|
666
|
+
identifier: identifier,
|
|
667
|
+
artifactName: artifactToDelete,
|
|
668
|
+
onClose: () => this.setState({
|
|
669
|
+
artifactToDelete: ''
|
|
670
|
+
}),
|
|
671
|
+
onEnd: context => {
|
|
672
|
+
this.fireCaptionDeleteSucceededEvent(context.traceId, context.artifactName);
|
|
673
|
+
this.setState({
|
|
674
|
+
artifactToDelete: ''
|
|
675
|
+
});
|
|
676
|
+
},
|
|
677
|
+
onError: (err, context) => {
|
|
678
|
+
this.fireCaptionDeleteFailedEvent(context.traceId, context.artifactName, err);
|
|
679
|
+
this.setState({
|
|
680
|
+
artifactToDelete: ''
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
}));
|
|
684
|
+
});
|
|
558
685
|
this.state.selectedTracksIndex = this.findPreselectedTrackIndex(this.props);
|
|
559
686
|
if (this.mediaUserPreferences) {
|
|
560
687
|
const userCaptionsEnabled = getUserCaptionsEnabled(this.mediaUserPreferences);
|
|
@@ -602,9 +729,11 @@ class _MediaPlayerBase extends Component {
|
|
|
602
729
|
} = this.props;
|
|
603
730
|
const {
|
|
604
731
|
isFullScreenEnabled,
|
|
605
|
-
playerSize,
|
|
606
732
|
playbackSpeed
|
|
607
733
|
} = this.state;
|
|
734
|
+
const {
|
|
735
|
+
playerSize
|
|
736
|
+
} = this;
|
|
608
737
|
fireAnalyticsEvent(createCustomMediaPlayerScreenEvent(type, {
|
|
609
738
|
isAutoPlay,
|
|
610
739
|
isHDAvailable,
|
|
@@ -615,17 +744,18 @@ class _MediaPlayerBase extends Component {
|
|
|
615
744
|
}, identifier.id), createAnalyticsEvent);
|
|
616
745
|
if (this.videoWrapperRef.current) {
|
|
617
746
|
this.videoWrapperRef.current.addEventListener('fullscreenchange', this.onFullScreenChange);
|
|
747
|
+
this.onResize(this.videoWrapperRef.current.getBoundingClientRect().width);
|
|
618
748
|
}
|
|
619
749
|
simultaneousPlayManager.subscribe(this);
|
|
620
750
|
if (isAutoPlay) {
|
|
621
|
-
var _this$props$onPlay, _this$
|
|
751
|
+
var _this$props$onPlay, _this$props6;
|
|
622
752
|
simultaneousPlayManager.pauseOthers(this);
|
|
623
753
|
if (onFirstPlay) {
|
|
624
754
|
this.fireFirstPlayedTrackEvent();
|
|
625
755
|
this.wasPlayedOnce = true;
|
|
626
756
|
onFirstPlay();
|
|
627
757
|
}
|
|
628
|
-
(_this$props$onPlay = (_this$
|
|
758
|
+
(_this$props$onPlay = (_this$props6 = this.props).onPlay) === null || _this$props$onPlay === void 0 ? void 0 : _this$props$onPlay.call(_this$props6);
|
|
629
759
|
}
|
|
630
760
|
}
|
|
631
761
|
componentWillUnmount() {
|
|
@@ -633,11 +763,14 @@ class _MediaPlayerBase extends Component {
|
|
|
633
763
|
this.videoWrapperRef.current.removeEventListener('fullscreenchange', this.onFullScreenChange);
|
|
634
764
|
}
|
|
635
765
|
if (this.state.isFullScreenEnabled) {
|
|
636
|
-
var _this$props$onFullscr2, _this$
|
|
637
|
-
(_this$props$onFullscr2 = (_this$
|
|
766
|
+
var _this$props$onFullscr2, _this$props7;
|
|
767
|
+
(_this$props$onFullscr2 = (_this$props7 = this.props).onFullscreenChange) === null || _this$props$onFullscr2 === void 0 ? void 0 : _this$props$onFullscr2.call(_this$props7, false);
|
|
638
768
|
}
|
|
639
769
|
simultaneousPlayManager.unsubscribe(this);
|
|
640
770
|
}
|
|
771
|
+
get playerSize() {
|
|
772
|
+
return getPlayerSize(this.state.playerWidth);
|
|
773
|
+
}
|
|
641
774
|
setActions(actions) {
|
|
642
775
|
// Actions are being sent constantly while the video is playing,
|
|
643
776
|
// though play and pause functions are always the same objects
|
|
@@ -656,9 +789,11 @@ class _MediaPlayerBase extends Component {
|
|
|
656
789
|
} = this.props;
|
|
657
790
|
const {
|
|
658
791
|
isFullScreenEnabled,
|
|
659
|
-
playerSize,
|
|
660
792
|
playbackSpeed
|
|
661
793
|
} = this.state;
|
|
794
|
+
const {
|
|
795
|
+
playerSize
|
|
796
|
+
} = this;
|
|
662
797
|
const playbackState = {
|
|
663
798
|
...this.videoState,
|
|
664
799
|
isAutoPlay,
|
|
@@ -734,6 +869,9 @@ class _MediaPlayerBase extends Component {
|
|
|
734
869
|
artifactName
|
|
735
870
|
}, this.props.identifier.id, traceId, error));
|
|
736
871
|
}
|
|
872
|
+
get isPlaying() {
|
|
873
|
+
return this.videoState.status === 'playing';
|
|
874
|
+
}
|
|
737
875
|
render() {
|
|
738
876
|
const {
|
|
739
877
|
type,
|
|
@@ -743,18 +881,8 @@ class _MediaPlayerBase extends Component {
|
|
|
743
881
|
onError,
|
|
744
882
|
poster,
|
|
745
883
|
videoControlsWrapperRef,
|
|
746
|
-
|
|
747
|
-
areControlsVisible,
|
|
748
|
-
identifier,
|
|
749
|
-
mediaSettings: {
|
|
750
|
-
canUpdateVideoCaptions = false
|
|
751
|
-
} = {}
|
|
884
|
+
areControlsVisible
|
|
752
885
|
} = this.props;
|
|
753
|
-
const {
|
|
754
|
-
areCaptionsEnabled,
|
|
755
|
-
isArtifactUploaderOpen,
|
|
756
|
-
artifactToDelete
|
|
757
|
-
} = this.state;
|
|
758
886
|
return /*#__PURE__*/React.createElement(Box, {
|
|
759
887
|
xcss: customVideoWrapperStyles.root,
|
|
760
888
|
ref: this.videoWrapperRef,
|
|
@@ -776,36 +904,16 @@ class _MediaPlayerBase extends Component {
|
|
|
776
904
|
//Video State(either prop or variable) is ReadOnly
|
|
777
905
|
this.videoState = videoState;
|
|
778
906
|
const {
|
|
779
|
-
status,
|
|
780
907
|
currentTime,
|
|
781
908
|
buffered,
|
|
782
909
|
duration,
|
|
783
910
|
isLoading
|
|
784
911
|
} = videoState;
|
|
785
|
-
const {
|
|
786
|
-
playerSize
|
|
787
|
-
} = this.state;
|
|
788
|
-
const isPlaying = status === 'playing';
|
|
789
|
-
const isLargePlayer = playerSize === 'large';
|
|
790
|
-
const isMediumPlayer = playerSize === 'medium';
|
|
791
|
-
const defaultSkipAmount = 10;
|
|
792
|
-
const skipBackward = (skipAmount = defaultSkipAmount) => {
|
|
793
|
-
var _this$props$onTimeCha2, _this$props6;
|
|
794
|
-
const newTime = videoState.currentTime - skipAmount;
|
|
795
|
-
actions.navigate(Math.max(newTime, 0));
|
|
796
|
-
(_this$props$onTimeCha2 = (_this$props6 = this.props).onTimeChanged) === null || _this$props$onTimeCha2 === void 0 ? void 0 : _this$props$onTimeCha2.call(_this$props6);
|
|
797
|
-
};
|
|
798
|
-
const skipForward = (skipAmount = defaultSkipAmount) => {
|
|
799
|
-
var _this$props$onTimeCha3, _this$props7;
|
|
800
|
-
const newTime = videoState.currentTime + skipAmount;
|
|
801
|
-
actions.navigate(Math.min(newTime, videoState.duration));
|
|
802
|
-
(_this$props$onTimeCha3 = (_this$props7 = this.props).onTimeChanged) === null || _this$props$onTimeCha3 === void 0 ? void 0 : _this$props$onTimeCha3.call(_this$props7);
|
|
803
|
-
};
|
|
804
912
|
const shortcuts = this.renderShortcuts({
|
|
805
|
-
togglePlayPauseAction: isPlaying ? this.pause : this.play,
|
|
913
|
+
togglePlayPauseAction: this.isPlaying ? this.pause : this.play,
|
|
806
914
|
toggleMute: actions.toggleMute,
|
|
807
|
-
skipBackward,
|
|
808
|
-
skipForward
|
|
915
|
+
skipBackward: this.skipBackward,
|
|
916
|
+
skipForward: this.skipForward
|
|
809
917
|
});
|
|
810
918
|
return /*#__PURE__*/React.createElement(Flex, {
|
|
811
919
|
direction: "column",
|
|
@@ -814,7 +922,7 @@ class _MediaPlayerBase extends Component {
|
|
|
814
922
|
setWidth: this.onResize
|
|
815
923
|
}), shortcuts, isLoading && this.renderSpinner(), /*#__PURE__*/React.createElement(PlayPauseBlanket, {
|
|
816
924
|
onDoubleClick: this.doubleClickToFullscreen,
|
|
817
|
-
onClick: isPlaying ? this.pausePlayByBlanketClick : this.startPlayByBlanketClick,
|
|
925
|
+
onClick: this.isPlaying ? this.pausePlayByBlanketClick : this.startPlayByBlanketClick,
|
|
818
926
|
"data-testid": "play-pause-blanket"
|
|
819
927
|
}, video), /*#__PURE__*/React.createElement(ControlsWrapper, {
|
|
820
928
|
ref: videoControlsWrapperRef,
|
|
@@ -828,57 +936,15 @@ class _MediaPlayerBase extends Component {
|
|
|
828
936
|
onChange: actions.navigate,
|
|
829
937
|
onChanged: this.onTimeChanged,
|
|
830
938
|
disableThumbTooltip: true,
|
|
831
|
-
skipBackward: skipBackward,
|
|
832
|
-
skipForward: skipForward,
|
|
939
|
+
skipBackward: this.skipBackward,
|
|
940
|
+
skipForward: this.skipForward,
|
|
833
941
|
isAlwaysActive: false
|
|
834
942
|
})), /*#__PURE__*/React.createElement(Flex, {
|
|
835
943
|
alignItems: "center",
|
|
836
944
|
justifyContent: "space-between",
|
|
837
945
|
xcss: timebarWrapperStyles.root
|
|
838
|
-
}, /*#__PURE__*/React.createElement(LeftControls, null, this.
|
|
839
|
-
textTracks: textTracks,
|
|
840
|
-
onSelected: this.onTextTracksSelected,
|
|
841
|
-
areCaptionsEnabled: !!areCaptionsEnabled,
|
|
842
|
-
onCaptionsEnabledChange: this.onCaptionsEnabledChange,
|
|
843
|
-
selectedTracksIndex: this.resolveSelectedTracksIndex()
|
|
844
|
-
}), this.renderFullScreenButton(), isLargePlayer && this.renderDownloadButton(), isMediumPlayer || isLargePlayer && canUpdateVideoCaptions && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CaptionsAdminControls, {
|
|
845
|
-
textTracks: textTracks,
|
|
846
|
-
onUpload: () => this.setState({
|
|
847
|
-
isArtifactUploaderOpen: true
|
|
848
|
-
}),
|
|
849
|
-
onDelete: this.onCaptionDelete
|
|
850
|
-
}), /*#__PURE__*/React.createElement(CaptionsUploaderBrowser, {
|
|
851
|
-
identifier: identifier,
|
|
852
|
-
isOpen: isArtifactUploaderOpen,
|
|
853
|
-
onClose: () => this.setState({
|
|
854
|
-
isArtifactUploaderOpen: false
|
|
855
|
-
}),
|
|
856
|
-
onEnd: (metadata, context) => {
|
|
857
|
-
this.fireCaptionUploadSucceededEvent(context.traceId);
|
|
858
|
-
},
|
|
859
|
-
onError: (err, context) => {
|
|
860
|
-
this.fireCaptionUploadFailedEvent(context.traceId, err);
|
|
861
|
-
}
|
|
862
|
-
}), /*#__PURE__*/React.createElement(CaptionDeleteConfirmationModal, {
|
|
863
|
-
identifier: identifier,
|
|
864
|
-
artifactName: artifactToDelete,
|
|
865
|
-
onClose: () => this.setState({
|
|
866
|
-
artifactToDelete: ''
|
|
867
|
-
}),
|
|
868
|
-
onEnd: context => {
|
|
869
|
-
this.fireCaptionDeleteSucceededEvent(context.traceId, context.artifactName);
|
|
870
|
-
this.setState({
|
|
871
|
-
artifactToDelete: ''
|
|
872
|
-
});
|
|
873
|
-
},
|
|
874
|
-
onError: (err, context) => {
|
|
875
|
-
this.fireCaptionDeleteFailedEvent(context.traceId, context.artifactName, err);
|
|
876
|
-
this.setState({
|
|
877
|
-
artifactToDelete: ''
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
}))))));
|
|
946
|
+
}, /*#__PURE__*/React.createElement(LeftControls, null, this.shouldRenderPlayPauseButton() && this.renderPlayPauseButton(), this.shouldRenderSkipButtons() && this.renderSkipButtons(), this.shouldRenderVolume() && this.renderVolume()), /*#__PURE__*/React.createElement(RightControls, null, this.shouldRenderCurrentTime() && this.renderCurrentTime(), this.shouldRenderCaptionsControls() && this.renderCaptionsControls(), this.shouldRenderSpeedControls() && this.renderSpeedControls(), this.shouldRenderHdButton() && this.renderHDButton(), this.shouldRenderDownloadButton() && this.renderDownloadButton(), this.shouldRenderFullScreenButton() && this.renderFullScreenButton(), this.shouldRenderCaptionsAdminControls() && this.renderCaptionsAdminControls()))));
|
|
881
947
|
}));
|
|
882
948
|
}
|
|
883
949
|
}
|
|
884
|
-
export const MediaPlayerBase =
|
|
950
|
+
export const MediaPlayerBase = injectIntl(_MediaPlayerBase);
|