@atlaskit/media-ui 28.5.2 → 28.5.3

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 (29) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/customMediaPlayer/index.js +1 -1
  3. package/dist/cjs/customMediaPlayer/mediaPlayer/mediaPlayer.js +21 -6
  4. package/dist/cjs/customMediaPlayer/mediaPlayer/mediaPlayerBase.js +81 -147
  5. package/dist/cjs/customMediaPlayer/mediaPlayer/types.js +5 -0
  6. package/dist/cjs/customMediaPlayer/mediaPlayer/useTextTracks.js +139 -66
  7. package/dist/es2019/customMediaPlayer/index.js +1 -1
  8. package/dist/es2019/customMediaPlayer/mediaPlayer/mediaPlayer.js +21 -6
  9. package/dist/es2019/customMediaPlayer/mediaPlayer/mediaPlayerBase.js +29 -111
  10. package/dist/es2019/customMediaPlayer/mediaPlayer/types.js +1 -0
  11. package/dist/es2019/customMediaPlayer/mediaPlayer/useTextTracks.js +129 -43
  12. package/dist/esm/customMediaPlayer/index.js +1 -1
  13. package/dist/esm/customMediaPlayer/mediaPlayer/mediaPlayer.js +21 -6
  14. package/dist/esm/customMediaPlayer/mediaPlayer/mediaPlayerBase.js +81 -147
  15. package/dist/esm/customMediaPlayer/mediaPlayer/types.js +1 -0
  16. package/dist/esm/customMediaPlayer/mediaPlayer/useTextTracks.js +140 -67
  17. package/dist/types/customMediaPlayer/mediaPlayer/index.d.ts +2 -1
  18. package/dist/types/customMediaPlayer/mediaPlayer/mediaPlayer.d.ts +2 -3
  19. package/dist/types/customMediaPlayer/mediaPlayer/mediaPlayerBase.d.ts +1 -34
  20. package/dist/types/customMediaPlayer/mediaPlayer/types.d.ts +38 -0
  21. package/dist/types/customMediaPlayer/mediaPlayer/useTextTracks.d.ts +8 -2
  22. package/dist/types/customMediaPlayer/react-video-renderer/text.d.ts +3 -2
  23. package/dist/types-ts4.5/customMediaPlayer/mediaPlayer/index.d.ts +2 -1
  24. package/dist/types-ts4.5/customMediaPlayer/mediaPlayer/mediaPlayer.d.ts +2 -3
  25. package/dist/types-ts4.5/customMediaPlayer/mediaPlayer/mediaPlayerBase.d.ts +1 -34
  26. package/dist/types-ts4.5/customMediaPlayer/mediaPlayer/types.d.ts +38 -0
  27. package/dist/types-ts4.5/customMediaPlayer/mediaPlayer/useTextTracks.d.ts +8 -2
  28. package/dist/types-ts4.5/customMediaPlayer/react-video-renderer/text.d.ts +3 -2
  29. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/media-ui
2
2
 
