@desynova-digital/player 4.2.1 → 4.2.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.
@@ -303,7 +303,7 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
303
303
  key: "combineM3U8Manifests",
304
304
  value: function () {
305
305
  var _combineM3U8Manifests = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(originalUrl, dubbedUrl, additionalTrackUrl) {
306
- var fetchManifest, fetchPromises, contents, originalContent, dubbedContent, additionalContent, extractAudioTracks, extractVideoStream, originalBase, dubbedBase, additionalBase, videoStreamUri, originalAudioTracks, dubbedAudioTracks, additionalAudioTracks, allTracksMap, allAudioTracks, combinedManifest, _i, _allAudioTracks, track;
306
+ var fetchManifest, fetchPromises, hasDubbed, hasAdditional, contents, originalContent, dubbedContent, additionalContent, extractAudioTracks, extractVideoStream, originalBase, dubbedBase, additionalBase, videoStreamUri, originalAudioTracks, dubbedAudioTracks, additionalAudioTracks, allTracksMap, allAudioTracks, combinedManifest, _i, _allAudioTracks, track;
307
307
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
308
308
  while (1) switch (_context2.prev = _context2.next) {
309
309
  case 0:
@@ -335,15 +335,23 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
335
335
  };
336
336
  }(); // Fetch all manifests
337
337
  fetchPromises = [fetchManifest(originalUrl)];
338
- if (dubbedUrl) fetchPromises.push(fetchManifest(dubbedUrl));
339
- if (additionalTrackUrl) fetchPromises.push(fetchManifest(additionalTrackUrl));
340
- _context2.next = 6;
338
+ hasDubbed = dubbedUrl && dubbedUrl.trim() !== '';
339
+ hasAdditional = additionalTrackUrl && additionalTrackUrl.trim() !== '';
340
+ if (hasDubbed) fetchPromises.push(fetchManifest(dubbedUrl));
341
+ if (hasAdditional) fetchPromises.push(fetchManifest(additionalTrackUrl));
342
+ _context2.next = 8;
341
343
  return Promise.all(fetchPromises);
342
- case 6:
344
+ case 8:
343
345
  contents = _context2.sent;
344
346
  originalContent = contents[0];
345
- dubbedContent = contents[1];
346
- additionalContent = contents[2];
347
+ dubbedContent = undefined;
348
+ additionalContent = undefined;
349
+ if (hasDubbed) {
350
+ dubbedContent = contents[1];
351
+ if (hasAdditional) additionalContent = contents[2];
352
+ } else if (hasAdditional) {
353
+ additionalContent = contents[1];
354
+ }
347
355
  extractAudioTracks = function extractAudioTracks(content, baseUrl) {
348
356
  var lines = content.split(/\r?\n/);
349
357
  var audioTracks = [];
@@ -393,7 +401,7 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
393
401
  };
394
402
  originalBase = originalUrl;
395
403
  dubbedBase = dubbedUrl;
396
- additionalBase = additionalTrackUrl || originalUrl;
404
+ additionalBase = additionalTrackUrl;
397
405
  videoStreamUri = extractVideoStream(originalContent, originalBase);
398
406
  originalAudioTracks = extractAudioTracks(originalContent, originalBase);
399
407
  dubbedAudioTracks = dubbedUrl ? extractAudioTracks(dubbedContent, dubbedBase) : [];
@@ -433,7 +441,7 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
433
441
  dubbedTrackInfo: this.dubbedTrackInfo,
434
442
  additionalTrackInfo: this.additionalTrackInfo
435
443
  });
436
- case 30:
444
+ case 33:
437
445
  case "end":
438
446
  return _context2.stop();
439
447
  }
@@ -448,7 +456,10 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
448
456
  key: "componentDidMount",
