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.
@@ -902,7 +902,6 @@ function createHlsAdPlayer(contentVideo, options) {
902
902
  adPlaying = false;
903
903
  setAdPlayingFlag(false);
904
904
  contentVideo.muted = true;
905
- contentVideo.volume = 0;
906
905
  if (adContainerEl) {
907
906
  adContainerEl.style.display = "none";
908
907
  adContainerEl.style.pointerEvents = "none";
@@ -922,7 +921,6 @@ function createHlsAdPlayer(contentVideo, options) {
922
921
  adPlaying = false;
923
922
  setAdPlayingFlag(false);
924
923
  contentVideo.muted = true;
925
- contentVideo.volume = 0;
926
924
  if (adContainerEl) {
927
925
  adContainerEl.style.display = "none";
928
926
  adContainerEl.style.pointerEvents = "none";
@@ -1027,7 +1025,7 @@ function createHlsAdPlayer(contentVideo, options) {
1027
1025
  },
1028
1026
  play: function play() {
1029
1027
  return _async_to_generator(function() {
1030
- var contentVolume, adVolume, mediaFile, isHlsAd;
1028
+ var contentVolume, mediaFile, isHlsAd;
1031
1029
  return _ts_generator(this, function(_state) {
1032
1030
  if (!currentAd) {
1033
1031
  console.warn("[HlsAdPlayer] Cannot play: No ad loaded (no ads available)");
@@ -1061,13 +1059,11 @@ function createHlsAdPlayer(contentVideo, options) {
1061
1059
  }
1062
1060
  console.log("[HlsAdPlayer] FORCE MUTING main video");
1063
1061
  contentVideo.muted = true;
1064
- contentVideo.volume = 0;
1065
1062
  adPlaying = true;
1066
1063
  setAdPlayingFlag(true);
1067
1064
  if (adVideoElement) {
1068
- adVolume = originalMutedState ? 0 : originalVolume;
1069
- adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
1070
- adVideoElement.muted = false;
1065
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
1066
+ adVideoElement.muted = originalMutedState;
1071
1067
  console.log("[HlsAdPlayer] Set ad video volume to ".concat(adVideoElement.volume, ", muted: ").concat(adVideoElement.muted, ", originalMutedState: ").concat(originalMutedState, ", contentVolume: ").concat(contentVolume));
1072
1068
  }
1073
1069
  if (adContainerEl) {
@@ -1175,8 +1171,8 @@ function createHlsAdPlayer(contentVideo, options) {
1175
1171
  setAdPlayingFlag(false);
1176
1172
  previousMutedState = contentVideo.muted;
1177
1173
  contentVideo.muted = originalMutedState;
1178
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1179
- console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState));
1174
+ contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1175
+ console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState, ", volume: ").concat(contentVideo.volume));
1180
1176
  if (adContainerEl) {
1181
1177
  adContainerEl.style.display = "none";
1182
1178
  adContainerEl.style.pointerEvents = "none";
@@ -1231,7 +1227,7 @@ function createHlsAdPlayer(contentVideo, options) {
1231
1227
  adPlaying = false;
1232
1228
  setAdPlayingFlag(false);
1233
1229
  contentVideo.muted = originalMutedState;
1234
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1230
+ contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1235
1231
  if (adHls) {
1236
1232
  adHls.destroy();
1237
1233
  adHls = void 0;
@@ -1287,7 +1283,9 @@ function createHlsAdPlayer(contentVideo, options) {
1287
1283
  },
1288
1284
  setAdVolume: function setAdVolume(volume) {
1289
1285
  if (adVideoElement && adPlaying) {
1290
- adVideoElement.volume = Math.max(0, Math.min(1, volume));
1286
+ var clamped = Math.max(0, Math.min(1, volume));
1287
+ adVideoElement.volume = clamped;
1288
+ adVideoElement.muted = clamped === 0;
1291
1289
  }
1292
1290
  },
1293
1291
  getAdVolume: function getAdVolume() {
@@ -2740,6 +2738,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2740
2738
  this.preloadPoolActive = false;
2741
2739
  this.preloadPoolLoopRunning = false;
2742
2740
  this.adDetectSentForCurrentBreak = false;
2741
+ this.adBreakEpoch = 0;
2743
2742
  this.palPlaybackStarted = false;
2744
2743
  this.streamCorrelator = generateCorrelator();
2745
2744
  this.consentSignals = {};
@@ -3282,10 +3281,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3282
3281
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3283
3282
  }
3284
3283
  }
3285
- var currentMuted = _this.video.muted;
3286
- var currentVolume = _this.video.volume;
3287
- var adVolume = currentMuted ? 0 : currentVolume;
3288
- _this.adPlayer.setAdVolume(adVolume);
3284
+ _this.adPlayer.setAdVolume(_this.getAdAudioVolume());
3289
3285
  if (_this.isShowingPlaceholder) {
3290
3286
  if (_this.config.debugAdTiming) {
3291
3287
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -3302,7 +3298,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3302
3298
  }).catch(function() {});
3303
3299
  if (!_this.video.muted) {
3304
3300
  _this.video.muted = true;
3305
- _this.video.volume = 0;
3306
3301
  if (_this.config.debugAdTiming) {
3307
3302
  console.log("[StormcloudVideoPlayer] Muted video on content_resume (ad ended, gap between ads)");
3308
3303
  }
@@ -3350,7 +3345,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3350
3345
  try {
3351
3346
  this.adPlayer.destroy();
3352
3347
  this.video.muted = true;
3353
- this.video.volume = 0;
3354
3348
  } catch (error) {
3355
3349
  if (this.config.debugAdTiming) {
3356
3350
  console.warn("[StormcloudVideoPlayer] Error destroying old AdController:", error);
@@ -3409,7 +3403,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3409
3403
  }
3410
3404
  if (!this.video.muted) {
3411
3405
  this.video.muted = true;
3412
- this.video.volume = 0;
3413
3406
  if (this.config.debugAdTiming) {
3414
3407
  console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
3415
3408
  }
@@ -4031,7 +4024,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4031
4024
  if (marker.type === "end") {
4032
4025
  if (!this.video.muted) {
4033
4026
  this.video.muted = true;
4034
- this.video.volume = 0;
4035
4027
  if (this.config.debugAdTiming) {
4036
4028
  console.log("[StormcloudVideoPlayer] Muted video on SCTE end marker");
4037
4029
  }
@@ -4069,13 +4061,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4069
4061
  {
4070
4062
  key: "startScte35AdBreak",
4071
4063
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
4072
- if (!this.video.muted) {
4073
- this.video.muted = true;
4074
- this.video.volume = 0;
4075
- if (this.config.debugAdTiming) {
4076
- console.log("[StormcloudVideoPlayer] Muted video on SCTE start marker");
4077
- }
4078
- }
4079
4064
  this.inAdBreak = true;
4080
4065
  this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
4081
4066
  this.scheduledScte35BreakKey = void 0;
@@ -5301,7 +5286,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5301
5286
  key: "preloadAdIntoPool",
5302
5287
  value: function preloadAdIntoPool(vastUrl) {
5303
5288
  return _async_to_generator(function() {
5304
- var _this, loadPromise;
5289
+ var _this, epoch, loadPromise;
5305
5290
  return _ts_generator(this, function(_state) {
5306
5291
  _this = this;
5307
5292
  if (this.isGamInCooldown()) {
@@ -5327,6 +5312,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5327
5312
  if (this.config.debugAdTiming) {
5328
5313
  console.log("[PRELOAD-POOL] \uD83D\uDCE5 Preloading ad into pool: ".concat(vastUrl));
5329
5314
  }
5315
+ epoch = this.adBreakEpoch;
5330
5316
  loadPromise = function() {
5331
5317
  return _async_to_generator(function() {
5332
5318
  var _this, hasAdError, adErrorPayload, errorListenerCleanup, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, lateErrorListener, error;
@@ -5404,6 +5390,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5404
5390
  2
5405
5391
  ];
5406
5392
  }
5393
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch) {
5394
+ if (this.config.debugAdTiming) {
5395
+ console.log("[PRELOAD-POOL] \uD83D\uDEAB Discarding preloaded ad - break ended during fetch");
5396
+ }
5397
+ if (errorListenerCleanup) {
5398
+ errorListenerCleanup();
5399
+ }
5400
+ try {
5401
+ preloadAd.destroy();
5402
+ } catch (unused) {}
5403
+ return [
5404
+ 2
5405
+ ];
5406
+ }
5407
5407
  poolEntry = {
5408
5408
  vastUrl: vastUrl,
5409
5409
  adController: preloadAd,
@@ -5475,7 +5475,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5475
5475
  key: "preloadPoolLoop",
5476
5476
  value: function preloadPoolLoop(baseVastUrl) {
5477
5477
  return _async_to_generator(function() {
5478
- var remaining, newUrls, newUrl;
5478
+ var epoch, remaining, newUrls, newUrl;
5479
5479
  return _ts_generator(this, function(_state) {
5480
5480
  switch(_state.label){
5481
5481
  case 0:
@@ -5485,12 +5485,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5485
5485
  ];
5486
5486
  }
5487
5487
  this.preloadPoolLoopRunning = true;
5488
+ epoch = this.adBreakEpoch;
5488
5489
  if (this.config.debugAdTiming) {
5489
5490
  console.log("[PRELOAD-POOL] \uD83D\uDD04 Starting continuous preload loop");
5490
5491
  }
5491
5492
  _state.label = 1;
5492
5493
  case 1:
5493
- if (!this.preloadPoolActive) return [
5494
+ if (!(this.preloadPoolActive && epoch === this.adBreakEpoch)) return [
5494
5495
  3,
5495
5496
  10
5496
5497
  ];
@@ -5535,7 +5536,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5535
5536
  3,
5536
5537
  8
5537
5538
  ];
5538
- if (!this.preloadPoolActive || this.isGamInCooldown()) {
5539
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch || this.isGamInCooldown()) {
5539
5540
  return [
5540
5541
  3,
5541
5542
  8
@@ -5662,7 +5663,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5662
5663
  key: "handleAdStart",
5663
5664
  value: function handleAdStart(_marker) {
5664
5665
  return _async_to_generator(function() {
5665
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, adVolume, adVolume1, error, fallbackPreloaded, adVolume2, fallbackError;
5666
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, preservedMuted, preservedVolume, adVolume, adVolume1, error, fallbackPreloaded, preservedMuted1, preservedVolume1, adVolume2, fallbackError;
5666
5667
  return _ts_generator(this, function(_state) {
5667
5668
  switch(_state.label){
5668
5669
  case 0:
@@ -5702,7 +5703,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5702
5703
  this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
5703
5704
  if (!this.video.muted) {
5704
5705
  this.video.muted = true;
5705
- this.video.volume = 0;
5706
5706
  if (this.config.debugAdTiming) {
5707
5707
  console.log("[StormcloudVideoPlayer] Muted video in handleAdStart");
5708
5708
  }
@@ -5772,10 +5772,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5772
5772
  3,
5773
5773
  3
5774
5774
  ];
5775
+ preservedMuted = this.adPlayer.getOriginalMutedState();
5776
+ preservedVolume = this.adPlayer.getOriginalVolume();
5775
5777
  this.adPlayer.destroy();
5776
5778
  this.video.muted = true;
5777
- this.video.volume = 0;
5778
5779
  this.adPlayer = preloadedController;
5780
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
5779
5781
  this.attachImaEventListeners();
5780
5782
  if (this.config.debugAdTiming) {
5781
5783
  console.log("[CONTINUOUS-FETCH] \u2705 Using preloaded ad, resuming and starting playback immediately (no request delay!)");
@@ -5873,11 +5875,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5873
5875
  ,
5874
5876
  12
5875
5877
  ]);
5878
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
5879
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
5876
5880
  this.adPlayer.destroy();
5877
5881
  this.video.muted = true;
5878
- this.video.volume = 0;
5879
5882
  this.adPlayer = fallbackPreloaded.adController;
5880
5883
  this.attachImaEventListeners();
5884
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
5881
5885
  this.adPlayer.resume();
5882
5886
  this.consecutiveFailures = 0;
5883
5887
  this.currentAdIndex++;
@@ -5965,7 +5969,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5965
5969
  key: "continuousFetchLoop",
5966
5970
  value: function continuousFetchLoop(baseVastUrl) {
5967
5971
  return _async_to_generator(function() {
5968
- var _this, _loop, _ret;
5972
+ var _this, _loop, epoch, _ret;
5969
5973
  return _ts_generator(this, function(_state) {
5970
5974
  switch(_state.label){
5971
5975
  case 0:
@@ -6075,9 +6079,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6075
6079
  }
6076
6080
  });
6077
6081
  };
6082
+ epoch = this.adBreakEpoch;
6078
6083
  _state.label = 1;
6079
6084
  case 1:
6080
- if (!(this.continuousFetchingActive && this.inAdBreak)) return [
6085
+ if (!(this.continuousFetchingActive && this.inAdBreak && epoch === this.adBreakEpoch)) return [
6081
6086
  3,
6082
6087
  3
6083
6088
  ];
@@ -6126,10 +6131,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6126
6131
  key: "tryNextAvailableAdWithRateLimit",
6127
6132
  value: function tryNextAvailableAdWithRateLimit() {
6128
6133
  return _async_to_generator(function() {
6129
- var backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6134
+ var epoch, backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6130
6135
  return _ts_generator(this, function(_state) {
6131
6136
  switch(_state.label){
6132
6137
  case 0:
6138
+ if (!this.inAdBreak) {
6139
+ return [
6140
+ 2
6141
+ ];
6142
+ }
6143
+ epoch = this.adBreakEpoch;
6133
6144
  if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
6134
6145
  if (this.config.debugAdTiming) {
6135
6146
  console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive failures (".concat(this.consecutiveFailures, "), ending ad break gracefully"));
@@ -6161,6 +6172,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6161
6172
  _state.sent();
6162
6173
  _state.label = 2;
6163
6174
  case 2:
6175
+ if (!this.inAdBreak || epoch !== this.adBreakEpoch) {
6176
+ return [
6177
+ 2
6178
+ ];
6179
+ }
6164
6180
  return [
6165
6181
  2,
6166
6182
  this.tryNextAvailableAd(0)
@@ -6175,10 +6191,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6175
6191
  value: function tryNextAvailableAd() {
6176
6192
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6177
6193
  return _async_to_generator(function() {
6178
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6194
+ var remaining, preloaded, preservedMuted, preservedVolume, error, nextAdUrl, error1, errorMessage, maxRetries;
6179
6195
  return _ts_generator(this, function(_state) {
6180
6196
  switch(_state.label){
6181
6197
  case 0:
6198
+ if (!this.inAdBreak) {
6199
+ return [
6200
+ 2
6201
+ ];
6202
+ }
6182
6203
  remaining = this.getRemainingAdMs();
6183
6204
  if (remaining <= 500) {
6184
6205
  if (this.config.debugAdTiming) {
@@ -6229,11 +6250,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6229
6250
  ,
6230
6251
  4
6231
6252
  ]);
6253
+ preservedMuted = this.adPlayer.getOriginalMutedState();
6254
+ preservedVolume = this.adPlayer.getOriginalVolume();
6232
6255
  this.adPlayer.destroy();
6233
6256
  this.video.muted = true;
6234
- this.video.volume = 0;
6235
6257
  this.adPlayer = preloaded.adController;
6236
6258
  this.attachImaEventListeners();
6259
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
6237
6260
  this.adPlayer.resume();
6238
6261
  this.currentAdIndex++;
6239
6262
  this.totalAdRequestsInBreak++;
@@ -6247,10 +6270,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6247
6270
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6248
6271
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6249
6272
  }
6250
- currentMuted = this.video.muted;
6251
- currentVolume = this.video.volume;
6252
- adVolume = currentMuted ? 0 : currentVolume;
6253
- this.adPlayer.setAdVolume(adVolume);
6273
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6254
6274
  this.consecutiveFailures = 0;
6255
6275
  return [
6256
6276
  2
@@ -6297,9 +6317,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6297
6317
  if (this.config.debugAdTiming) {
6298
6318
  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)"));
6299
6319
  }
6300
- currentMuted1 = this.video.muted;
6301
- currentVolume1 = this.video.volume;
6302
- this.adPlayer.updateOriginalMutedState(currentMuted1, currentVolume1);
6303
6320
  this.currentAdIndex++;
6304
6321
  this.totalAdRequestsInBreak++;
6305
6322
  this.lastAdRequestTime = Date.now();
@@ -6392,7 +6409,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6392
6409
  key: "showPlaceholderAndWaitForAds",
6393
6410
  value: function showPlaceholderAndWaitForAds() {
6394
6411
  return _async_to_generator(function() {
6395
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
6412
+ var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
6396
6413
  return _ts_generator(this, function(_state) {
6397
6414
  switch(_state.label){
6398
6415
  case 0:
@@ -6488,9 +6505,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6488
6505
  }
6489
6506
  this.isShowingPlaceholder = false;
6490
6507
  this.adPlayer.hidePlaceholder();
6491
- currentMuted = this.video.muted;
6492
- currentVolume = this.video.volume;
6493
- this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
6494
6508
  this.currentAdIndex++;
6495
6509
  this.totalAdRequestsInBreak++;
6496
6510
  this.lastAdRequestTime = Date.now();
@@ -6940,7 +6954,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6940
6954
  key: "playSingleAd",
6941
6955
  value: function playSingleAd(vastTagUrl) {
6942
6956
  return _async_to_generator(function() {
6943
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
6957
+ var requestToken, playError, preloadedFallback, preservedMuted, preservedVolume, fallbackError, error, errorMessage, preloadedFallback1, preservedMuted1, preservedVolume1, fallbackError1;
6944
6958
  return _ts_generator(this, function(_state) {
6945
6959
  switch(_state.label){
6946
6960
  case 0:
@@ -7027,10 +7041,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7027
7041
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7028
7042
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
7029
7043
  }
7030
- currentMuted = this.video.muted;
7031
- currentVolume = this.video.volume;
7032
- adVolume = currentMuted ? 0 : currentVolume;
7033
- this.adPlayer.setAdVolume(adVolume);
7044
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7034
7045
  this.consecutiveFailures = 0;
7035
7046
  this.temporaryFailureUrls.delete(vastTagUrl);
7036
7047
  return [
@@ -7059,11 +7070,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7059
7070
  10
7060
7071
  ]);
7061
7072
  this.clearAdFailsafeTimer();
7073
+ preservedMuted = this.adPlayer.getOriginalMutedState();
7074
+ preservedVolume = this.adPlayer.getOriginalVolume();
7062
7075
  this.adPlayer.destroy();
7063
7076
  this.video.muted = true;
7064
- this.video.volume = 0;
7065
7077
  this.adPlayer = preloadedFallback.adController;
7066
7078
  this.attachImaEventListeners();
7079
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
7067
7080
  this.adPlayer.resume();
7068
7081
  this.consecutiveFailures = 0;
7069
7082
  this.currentAdIndex++;
@@ -7077,10 +7090,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7077
7090
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7078
7091
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
7079
7092
  }
7080
- currentMuted1 = this.video.muted;
7081
- currentVolume1 = this.video.volume;
7082
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7083
- this.adPlayer.setAdVolume(adVolume1);
7093
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7084
7094
  return [
7085
7095
  2
7086
7096
  ];
@@ -7139,11 +7149,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7139
7149
  ]);
7140
7150
  this.clearAdRequestWatchdog();
7141
7151
  this.clearAdFailsafeTimer();
7152
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
7153
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
7142
7154
  this.adPlayer.destroy();
7143
7155
  this.video.muted = true;
7144
- this.video.volume = 0;
7145
7156
  this.adPlayer = preloadedFallback1.adController;
7146
7157
  this.attachImaEventListeners();
7158
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
7147
7159
  this.adPlayer.resume();
7148
7160
  this.consecutiveFailures = 0;
7149
7161
  this.currentAdIndex++;
@@ -7154,10 +7166,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7154
7166
  ];
7155
7167
  case 14:
7156
7168
  _state.sent();
7157
- currentMuted2 = this.video.muted;
7158
- currentVolume2 = this.video.volume;
7159
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7160
- this.adPlayer.setAdVolume(adVolume2);
7169
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7161
7170
  return [
7162
7171
  2
7163
7172
  ];
@@ -7203,6 +7212,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7203
7212
  if (this.config.debugAdTiming) {
7204
7213
  console.log("[StormcloudVideoPlayer] \uD83C\uDFC1 Ad pod complete - cleaning up");
7205
7214
  }
7215
+ this.adBreakEpoch++;
7206
7216
  this.clearAdRequestWatchdog();
7207
7217
  this.clearAdFailsafeTimer();
7208
7218
  this.activeAdRequestToken = null;
@@ -7459,10 +7469,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7459
7469
  key: "toggleMute",
7460
7470
  value: function toggleMute() {
7461
7471
  if (this.adPlayer.isAdPlaying()) {
7462
- var currentPerceptualState = this.isMuted();
7463
- var newMutedState = !currentPerceptualState;
7472
+ var newMutedState = !this.adPlayer.getOriginalMutedState();
7473
+ var restoreVolume = this.adPlayer.getOriginalVolume() || 1;
7464
7474
  this.adPlayer.updateOriginalMutedState(newMutedState, this.video.volume);
7465
- this.adPlayer.setAdVolume(newMutedState ? 0 : 1);
7475
+ this.adPlayer.setAdVolume(newMutedState ? 0 : restoreVolume);
7466
7476
  if (this.config.debugAdTiming) {
7467
7477
  console.log("[StormcloudVideoPlayer] Mute toggle during ad - immediately applied:", newMutedState);
7468
7478
  }
@@ -7517,10 +7527,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7517
7527
  key: "isMuted",
7518
7528
  value: function isMuted() {
7519
7529
  if (this.adPlayer.isAdPlaying()) {
7520
- if (this.config.debugAdTiming) {
7521
- console.log("[StormcloudVideoPlayer] isMuted() override during ad playback -> false");
7522
- }
7523
- return false;
7530
+ return this.adPlayer.getOriginalMutedState();
7524
7531
  }
7525
7532
  return this.video.muted;
7526
7533
  }
@@ -7587,6 +7594,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7587
7594
  return this.video.volume;
7588
7595
  }
7589
7596
  },
7597
+ {
7598
+ key: "getAdAudioVolume",
7599
+ value: function getAdAudioVolume() {
7600
+ return this.adPlayer.getOriginalMutedState() ? 0 : this.adPlayer.getOriginalVolume();
7601
+ }
7602
+ },
7590
7603
  {
7591
7604
  key: "isFullscreen",
7592
7605
  value: function isFullscreen() {