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.
@@ -2390,6 +2390,9 @@ var DEFAULT_MQTT_CONFIG = {
2390
2390
  qos: 1
2391
2391
  };
2392
2392
  var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
2393
+ function applyMQTTConfig(overrides) {
2394
+ Object.assign(mqttConfig, overrides);
2395
+ }
2393
2396
  function isMQTTEnabled() {
2394
2397
  return mqttConfig.enabled;
2395
2398
  }
@@ -3832,10 +3835,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3832
3835
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3833
3836
  }
3834
3837
  }
3835
- var currentMuted = _this.video.muted;
3836
- var currentVolume = _this.video.volume;
3837
- var adVolume = currentMuted ? 0 : currentVolume;
3838
- _this.ima.setAdVolume(adVolume);
3838
+ _this.ima.setAdVolume(_this.getPreAdBreakAdVolume());
3839
3839
  if (_this.isShowingPlaceholder) {
3840
3840
  if (_this.config.debugAdTiming) {
3841
3841
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -4589,6 +4589,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4589
4589
  {
4590
4590
  key: "startScte35AdBreak",
4591
4591
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
4592
+ this.capturePreAdBreakAudio();
4592
4593
  if (!this.video.muted) {
4593
4594
  this.video.muted = true;
4594
4595
  this.video.volume = 0;
@@ -5364,6 +5365,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5364
5365
  return !!(this.config.isVmap && ((_this_config_vmapUrl = this.config.vmapUrl) === null || _this_config_vmapUrl === void 0 ? void 0 : _this_config_vmapUrl.trim()));
5365
5366
  }
5366
5367
  },
5368
+ {
5369
+ key: "applyMqttConfigFromResponse",
5370
+ value: function applyMqttConfigFromResponse(data) {
5371
+ var _data_response;
5372
+ var mqttConfig2 = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.mqtt_config;
5373
+ if (!mqttConfig2 || (typeof mqttConfig2 === "undefined" ? "undefined" : _type_of(mqttConfig2)) !== "object") {
5374
+ return;
5375
+ }
5376
+ applyMQTTConfig(mqttConfig2);
5377
+ if (this.config.debugAdTiming) {
5378
+ console.log("[StormcloudVideoPlayer] Applied MQTT config from /ads/web:", mqttConfig2);
5379
+ }
5380
+ }
5381
+ },
5367
5382
  {
5368
5383
  key: "fetchAdConfiguration",
5369
5384
  value: function fetchAdConfiguration() {
@@ -5450,6 +5465,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5450
5465
  ];
5451
5466
  case 4:
5452
5467
  data = _state.sent();
5468
+ this.applyMqttConfigFromResponse(data);
5453
5469
  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;
5454
5470
  if (imaPayload) {
5455
5471
  this.apiVastTagUrl = decodeURIComponent(imaPayload);
@@ -6255,9 +6271,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6255
6271
  this.continuousFetchingActive = true;
6256
6272
  this.isShowingPlaceholder = false;
6257
6273
  this.totalAdRequestsInBreak = 0;
6258
- currentMuted = this.video.muted;
6259
- currentVolume = this.video.volume;
6260
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
6274
+ this.capturePreAdBreakAudio();
6275
+ currentMuted = this.preAdBreakAudio.muted;
6276
+ currentVolume = this.preAdBreakAudio.volume;
6261
6277
  if (!this.video.muted) {
6262
6278
  this.video.muted = true;
6263
6279
  this.video.volume = 0;
@@ -6732,7 +6748,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6732
6748
  value: function tryNextAvailableAd() {
6733
6749
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6734
6750
  return _async_to_generator(function() {
6735
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6751
+ var remaining, preloaded, error, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error1, errorMessage, maxRetries;
6736
6752
  return _ts_generator(this, function(_state) {
6737
6753
  switch(_state.label){
6738
6754
  case 0:
@@ -6804,10 +6820,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6804
6820
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6805
6821
  this.scheduleAdStopAtBreakBoundary();
6806
6822
  }
6807
- currentMuted = this.video.muted;
6808
- currentVolume = this.video.volume;
6809
- adVolume = currentMuted ? 0 : currentVolume;
6810
- this.ima.setAdVolume(adVolume);
6823
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
6811
6824
  this.consecutiveFailures = 0;
6812
6825
  return [
6813
6826
  2
@@ -6854,9 +6867,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6854
6867
  if (this.config.debugAdTiming) {
6855
6868
  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)"));
6856
6869
  }
6857
- currentMuted1 = this.video.muted;
6858
- currentVolume1 = this.video.volume;
6859
- this.ima.updateOriginalMutedState(currentMuted1, currentVolume1);
6870
+ 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);
6860
6871
  this.currentAdIndex++;
6861
6872
  this.totalAdRequestsInBreak++;
6862
6873
  this.lastAdRequestTime = Date.now();
@@ -6949,7 +6960,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6949
6960
  key: "showPlaceholderAndWaitForAds",
6950
6961
  value: function showPlaceholderAndWaitForAds() {
6951
6962
  return _async_to_generator(function() {
6952
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
6963
+ var remaining, waitTime, checkInterval, maxChecks, i, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error, errorMessage;
6953
6964
  return _ts_generator(this, function(_state) {
6954
6965
  switch(_state.label){
6955
6966
  case 0:
@@ -7045,9 +7056,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7045
7056
  }
7046
7057
  this.isShowingPlaceholder = false;
7047
7058
  this.ima.hidePlaceholder();
7048
- currentMuted = this.video.muted;
7049
- currentVolume = this.video.volume;
7050
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
7059
+ 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);
7051
7060
  this.currentAdIndex++;
7052
7061
  this.totalAdRequestsInBreak++;
7053
7062
  this.lastAdRequestTime = Date.now();
@@ -7229,7 +7238,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7229
7238
  first = tags[0];
7230
7239
  rest = tags.slice(1);
7231
7240
  this.adPodQueue = rest;
7232
- this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
7241
+ this.capturePreAdBreakAudio();
7233
7242
  this.showAds = true;
7234
7243
  this.inAdBreak = true;
7235
7244
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -7256,12 +7265,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7256
7265
  ];
7257
7266
  case 3:
7258
7267
  error = _state.sent();
7259
- this.adPodQueue = [];
7260
- this.inAdBreak = false;
7261
- this.showAds = false;
7262
7268
  if (this.config.debugAdTiming) {
7263
7269
  console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
7264
7270
  }
7271
+ this.handleAdPodComplete();
7265
7272
  return [
7266
7273
  3,
7267
7274
  4
@@ -7492,7 +7499,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7492
7499
  key: "playSingleAd",
7493
7500
  value: function playSingleAd(vastTagUrl) {
7494
7501
  return _async_to_generator(function() {
7495
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
7502
+ var requestToken, playError, preloadedFallback, fallbackError, error, errorMessage, preloadedFallback1, fallbackError1;
7496
7503
  return _ts_generator(this, function(_state) {
7497
7504
  switch(_state.label){
7498
7505
  case 0:
@@ -7579,10 +7586,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7579
7586
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7580
7587
  this.scheduleAdStopAtBreakBoundary();
7581
7588
  }
7582
- currentMuted = this.video.muted;
7583
- currentVolume = this.video.volume;
7584
- adVolume = currentMuted ? 0 : currentVolume;
7585
- this.ima.setAdVolume(adVolume);
7589
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7586
7590
  this.consecutiveFailures = 0;
7587
7591
  this.temporaryFailureUrls.delete(vastTagUrl);
7588
7592
  return [
@@ -7629,10 +7633,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7629
7633
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7630
7634
  this.scheduleAdStopAtBreakBoundary();
7631
7635
  }
7632
- currentMuted1 = this.video.muted;
7633
- currentVolume1 = this.video.volume;
7634
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7635
- this.ima.setAdVolume(adVolume1);
7636
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7636
7637
  return [
7637
7638
  2
7638
7639
  ];
@@ -7706,10 +7707,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7706
7707
  ];
7707
7708
  case 14:
7708
7709
  _state.sent();
7709
- currentMuted2 = this.video.muted;
7710
- currentVolume2 = this.video.volume;
7711
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7712
- this.ima.setAdVolume(adVolume2);
7710
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7713
7711
  return [
7714
7712
  2
7715
7713
  ];
@@ -7749,6 +7747,33 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7749
7747
  }).call(this);
7750
7748
  }
7751
7749
  },
7750
+ {
7751
+ key: "capturePreAdBreakAudio",
7752
+ value: function capturePreAdBreakAudio() {
7753
+ if (this.preAdBreakAudio) {
7754
+ return;
7755
+ }
7756
+ var captured = {
7757
+ muted: this.video.muted,
7758
+ volume: typeof this.video.volume === "number" && !Number.isNaN(this.video.volume) ? Math.max(0, Math.min(1, this.video.volume)) : 1
7759
+ };
7760
+ this.preAdBreakAudio = captured;
7761
+ this.ima.updateOriginalMutedState(captured.muted, captured.volume);
7762
+ if (this.config.debugAdTiming) {
7763
+ console.log("[StormcloudVideoPlayer] Captured pre-ad-break audio state: muted=".concat(captured.muted, ", volume=").concat(captured.volume));
7764
+ }
7765
+ }
7766
+ },
7767
+ {
7768
+ key: "getPreAdBreakAdVolume",
7769
+ value: function getPreAdBreakAdVolume() {
7770
+ var state = this.preAdBreakAudio;
7771
+ if (state) {
7772
+ return state.muted ? 0 : state.volume;
7773
+ }
7774
+ return this.ima.getOriginalMutedState() ? 0 : this.ima.getOriginalVolume();
7775
+ }
7776
+ },
7752
7777
  {
7753
7778
  key: "handleAdPodComplete",
7754
7779
  value: function handleAdPodComplete() {
@@ -7782,14 +7807,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7782
7807
  this.consecutiveFailures = 0;
7783
7808
  this.globalConsecutiveNoFills = 0;
7784
7809
  this.ima.stop().catch(function() {});
7785
- var restoredMuted = this.ima.getOriginalMutedState();
7786
- var restoredVolume = this.ima.getOriginalVolume();
7810
+ var restoredMuted = this.preAdBreakAudio ? this.preAdBreakAudio.muted : this.ima.getOriginalMutedState();
7811
+ var restoredVolume = this.preAdBreakAudio ? this.preAdBreakAudio.volume : this.ima.getOriginalVolume();
7812
+ this.ima.updateOriginalMutedState(restoredMuted, restoredVolume);
7787
7813
  if (this.video.muted !== restoredMuted) {
7788
7814
  this.video.muted = restoredMuted;
7789
7815
  }
7790
7816
  if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
7791
7817
  this.video.volume = restoredVolume;
7792
7818
  }
7819
+ this.preAdBreakAudio = void 0;
7820
+ if (this.config.debugAdTiming) {
7821
+ console.log("[StormcloudVideoPlayer] Restored post-ad-break audio state: muted=".concat(restoredMuted, ", volume=").concat(restoredVolume));
7822
+ }
7793
7823
  if (this.shouldContinueLiveStreamDuringAds()) {
7794
7824
  if (this.video.paused) {
7795
7825
  var _this_video_play;
@@ -8199,6 +8229,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8199
8229
  this.clearAdFailsafeTimer();
8200
8230
  this.clearAdRequestWatchdog();
8201
8231
  this.clearPendingAdBreak();
8232
+ this.preAdBreakAudio = void 0;
8202
8233
  if (this.placeholderContainer) {
8203
8234
  if (this.placeholderContainer.parentElement) {
8204
8235
  this.placeholderContainer.parentElement.removeChild(this.placeholderContainer);