449
457
  value: function componentDidMount() {
450
458
  var _this2 = this;
451
- var src = this.props.src;
459
+ var _this$props4 = this.props,
460
+ src = _this$props4.src,
461
+ dubbedTracks = _this$props4.dubbedTracks,
462
+ additionalTracks = _this$props4.additionalTracks;
452
463
  var isM3U8 = src.split('.').pop() === 'm3u8';
453
464
  this.setState({
454
465
  isM3U8: isM3U8
@@ -457,7 +468,7 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
457
468
  var _this$manager$getStat = this.manager.getState(),
458
469
  HLSConfig = _this$manager$getStat.player.HLSConfig;
459
470
  this.hls = new _hls["default"](HLSConfig);
460
- this.setupHLS(src);
471
+ this.setupHLS(src, dubbedTracks, additionalTracks);
461
472
  } else {
462
473
  this.video.src = src;
463
474
  }
@@ -486,12 +497,12 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
486
497
  value: function componentDidUpdate(prevProps) {
487
498
  var _this3 = this,
488
499
  _prevProps$player;
489
- var _this$props4 = this.props,
490
- parentAnnotations = _this$props4.parentAnnotations,
491
- inTime = _this$props4.inTime,
492
- outTime = _this$props4.outTime,
493
- isRightMenuVisible = _this$props4.isRightMenuVisible,
494
- player = _this$props4.player;
500
+ var _this$props5 = this.props,
501
+ parentAnnotations = _this$props5.parentAnnotations,
502
+ inTime = _this$props5.inTime,
503
+ outTime = _this$props5.outTime,
504
+ isRightMenuVisible = _this$props5.isRightMenuVisible,
505
+ player = _this$props5.player;
495
506
  var hasNewAnnotations = JSON.stringify(parentAnnotations) !== JSON.stringify(prevProps.parentAnnotations);
496
507
  if (hasNewAnnotations) {
497
508
  Promise.resolve().then(function () {
@@ -548,9 +559,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
548
559
  */
549
560
  function checkWatermark() {
550
561
  var watermark = this.state.watermark;
551
- var _this$props5 = this.props,
552
- onPlayerClose = _this$props5.onPlayerClose,
553
- userEmail = _this$props5.userEmail;
562
+ var _this$props6 = this.props,
563
+ onPlayerClose = _this$props6.onPlayerClose,
564
+ userEmail = _this$props6.userEmail;
554
565
  var watermark_text = document.querySelector('#watermark-text');
555
566
  var video_player = null;
556
567
  var watermark_dimension = null;
@@ -585,9 +596,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
585
596
  var _this4 = this;
586
597
  var dubbedTracksOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
587
598
  var additionalTracksOverride = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
588
- var _this$props6 = this.props,
589
- actions = _this$props6.actions,
590
- activeTrackIndex = _this$props6.activeTrackIndex;
599
+ var _this$props7 = this.props,
600
+ actions = _this$props7.actions,
601
+ activeTrackIndex = _this$props7.activeTrackIndex;
591
602
  var self = this;
592
603
  var effectiveDubbedTracks = dubbedTracksOverride !== undefined ? dubbedTracksOverride : this.props.dubbedTracks;
593
604
  var effectiveAdditionalTracks = additionalTracksOverride !== undefined ? additionalTracksOverride : this.props.additionalTracks;
@@ -600,6 +611,14 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
600
611
  };
601
612
  var hasDubbed = effectiveDubbedTracks && effectiveDubbedTracks.trim() !== '';
602
613
  var hasAdditionalTracks = effectiveAdditionalTracks && effectiveAdditionalTracks.trim() !== '';
614
+ if (this.combinedManifestUrl) {
615
+ try {
616
+ URL.revokeObjectURL(this.combinedManifestUrl);
617
+ } catch (e) {
618
+ console.warn('Error revoking blob URL in setupHLS:', e);
619
+ }
620
+ this.combinedManifestUrl = null;
621
+ }
603
622
  if (hasDubbed || hasAdditionalTracks) {
604
623
  this.combineM3U8Manifests(originalSrc, hasDubbed ? effectiveDubbedTracks : null, hasAdditionalTracks ? effectiveAdditionalTracks : null).then(function (_ref2) {
605
624
  var combinedManifest = _ref2.combinedManifest,
@@ -628,7 +647,7 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
628
647
  var audioTracksWithFlags = (data.audioTracks || []).map(function (track) {
629
648
  var flaggedTrack = _objectSpread({}, track);
630
649
  // Match by NAME and URI
631
- if (self.dubbedTrackInfo && self.dubbedTrackInfo.length > 0) {
650
+ if (self.dubbedTrackInfo && self.dubbedTrackInfo.length > 0 && hasDubbed) {
632
651
  var matched = self.dubbedTrackInfo.some(function (dubbedTrack) {
633
652
  return dubbedTrack.name === track.name && dubbedTrack.uri === track.url;
634
653
  });
@@ -636,7 +655,7 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
636
655
  flaggedTrack.isDubbedTrack = true;
637
656
  }
638
657
  }
639
- if (self.additionalTrackInfo && self.additionalTrackInfo.length > 0) {
658
+ if (self.additionalTrackInfo && self.additionalTrackInfo.length > 0 && hasAdditionalTracks) {
640
659
  var _matched = self.additionalTrackInfo.some(function (additionalTrack) {
641
660
  return additionalTrack.name === track.name && additionalTrack.uri === track.url;
642
661
  });
@@ -684,7 +703,12 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
684
703
  self.hls.off(_hls["default"].Events.AUDIO_TRACK_SWITCHED, _onTrackSwitched);
685
704
  };
686
705
  self.hls.on(_hls["default"].Events.AUDIO_TRACK_SWITCHED, _onTrackSwitched);
687
- self.hls.audioTrack = defaultIndex;
706
+ var maxTrackIndex = audioTracksWithFlags.length - 1;
707
+ var safeTrackIndex = Math.min(defaultIndex, maxTrackIndex);
708
+ if (safeTrackIndex !== defaultIndex) {
709
+ console.warn("[Video] Clamping audio track from ".concat(defaultIndex, " to ").concat(safeTrackIndex, " (max: ").concat(maxTrackIndex, ")"));
710
+ }
711
+ self.hls.audioTrack = safeTrackIndex;
688
712
  });
689
713
  this.hls.on(_hls["default"].Events.ERROR, function (event, data) {
690
714
  console.log('HLS.Events.ERROR: ', event, data);
@@ -791,16 +815,16 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
791
815
  }, {
792
816
  key: "getStyle",
793
817
  value: function getStyle() {
794
- var _this$props7 = this.props,
795
- fluid = _this$props7.fluid,
796
- noRightComponent = _this$props7.noRightComponent;
818
+ var _this$props8 = this.props,
819
+ fluid = _this$props8.fluid,
820
+ noRightComponent = _this$props8.noRightComponent;
797
821
  var _this$manager$getStat2 = this.manager.getState(),
798
822
  player = _this$manager$getStat2.player;
799
823
  var style = {};
800
- var _this$props8 = this.props,
801
- aspectRatio = _this$props8.aspectRatio,
802
- width = _this$props8.width,
803
- height = _this$props8.height;
824
+ var _this$props9 = this.props,
825
+ aspectRatio = _this$props9.aspectRatio,
826
+ width = _this$props9.width,
827
+ height = _this$props9.height;
804
828
  /*
805
829
  * The aspect ratio is either used directly
806
830
  * or to calculate width and height.
@@ -904,29 +928,37 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
904
928
  }, {
905
929
  key: "UNSAFE_componentWillReceiveProps",
906
930
  value: function UNSAFE_componentWillReceiveProps(newProps) {
907
- var _this$props9 = this.props,
908
- src = _this$props9.src,
909
- dubbedTracks = _this$props9.dubbedTracks,
910
- additionalTracks = _this$props9.additionalTracks,
911
- activeAudio = _this$props9.player.activeAudio,
912
- currentSubtitleObj = _this$props9.currentSubtitleObj,
913
- markers = _this$props9.markers,
914
- playerType = _this$props9.playerType;
931
+ var _this$props10 = this.props,
932
+ src = _this$props10.src,
933
+ dubbedTracks = _this$props10.dubbedTracks,
934
+ additionalTracks = _this$props10.additionalTracks,
935
+ activeAudio = _this$props10.player.activeAudio,
936
+ currentSubtitleObj = _this$props10.currentSubtitleObj,
937
+ markers = _this$props10.markers,
938
+ playerType = _this$props10.playerType;
915
939
  if (markers && markers !== newProps.markers && newProps.markers) {
916
940
  this.displaySubtitle(newProps.markers);
917
941
  }
918
942
  if (newProps.src !== src || newProps.dubbedTracks !== dubbedTracks || newProps.additionalTracks !== additionalTracks) {
919
943
  var isM3U8 = this.state.isM3U8;
944
+ var oldCombinedUrl = this.combinedManifestUrl;
920
945
  if (_hls["default"].isSupported() && isM3U8) {
921
946
  if (this.hls) {
922
947
  this.hls.detachMedia();
923
948
  this.hls.destroy();
949
+ this.hls = null;
924
950
  }
925
951
  } else if (this.video) {
926
952
  this.video.src = '';
927
953
  }
928
- if (this.combinedManifestUrl) {
929
- URL.revokeObjectURL(this.combinedManifestUrl);
954
+ this.dubbedTrackInfo = [];
955
+ this.additionalTrackInfo = [];
956
+ if (oldCombinedUrl) {
957
+ try {
958
+ URL.revokeObjectURL(oldCombinedUrl);
959
+ } catch (e) {
960
+ console.warn('Error revoking blob URL:', e);
961
+ }
930
962
  this.combinedManifestUrl = null;
931
963
  }
932
964
  var m3u8 = newProps.src.split('.').pop() === 'm3u8';
@@ -1079,9 +1111,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1079
1111
  }, {
1080
1112
  key: "toggleFullscreen",
1081
1113
  value: function toggleFullscreen() {
1082
- var _this$props10 = this.props,
1083
- player = _this$props10.player,
1084
- actions = _this$props10.actions;
1114
+ var _this$props11 = this.props,
1115
+ player = _this$props11.player,
1116
+ actions = _this$props11.actions;
1085
1117
  actions.toggleFullscreen(player);
1086
1118
  }
1087
1119
 
@@ -1092,10 +1124,10 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1092
1124
  }, {
1093
1125
  key: "handleLoadStart",
1094
1126
  value: function handleLoadStart() {
1095
- var _this$props11 = this.props,
1096
- actions = _this$props11.actions,
1097
- onLoadStart = _this$props11.onLoadStart,
1098
- fileType = _this$props11.fileType;
1127
+ var _this$props12 = this.props,
1128
+ actions = _this$props12.actions,
1129
+ onLoadStart = _this$props12.onLoadStart,
1130
+ fileType = _this$props12.fileType;
1099
1131
  if (fileType === 'audio') {
1100
1132
  this.audioVisualizer();
1101
1133
  }
@@ -1112,9 +1144,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1112
1144
  }, {
1113
1145
  key: "handleCanPlay",
1114
1146
  value: function handleCanPlay() {
1115
- var _this$props12 = this.props,
1116
- actions = _this$props12.actions,
1117
- onCanPlay = _this$props12.onCanPlay;
1147
+ var _this$props13 = this.props,
1148
+ actions = _this$props13.actions,
1149
+ onCanPlay = _this$props13.onCanPlay;
1118
1150
  actions.handleCanPlay(this.getProperties());
1119
1151
  if (onCanPlay) {
1120
1152
  onCanPlay.apply(void 0, arguments);
@@ -1128,9 +1160,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1128
1160
  }, {
1129
1161
  key: "handleCanPlayThrough",
1130
1162
  value: function handleCanPlayThrough() {
1131
- var _this$props13 = this.props,
1132
- actions = _this$props13.actions,
1133
- onCanPlayThrough = _this$props13.onCanPlayThrough;
1163
+ var _this$props14 = this.props,
1164
+ actions = _this$props14.actions,
1165
+ onCanPlayThrough = _this$props14.onCanPlayThrough;
1134
1166
  actions.handleCanPlayThrough(this.getProperties());
1135
1167
  if (onCanPlayThrough) {
1136
1168
  onCanPlayThrough.apply(void 0, arguments);
@@ -1144,9 +1176,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1144
1176
  }, {
1145
1177
  key: "handlePlaying",
1146
1178
  value: function handlePlaying() {
1147
- var _this$props14 = this.props,
1148
- actions = _this$props14.actions,
1149
- onPlaying = _this$props14.onPlaying;
1179
+ var _this$props15 = this.props,
1180
+ actions = _this$props15.actions,
1181
+ onPlaying = _this$props15.onPlaying;
1150
1182
  actions.handlePlaying(this.getProperties());
1151
1183
  if (onPlaying) {
1152
1184
  onPlaying.apply(void 0, arguments);
@@ -1157,9 +1189,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1157
1189
  }, {
1158
1190
  key: "handlePlay",
1159
1191
  value: function handlePlay() {
1160
- var _this$props15 = this.props,
1161
- actions = _this$props15.actions,
1162
- onPlay = _this$props15.onPlay;
1192
+ var _this$props16 = this.props,
1193
+ actions = _this$props16.actions,
1194
+ onPlay = _this$props16.onPlay;
1163
1195
  actions.handlePlay(this.getProperties());
1164
1196
  if (onPlay) {
1165
1197
  onPlay.apply(void 0, arguments);
@@ -1170,9 +1202,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1170
1202
  }, {
1171
1203
  key: "handlePause",
1172
1204
  value: function handlePause() {
1173
- var _this$props16 = this.props,
1174
- actions = _this$props16.actions,
1175
- onPause = _this$props16.onPause;
1205
+ var _this$props17 = this.props,
1206
+ actions = _this$props17.actions,
1207
+ onPause = _this$props17.onPause;
1176
1208
  actions.handlePause(this.getProperties());
1177
1209
  if (onPause) {
1178
1210
  onPause.apply(void 0, arguments);
@@ -1186,9 +1218,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1186
1218
  }, {
1187
1219
  key: "handleDurationChange",
1188
1220
  value: function handleDurationChange() {
1189
- var _this$props17 = this.props,
1190
- actions = _this$props17.actions,
1191
- onDurationChange = _this$props17.onDurationChange;
1221
+ var _this$props18 = this.props,
1222
+ actions = _this$props18.actions,
1223
+ onDurationChange = _this$props18.onDurationChange;
1192
1224
  actions.handleDurationChange(this.getProperties());
1193
1225
  if (onDurationChange) {
1194
1226
  onDurationChange.apply(void 0, arguments);
@@ -1202,9 +1234,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1202
1234
  }, {
1203
1235
  key: "handleProgress",
1204
1236
  value: function handleProgress() {
1205
- var _this$props18 = this.props,
1206
- actions = _this$props18.actions,
1207
- onProgress = _this$props18.onProgress;
1237
+ var _this$props19 = this.props,
1238
+ actions = _this$props19.actions,
1239
+ onProgress = _this$props19.onProgress;
1208
1240
  if (this.video) {
1209
1241
  actions.handleProgressChange(this.getProperties());
1210
1242
  }
@@ -1225,11 +1257,11 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1225
1257
  }, {
1226
1258
  key: "displaySubtitle",
1227
1259
  value: function displaySubtitle(marker) {
1228
- var _this$props19 = this.props,
1229
- markers = _this$props19.markers,
1230
- resetSubtitleData = _this$props19.resetSubtitleData,
1231
- subtitleReadOnly = _this$props19.subtitleReadOnly,
1232
- subtitleDataList = _this$props19.subtitleDataList;
1260
+ var _this$props20 = this.props,
1261
+ markers = _this$props20.markers,
1262
+ resetSubtitleData = _this$props20.resetSubtitleData,
1263
+ subtitleReadOnly = _this$props20.subtitleReadOnly,
1264
+ subtitleDataList = _this$props20.subtitleDataList;
1233
1265
  var currentSubtitleObj = this.state.currentSubtitleObj;
1234
1266
  if (resetSubtitleData) {
1235
1267
  resetSubtitleData();
@@ -1271,11 +1303,11 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1271
1303
  }, {
1272
1304
  key: "handleEnded",
1273
1305
  value: function handleEnded() {
1274
- var _this$props20 = this.props,
1275
- loop = _this$props20.loop,
1276
- player = _this$props20.player,
1277
- actions = _this$props20.actions,
1278
- onEnded = _this$props20.onEnded;
1306
+ var _this$props21 = this.props,
1307
+ loop = _this$props21.loop,
1308
+ player = _this$props21.player,
1309
+ actions = _this$props21.actions,
1310
+ onEnded = _this$props21.onEnded;
1279
1311
  if (loop) {
1280
1312
  this.seek(0);
1281
1313
  this.play();
@@ -1292,9 +1324,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1292
1324
  }, {
1293
1325
  key: "handleWaiting",
1294
1326
  value: function handleWaiting() {
1295
- var _this$props21 = this.props,
1296
- actions = _this$props21.actions,
1297
- onWaiting = _this$props21.onWaiting;
1327
+ var _this$props22 = this.props,
1328
+ actions = _this$props22.actions,
1329
+ onWaiting = _this$props22.onWaiting;
1298
1330
  actions.handleWaiting(this.getProperties());
1299
1331
  if (onWaiting) {
1300
1332
  onWaiting.apply(void 0, arguments);
@@ -1308,9 +1340,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1308
1340
  }, {
1309
1341
  key: "handleSeeking",
1310
1342
  value: function handleSeeking() {
1311
- var _this$props22 = this.props,
1312
- actions = _this$props22.actions,
1313
- onSeeking = _this$props22.onSeeking;
1343
+ var _this$props23 = this.props,
1344
+ actions = _this$props23.actions,
1345
+ onSeeking = _this$props23.onSeeking;
1314
1346
  actions.handleSeeking(this.getProperties());
1315
1347
  if (onSeeking) {
1316
1348
  onSeeking.apply(void 0, arguments);
@@ -1324,9 +1356,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1324
1356
  }, {
1325
1357
  key: "handleSeeked",
1326
1358
  value: function handleSeeked() {
1327
- var _this$props23 = this.props,
1328
- actions = _this$props23.actions,
1329
- onSeeked = _this$props23.onSeeked;
1359
+ var _this$props24 = this.props,
1360
+ actions = _this$props24.actions,
1361
+ onSeeked = _this$props24.onSeeked;
1330
1362
  actions.handleSeeked(this.getProperties());
1331
1363
  if (onSeeked) {
1332
1364
  onSeeked.apply(void 0, arguments);
@@ -1345,9 +1377,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1345
1377
  }, {
1346
1378
  key: "handleSuspend",
1347
1379
  value: function handleSuspend() {
1348
- var _this$props24 = this.props,
1349
- actions = _this$props24.actions,
1350
- onSuspend = _this$props24.onSuspend;
1380
+ var _this$props25 = this.props,
1381
+ actions = _this$props25.actions,
1382
+ onSuspend = _this$props25.onSuspend;
1351
1383
  actions.handleSuspend(this.getProperties());
1352
1384
  if (onSuspend) {
1353
1385
  onSuspend.apply(void 0, arguments);
@@ -1358,9 +1390,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1358
1390
  }, {
1359
1391
  key: "handleAbort",
1360
1392
  value: function handleAbort() {
1361
- var _this$props25 = this.props,
1362
- actions = _this$props25.actions,
1363
- onAbort = _this$props25.onAbort;
1393
+ var _this$props26 = this.props,
1394
+ actions = _this$props26.actions,
1395
+ onAbort = _this$props26.onAbort;
1364
1396
  actions.handleAbort(this.getProperties());
1365
1397
  if (onAbort) {
1366
1398
  onAbort.apply(void 0, arguments);
@@ -1371,9 +1403,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1371
1403
  }, {
1372
1404
  key: "handleEmptied",
1373
1405
  value: function handleEmptied() {
1374
- var _this$props26 = this.props,
1375
- actions = _this$props26.actions,
1376
- onEmptied = _this$props26.onEmptied;
1406
+ var _this$props27 = this.props,
1407
+ actions = _this$props27.actions,
1408
+ onEmptied = _this$props27.onEmptied;
1377
1409
  actions.handleEmptied(this.getProperties());
1378
1410
  if (onEmptied) {
1379
1411
  onEmptied.apply(void 0, arguments);
@@ -1387,9 +1419,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1387
1419
  }, {
1388
1420
  key: "handleStalled",
1389
1421
  value: function handleStalled() {
1390
- var _this$props27 = this.props,
1391
- actions = _this$props27.actions,
1392
- onStalled = _this$props27.onStalled;
1422
+ var _this$props28 = this.props,
1423
+ actions = _this$props28.actions,
1424
+ onStalled = _this$props28.onStalled;
1393
1425
  actions.handleStalled(this.getProperties());
1394
1426
  if (onStalled) {
1395
1427
  onStalled.apply(void 0, arguments);
@@ -1403,10 +1435,10 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1403
1435
  }, {
1404
1436
  key: "handleLoadedMetaData",
1405
1437
  value: function handleLoadedMetaData() {
1406
- var _this$props28 = this.props,
1407
- actions = _this$props28.actions,
1408
- onLoadedMetadata = _this$props28.onLoadedMetadata,
1409
- startTime = _this$props28.startTime;
1438
+ var _this$props29 = this.props,
1439
+ actions = _this$props29.actions,
1440
+ onLoadedMetadata = _this$props29.onLoadedMetadata,
1441
+ startTime = _this$props29.startTime;
1410
1442
  if (startTime && startTime > 0) {
1411
1443
  this.video.currentTime = startTime;
1412
1444
  }
@@ -1423,9 +1455,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1423
1455
  }, {
1424
1456
  key: "handleLoadedData",
1425
1457
  value: function handleLoadedData() {
1426
- var _this$props29 = this.props,
1427
- actions = _this$props29.actions,
1428
- onLoadedData = _this$props29.onLoadedData;
1458
+ var _this$props30 = this.props,
1459
+ actions = _this$props30.actions,
1460
+ onLoadedData = _this$props30.onLoadedData;
1429
1461
  actions.handleLoadedData(this.getProperties());
1430
1462
  if (onLoadedData) {
1431
1463
  onLoadedData.apply(void 0, arguments);
@@ -1439,11 +1471,11 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1439
1471
  }, {
1440
1472
  key: "handleTimeUpdate",
1441
1473
  value: function handleTimeUpdate() {
1442
- var _this$props30 = this.props,
1443
- previewActive = _this$props30.player.previewActive,
1444
- actions = _this$props30.actions,
1445
- onTimeUpdate = _this$props30.onTimeUpdate,
1446
- rightMarker = _this$props30.playerSelectedMarker.rightMarker;
1474
+ var _this$props31 = this.props,
1475
+ previewActive = _this$props31.player.previewActive,
1476
+ actions = _this$props31.actions,
1477
+ onTimeUpdate = _this$props31.onTimeUpdate,
1478
+ rightMarker = _this$props31.playerSelectedMarker.rightMarker;
1447
1479
 
1448
1480
  //for annotation time updataton for svg
1449
1481
  var _this$getTimeData3 = this.getTimeData(this.video.currentTime),
@@ -1471,9 +1503,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1471
1503
  }, {
1472
1504
  key: "handleRateChange",
1473
1505
  value: function handleRateChange() {
1474
- var _this$props31 = this.props,
1475
- actions = _this$props31.actions,
1476
- onRateChange = _this$props31.onRateChange;
1506
+ var _this$props32 = this.props,
1507
+ actions = _this$props32.actions,
1508
+ onRateChange = _this$props32.onRateChange;
1477
1509
  actions.handleRateChange(this.getProperties());
1478
1510
  if (onRateChange) {
1479
1511
  onRateChange.apply(void 0, arguments);
@@ -1484,9 +1516,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1484
1516
  }, {
1485
1517
  key: "handleVolumeChange",
1486
1518
  value: function handleVolumeChange() {
1487
- var _this$props32 = this.props,
1488
- actions = _this$props32.actions,
1489
- onVolumeChange = _this$props32.onVolumeChange;
1519
+ var _this$props33 = this.props,
1520
+ actions = _this$props33.actions,
1521
+ onVolumeChange = _this$props33.onVolumeChange;
1490
1522
  actions.handleVolumeChange(this.getProperties());
1491
1523
  if (onVolumeChange) {
1492
1524
  onVolumeChange.apply(void 0, arguments);
@@ -1500,9 +1532,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1500
1532
  }, {
1501
1533
  key: "handleError",
1502
1534
  value: function handleError() {
1503
- var _this$props33 = this.props,
1504
- actions = _this$props33.actions,
1505
- onError = _this$props33.onError;
1535
+ var _this$props34 = this.props,
1536
+ actions = _this$props34.actions,
1537
+ onError = _this$props34.onError;
1506
1538
  actions.handleError(this.getProperties());
1507
1539
  if (onError) {
1508
1540
  onError.apply(void 0, arguments);
@@ -1531,10 +1563,10 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1531
1563
  }, {
1532
1564
  key: "calculateHeightBasedOnResolution",
1533
1565
  value: function calculateHeightBasedOnResolution() {
1534
- var _this$props34 = this.props,
1535
- player = _this$props34.player,
1536
- isRightMenuVisible = _this$props34.isRightMenuVisible,
1537
- heightRatio = _this$props34.heightRatio;
1566
+ var _this$props35 = this.props,
1567
+ player = _this$props35.player,
1568
+ isRightMenuVisible = _this$props35.isRightMenuVisible,
1569
+ heightRatio = _this$props35.heightRatio;
1538
1570
  var ratio = typeof heightRatio === 'number' ? heightRatio : 1;
1539
1571
  if (!(player !== null && player !== void 0 && player.isFullscreen) || !isRightMenuVisible) {
1540
1572
  if (this.state.calculatedHeight !== null) {
@@ -1664,9 +1696,9 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1664
1696
  }, {
1665
1697
  key: "handleSubtitleContainerClick",
1666
1698
  value: function handleSubtitleContainerClick() {
1667
- var _this$props35 = this.props,
1668
- actions = _this$props35.actions,
1669
- player = _this$props35.player;
1699
+ var _this$props36 = this.props,
1700
+ actions = _this$props36.actions,
1701
+ player = _this$props36.player;
1670
1702
  if (player.paused) {
1671
1703
  actions.play();
1672
1704
  } else {
@@ -1676,11 +1708,11 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1676
1708
  }, {
1677
1709
  key: "handleSubtitleClick",
1678
1710
  value: function handleSubtitleClick(e) {
1679
- var _this$props36 = this.props,
1680
- actions = _this$props36.actions,
1681
- player = _this$props36.player,
1682
- onScreenSubtitleClick = _this$props36.onScreenSubtitleClick,
1683
- controlType = _this$props36.controlType;
1711
+ var _this$props37 = this.props,
1712
+ actions = _this$props37.actions,
1713
+ player = _this$props37.player,
1714
+ onScreenSubtitleClick = _this$props37.onScreenSubtitleClick,
1715
+ controlType = _this$props37.controlType;
1684
1716
  var currentSubtitleObj = this.state.currentSubtitleObj;
1685
1717
  if (controlType === 'advanced') {
1686
1718
  if (onScreenSubtitleClick) {
@@ -1705,22 +1737,22 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
1705
1737
  _this$props$parentAnn2,
1706
1738
  _this$props$parentAnn3,
1707
1739
  _this$props$parentAnn4;
1708
- var _this$props37 = this.props,
1709
- loop = _this$props37.loop,
1710
- poster = _this$props37.poster,
1711
- preload = _this$props37.preload,
1712
- autoPlay = _this$props37.autoPlay,
1713
- playsInline = _this$props37.playsInline,
1714
- muted = _this$props37.muted,
1715
- crossOrigin = _this$props37.crossOrigin,
1716
- videoId = _this$props37.videoId,
1717
- fileType = _this$props37.fileType,
1718
- userEmail = _this$props37.userEmail,
1719
- theme = _this$props37.theme,
1720
- player = _this$props37.player,
1721
- playerType = _this$props37.playerType,
1722
- markers = _this$props37.markers,
1723
- isRightMenuVisible = _this$props37.isRightMenuVisible;
1740
+ var _this$props38 = this.props,
1741
+ loop = _this$props38.loop,
1742
+ poster = _this$props38.poster,
1743
+ preload = _this$props38.preload,
1744
+ autoPlay = _this$props38.autoPlay,
1745
+ playsInline = _this$props38.playsInline,
1746
+ muted = _this$props38.muted,
1747
+ crossOrigin = _this$props38.crossOrigin,
1748
+ videoId = _this$props38.videoId,
1749
+ fileType = _this$props38.fileType,
1750
+ userEmail = _this$props38.userEmail,
1751
+ theme = _this$props38.theme,
1752
+ player = _this$props38.player,
1753
+ playerType = _this$props38.playerType,
1754
+ markers = _this$props38.markers,
1755
+ isRightMenuVisible = _this$props38.isRightMenuVisible;
1724
1756
  var _this$state2 = this.state,
1725
1757
  isBuffering = _this$state2.isBuffering,
1726
1758
  watermark = _this$state2.watermark,
@@ -109,9 +109,67 @@ var AudioTracksMenuButton = /*#__PURE__*/function (_Component) {
109
109
  }, {
110
110
  key: "ensureValidAudioTrack",
111
111
  value: function ensureValidAudioTrack() {
112
- var player = this.props.player;
112
+ var _this$props = this.props,
113
+ player = _this$props.player,
114
+ additionalTrackQuality = _this$props.additionalTrackQuality;
113
115
  var allTracks = player.audioTracksArr || [];
114
- if (allTracks.length === 0) return;
116
+ var activeAudio = player.activeAudio;
117
+ if (allTracks.length === 0 || !activeAudio) {
118
+ var dubbedTracks = allTracks.filter(function (track) {
119
+ return track.isDubbedTrack === true;
120
+ });
121
+ if (dubbedTracks.length) {
122
+ this.setState({
123
+ openAccordion: 'dubbed'
124
+ });
125
+ } else {
126
+ this.setState({
127
+ openAccordion: 'original'
128
+ });
129
+ }
130
+ return;
131
+ }
132
+ var hasDubbed = allTracks.some(function (track) {
133
+ return track.isDubbedTrack === true;
134
+ });
135
+ var hasOriginal = allTracks.some(function (track) {
136
+ return !track.isDubbedTrack && !track.isAdditionalTrack;
137
+ });
138
+ var hasAdditional = allTracks.some(function (track) {
139
+ return track.isAdditionalTrack === true;
140
+ });
141
+ var categoriesPresent = [hasDubbed, hasOriginal, hasAdditional].filter(Boolean).length;
142
+ if (categoriesPresent === 1) {
143
+ if (hasDubbed) {
144
+ this.setState({
145
+ openAccordion: 'dubbed'
146
+ });
147
+ } else if (hasAdditional) {
148
+ this.setState({
149
+ openAccordion: additionalTrackQuality || 'additional'
150
+ });
151
+ } else if (hasOriginal) {
152
+ this.setState({
153
+ openAccordion: 'original'
154
+ });
155
+ }
156
+ return;
157
+ }
158
+ var isDubbed = activeAudio.isDubbedTrack === true;
159
+ var isAdditional = activeAudio.isAdditionalTrack === true;
160
+ if (isDubbed) {
161
+ this.setState({
162
+ openAccordion: 'dubbed'
163
+ });
164
+ } else if (isAdditional) {
165
+ this.setState({
166
+ openAccordion: additionalTrackQuality || 'additional'
167
+ });
168
+ } else {
169
+ this.setState({
170
+ openAccordion: 'original'
171
+ });
172
+ }
115
173
  }
116
174
  }, {
117
175
  key: "changeTrack",
@@ -124,12 +182,12 @@ var AudioTracksMenuButton = /*#__PURE__*/function (_Component) {
124
182
  value: function render() {
125
183
  var _player$activeAudio,
126
184
  _this2 = this;
127
- var _this$props = this.props,
128
- player = _this$props.player,
129
- actions = _this$props.actions,
130
- theme = _this$props.theme,
131
- activeVersion = _this$props.activeVersion,
132
- additionalTrackQuality = _this$props.additionalTrackQuality;
185
+ var _this$props2 = this.props,
186
+ player = _this$props2.player,
187
+ actions = _this$props2.actions,
188
+ theme = _this$props2.theme,
189
+ activeVersion = _this$props2.activeVersion,
190
+ additionalTrackQuality = _this$props2.additionalTrackQuality;
133
191
  var openAccordion = this.state.openAccordion;
134
192
  var allTracks = player.audioTracksArr || [];
135
193
  var originalTracks = allTracks.filter(function (track) {
@@ -159,19 +217,19 @@ var AudioTracksMenuButton = /*#__PURE__*/function (_Component) {
159
217
  position: "left"
160
218
  }, /*#__PURE__*/_react["default"].createElement("div", {
161
219
  className: "menu-container"
162
- }, (hasDubbedTracks || hasAdditionalTracks) && /*#__PURE__*/_react["default"].createElement(NowPlayingContainer, null, /*#__PURE__*/_react["default"].createElement(NowPlayingLabel, null, "Now playing"), /*#__PURE__*/_react["default"].createElement(NowPlayingTrackName, {
220
+ }, (hasDubbedTracks || hasAdditionalTracks || hasOriginalTracks) && /*#__PURE__*/_react["default"].createElement(NowPlayingContainer, null, /*#__PURE__*/_react["default"].createElement(NowPlayingLabel, null, "Now playing"), /*#__PURE__*/_react["default"].createElement(NowPlayingTrackName, {
163
221
  theme: theme
164
- }, currentTrackName)), hasDubbedTracks && /*#__PURE__*/_react["default"].createElement(AccordionContainer, null, /*#__PURE__*/_react["default"].createElement(AccordionHeader, {
222
+ }, currentTrackName)), hasAdditionalTracks && /*#__PURE__*/_react["default"].createElement(AccordionContainer, null, /*#__PURE__*/_react["default"].createElement(AccordionHeader, {
165
223
  theme: theme,
166
- onClick: this.toggleDubbedAccordion
167
- }, /*#__PURE__*/_react["default"].createElement(HeaderTitle, null, "Dubbed tracks"), /*#__PURE__*/_react["default"].createElement(HeaderIcon, {
168
- isOpen: openAccordion === 'dubbed'
224
+ onClick: this.toggleAdditionalAccordion
225
+ }, /*#__PURE__*/_react["default"].createElement(HeaderTitle, null, activeVersion.category, " ", additionalTrackQuality), /*#__PURE__*/_react["default"].createElement(HeaderIcon, {
226
+ isOpen: openAccordion === additionalTrackQuality
169
227
  }, /*#__PURE__*/_react["default"].createElement(_components.Icon, {
170
228
  color: "#999999",
171
229
  name: "dropdown_more_icon"
172
230
  }))), /*#__PURE__*/_react["default"].createElement(AccordionContent, {
173
- isOpen: openAccordion === 'dubbed'
174
- }, dubbedTracks.map(function (track, index) {
231
+ isOpen: openAccordion === additionalTrackQuality
232
+ }, additionalTrack.map(function (track, index) {
175
233
  return /*#__PURE__*/_react["default"].createElement(AudioTrackBlock, {
176
234
  theme: theme,
177
235
  onClick: function onClick() {
@@ -189,18 +247,18 @@ var AudioTracksMenuButton = /*#__PURE__*/function (_Component) {
189
247
  } : {
190
248
  color: '#333333'
191
249
  }
192
- }, track.name || "Dubbed Track ".concat(index + 1)));
193
- }))), hasAdditionalTracks && /*#__PURE__*/_react["default"].createElement(AccordionContainer, null, /*#__PURE__*/_react["default"].createElement(AccordionHeader, {
250
+ }, track.name || "Track ".concat(index + 1)));
251
+ }))), hasDubbedTracks && /*#__PURE__*/_react["default"].createElement(AccordionContainer, null, /*#__PURE__*/_react["default"].createElement(AccordionHeader, {
194
252
  theme: theme,
195
- onClick: this.toggleAdditionalAccordion
196
- }, /*#__PURE__*/_react["default"].createElement(HeaderTitle, null, activeVersion.category, " ", additionalTrackQuality), /*#__PURE__*/_react["default"].createElement(HeaderIcon, {
197
- isOpen: openAccordion === additionalTrackQuality
253
+ onClick: this.toggleDubbedAccordion
254
+ }, /*#__PURE__*/_react["default"].createElement(HeaderTitle, null, "Dubbed tracks"), /*#__PURE__*/_react["default"].createElement(HeaderIcon, {
255
+ isOpen: openAccordion === 'dubbed'
198
256
  }, /*#__PURE__*/_react["default"].createElement(_components.Icon, {
199
257
  color: "#999999",
200
258
  name: "dropdown_more_icon"
201
259
  }))), /*#__PURE__*/_react["default"].createElement(AccordionContent, {
202
- isOpen: openAccordion === additionalTrackQuality
203
- }, additionalTrack.map(function (track, index) {
260
+ isOpen: openAccordion === 'dubbed'
261
+ }, dubbedTracks.map(function (track, index) {
204
262
  return /*#__PURE__*/_react["default"].createElement(AudioTrackBlock, {
205
263
  theme: theme,
206
264
  onClick: function onClick() {
@@ -218,7 +276,7 @@ var AudioTracksMenuButton = /*#__PURE__*/function (_Component) {
218
276
  } : {
219
277
  color: '#333333'
220
278
  }
221
- }, track.name || "Track ".concat(index + 1)));
279
+ }, track.name || "Dubbed Track ".concat(index + 1)));
222
280
  }))), hasOriginalTracks && /*#__PURE__*/_react["default"].createElement(AccordionContainer, null, (hasDubbedTracks || hasAdditionalTracks) && /*#__PURE__*/_react["default"].createElement(AccordionHeader, {
223
281
  theme: theme,
224
282
  onClick: this.toggleOriginalAccordion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@desynova-digital/player",
3
- "version": "4.2.1",
3
+ "version": "4.2.3",
4
4
  "description": "Video Player Package for Contido Application",
5
5
  "main": "index.js",
6
6
  "scripts": {