stormcloud-video-player 0.8.7 → 0.8.9

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.
@@ -814,7 +814,6 @@ function createHlsAdPlayer(contentVideo, options) {
814
814
  adPlaying = false;
815
815
  setAdPlayingFlag(false);
816
816
  contentVideo.muted = true;
817
- contentVideo.volume = 0;
818
817
  if (adContainerEl) {
819
818
  adContainerEl.style.display = "none";
820
819
  adContainerEl.style.pointerEvents = "none";
@@ -834,7 +833,6 @@ function createHlsAdPlayer(contentVideo, options) {
834
833
  adPlaying = false;
835
834
  setAdPlayingFlag(false);
836
835
  contentVideo.muted = true;
837
- contentVideo.volume = 0;
838
836
  if (adContainerEl) {
839
837
  adContainerEl.style.display = "none";
840
838
  adContainerEl.style.pointerEvents = "none";
@@ -939,7 +937,7 @@ function createHlsAdPlayer(contentVideo, options) {
939
937
  },
940
938
  play: function play() {
941
939
  return _async_to_generator(function() {
942
- var contentVolume, adVolume, mediaFile, isHlsAd;
940
+ var contentVolume, mediaFile, isHlsAd;
943
941
  return _ts_generator(this, function(_state) {
944
942
  if (!currentAd) {
945
943
  console.warn("[HlsAdPlayer] Cannot play: No ad loaded (no ads available)");
@@ -973,13 +971,11 @@ function createHlsAdPlayer(contentVideo, options) {
973
971
  }
974
972
  console.log("[HlsAdPlayer] FORCE MUTING main video");
975
973
  contentVideo.muted = true;
976
- contentVideo.volume = 0;
977
974
  adPlaying = true;
978
975
  setAdPlayingFlag(true);
979
976
  if (adVideoElement) {
980
- adVolume = originalMutedState ? 0 : originalVolume;
981
- adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
982
- adVideoElement.muted = false;
977
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
978
+ adVideoElement.muted = originalMutedState;
983
979
  console.log("[HlsAdPlayer] Set ad video volume to ".concat(adVideoElement.volume, ", muted: ").concat(adVideoElement.muted, ", originalMutedState: ").concat(originalMutedState, ", contentVolume: ").concat(contentVolume));
984
980
  }
985
981
  if (adContainerEl) {
@@ -1087,8 +1083,8 @@ function createHlsAdPlayer(contentVideo, options) {
1087
1083
  setAdPlayingFlag(false);
1088
1084
  previousMutedState = contentVideo.muted;
1089
1085
  contentVideo.muted = originalMutedState;
1090
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1091
- console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState));
1086
+ contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1087
+ console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState, ", volume: ").concat(contentVideo.volume));
1092
1088
  if (adContainerEl) {
1093
1089
  adContainerEl.style.display = "none";
1094
1090
  adContainerEl.style.pointerEvents = "none";
@@ -1143,7 +1139,7 @@ function createHlsAdPlayer(contentVideo, options) {
1143
1139
  adPlaying = false;
1144
1140
  setAdPlayingFlag(false);
1145
1141
  contentVideo.muted = originalMutedState;
1146
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1142
+ contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1147
1143
  if (adHls) {
1148
1144
  adHls.destroy();
1149
1145
  adHls = void 0;
@@ -1199,7 +1195,9 @@ function createHlsAdPlayer(contentVideo, options) {
1199
1195
  },
1200
1196
  setAdVolume: function setAdVolume(volume) {
1201
1197
  if (adVideoElement && adPlaying) {
1202
- adVideoElement.volume = Math.max(0, Math.min(1, volume));
1198
+ var clamped = Math.max(0, Math.min(1, volume));
1199
+ adVideoElement.volume = clamped;
1200
+ adVideoElement.muted = clamped === 0;
1203
1201
  }
1204
1202
  },
1205
1203
  getAdVolume: function getAdVolume() {
@@ -2652,6 +2650,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2652
2650
  this.preloadPoolActive = false;
2653
2651
  this.preloadPoolLoopRunning = false;
2654
2652
  this.adDetectSentForCurrentBreak = false;
2653
+ this.adBreakEpoch = 0;
2655
2654
  this.palPlaybackStarted = false;
2656
2655
  this.streamCorrelator = generateCorrelator();
2657
2656
  this.consentSignals = {};
@@ -3194,10 +3193,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3194
3193
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3195
3194
  }
3196
3195
  }
3197
- var currentMuted = _this.video.muted;
3198
- var currentVolume = _this.video.volume;
3199
- var adVolume = currentMuted ? 0 : currentVolume;
3200
- _this.adPlayer.setAdVolume(adVolume);
3196
+ _this.adPlayer.setAdVolume(_this.getAdAudioVolume());
3201
3197
  if (_this.isShowingPlaceholder) {
3202
3198
  if (_this.config.debugAdTiming) {
3203
3199
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -3214,7 +3210,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3214
3210
  }).catch(function() {});
3215
3211
  if (!_this.video.muted) {
3216
3212
  _this.video.muted = true;
3217
- _this.video.volume = 0;
3218
3213
  if (_this.config.debugAdTiming) {
3219
3214
  console.log("[StormcloudVideoPlayer] Muted video on content_resume (ad ended, gap between ads)");
3220
3215
  }
@@ -3262,7 +3257,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3262
3257
  try {
3263
3258
  this.adPlayer.destroy();
3264
3259
  this.video.muted = true;
3265
- this.video.volume = 0;
3266
3260
  } catch (error) {
3267
3261
  if (this.config.debugAdTiming) {
3268
3262
  console.warn("[StormcloudVideoPlayer] Error destroying old AdController:", error);
@@ -3321,7 +3315,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3321
3315
  }
3322
3316
  if (!this.video.muted) {
3323
3317
  this.video.muted = true;
3324
- this.video.volume = 0;
3325
3318
  if (this.config.debugAdTiming) {
3326
3319
  console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
3327
3320
  }
@@ -3943,7 +3936,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3943
3936
  if (marker.type === "end") {
3944
3937
  if (!this.video.muted) {
3945
3938
  this.video.muted = true;
3946
- this.video.volume = 0;
3947
3939
  if (this.config.debugAdTiming) {
3948
3940
  console.log("[StormcloudVideoPlayer] Muted video on SCTE end marker");
3949
3941
  }
@@ -3981,13 +3973,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3981
3973
  {
3982
3974
  key: "startScte35AdBreak",
3983
3975
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
3984
- if (!this.video.muted) {
3985
- this.video.muted = true;
3986
- this.video.volume = 0;
3987
- if (this.config.debugAdTiming) {
3988
- console.log("[StormcloudVideoPlayer] Muted video on SCTE start marker");
3989
- }
3990
- }
3991
3976
  this.inAdBreak = true;
3992
3977
  this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
3993
3978
  this.scheduledScte35BreakKey = void 0;
@@ -5213,7 +5198,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5213
5198
  key: "preloadAdIntoPool",
5214
5199
  value: function preloadAdIntoPool(vastUrl) {
5215
5200
  return _async_to_generator(function() {
5216
- var _this, loadPromise;
5201
+ var _this, epoch, loadPromise;
5217
5202
  return _ts_generator(this, function(_state) {
5218
5203
  _this = this;
5219
5204
  if (this.isGamInCooldown()) {
@@ -5239,6 +5224,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5239
5224
  if (this.config.debugAdTiming) {
5240
5225
  console.log("[PRELOAD-POOL] \uD83D\uDCE5 Preloading ad into pool: ".concat(vastUrl));
5241
5226
  }
5227
+ epoch = this.adBreakEpoch;
5242
5228
  loadPromise = function() {
5243
5229
  return _async_to_generator(function() {
5244
5230
  var _this, hasAdError, adErrorPayload, errorListenerCleanup, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, lateErrorListener, error;
@@ -5316,6 +5302,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5316
5302
  2
5317
5303
  ];
5318
5304
  }
5305
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch) {
5306
+ if (this.config.debugAdTiming) {
5307
+ console.log("[PRELOAD-POOL] \uD83D\uDEAB Discarding preloaded ad - break ended during fetch");
5308
+ }
5309
+ if (errorListenerCleanup) {
5310
+ errorListenerCleanup();
5311
+ }
5312
+ try {
5313
+ preloadAd.destroy();
5314
+ } catch (unused) {}
5315
+ return [
5316
+ 2
5317
+ ];
5318
+ }
5319
5319
  poolEntry = {
5320
5320
  vastUrl: vastUrl,
5321
5321
  adController: preloadAd,
@@ -5387,7 +5387,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5387
5387
  key: "preloadPoolLoop",
5388
5388
  value: function preloadPoolLoop(baseVastUrl) {
5389
5389
  return _async_to_generator(function() {
5390
- var remaining, newUrls, newUrl;
5390
+ var epoch, remaining, newUrls, newUrl;
5391
5391
  return _ts_generator(this, function(_state) {
5392
5392
  switch(_state.label){
5393
5393
  case 0:
@@ -5397,12 +5397,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5397
5397
  ];
5398
5398
  }
5399
5399
  this.preloadPoolLoopRunning = true;
5400
+ epoch = this.adBreakEpoch;
5400
5401
  if (this.config.debugAdTiming) {
5401
5402
  console.log("[PRELOAD-POOL] \uD83D\uDD04 Starting continuous preload loop");
5402
5403
  }
5403
5404
  _state.label = 1;
5404
5405
  case 1:
5405
- if (!this.preloadPoolActive) return [
5406
+ if (!(this.preloadPoolActive && epoch === this.adBreakEpoch)) return [
5406
5407
  3,
5407
5408
  10
5408
5409
  ];
@@ -5447,7 +5448,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5447
5448
  3,
5448
5449
  8
5449
5450
  ];
5450
- if (!this.preloadPoolActive || this.isGamInCooldown()) {
5451
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch || this.isGamInCooldown()) {
5451
5452
  return [
5452
5453
  3,
5453
5454
  8
@@ -5574,7 +5575,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5574
5575
  key: "handleAdStart",
5575
5576
  value: function handleAdStart(_marker) {
5576
5577
  return _async_to_generator(function() {
5577
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, adVolume, adVolume1, error, fallbackPreloaded, adVolume2, fallbackError;
5578
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, preservedMuted, preservedVolume, adVolume, adVolume1, error, fallbackPreloaded, preservedMuted1, preservedVolume1, adVolume2, fallbackError;
5578
5579
  return _ts_generator(this, function(_state) {
5579
5580
  switch(_state.label){
5580
5581
  case 0:
@@ -5614,7 +5615,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5614
5615
  this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
5615
5616
  if (!this.video.muted) {
5616
5617
  this.video.muted = true;
5617
- this.video.volume = 0;
5618
5618
  if (this.config.debugAdTiming) {
5619
5619
  console.log("[StormcloudVideoPlayer] Muted video in handleAdStart");
5620
5620
  }
@@ -5684,10 +5684,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5684
5684
  3,
5685
5685
  3
5686
5686
  ];
5687
+ preservedMuted = this.adPlayer.getOriginalMutedState();
5688
+ preservedVolume = this.adPlayer.getOriginalVolume();
5687
5689
  this.adPlayer.destroy();
5688
5690
  this.video.muted = true;
5689
- this.video.volume = 0;
5690
5691
  this.adPlayer = preloadedController;
5692
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
5691
5693
  this.attachImaEventListeners();
5692
5694
  if (this.config.debugAdTiming) {
5693
5695
  console.log("[CONTINUOUS-FETCH] \u2705 Using preloaded ad, resuming and starting playback immediately (no request delay!)");
@@ -5785,11 +5787,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5785
5787
  ,
5786
5788
  12
5787
5789
  ]);
5790
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
5791
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
5788
5792
  this.adPlayer.destroy();
5789
5793
  this.video.muted = true;
5790
- this.video.volume = 0;
5791
5794
  this.adPlayer = fallbackPreloaded.adController;
5792
5795
  this.attachImaEventListeners();
5796
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
5793
5797
  this.adPlayer.resume();
5794
5798
  this.consecutiveFailures = 0;
5795
5799
  this.currentAdIndex++;
@@ -5877,7 +5881,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5877
5881
  key: "continuousFetchLoop",
5878
5882
  value: function continuousFetchLoop(baseVastUrl) {
5879
5883
  return _async_to_generator(function() {
5880
- var _this, _loop, _ret;
5884
+ var _this, _loop, epoch, _ret;
5881
5885
  return _ts_generator(this, function(_state) {
5882
5886
  switch(_state.label){
5883
5887
  case 0:
@@ -5987,9 +5991,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5987
5991
  }
5988
5992
  });
5989
5993
  };
5994
+ epoch = this.adBreakEpoch;
5990
5995
  _state.label = 1;
5991
5996
  case 1:
5992
- if (!(this.continuousFetchingActive && this.inAdBreak)) return [
5997
+ if (!(this.continuousFetchingActive && this.inAdBreak && epoch === this.adBreakEpoch)) return [
5993
5998
  3,
5994
5999
  3
5995
6000
  ];
@@ -6038,10 +6043,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6038
6043
  key: "tryNextAvailableAdWithRateLimit",
6039
6044
  value: function tryNextAvailableAdWithRateLimit() {
6040
6045
  return _async_to_generator(function() {
6041
- var backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6046
+ var epoch, backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6042
6047
  return _ts_generator(this, function(_state) {
6043
6048
  switch(_state.label){
6044
6049
  case 0:
6050
+ if (!this.inAdBreak) {
6051
+ return [
6052
+ 2
6053
+ ];
6054
+ }
6055
+ epoch = this.adBreakEpoch;
6045
6056
  if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
6046
6057
  if (this.config.debugAdTiming) {
6047
6058
  console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive failures (".concat(this.consecutiveFailures, "), ending ad break gracefully"));
@@ -6073,6 +6084,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6073
6084
  _state.sent();
6074
6085
  _state.label = 2;
6075
6086
  case 2:
6087
+ if (!this.inAdBreak || epoch !== this.adBreakEpoch) {
6088
+ return [
6089
+ 2
6090
+ ];
6091
+ }
6076
6092
  return [
6077
6093
  2,
6078
6094
  this.tryNextAvailableAd(0)
@@ -6087,10 +6103,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6087
6103
  value: function tryNextAvailableAd() {
6088
6104
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6089
6105
  return _async_to_generator(function() {
6090
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6106
+ var remaining, preloaded, preservedMuted, preservedVolume, error, nextAdUrl, error1, errorMessage, maxRetries;
6091
6107
  return _ts_generator(this, function(_state) {
6092
6108
  switch(_state.label){
6093
6109
  case 0:
6110
+ if (!this.inAdBreak) {
6111
+ return [
6112
+ 2
6113
+ ];
6114
+ }
6094
6115
  remaining = this.getRemainingAdMs();
6095
6116
  if (remaining <= 500) {
6096
6117
  if (this.config.debugAdTiming) {
@@ -6141,11 +6162,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6141
6162
  ,
6142
6163
  4
6143
6164
  ]);
6165
+ preservedMuted = this.adPlayer.getOriginalMutedState();
6166
+ preservedVolume = this.adPlayer.getOriginalVolume();
6144
6167
  this.adPlayer.destroy();
6145
6168
  this.video.muted = true;
6146
- this.video.volume = 0;
6147
6169
  this.adPlayer = preloaded.adController;
6148
6170
  this.attachImaEventListeners();
6171
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
6149
6172
  this.adPlayer.resume();
6150
6173
  this.currentAdIndex++;
6151
6174
  this.totalAdRequestsInBreak++;
@@ -6159,10 +6182,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6159
6182
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6160
6183
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6161
6184
  }
6162
- currentMuted = this.video.muted;
6163
- currentVolume = this.video.volume;
6164
- adVolume = currentMuted ? 0 : currentVolume;
6165
- this.adPlayer.setAdVolume(adVolume);
6185
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6166
6186
  this.consecutiveFailures = 0;
6167
6187
  return [
6168
6188
  2
@@ -6209,9 +6229,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6209
6229
  if (this.config.debugAdTiming) {
6210
6230
  console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC Requesting next ad via HLS ad player (".concat(this.currentAdIndex + 1, "/").concat(this.totalAdsInBreak, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
6211
6231
  }
6212
- currentMuted1 = this.video.muted;
6213
- currentVolume1 = this.video.volume;
6214
- this.adPlayer.updateOriginalMutedState(currentMuted1, currentVolume1);
6215
6232
  this.currentAdIndex++;
6216
6233
  this.totalAdRequestsInBreak++;
6217
6234
  this.lastAdRequestTime = Date.now();
@@ -6304,7 +6321,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6304
6321
  key: "showPlaceholderAndWaitForAds",
6305
6322
  value: function showPlaceholderAndWaitForAds() {
6306
6323
  return _async_to_generator(function() {
6307
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
6324
+ var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
6308
6325
  return _ts_generator(this, function(_state) {
6309
6326
  switch(_state.label){
6310
6327
  case 0:
@@ -6400,9 +6417,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6400
6417
  }
6401
6418
  this.isShowingPlaceholder = false;
6402
6419
  this.adPlayer.hidePlaceholder();
6403
- currentMuted = this.video.muted;
6404
- currentVolume = this.video.volume;
6405
- this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
6406
6420
  this.currentAdIndex++;
6407
6421
  this.totalAdRequestsInBreak++;
6408
6422
  this.lastAdRequestTime = Date.now();
@@ -6852,7 +6866,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6852
6866
  key: "playSingleAd",
6853
6867
  value: function playSingleAd(vastTagUrl) {
6854
6868
  return _async_to_generator(function() {
6855
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
6869
+ var requestToken, playError, preloadedFallback, preservedMuted, preservedVolume, fallbackError, error, errorMessage, preloadedFallback1, preservedMuted1, preservedVolume1, fallbackError1;
6856
6870
  return _ts_generator(this, function(_state) {
6857
6871
  switch(_state.label){
6858
6872
  case 0:
@@ -6939,10 +6953,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6939
6953
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6940
6954
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6941
6955
  }
6942
- currentMuted = this.video.muted;
6943
- currentVolume = this.video.volume;
6944
- adVolume = currentMuted ? 0 : currentVolume;
6945
- this.adPlayer.setAdVolume(adVolume);
6956
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6946
6957
  this.consecutiveFailures = 0;
6947
6958
  this.temporaryFailureUrls.delete(vastTagUrl);
6948
6959
  return [
@@ -6971,11 +6982,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6971
6982
  10
6972
6983
  ]);
6973
6984
  this.clearAdFailsafeTimer();
6985
+ preservedMuted = this.adPlayer.getOriginalMutedState();
6986
+ preservedVolume = this.adPlayer.getOriginalVolume();
6974
6987
  this.adPlayer.destroy();
6975
6988
  this.video.muted = true;
6976
- this.video.volume = 0;
6977
6989
  this.adPlayer = preloadedFallback.adController;
6978
6990
  this.attachImaEventListeners();
6991
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
6979
6992
  this.adPlayer.resume();
6980
6993
  this.consecutiveFailures = 0;
6981
6994
  this.currentAdIndex++;
@@ -6989,10 +7002,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6989
7002
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6990
7003
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6991
7004
  }
6992
- currentMuted1 = this.video.muted;
6993
- currentVolume1 = this.video.volume;
6994
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
6995
- this.adPlayer.setAdVolume(adVolume1);
7005
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6996
7006
  return [
6997
7007
  2
6998
7008
  ];
@@ -7051,11 +7061,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7051
7061
  ]);
7052
7062
  this.clearAdRequestWatchdog();
7053
7063
  this.clearAdFailsafeTimer();
7064
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
7065
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
7054
7066
  this.adPlayer.destroy();
7055
7067
  this.video.muted = true;
7056
- this.video.volume = 0;
7057
7068
  this.adPlayer = preloadedFallback1.adController;
7058
7069
  this.attachImaEventListeners();
7070
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
7059
7071
  this.adPlayer.resume();
7060
7072
  this.consecutiveFailures = 0;
7061
7073
  this.currentAdIndex++;
@@ -7066,10 +7078,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7066
7078
  ];
7067
7079
  case 14:
7068
7080
  _state.sent();
7069
- currentMuted2 = this.video.muted;
7070
- currentVolume2 = this.video.volume;
7071
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7072
- this.adPlayer.setAdVolume(adVolume2);
7081
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7073
7082
  return [
7074
7083
  2
7075
7084
  ];
@@ -7115,6 +7124,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7115
7124
  if (this.config.debugAdTiming) {
7116
7125
  console.log("[StormcloudVideoPlayer] \uD83C\uDFC1 Ad pod complete - cleaning up");
7117
7126
  }
7127
+ this.adBreakEpoch++;
7118
7128
  this.clearAdRequestWatchdog();
7119
7129
  this.clearAdFailsafeTimer();
7120
7130
  this.activeAdRequestToken = null;
@@ -7371,10 +7381,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7371
7381
  key: "toggleMute",
7372
7382
  value: function toggleMute() {
7373
7383
  if (this.adPlayer.isAdPlaying()) {
7374
- var currentPerceptualState = this.isMuted();
7375
- var newMutedState = !currentPerceptualState;
7384
+ var newMutedState = !this.adPlayer.getOriginalMutedState();
7385
+ var restoreVolume = this.adPlayer.getOriginalVolume() || 1;
7376
7386
  this.adPlayer.updateOriginalMutedState(newMutedState, this.video.volume);
7377
- this.adPlayer.setAdVolume(newMutedState ? 0 : 1);
7387
+ this.adPlayer.setAdVolume(newMutedState ? 0 : restoreVolume);
7378
7388
  if (this.config.debugAdTiming) {
7379
7389
  console.log("[StormcloudVideoPlayer] Mute toggle during ad - immediately applied:", newMutedState);
7380
7390
  }
@@ -7429,10 +7439,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7429
7439
  key: "isMuted",
7430
7440
  value: function isMuted() {
7431
7441
  if (this.adPlayer.isAdPlaying()) {
7432
- if (this.config.debugAdTiming) {
7433
- console.log("[StormcloudVideoPlayer] isMuted() override during ad playback -> false");
7434
- }
7435
- return false;
7442
+ return this.adPlayer.getOriginalMutedState();
7436
7443
  }
7437
7444
  return this.video.muted;
7438
7445
  }
@@ -7499,6 +7506,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7499
7506
  return this.video.volume;
7500
7507
  }
7501
7508
  },
7509
+ {
7510
+ key: "getAdAudioVolume",
7511
+ value: function getAdAudioVolume() {
7512
+ return this.adPlayer.getOriginalMutedState() ? 0 : this.adPlayer.getOriginalVolume();
7513
+ }
7514
+ },
7502
7515
  {
7503
7516
  key: "isFullscreen",
7504
7517
  value: function isFullscreen() {