stormcloud-video-player 0.3.65 → 0.3.67

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.
@@ -2478,6 +2478,9 @@ var DEFAULT_MQTT_CONFIG = {
2478
2478
  qos: 1
2479
2479
  };
2480
2480
  var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
2481
+ function applyMQTTConfig(overrides) {
2482
+ Object.assign(mqttConfig, overrides);
2483
+ }
2481
2484
  function isMQTTEnabled() {
2482
2485
  return mqttConfig.enabled;
2483
2486
  }
@@ -3920,10 +3923,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3920
3923
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3921
3924
  }
3922
3925
  }
3923
- var currentMuted = _this.video.muted;
3924
- var currentVolume = _this.video.volume;
3925
- var adVolume = currentMuted ? 0 : currentVolume;
3926
- _this.ima.setAdVolume(adVolume);
3926
+ _this.ima.setAdVolume(_this.getPreAdBreakAdVolume());
3927
3927
  if (_this.isShowingPlaceholder) {
3928
3928
  if (_this.config.debugAdTiming) {
3929
3929
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -4677,6 +4677,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4677
4677
  {
4678
4678
  key: "startScte35AdBreak",
4679
4679
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
4680
+ this.capturePreAdBreakAudio();
4680
4681
  if (!this.video.muted) {
4681
4682
  this.video.muted = true;
4682
4683
  this.video.volume = 0;
@@ -5452,6 +5453,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5452
5453
  return !!(this.config.isVmap && ((_this_config_vmapUrl = this.config.vmapUrl) === null || _this_config_vmapUrl === void 0 ? void 0 : _this_config_vmapUrl.trim()));
5453
5454
  }
5454
5455
  },
5456
+ {
5457
+ key: "applyMqttConfigFromResponse",
5458
+ value: function applyMqttConfigFromResponse(data) {
5459
+ var _data_response;
5460
+ var mqttConfig2 = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.mqtt_config;
5461
+ if (!mqttConfig2 || (typeof mqttConfig2 === "undefined" ? "undefined" : _type_of(mqttConfig2)) !== "object") {
5462
+ return;
5463
+ }
5464
+ applyMQTTConfig(mqttConfig2);
5465
+ if (this.config.debugAdTiming) {
5466
+ console.log("[StormcloudVideoPlayer] Applied MQTT config from /ads/web:", mqttConfig2);
5467
+ }
5468
+ }
5469
+ },
5455
5470
  {
5456
5471
  key: "fetchAdConfiguration",
5457
5472
  value: function fetchAdConfiguration() {
@@ -5538,6 +5553,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5538
5553
  ];
5539
5554
  case 4:
5540
5555
  data = _state.sent();
5556
+ this.applyMqttConfigFromResponse(data);
5541
5557
  imaPayload = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : (_data_response_ima = _data_response.ima) === null || _data_response_ima === void 0 ? void 0 : (_data_response_ima_publisherdeskima = _data_response_ima["publisherdesk.ima"]) === null || _data_response_ima_publisherdeskima === void 0 ? void 0 : _data_response_ima_publisherdeskima.payload;
5542
5558
  if (imaPayload) {
5543
5559
  this.apiVastTagUrl = decodeURIComponent(imaPayload);
@@ -6343,9 +6359,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6343
6359
  this.continuousFetchingActive = true;
6344
6360
  this.isShowingPlaceholder = false;
6345
6361
  this.totalAdRequestsInBreak = 0;
6346
- currentMuted = this.video.muted;
6347
- currentVolume = this.video.volume;
6348
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
6362
+ this.capturePreAdBreakAudio();
6363
+ currentMuted = this.preAdBreakAudio.muted;
6364
+ currentVolume = this.preAdBreakAudio.volume;
6349
6365
  if (!this.video.muted) {
6350
6366
  this.video.muted = true;
6351
6367
  this.video.volume = 0;
@@ -6820,7 +6836,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6820
6836
  value: function tryNextAvailableAd() {
6821
6837
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6822
6838
  return _async_to_generator(function() {
6823
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6839
+ var remaining, preloaded, error, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error1, errorMessage, maxRetries;
6824
6840
  return _ts_generator(this, function(_state) {
6825
6841
  switch(_state.label){
6826
6842
  case 0:
@@ -6892,10 +6908,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6892
6908
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6893
6909
  this.scheduleAdStopAtBreakBoundary();
6894
6910
  }
6895
- currentMuted = this.video.muted;
6896
- currentVolume = this.video.volume;
6897
- adVolume = currentMuted ? 0 : currentVolume;
6898
- this.ima.setAdVolume(adVolume);
6911
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
6899
6912
  this.consecutiveFailures = 0;
6900
6913
  return [
6901
6914
  2
@@ -6942,9 +6955,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6942
6955
  if (this.config.debugAdTiming) {
6943
6956
  console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC Requesting next ad via IMA SDK (".concat(this.currentAdIndex + 1, "/").concat(this.totalAdsInBreak, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
6944
6957
  }
6945
- currentMuted1 = this.video.muted;
6946
- currentVolume1 = this.video.volume;
6947
- this.ima.updateOriginalMutedState(currentMuted1, currentVolume1);
6958
+ this.ima.updateOriginalMutedState((_ref = (_this_preAdBreakAudio = this.preAdBreakAudio) === null || _this_preAdBreakAudio === void 0 ? void 0 : _this_preAdBreakAudio.muted) !== null && _ref !== void 0 ? _ref : this.video.muted, (_ref1 = (_this_preAdBreakAudio1 = this.preAdBreakAudio) === null || _this_preAdBreakAudio1 === void 0 ? void 0 : _this_preAdBreakAudio1.volume) !== null && _ref1 !== void 0 ? _ref1 : this.video.volume);
6948
6959
  this.currentAdIndex++;
6949
6960
  this.totalAdRequestsInBreak++;
6950
6961
  this.lastAdRequestTime = Date.now();
@@ -7037,7 +7048,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7037
7048
  key: "showPlaceholderAndWaitForAds",
7038
7049
  value: function showPlaceholderAndWaitForAds() {
7039
7050
  return _async_to_generator(function() {
7040
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
7051
+ var remaining, waitTime, checkInterval, maxChecks, i, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error, errorMessage;
7041
7052
  return _ts_generator(this, function(_state) {
7042
7053
  switch(_state.label){
7043
7054
  case 0:
@@ -7133,9 +7144,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7133
7144
  }
7134
7145
  this.isShowingPlaceholder = false;
7135
7146
  this.ima.hidePlaceholder();
7136
- currentMuted = this.video.muted;
7137
- currentVolume = this.video.volume;
7138
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
7147
+ this.ima.updateOriginalMutedState((_ref = (_this_preAdBreakAudio = this.preAdBreakAudio) === null || _this_preAdBreakAudio === void 0 ? void 0 : _this_preAdBreakAudio.muted) !== null && _ref !== void 0 ? _ref : this.video.muted, (_ref1 = (_this_preAdBreakAudio1 = this.preAdBreakAudio) === null || _this_preAdBreakAudio1 === void 0 ? void 0 : _this_preAdBreakAudio1.volume) !== null && _ref1 !== void 0 ? _ref1 : this.video.volume);
7139
7148
  this.currentAdIndex++;
7140
7149
  this.totalAdRequestsInBreak++;
7141
7150
  this.lastAdRequestTime = Date.now();
@@ -7317,7 +7326,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7317
7326
  first = tags[0];
7318
7327
  rest = tags.slice(1);
7319
7328
  this.adPodQueue = rest;
7320
- this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
7329
+ this.capturePreAdBreakAudio();
7321
7330
  this.showAds = true;
7322
7331
  this.inAdBreak = true;
7323
7332
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -7344,12 +7353,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7344
7353
  ];
7345
7354
  case 3:
7346
7355
  error = _state.sent();
7347
- this.adPodQueue = [];
7348
- this.inAdBreak = false;
7349
- this.showAds = false;
7350
7356
  if (this.config.debugAdTiming) {
7351
7357
  console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
7352
7358
  }
7359
+ this.handleAdPodComplete();
7353
7360
  return [
7354
7361
  3,
7355
7362
  4
@@ -7580,7 +7587,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7580
7587
  key: "playSingleAd",
7581
7588
  value: function playSingleAd(vastTagUrl) {
7582
7589
  return _async_to_generator(function() {
7583
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
7590
+ var requestToken, playError, preloadedFallback, fallbackError, error, errorMessage, preloadedFallback1, fallbackError1;
7584
7591
  return _ts_generator(this, function(_state) {
7585
7592
  switch(_state.label){
7586
7593
  case 0:
@@ -7667,10 +7674,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7667
7674
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7668
7675
  this.scheduleAdStopAtBreakBoundary();
7669
7676
  }
7670
- currentMuted = this.video.muted;
7671
- currentVolume = this.video.volume;
7672
- adVolume = currentMuted ? 0 : currentVolume;
7673
- this.ima.setAdVolume(adVolume);
7677
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7674
7678
  this.consecutiveFailures = 0;
7675
7679
  this.temporaryFailureUrls.delete(vastTagUrl);
7676
7680
  return [
@@ -7717,10 +7721,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7717
7721
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7718
7722
  this.scheduleAdStopAtBreakBoundary();
7719
7723
  }
7720
- currentMuted1 = this.video.muted;
7721
- currentVolume1 = this.video.volume;
7722
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7723
- this.ima.setAdVolume(adVolume1);
7724
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7724
7725
  return [
7725
7726
  2
7726
7727
  ];
@@ -7794,10 +7795,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7794
7795
  ];
7795
7796
  case 14:
7796
7797
  _state.sent();
7797
- currentMuted2 = this.video.muted;
7798
- currentVolume2 = this.video.volume;
7799
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7800
- this.ima.setAdVolume(adVolume2);
7798
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7801
7799
  return [
7802
7800
  2
7803
7801
  ];
@@ -7837,6 +7835,33 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7837
7835
  }).call(this);
7838
7836
  }
7839
7837
  },
7838
+ {
7839
+ key: "capturePreAdBreakAudio",
7840
+ value: function capturePreAdBreakAudio() {
7841
+ if (this.preAdBreakAudio) {
7842
+ return;
7843
+ }
7844
+ var captured = {
7845
+ muted: this.video.muted,
7846
+ volume: typeof this.video.volume === "number" && !Number.isNaN(this.video.volume) ? Math.max(0, Math.min(1, this.video.volume)) : 1
7847
+ };
7848
+ this.preAdBreakAudio = captured;
7849
+ this.ima.updateOriginalMutedState(captured.muted, captured.volume);
7850
+ if (this.config.debugAdTiming) {
7851
+ console.log("[StormcloudVideoPlayer] Captured pre-ad-break audio state: muted=".concat(captured.muted, ", volume=").concat(captured.volume));
7852
+ }
7853
+ }
7854
+ },
7855
+ {
7856
+ key: "getPreAdBreakAdVolume",
7857
+ value: function getPreAdBreakAdVolume() {
7858
+ var state = this.preAdBreakAudio;
7859
+ if (state) {
7860
+ return state.muted ? 0 : state.volume;
7861
+ }
7862
+ return this.ima.getOriginalMutedState() ? 0 : this.ima.getOriginalVolume();
7863
+ }
7864
+ },
7840
7865
  {
7841
7866
  key: "handleAdPodComplete",
7842
7867
  value: function handleAdPodComplete() {
@@ -7870,14 +7895,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7870
7895
  this.consecutiveFailures = 0;
7871
7896
  this.globalConsecutiveNoFills = 0;
7872
7897
  this.ima.stop().catch(function() {});
7873
- var restoredMuted = this.ima.getOriginalMutedState();
7874
- var restoredVolume = this.ima.getOriginalVolume();
7898
+ var restoredMuted = this.preAdBreakAudio ? this.preAdBreakAudio.muted : this.ima.getOriginalMutedState();
7899
+ var restoredVolume = this.preAdBreakAudio ? this.preAdBreakAudio.volume : this.ima.getOriginalVolume();
7900
+ this.ima.updateOriginalMutedState(restoredMuted, restoredVolume);
7875
7901
  if (this.video.muted !== restoredMuted) {
7876
7902
  this.video.muted = restoredMuted;
7877
7903
  }
7878
7904
  if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
7879
7905
  this.video.volume = restoredVolume;
7880
7906
  }
7907
+ this.preAdBreakAudio = void 0;
7908
+ if (this.config.debugAdTiming) {
7909
+ console.log("[StormcloudVideoPlayer] Restored post-ad-break audio state: muted=".concat(restoredMuted, ", volume=").concat(restoredVolume));
7910
+ }
7881
7911
  if (this.shouldContinueLiveStreamDuringAds()) {
7882
7912
  if (this.video.paused) {
7883
7913
  var _this_video_play;
@@ -8287,6 +8317,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8287
8317
  this.clearAdFailsafeTimer();
8288
8318
  this.clearAdRequestWatchdog();
8289
8319
  this.clearPendingAdBreak();
8320
+ this.preAdBreakAudio = void 0;
8290
8321
  if (this.placeholderContainer) {
8291
8322
  if (this.placeholderContainer.parentElement) {
8292
8323
  this.placeholderContainer.parentElement.removeChild(this.placeholderContainer);