3
+ ## 28.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#177475](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/177475)
8
+ [`1aab7f41921a4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1aab7f41921a4) -
9
+ Refactored Media Player to fetch captions on request. Moved all captions logic to internal hook.
10
+ - Updated dependencies
11
+
3
12
  ## 28.5.2
4
13
 
5
14
  ### Patch Changes
@@ -16,7 +16,7 @@ var CustomMediaPlayerBase = exports.CustomMediaPlayerBase = function CustomMedia
16
16
  return (0, _platformFeatureFlags.fg)('platform_media_compiled') ? /*#__PURE__*/_react.default.createElement(_indexCompiled.CustomMediaPlayerBase, props) : /*#__PURE__*/_react.default.createElement(_indexEmotion.CustomMediaPlayerBase, props);
17
17
  };
18
18
  var packageName = "@atlaskit/media-ui";
19
- var packageVersion = "28.5.1";
19
+ var packageVersion = "28.5.2";
20
20
 
21
21
  // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
22
22
  var CustomMediaPlayer = exports.CustomMediaPlayer = (0, _mediaCommon.withMediaAnalyticsContext)({
@@ -6,19 +6,22 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.MediaPlayerWihtoutContext = exports.MediaPlayer = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
10
  var _react = _interopRequireDefault(require("react"));
10
11
  var _mediaCommon = require("@atlaskit/media-common");
11
12
  var _mediaClientReact = require("@atlaskit/media-client-react");
12
13
  var _mediaPlayerBase = require("./mediaPlayerBase");
13
- var _useTextTracks = require("./useTextTracks");
14
+ var _useTextTracks2 = require("./useTextTracks");
14
15
  var _analyticsNext = require("@atlaskit/analytics-next");
16
+ var _excluded = ["onPlay"];
15
17
  var packageName = "@atlaskit/media-ui";
16
- var packageVersion = "28.5.1";
17
- var MediaPlayerWihtoutContext = exports.MediaPlayerWihtoutContext = function MediaPlayerWihtoutContext(props) {
18
+ var packageVersion = "28.5.2";
19
+ var MediaPlayerWihtoutContext = exports.MediaPlayerWihtoutContext = function MediaPlayerWihtoutContext(_ref) {
20
+ var _onPlay = _ref.onPlay,
21
+ props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
18
22
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
19
23
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
20
24
  var mediaSettings = (0, _mediaClientReact.useMediaSettings)();
21
- var mediaClient = (0, _mediaClientReact.useMediaClient)();
22
25
  var _props$identifier = props.identifier,
23
26
  id = _props$identifier.id,
24
27
  collectionName = _props$identifier.collectionName;
@@ -26,12 +29,24 @@ var MediaPlayerWihtoutContext = exports.MediaPlayerWihtoutContext = function Med
26
29
  collectionName: collectionName
27
30
  }),
28
31
  fileState = _useFileState.fileState;
29
- var textTracks = (0, _useTextTracks.useTextTracks)(fileState, mediaClient, collectionName);
32
+ var _useTextTracks = (0, _useTextTracks2.useTextTracks)(fileState, collectionName),
33
+ textTracks = _useTextTracks.textTracks,
34
+ verifyUserCaptionsEnabled = _useTextTracks.verifyUserCaptionsEnabled,
35
+ setSelectedTracksIndex = _useTextTracks.setSelectedTracksIndex,
36
+ setAreCaptionsEnabled = _useTextTracks.setAreCaptionsEnabled,
37
+ areCaptionsEnabled = _useTextTracks.areCaptionsEnabled;
30
38
  return /*#__PURE__*/_react.default.createElement(_mediaPlayerBase.MediaPlayerBase, (0, _extends2.default)({}, props, {
31
39
  fileState: fileState,
32
40
  mediaSettings: mediaSettings,
33
41
  textTracks: textTracks,
34
- createAnalyticsEvent: createAnalyticsEvent
42
+ createAnalyticsEvent: createAnalyticsEvent,
43
+ areCaptionsEnabled: areCaptionsEnabled,
44
+ onPlay: function onPlay() {
45
+ verifyUserCaptionsEnabled();
46
+ _onPlay === null || _onPlay === void 0 || _onPlay();
47
+ },
48
+ onTextTracksSelected: setSelectedTracksIndex,
49
+ onCaptionsEnabledChange: setAreCaptionsEnabled
35
50
  }));
36
51
  };
37
52
  var MediaPlayer = exports.MediaPlayer = (0, _mediaCommon.withMediaAnalyticsContext)({
@@ -50,7 +50,6 @@ var _legacyCustomIcons = require("@atlaskit/legacy-custom-icons");
50
50
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
51
51
  var _videoSkipForwardTen = _interopRequireDefault(require("@atlaskit/icon/core/video-skip-forward-ten"));
52
52
  var _videoSkipBackwardTen = _interopRequireDefault(require("@atlaskit/icon/core/video-skip-backward-ten"));
53
- var _captions = require("./captions");
54
53
  var _artifactUploader = require("./captions/artifactUploader");
55
54
  var _captionDeleteConfirmationModal = _interopRequireDefault(require("./captions/captionDeleteConfirmationModal"));
56
55
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -131,10 +130,13 @@ var spinnerWrapperStyles = {
131
130
  root: "_kqswstnw _154ize3t _1ltvze3t _1bsb1osq _4t3i1osq"
132
131
  };
133
132
  var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
134
- function _MediaPlayerBase(props) {
133
+ function _MediaPlayerBase() {
135
134
  var _this;
136
135
  (0, _classCallCheck2.default)(this, _MediaPlayerBase);
137
- _this = _callSuper(this, _MediaPlayerBase, [props]);
136
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
137
+ args[_key] = arguments[_key];
138
+ }
139
+ _this = _callSuper(this, _MediaPlayerBase, [].concat(args));
138
140
  (0, _defineProperty2.default)(_this, "videoWrapperRef", /*#__PURE__*/_react.default.createRef());
139
141
  (0, _defineProperty2.default)(_this, "videoState", {
140
142
  isLoading: true,
@@ -156,25 +158,9 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
156
158
  playerWidth: 100,
157
159
  // initial value for playerSize: 'small', i.e. width < 260px
158
160
  playbackSpeed: 1,
159
- selectedTracksIndex: -1,
160
- areCaptionsEnabled: false,
161
161
  isArtifactUploaderOpen: false,
162
162
  artifactToDelete: undefined
163
163
  });
164
- (0, _defineProperty2.default)(_this, "findPreselectedTrackIndex", function (_ref) {
165
- var _textTracks$captions;
166
- var textTracks = _ref.textTracks,
167
- intl = _ref.intl;
168
- return (0, _captions.findPreselectedTrackIndex)((textTracks === null || textTracks === void 0 || (_textTracks$captions = textTracks.captions) === null || _textTracks$captions === void 0 ? void 0 : _textTracks$captions.tracks) || [], intl.locale, _this.getUserCaptionsPreference());
169
- });
170
- (0, _defineProperty2.default)(_this, "getUserCaptionsPreference", function () {
171
- return _this.mediaUserPreferences && (0, _captions.getUserCaptionsLocale)(_this.mediaUserPreferences);
172
- });
173
- (0, _defineProperty2.default)(_this, "setUserCaptionsPreference", function (selectedTracks) {
174
- if (_this.mediaUserPreferences) {
175
- (0, _captions.setUserCaptionsLocale)(_this.mediaUserPreferences, selectedTracks.lang);
176
- }
177
- });
178
164
  (0, _defineProperty2.default)(_this, "fireFirstPlayedTrackEvent", function () {
179
165
  var _this$props = _this.props,
180
166
  type = _this$props.type,
@@ -373,11 +359,11 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
373
359
  })
374
360
  });
375
361
  });
376
- (0, _defineProperty2.default)(_this, "renderShortcuts", function (_ref2) {
377
- var togglePlayPauseAction = _ref2.togglePlayPauseAction,
378
- toggleMute = _ref2.toggleMute,
379
- skipBackward = _ref2.skipBackward,
380
- skipForward = _ref2.skipForward;
362
+ (0, _defineProperty2.default)(_this, "renderShortcuts", function (_ref) {
363
+ var togglePlayPauseAction = _ref.togglePlayPauseAction,
364
+ toggleMute = _ref.toggleMute,
365
+ skipBackward = _ref.skipBackward,
366
+ skipForward = _ref.skipForward;
381
367
  var isShortcutEnabled = _this.props.isShortcutEnabled;
382
368
  var isFullScreenEnabled = _this.state.isFullScreenEnabled;
383
369
  var shortcuts = (isShortcutEnabled || isFullScreenEnabled) && [/*#__PURE__*/_react.default.createElement(_shortcut.Shortcut, {
@@ -501,7 +487,9 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
501
487
  (_this$props$onPause = (_this$props9 = _this.props).onPause) === null || _this$props$onPause === void 0 || _this$props$onPause.call(_this$props9);
502
488
  });
503
489
  (0, _defineProperty2.default)(_this, "play", function () {
504
- var onFirstPlay = _this.props.onFirstPlay;
490
+ var _this$props0 = _this.props,
491
+ onFirstPlay = _this$props0.onFirstPlay,
492
+ onPlay = _this$props0.onPlay;
505
493
  if (_this.actions) {
506
494
  _this.actions.play();
507
495
  }
@@ -511,12 +499,7 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
511
499
  _this.wasPlayedOnce = true;
512
500
  onFirstPlay();
513
501
  }
514
- if (_this.mediaUserPreferences) {
515
- var userCaptionsEnabled = (0, _captions.getUserCaptionsEnabled)(_this.mediaUserPreferences);
516
- _this.setState({
517
- areCaptionsEnabled: userCaptionsEnabled
518
- });
519
- }
502
+ onPlay === null || onPlay === void 0 || onPlay();
520
503
  });
521
504
  (0, _defineProperty2.default)(_this, "getMediaButtonClickHandler", function (action, buttonType) {
522
505
  return function () {
@@ -535,13 +518,13 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
535
518
  };
536
519
  });
537
520
  (0, _defineProperty2.default)(_this, "onViewed", function (videoState) {
538
- var _this$props0 = _this.props,
539
- createAnalyticsEvent = _this$props0.createAnalyticsEvent,
540
- identifier = _this$props0.identifier,
541
- isAutoPlay = _this$props0.isAutoPlay,
542
- isHDAvailable = _this$props0.isHDAvailable,
543
- isHDActive = _this$props0.isHDActive,
544
- type = _this$props0.type;
521
+ var _this$props1 = _this.props,
522
+ createAnalyticsEvent = _this$props1.createAnalyticsEvent,
523
+ identifier = _this$props1.identifier,
524
+ isAutoPlay = _this$props1.isAutoPlay,
525
+ isHDAvailable = _this$props1.isHDAvailable,
526
+ isHDActive = _this$props1.isHDActive,
527
+ type = _this$props1.type;
545
528
  var _this$state2 = _this.state,
546
529
  isFullScreenEnabled = _this$state2.isFullScreenEnabled,
547
530
  playbackSpeed = _this$state2.playbackSpeed;
@@ -587,17 +570,12 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
587
570
  (0, _defineProperty2.default)(_this, "startPlayByButtonClick", _this.getMediaButtonClickHandler(_this.play, 'playButton'));
588
571
  (0, _defineProperty2.default)(_this, "pausePlayByButtonClick", _this.getMediaButtonClickHandler(_this.pause, 'pauseButton'));
589
572
  (0, _defineProperty2.default)(_this, "onTextTracksSelected", function (selectedTracksIndex) {
590
- var _this$props$textTrack;
591
- var selectedTracks = (_this$props$textTrack = _this.props.textTracks) === null || _this$props$textTrack === void 0 || (_this$props$textTrack = _this$props$textTrack.captions) === null || _this$props$textTrack === void 0 ? void 0 : _this$props$textTrack.tracks[selectedTracksIndex];
592
- !!selectedTracks && _this.setUserCaptionsPreference(selectedTracks);
593
- _this.setState({
594
- selectedTracksIndex: selectedTracksIndex
595
- });
573
+ var _this$props$onTextTra, _this$props10;
574
+ (_this$props$onTextTra = (_this$props10 = _this.props).onTextTracksSelected) === null || _this$props$onTextTra === void 0 || _this$props$onTextTra.call(_this$props10, selectedTracksIndex);
596
575
  });
597
576
  (0, _defineProperty2.default)(_this, "onCaptionsEnabledChange", function (areCaptionsEnabled) {
598
- _this.setState({
599
- areCaptionsEnabled: areCaptionsEnabled
600
- });
577
+ var _this$props$onCaption, _this$props11;
578
+ (_this$props$onCaption = (_this$props11 = _this.props).onCaptionsEnabledChange) === null || _this$props$onCaption === void 0 || _this$props$onCaption.call(_this$props11, areCaptionsEnabled);
601
579
  });
602
580
  (0, _defineProperty2.default)(_this, "onCaptionDelete", function (artifactName) {
603
581
  // Modal is not supported in fullscreen mode (as it uses portals which are not in the same DOM tree),
@@ -609,37 +587,24 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
609
587
  artifactToDelete: artifactName
610
588
  });
611
589
  });
612
- (0, _defineProperty2.default)(_this, "resolveSelectedTracksIndex", function () {
613
- var _this$state3 = _this.state,
614
- areCaptionsEnabled = _this$state3.areCaptionsEnabled,
615
- selectedTracksIndex = _this$state3.selectedTracksIndex;
616
- return areCaptionsEnabled ? selectedTracksIndex > -1 ? selectedTracksIndex : 0 : -1;
617
- });
618
- (0, _defineProperty2.default)(_this, "resolveTextTracks", function () {
619
- var areCaptionsEnabled = _this.state.areCaptionsEnabled;
620
- var textTracks = _this.props.textTracks;
621
- var tracksKey = 'captions';
622
- if (areCaptionsEnabled && textTracks !== null && textTracks !== void 0 && textTracks[tracksKey]) {
623
- return _objectSpread(_objectSpread({}, textTracks), {}, (0, _defineProperty2.default)({}, tracksKey, _objectSpread(_objectSpread({}, textTracks[tracksKey]), {}, {
624
- selectedTrackIndex: _this.resolveSelectedTracksIndex()
625
- })));
626
- }
627
- return undefined;
628
- });
629
590
  (0, _defineProperty2.default)(_this, "shouldRenderCaptionsControls", function () {
591
+ var _textTracks$captions;
630
592
  var textTracks = _this.props.textTracks;
631
593
  var playerWidth = _this.state.playerWidth;
632
- return breakpointControls.captionsControls(playerWidth) && !!textTracks;
594
+ return breakpointControls.captionsControls(playerWidth) && !!textTracks && !!((_textTracks$captions = textTracks.captions) !== null && _textTracks$captions !== void 0 && (_textTracks$captions = _textTracks$captions.tracks) !== null && _textTracks$captions !== void 0 && _textTracks$captions.length);
633
595
  });
634
596
  (0, _defineProperty2.default)(_this, "renderCaptionsControls", function () {
635
597
  var textTracks = _this.props.textTracks;
636
- var areCaptionsEnabled = _this.state.areCaptionsEnabled;
598
+ var _ref2 = (textTracks === null || textTracks === void 0 ? void 0 : textTracks.captions) || {},
599
+ _ref2$selectedTrackIn = _ref2.selectedTrackIndex,
600
+ selectedTrackIndex = _ref2$selectedTrackIn === void 0 ? -1 : _ref2$selectedTrackIn;
601
+ var areCaptionsEnabled = _this.props.areCaptionsEnabled;
637
602
  return textTracks && /*#__PURE__*/_react.default.createElement(_captionsSelectControls.CaptionsSelectControls, {
638
603
  textTracks: textTracks,
639
604
  onSelected: _this.onTextTracksSelected,
640
605
  areCaptionsEnabled: !!areCaptionsEnabled,
641
606
  onCaptionsEnabledChange: _this.onCaptionsEnabledChange,
642
- selectedTracksIndex: _this.resolveSelectedTracksIndex()
607
+ selectedTracksIndex: selectedTrackIndex
643
608
  });
644
609
  });
645
610
  (0, _defineProperty2.default)(_this, "shouldRenderCaptionsAdminControls", function () {
@@ -648,12 +613,12 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
648
613
  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);
649
614
  });
650
615
  (0, _defineProperty2.default)(_this, "renderCaptionsAdminControls", function () {
651
- var _this$state4 = _this.state,
652
- isArtifactUploaderOpen = _this$state4.isArtifactUploaderOpen,
653
- artifactToDelete = _this$state4.artifactToDelete;
654
- var _this$props1 = _this.props,
655
- textTracks = _this$props1.textTracks,
656
- identifier = _this$props1.identifier;
616
+ var _this$state3 = _this.state,
617
+ isArtifactUploaderOpen = _this$state3.isArtifactUploaderOpen,
618
+ artifactToDelete = _this$state3.artifactToDelete;
619
+ var _this$props12 = _this.props,
620
+ textTracks = _this$props12.textTracks,
621
+ identifier = _this$props12.identifier;
657
622
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_captionsAdminControls.CaptionsAdminControls, {
658
623
  textTracks: textTracks,
659
624
  onUpload: function onUpload() {
@@ -698,57 +663,23 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
698
663
  }
699
664
  }));
700
665
  });
701
- _this.state.selectedTracksIndex = _this.findPreselectedTrackIndex(_this.props);
702
- if (_this.mediaUserPreferences) {
703
- var userCaptionsEnabled = (0, _captions.getUserCaptionsEnabled)(_this.mediaUserPreferences);
704
- _this.state.areCaptionsEnabled = userCaptionsEnabled;
705
- }
706
666
  return _this;
707
667
  }
708
668
  (0, _inherits2.default)(_MediaPlayerBase, _Component);
709
669
  return (0, _createClass2.default)(_MediaPlayerBase, [{
710
- key: "componentDidUpdate",
711
- value: function componentDidUpdate(prevProps, prevState) {
712
- var _prevTextTracks$capti, _textTracks$captions2;
713
- var _this$props10 = this.props,
714
- intl = _this$props10.intl,
715
- textTracks = _this$props10.textTracks;
716
- var prevIntl = prevProps.intl,
717
- prevTextTracks = prevProps.textTracks;
718
- var didLocaleChange = prevIntl.locale !== intl.locale;
719
- var didTextTracksChange = (prevTextTracks === null || prevTextTracks === void 0 || (_prevTextTracks$capti = prevTextTracks.captions) === null || _prevTextTracks$capti === void 0 ? void 0 : _prevTextTracks$capti.tracks) !== (textTracks === null || textTracks === void 0 || (_textTracks$captions2 = textTracks.captions) === null || _textTracks$captions2 === void 0 ? void 0 : _textTracks$captions2.tracks);
720
- if (didLocaleChange || didTextTracksChange) {
721
- this.setState({
722
- selectedTracksIndex: this.findPreselectedTrackIndex(this.props)
723
- });
724
- }
725
- if (this.mediaUserPreferences && prevState.areCaptionsEnabled !== this.state.areCaptionsEnabled) {
726
- (0, _captions.setUserCaptionsEnabled)(this.mediaUserPreferences, !!this.state.areCaptionsEnabled);
727
- }
728
- }
729
- }, {
730
- key: "mediaUserPreferences",
731
- get: function get() {
732
- var _this$props$mediaSett2 = this.props.mediaSettings,
733
- _this$props$mediaSett3 = _this$props$mediaSett2 === void 0 ? {} : _this$props$mediaSett2,
734
- _this$props$mediaSett4 = _this$props$mediaSett3.mediaUserPreferences,
735
- mediaUserPreferences = _this$props$mediaSett4 === void 0 ? undefined : _this$props$mediaSett4;
736
- return mediaUserPreferences;
737
- }
738
- }, {
739
670
  key: "componentDidMount",
740
671
  value: function componentDidMount() {
741
- var _this$props11 = this.props,
742
- type = _this$props11.type,
743
- identifier = _this$props11.identifier,
744
- isAutoPlay = _this$props11.isAutoPlay,
745
- isHDAvailable = _this$props11.isHDAvailable,
746
- isHDActive = _this$props11.isHDActive,
747
- onFirstPlay = _this$props11.onFirstPlay,
748
- createAnalyticsEvent = _this$props11.createAnalyticsEvent;
749
- var _this$state5 = this.state,
750
- isFullScreenEnabled = _this$state5.isFullScreenEnabled,
751
- playbackSpeed = _this$state5.playbackSpeed;
672
+ var _this$props13 = this.props,
673
+ type = _this$props13.type,
674
+ identifier = _this$props13.identifier,
675
+ isAutoPlay = _this$props13.isAutoPlay,
676
+ isHDAvailable = _this$props13.isHDAvailable,
677
+ isHDActive = _this$props13.isHDActive,
678
+ onFirstPlay = _this$props13.onFirstPlay,
679
+ createAnalyticsEvent = _this$props13.createAnalyticsEvent;
680
+ var _this$state4 = this.state,
681
+ isFullScreenEnabled = _this$state4.isFullScreenEnabled,
682
+ playbackSpeed = _this$state4.playbackSpeed;
752
683
  var playerSize = this.playerSize;
753
684
  (0, _analytics.fireAnalyticsEvent)((0, _analytics.createCustomMediaPlayerScreenEvent)(type, {
754
685
  isAutoPlay: isAutoPlay,
@@ -764,14 +695,14 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
764
695
  }
765
696
  _simultaneousPlayManager.default.subscribe(this);
766
697
  if (isAutoPlay) {
767
- var _this$props$onPlay, _this$props12;
698
+ var _this$props$onPlay, _this$props14;
768
699
  _simultaneousPlayManager.default.pauseOthers(this);
769
700
  if (onFirstPlay) {
770
701
  this.fireFirstPlayedTrackEvent();
771
702
  this.wasPlayedOnce = true;
772
703
  onFirstPlay();
773
704
  }
774
- (_this$props$onPlay = (_this$props12 = this.props).onPlay) === null || _this$props$onPlay === void 0 || _this$props$onPlay.call(_this$props12);
705
+ (_this$props$onPlay = (_this$props14 = this.props).onPlay) === null || _this$props$onPlay === void 0 || _this$props$onPlay.call(_this$props14);
775
706
  }
776
707
  }
777
708
  }, {
@@ -781,8 +712,8 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
781
712
  this.videoWrapperRef.current.removeEventListener('fullscreenchange', this.onFullScreenChange);
782
713
  }
783
714
  if (this.state.isFullScreenEnabled) {
784
- var _this$props$onFullscr2, _this$props13;
785
- (_this$props$onFullscr2 = (_this$props13 = this.props).onFullscreenChange) === null || _this$props$onFullscr2 === void 0 || _this$props$onFullscr2.call(_this$props13, false);
715
+ var _this$props$onFullscr2, _this$props15;
716
+ (_this$props$onFullscr2 = (_this$props15 = this.props).onFullscreenChange) === null || _this$props$onFullscr2 === void 0 || _this$props$onFullscr2.call(_this$props15, false);
786
717
  }
787
718
  _simultaneousPlayManager.default.unsubscribe(this);
788
719
  }
@@ -803,16 +734,16 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
803
734
  }, {
804
735
  key: "createAndFireUIEvent",
805
736
  value: function createAndFireUIEvent(eventType, actionSubjectId) {
806
- var _this$props14 = this.props,
807
- type = _this$props14.type,
808
- identifier = _this$props14.identifier,
809
- isHDActive = _this$props14.isHDActive,
810
- isHDAvailable = _this$props14.isHDAvailable,
811
- isAutoPlay = _this$props14.isAutoPlay,
812
- createAnalyticsEvent = _this$props14.createAnalyticsEvent;
813
- var _this$state6 = this.state,
814
- isFullScreenEnabled = _this$state6.isFullScreenEnabled,
815
- playbackSpeed = _this$state6.playbackSpeed;
737
+ var _this$props16 = this.props,
738
+ type = _this$props16.type,
739
+ identifier = _this$props16.identifier,
740
+ isHDActive = _this$props16.isHDActive,
741
+ isHDAvailable = _this$props16.isHDAvailable,
742
+ isAutoPlay = _this$props16.isAutoPlay,
743
+ createAnalyticsEvent = _this$props16.createAnalyticsEvent;
744
+ var _this$state5 = this.state,
745
+ isFullScreenEnabled = _this$state5.isFullScreenEnabled,
746
+ playbackSpeed = _this$state5.playbackSpeed;
816
747
  var playerSize = this.playerSize;
817
748
  var playbackState = _objectSpread(_objectSpread({}, this.videoState), {}, {
818
749
  isAutoPlay: isAutoPlay,
@@ -855,13 +786,15 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
855
786
  }, {
856
787
  key: "baseAnalyticCaptionAttributes",
857
788
  value: function baseAnalyticCaptionAttributes() {
858
- var _textTracks$captions3, _textTracks$captions4;
789
+ var _textTracks$captions2, _textTracks$captions3;
859
790
  var textTracks = this.props.textTracks;
860
- var selectedTracksIndex = this.state.selectedTracksIndex;
791
+ var _ref3 = (textTracks === null || textTracks === void 0 ? void 0 : textTracks.captions) || {},
792
+ _ref3$selectedTrackIn = _ref3.selectedTrackIndex,
793
+ selectedTrackIndex = _ref3$selectedTrackIn === void 0 ? -1 : _ref3$selectedTrackIn;
861
794
  var captionAttributes = {
862
- selectedTrackIndex: selectedTracksIndex,
863
- availableCaptionTracks: (textTracks === null || textTracks === void 0 || (_textTracks$captions3 = textTracks.captions) === null || _textTracks$captions3 === void 0 || (_textTracks$captions3 = _textTracks$captions3.tracks) === null || _textTracks$captions3 === void 0 ? void 0 : _textTracks$captions3.length) || 0,
864
- selectedTrackLanguage: (textTracks === null || textTracks === void 0 || (_textTracks$captions4 = textTracks.captions) === null || _textTracks$captions4 === void 0 || (_textTracks$captions4 = _textTracks$captions4.tracks) === null || _textTracks$captions4 === void 0 || (_textTracks$captions4 = _textTracks$captions4[selectedTracksIndex]) === null || _textTracks$captions4 === void 0 ? void 0 : _textTracks$captions4.lang) || null
795
+ selectedTrackIndex: selectedTrackIndex,
796
+ availableCaptionTracks: (textTracks === null || textTracks === void 0 || (_textTracks$captions2 = textTracks.captions) === null || _textTracks$captions2 === void 0 || (_textTracks$captions2 = _textTracks$captions2.tracks) === null || _textTracks$captions2 === void 0 ? void 0 : _textTracks$captions2.length) || 0,
797
+ selectedTrackLanguage: (textTracks === null || textTracks === void 0 || (_textTracks$captions3 = textTracks.captions) === null || _textTracks$captions3 === void 0 || (_textTracks$captions3 = _textTracks$captions3.tracks) === null || _textTracks$captions3 === void 0 || (_textTracks$captions3 = _textTracks$captions3[selectedTrackIndex]) === null || _textTracks$captions3 === void 0 ? void 0 : _textTracks$captions3.lang) || null
865
798
  };
866
799
  return captionAttributes;
867
800
  }
@@ -903,15 +836,16 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
903
836
  key: "render",
904
837
  value: function render() {
905
838
  var _this4 = this;
906
- var _this$props15 = this.props,
907
- type = _this$props15.type,
908
- src = _this$props15.src,
909
- isAutoPlay = _this$props15.isAutoPlay,
910
- onCanPlay = _this$props15.onCanPlay,
911
- onError = _this$props15.onError,
912
- poster = _this$props15.poster,
913
- videoControlsWrapperRef = _this$props15.videoControlsWrapperRef,
914
- areControlsVisible = _this$props15.areControlsVisible;
839
+ var _this$props17 = this.props,
840
+ type = _this$props17.type,
841
+ src = _this$props17.src,
842
+ isAutoPlay = _this$props17.isAutoPlay,
843
+ onCanPlay = _this$props17.onCanPlay,
844
+ onError = _this$props17.onError,
845
+ poster = _this$props17.poster,
846
+ videoControlsWrapperRef = _this$props17.videoControlsWrapperRef,
847
+ areControlsVisible = _this$props17.areControlsVisible,
848
+ textTracks = _this$props17.textTracks;
915
849
  return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
916
850
  xcss: customVideoWrapperStyles.root,
917
851
  ref: this.videoWrapperRef,
@@ -925,7 +859,7 @@ var _MediaPlayerBase = /*#__PURE__*/function (_Component) {
925
859
  onTimeChange: this.onCurrentTimeChange,
926
860
  onError: onError,
927
861
  poster: poster,
928
- textTracks: this.resolveTextTracks(),
862
+ textTracks: textTracks,
929
863
  textTracksPosition: areControlsVisible ? -3.7 : undefined
930
864
  }, function (video, videoState, actions) {
931
865
  _this4.onViewed(videoState);
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });