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.
package/lib/index.cjs CHANGED
@@ -1050,7 +1050,6 @@ function createHlsAdPlayer(contentVideo, options) {
1050
1050
  adPlaying = false;
1051
1051
  setAdPlayingFlag(false);
1052
1052
  contentVideo.muted = true;
1053
- contentVideo.volume = 0;
1054
1053
  if (adContainerEl) {
1055
1054
  adContainerEl.style.display = "none";
1056
1055
  adContainerEl.style.pointerEvents = "none";
@@ -1070,7 +1069,6 @@ function createHlsAdPlayer(contentVideo, options) {
1070
1069
  adPlaying = false;
1071
1070
  setAdPlayingFlag(false);
1072
1071
  contentVideo.muted = true;
1073
- contentVideo.volume = 0;
1074
1072
  if (adContainerEl) {
1075
1073
  adContainerEl.style.display = "none";
1076
1074
  adContainerEl.style.pointerEvents = "none";
@@ -1175,7 +1173,7 @@ function createHlsAdPlayer(contentVideo, options) {
1175
1173
  },
1176
1174
  play: function play() {
1177
1175
  return _async_to_generator(function() {
1178
- var contentVolume, adVolume, mediaFile, isHlsAd;
1176
+ var contentVolume, mediaFile, isHlsAd;
1179
1177
  return _ts_generator(this, function(_state) {
1180
1178
  if (!currentAd) {
1181
1179
  console.warn("[HlsAdPlayer] Cannot play: No ad loaded (no ads available)");
@@ -1209,13 +1207,11 @@ function createHlsAdPlayer(contentVideo, options) {
1209
1207
  }
1210
1208
  console.log("[HlsAdPlayer] FORCE MUTING main video");
1211
1209
  contentVideo.muted = true;
1212
- contentVideo.volume = 0;
1213
1210
  adPlaying = true;
1214
1211
  setAdPlayingFlag(true);
1215
1212
  if (adVideoElement) {
1216
- adVolume = originalMutedState ? 0 : originalVolume;
1217
- adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
1218
- adVideoElement.muted = false;
1213
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
1214
+ adVideoElement.muted = originalMutedState;
1219
1215
  console.log("[HlsAdPlayer] Set ad video volume to ".concat(adVideoElement.volume, ", muted: ").concat(adVideoElement.muted, ", originalMutedState: ").concat(originalMutedState, ", contentVolume: ").concat(contentVolume));
1220
1216
  }
1221
1217
  if (adContainerEl) {
@@ -1323,8 +1319,8 @@ function createHlsAdPlayer(contentVideo, options) {
1323
1319
  setAdPlayingFlag(false);
1324
1320
  previousMutedState = contentVideo.muted;
1325
1321
  contentVideo.muted = originalMutedState;
1326
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1327
- console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState));
1322
+ contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1323
+ console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState, ", volume: ").concat(contentVideo.volume));
1328
1324
  if (adContainerEl) {
1329
1325
  adContainerEl.style.display = "none";
1330
1326
  adContainerEl.style.pointerEvents = "none";
@@ -1379,7 +1375,7 @@ function createHlsAdPlayer(contentVideo, options) {
1379
1375
  adPlaying = false;
1380
1376
  setAdPlayingFlag(false);
1381
1377
  contentVideo.muted = originalMutedState;
1382
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1378
+ contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1383
1379
  if (adHls) {
1384
1380
  adHls.destroy();
1385
1381
  adHls = void 0;
@@ -1435,7 +1431,9 @@ function createHlsAdPlayer(contentVideo, options) {
1435
1431
  },
1436
1432
  setAdVolume: function setAdVolume(volume) {
1437
1433
  if (adVideoElement && adPlaying) {
1438
- adVideoElement.volume = Math.max(0, Math.min(1, volume));
1434
+ var clamped = Math.max(0, Math.min(1, volume));
1435
+ adVideoElement.volume = clamped;
1436
+ adVideoElement.muted = clamped === 0;
1439
1437
  }
1440
1438
  },
1441
1439
  getAdVolume: function getAdVolume() {
@@ -2935,6 +2933,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2935
2933
  this.preloadPoolActive = false;
2936
2934
  this.preloadPoolLoopRunning = false;
2937
2935
  this.adDetectSentForCurrentBreak = false;
2936
+ this.adBreakEpoch = 0;
2938
2937
  this.palPlaybackStarted = false;
2939
2938
  this.streamCorrelator = generateCorrelator();
2940
2939
  this.consentSignals = {};
@@ -3477,10 +3476,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3477
3476
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3478
3477
  }
3479
3478
  }
3480
- var currentMuted = _this.video.muted;
3481
- var currentVolume = _this.video.volume;
3482
- var adVolume = currentMuted ? 0 : currentVolume;
3483
- _this.adPlayer.setAdVolume(adVolume);
3479
+ _this.adPlayer.setAdVolume(_this.getAdAudioVolume());
3484
3480
  if (_this.isShowingPlaceholder) {
3485
3481
  if (_this.config.debugAdTiming) {
3486
3482
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -3497,7 +3493,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3497
3493
  }).catch(function() {});
3498
3494
  if (!_this.video.muted) {
3499
3495
  _this.video.muted = true;
3500
- _this.video.volume = 0;
3501
3496
  if (_this.config.debugAdTiming) {
3502
3497
  console.log("[StormcloudVideoPlayer] Muted video on content_resume (ad ended, gap between ads)");
3503
3498
  }
@@ -3545,7 +3540,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3545
3540
  try {
3546
3541
  this.adPlayer.destroy();
3547
3542
  this.video.muted = true;
3548
- this.video.volume = 0;
3549
3543
  } catch (error) {
3550
3544
  if (this.config.debugAdTiming) {
3551
3545
  console.warn("[StormcloudVideoPlayer] Error destroying old AdController:", error);
@@ -3604,7 +3598,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3604
3598
  }
3605
3599
  if (!this.video.muted) {
3606
3600
  this.video.muted = true;
3607
- this.video.volume = 0;
3608
3601
  if (this.config.debugAdTiming) {
3609
3602
  console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
3610
3603
  }
@@ -4226,7 +4219,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4226
4219
  if (marker.type === "end") {
4227
4220
  if (!this.video.muted) {
4228
4221
  this.video.muted = true;
4229
- this.video.volume = 0;
4230
4222
  if (this.config.debugAdTiming) {
4231
4223
  console.log("[StormcloudVideoPlayer] Muted video on SCTE end marker");
4232
4224
  }
@@ -4264,13 +4256,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4264
4256
  {
4265
4257
  key: "startScte35AdBreak",
4266
4258
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
4267
- if (!this.video.muted) {
4268
- this.video.muted = true;
4269
- this.video.volume = 0;
4270
- if (this.config.debugAdTiming) {
4271
- console.log("[StormcloudVideoPlayer] Muted video on SCTE start marker");
4272
- }
4273
- }
4274
4259
  this.inAdBreak = true;
4275
4260
  this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
4276
4261
  this.scheduledScte35BreakKey = void 0;
@@ -5496,7 +5481,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5496
5481
  key: "preloadAdIntoPool",
5497
5482
  value: function preloadAdIntoPool(vastUrl) {
5498
5483
  return _async_to_generator(function() {
5499
- var _this, loadPromise;
5484
+ var _this, epoch, loadPromise;
5500
5485
  return _ts_generator(this, function(_state) {
5501
5486
  _this = this;
5502
5487
  if (this.isGamInCooldown()) {
@@ -5522,6 +5507,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5522
5507
  if (this.config.debugAdTiming) {
5523
5508
  console.log("[PRELOAD-POOL] \uD83D\uDCE5 Preloading ad into pool: ".concat(vastUrl));
5524
5509
  }
5510
+ epoch = this.adBreakEpoch;
5525
5511
  loadPromise = function() {
5526
5512
  return _async_to_generator(function() {
5527
5513
  var _this, hasAdError, adErrorPayload, errorListenerCleanup, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, lateErrorListener, error;
@@ -5599,6 +5585,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5599
5585
  2
5600
5586
  ];
5601
5587
  }
5588
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch) {
5589
+ if (this.config.debugAdTiming) {
5590
+ console.log("[PRELOAD-POOL] \uD83D\uDEAB Discarding preloaded ad - break ended during fetch");
5591
+ }
5592
+ if (errorListenerCleanup) {
5593
+ errorListenerCleanup();
5594
+ }
5595
+ try {
5596
+ preloadAd.destroy();
5597
+ } catch (unused) {}
5598
+ return [
5599
+ 2
5600
+ ];
5601
+ }
5602
5602
  poolEntry = {
5603
5603
  vastUrl: vastUrl,
5604
5604
  adController: preloadAd,
@@ -5670,7 +5670,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5670
5670
  key: "preloadPoolLoop",
5671
5671
  value: function preloadPoolLoop(baseVastUrl) {
5672
5672
  return _async_to_generator(function() {
5673
- var remaining, newUrls, newUrl;
5673
+ var epoch, remaining, newUrls, newUrl;
5674
5674
  return _ts_generator(this, function(_state) {
5675
5675
  switch(_state.label){
5676
5676
  case 0:
@@ -5680,12 +5680,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5680
5680
  ];
5681
5681
  }
5682
5682
  this.preloadPoolLoopRunning = true;
5683
+ epoch = this.adBreakEpoch;
5683
5684
  if (this.config.debugAdTiming) {
5684
5685
  console.log("[PRELOAD-POOL] \uD83D\uDD04 Starting continuous preload loop");
5685
5686
  }
5686
5687
  _state.label = 1;
5687
5688
  case 1:
5688
- if (!this.preloadPoolActive) return [
5689
+ if (!(this.preloadPoolActive && epoch === this.adBreakEpoch)) return [
5689
5690
  3,
5690
5691
  10
5691
5692
  ];
@@ -5730,7 +5731,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5730
5731
  3,
5731
5732
  8
5732
5733
  ];
5733
- if (!this.preloadPoolActive || this.isGamInCooldown()) {
5734
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch || this.isGamInCooldown()) {
5734
5735
  return [
5735
5736
  3,
5736
5737
  8
@@ -5857,7 +5858,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5857
5858
  key: "handleAdStart",
5858
5859
  value: function handleAdStart(_marker) {
5859
5860
  return _async_to_generator(function() {
5860
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, adVolume, adVolume1, error, fallbackPreloaded, adVolume2, fallbackError;
5861
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, preservedMuted, preservedVolume, adVolume, adVolume1, error, fallbackPreloaded, preservedMuted1, preservedVolume1, adVolume2, fallbackError;
5861
5862
  return _ts_generator(this, function(_state) {
5862
5863
  switch(_state.label){
5863
5864
  case 0:
@@ -5897,7 +5898,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5897
5898
  this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
5898
5899
  if (!this.video.muted) {
5899
5900
  this.video.muted = true;
5900
- this.video.volume = 0;
5901
5901
  if (this.config.debugAdTiming) {
5902
5902
  console.log("[StormcloudVideoPlayer] Muted video in handleAdStart");
5903
5903
  }
@@ -5967,10 +5967,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5967
5967
  3,
5968
5968
  3
5969
5969
  ];
5970
+ preservedMuted = this.adPlayer.getOriginalMutedState();
5971
+ preservedVolume = this.adPlayer.getOriginalVolume();
5970
5972
  this.adPlayer.destroy();
5971
5973
  this.video.muted = true;
5972
- this.video.volume = 0;
5973
5974
  this.adPlayer = preloadedController;
5975
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
5974
5976
  this.attachImaEventListeners();
5975
5977
  if (this.config.debugAdTiming) {
5976
5978
  console.log("[CONTINUOUS-FETCH] \u2705 Using preloaded ad, resuming and starting playback immediately (no request delay!)");
@@ -6068,11 +6070,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6068
6070
  ,
6069
6071
  12
6070
6072
  ]);
6073
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
6074
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
6071
6075
  this.adPlayer.destroy();
6072
6076
  this.video.muted = true;
6073
- this.video.volume = 0;
6074
6077
  this.adPlayer = fallbackPreloaded.adController;
6075
6078
  this.attachImaEventListeners();
6079
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
6076
6080
  this.adPlayer.resume();
6077
6081
  this.consecutiveFailures = 0;
6078
6082
  this.currentAdIndex++;
@@ -6160,7 +6164,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6160
6164
  key: "continuousFetchLoop",
6161
6165
  value: function continuousFetchLoop(baseVastUrl) {
6162
6166
  return _async_to_generator(function() {
6163
- var _this, _loop, _ret;
6167
+ var _this, _loop, epoch, _ret;
6164
6168
  return _ts_generator(this, function(_state) {
6165
6169
  switch(_state.label){
6166
6170
  case 0:
@@ -6270,9 +6274,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6270
6274
  }
6271
6275
  });
6272
6276
  };
6277
+ epoch = this.adBreakEpoch;
6273
6278
  _state.label = 1;
6274
6279
  case 1:
6275
- if (!(this.continuousFetchingActive && this.inAdBreak)) return [
6280
+ if (!(this.continuousFetchingActive && this.inAdBreak && epoch === this.adBreakEpoch)) return [
6276
6281
  3,
6277
6282
  3
6278
6283
  ];
@@ -6321,10 +6326,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6321
6326
  key: "tryNextAvailableAdWithRateLimit",
6322
6327
  value: function tryNextAvailableAdWithRateLimit() {
6323
6328
  return _async_to_generator(function() {
6324
- var backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6329
+ var epoch, backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6325
6330
  return _ts_generator(this, function(_state) {
6326
6331
  switch(_state.label){
6327
6332
  case 0:
6333
+ if (!this.inAdBreak) {
6334
+ return [
6335
+ 2
6336
+ ];
6337
+ }
6338
+ epoch = this.adBreakEpoch;
6328
6339
  if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
6329
6340
  if (this.config.debugAdTiming) {
6330
6341
  console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive failures (".concat(this.consecutiveFailures, "), ending ad break gracefully"));
@@ -6356,6 +6367,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6356
6367
  _state.sent();
6357
6368
  _state.label = 2;
6358
6369
  case 2:
6370
+ if (!this.inAdBreak || epoch !== this.adBreakEpoch) {
6371
+ return [
6372
+ 2
6373
+ ];
6374
+ }
6359
6375
  return [
6360
6376
  2,
6361
6377
  this.tryNextAvailableAd(0)
@@ -6370,10 +6386,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6370
6386
  value: function tryNextAvailableAd() {
6371
6387
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6372
6388
  return _async_to_generator(function() {
6373
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6389
+ var remaining, preloaded, preservedMuted, preservedVolume, error, nextAdUrl, error1, errorMessage, maxRetries;
6374
6390
  return _ts_generator(this, function(_state) {
6375
6391
  switch(_state.label){
6376
6392
  case 0:
6393
+ if (!this.inAdBreak) {
6394
+ return [
6395
+ 2
6396
+ ];
6397
+ }
6377
6398
  remaining = this.getRemainingAdMs();
6378
6399
  if (remaining <= 500) {
6379
6400
  if (this.config.debugAdTiming) {
@@ -6424,11 +6445,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6424
6445
  ,
6425
6446
  4
6426
6447
  ]);
6448
+ preservedMuted = this.adPlayer.getOriginalMutedState();
6449
+ preservedVolume = this.adPlayer.getOriginalVolume();
6427
6450
  this.adPlayer.destroy();
6428
6451
  this.video.muted = true;
6429
- this.video.volume = 0;
6430
6452
  this.adPlayer = preloaded.adController;
6431
6453
  this.attachImaEventListeners();
6454
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
6432
6455
  this.adPlayer.resume();
6433
6456
  this.currentAdIndex++;
6434
6457
  this.totalAdRequestsInBreak++;
@@ -6442,10 +6465,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6442
6465
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6443
6466
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6444
6467
  }
6445
- currentMuted = this.video.muted;
6446
- currentVolume = this.video.volume;
6447
- adVolume = currentMuted ? 0 : currentVolume;
6448
- this.adPlayer.setAdVolume(adVolume);
6468
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6449
6469
  this.consecutiveFailures = 0;
6450
6470
  return [
6451
6471
  2
@@ -6492,9 +6512,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6492
6512
  if (this.config.debugAdTiming) {
6493
6513
  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)"));
6494
6514
  }
6495
- currentMuted1 = this.video.muted;
6496
- currentVolume1 = this.video.volume;
6497
- this.adPlayer.updateOriginalMutedState(currentMuted1, currentVolume1);
6498
6515
  this.currentAdIndex++;
6499
6516
  this.totalAdRequestsInBreak++;
6500
6517
  this.lastAdRequestTime = Date.now();
@@ -6587,7 +6604,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6587
6604
  key: "showPlaceholderAndWaitForAds",
6588
6605
  value: function showPlaceholderAndWaitForAds() {
6589
6606
  return _async_to_generator(function() {
6590
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
6607
+ var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
6591
6608
  return _ts_generator(this, function(_state) {
6592
6609
  switch(_state.label){
6593
6610
  case 0:
@@ -6683,9 +6700,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6683
6700
  }
6684
6701
  this.isShowingPlaceholder = false;
6685
6702
  this.adPlayer.hidePlaceholder();
6686
- currentMuted = this.video.muted;
6687
- currentVolume = this.video.volume;
6688
- this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
6689
6703
  this.currentAdIndex++;
6690
6704
  this.totalAdRequestsInBreak++;
6691
6705
  this.lastAdRequestTime = Date.now();
@@ -7135,7 +7149,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7135
7149
  key: "playSingleAd",
7136
7150
  value: function playSingleAd(vastTagUrl) {
7137
7151
  return _async_to_generator(function() {
7138
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
7152
+ var requestToken, playError, preloadedFallback, preservedMuted, preservedVolume, fallbackError, error, errorMessage, preloadedFallback1, preservedMuted1, preservedVolume1, fallbackError1;
7139
7153
  return _ts_generator(this, function(_state) {
7140
7154
  switch(_state.label){
7141
7155
  case 0:
@@ -7222,10 +7236,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7222
7236
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7223
7237
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
7224
7238
  }
7225
- currentMuted = this.video.muted;
7226
- currentVolume = this.video.volume;
7227
- adVolume = currentMuted ? 0 : currentVolume;
7228
- this.adPlayer.setAdVolume(adVolume);
7239
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7229
7240
  this.consecutiveFailures = 0;
7230
7241
  this.temporaryFailureUrls.delete(vastTagUrl);
7231
7242
  return [
@@ -7254,11 +7265,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7254
7265
  10
7255
7266
  ]);
7256
7267
  this.clearAdFailsafeTimer();
7268
+ preservedMuted = this.adPlayer.getOriginalMutedState();
7269
+ preservedVolume = this.adPlayer.getOriginalVolume();
7257
7270
  this.adPlayer.destroy();
7258
7271
  this.video.muted = true;
7259
- this.video.volume = 0;
7260
7272
  this.adPlayer = preloadedFallback.adController;
7261
7273
  this.attachImaEventListeners();
7274
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
7262
7275
  this.adPlayer.resume();
7263
7276
  this.consecutiveFailures = 0;
7264
7277
  this.currentAdIndex++;
@@ -7272,10 +7285,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7272
7285
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7273
7286
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
7274
7287
  }
7275
- currentMuted1 = this.video.muted;
7276
- currentVolume1 = this.video.volume;
7277
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7278
- this.adPlayer.setAdVolume(adVolume1);
7288
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7279
7289
  return [
7280
7290
  2
7281
7291
  ];
@@ -7334,11 +7344,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7334
7344
  ]);
7335
7345
  this.clearAdRequestWatchdog();
7336
7346
  this.clearAdFailsafeTimer();
7347
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
7348
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
7337
7349
  this.adPlayer.destroy();
7338
7350
  this.video.muted = true;
7339
- this.video.volume = 0;
7340
7351
  this.adPlayer = preloadedFallback1.adController;
7341
7352
  this.attachImaEventListeners();
7353
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
7342
7354
  this.adPlayer.resume();
7343
7355
  this.consecutiveFailures = 0;
7344
7356
  this.currentAdIndex++;
@@ -7349,10 +7361,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7349
7361
  ];
7350
7362
  case 14:
7351
7363
  _state.sent();
7352
- currentMuted2 = this.video.muted;
7353
- currentVolume2 = this.video.volume;
7354
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7355
- this.adPlayer.setAdVolume(adVolume2);
7364
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7356
7365
  return [
7357
7366
  2
7358
7367
  ];
@@ -7398,6 +7407,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7398
7407
  if (this.config.debugAdTiming) {
7399
7408
  console.log("[StormcloudVideoPlayer] \uD83C\uDFC1 Ad pod complete - cleaning up");
7400
7409
  }
7410
+ this.adBreakEpoch++;
7401
7411
  this.clearAdRequestWatchdog();
7402
7412
  this.clearAdFailsafeTimer();
7403
7413
  this.activeAdRequestToken = null;
@@ -7654,10 +7664,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7654
7664
  key: "toggleMute",
7655
7665
  value: function toggleMute() {
7656
7666
  if (this.adPlayer.isAdPlaying()) {
7657
- var currentPerceptualState = this.isMuted();
7658
- var newMutedState = !currentPerceptualState;
7667
+ var newMutedState = !this.adPlayer.getOriginalMutedState();
7668
+ var restoreVolume = this.adPlayer.getOriginalVolume() || 1;
7659
7669
  this.adPlayer.updateOriginalMutedState(newMutedState, this.video.volume);
7660
- this.adPlayer.setAdVolume(newMutedState ? 0 : 1);
7670
+ this.adPlayer.setAdVolume(newMutedState ? 0 : restoreVolume);
7661
7671
  if (this.config.debugAdTiming) {
7662
7672
  console.log("[StormcloudVideoPlayer] Mute toggle during ad - immediately applied:", newMutedState);
7663
7673
  }
@@ -7712,10 +7722,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7712
7722
  key: "isMuted",
7713
7723
  value: function isMuted() {
7714
7724
  if (this.adPlayer.isAdPlaying()) {
7715
- if (this.config.debugAdTiming) {
7716
- console.log("[StormcloudVideoPlayer] isMuted() override during ad playback -> false");
7717
- }
7718
- return false;
7725
+ return this.adPlayer.getOriginalMutedState();
7719
7726
  }
7720
7727
  return this.video.muted;
7721
7728
  }
@@ -7782,6 +7789,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7782
7789
  return this.video.volume;
7783
7790
  }
7784
7791
  },
7792
+ {
7793
+ key: "getAdAudioVolume",
7794
+ value: function getAdAudioVolume() {
7795
+ return this.adPlayer.getOriginalMutedState() ? 0 : this.adPlayer.getOriginalVolume();
7796
+ }
7797
+ },
7785
7798
  {
7786
7799
  key: "isFullscreen",
7787
7800
  value: function isFullscreen() {