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.
@@ -852,7 +852,6 @@ function createHlsAdPlayer(contentVideo, options) {
852
852
  adPlaying = false;
853
853
  setAdPlayingFlag(false);
854
854
  contentVideo.muted = true;
855
- contentVideo.volume = 0;
856
855
  if (adContainerEl) {
857
856
  adContainerEl.style.display = "none";
858
857
  adContainerEl.style.pointerEvents = "none";
@@ -872,7 +871,6 @@ function createHlsAdPlayer(contentVideo, options) {
872
871
  adPlaying = false;
873
872
  setAdPlayingFlag(false);
874
873
  contentVideo.muted = true;
875
- contentVideo.volume = 0;
876
874
  if (adContainerEl) {
877
875
  adContainerEl.style.display = "none";
878
876
  adContainerEl.style.pointerEvents = "none";
@@ -977,7 +975,7 @@ function createHlsAdPlayer(contentVideo, options) {
977
975
  },
978
976
  play: function play() {
979
977
  return _async_to_generator(function() {
980
- var contentVolume, adVolume, mediaFile, isHlsAd;
978
+ var contentVolume, mediaFile, isHlsAd;
981
979
  return _ts_generator(this, function(_state) {
982
980
  if (!currentAd) {
983
981
  console.warn("[HlsAdPlayer] Cannot play: No ad loaded (no ads available)");
@@ -1011,13 +1009,11 @@ function createHlsAdPlayer(contentVideo, options) {
1011
1009
  }
1012
1010
  console.log("[HlsAdPlayer] FORCE MUTING main video");
1013
1011
  contentVideo.muted = true;
1014
- contentVideo.volume = 0;
1015
1012
  adPlaying = true;
1016
1013
  setAdPlayingFlag(true);
1017
1014
  if (adVideoElement) {
1018
- adVolume = originalMutedState ? 0 : originalVolume;
1019
- adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
1020
- adVideoElement.muted = false;
1015
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
1016
+ adVideoElement.muted = originalMutedState;
1021
1017
  console.log("[HlsAdPlayer] Set ad video volume to ".concat(adVideoElement.volume, ", muted: ").concat(adVideoElement.muted, ", originalMutedState: ").concat(originalMutedState, ", contentVolume: ").concat(contentVolume));
1022
1018
  }
1023
1019
  if (adContainerEl) {
@@ -1125,8 +1121,8 @@ function createHlsAdPlayer(contentVideo, options) {
1125
1121
  setAdPlayingFlag(false);
1126
1122
  previousMutedState = contentVideo.muted;
1127
1123
  contentVideo.muted = originalMutedState;
1128
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1129
- console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState));
1124
+ contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1125
+ console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState, ", volume: ").concat(contentVideo.volume));
1130
1126
  if (adContainerEl) {
1131
1127
  adContainerEl.style.display = "none";
1132
1128
  adContainerEl.style.pointerEvents = "none";
@@ -1181,7 +1177,7 @@ function createHlsAdPlayer(contentVideo, options) {
1181
1177
  adPlaying = false;
1182
1178
  setAdPlayingFlag(false);
1183
1179
  contentVideo.muted = originalMutedState;
1184
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1180
+ contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1185
1181
  if (adHls) {
1186
1182
  adHls.destroy();
1187
1183
  adHls = void 0;
@@ -1237,7 +1233,9 @@ function createHlsAdPlayer(contentVideo, options) {
1237
1233
  },
1238
1234
  setAdVolume: function setAdVolume(volume) {
1239
1235
  if (adVideoElement && adPlaying) {
1240
- adVideoElement.volume = Math.max(0, Math.min(1, volume));
1236
+ var clamped = Math.max(0, Math.min(1, volume));
1237
+ adVideoElement.volume = clamped;
1238
+ adVideoElement.muted = clamped === 0;
1241
1239
  }
1242
1240
  },
1243
1241
  getAdVolume: function getAdVolume() {
@@ -2690,6 +2688,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2690
2688
  this.preloadPoolActive = false;
2691
2689
  this.preloadPoolLoopRunning = false;
2692
2690
  this.adDetectSentForCurrentBreak = false;
2691
+ this.adBreakEpoch = 0;
2693
2692
  this.palPlaybackStarted = false;
2694
2693
  this.streamCorrelator = generateCorrelator();
2695
2694
  this.consentSignals = {};
@@ -3232,10 +3231,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3232
3231
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3233
3232
  }
3234
3233
  }
3235
- var currentMuted = _this.video.muted;
3236
- var currentVolume = _this.video.volume;
3237
- var adVolume = currentMuted ? 0 : currentVolume;
3238
- _this.adPlayer.setAdVolume(adVolume);
3234
+ _this.adPlayer.setAdVolume(_this.getAdAudioVolume());
3239
3235
  if (_this.isShowingPlaceholder) {
3240
3236
  if (_this.config.debugAdTiming) {
3241
3237
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -3252,7 +3248,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3252
3248
  }).catch(function() {});
3253
3249
  if (!_this.video.muted) {
3254
3250
  _this.video.muted = true;
3255
- _this.video.volume = 0;
3256
3251
  if (_this.config.debugAdTiming) {
3257
3252
  console.log("[StormcloudVideoPlayer] Muted video on content_resume (ad ended, gap between ads)");
3258
3253
  }
@@ -3300,7 +3295,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3300
3295
  try {
3301
3296
  this.adPlayer.destroy();
3302
3297
  this.video.muted = true;
3303
- this.video.volume = 0;
3304
3298
  } catch (error) {
3305
3299
  if (this.config.debugAdTiming) {
3306
3300
  console.warn("[StormcloudVideoPlayer] Error destroying old AdController:", error);
@@ -3359,7 +3353,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3359
3353
  }
3360
3354
  if (!this.video.muted) {
3361
3355
  this.video.muted = true;
3362
- this.video.volume = 0;
3363
3356
  if (this.config.debugAdTiming) {
3364
3357
  console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
3365
3358
  }
@@ -3981,7 +3974,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3981
3974
  if (marker.type === "end") {
3982
3975
  if (!this.video.muted) {
3983
3976
  this.video.muted = true;
3984
- this.video.volume = 0;
3985
3977
  if (this.config.debugAdTiming) {
3986
3978
  console.log("[StormcloudVideoPlayer] Muted video on SCTE end marker");
3987
3979
  }
@@ -4019,13 +4011,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4019
4011
  {
4020
4012
  key: "startScte35AdBreak",
4021
4013
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
4022
- if (!this.video.muted) {
4023
- this.video.muted = true;
4024
- this.video.volume = 0;
4025
- if (this.config.debugAdTiming) {
4026
- console.log("[StormcloudVideoPlayer] Muted video on SCTE start marker");
4027
- }
4028
- }
4029
4014
  this.inAdBreak = true;
4030
4015
  this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
4031
4016
  this.scheduledScte35BreakKey = void 0;
@@ -5251,7 +5236,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5251
5236
  key: "preloadAdIntoPool",
5252
5237
  value: function preloadAdIntoPool(vastUrl) {
5253
5238
  return _async_to_generator(function() {
5254
- var _this, loadPromise;
5239
+ var _this, epoch, loadPromise;
5255
5240
  return _ts_generator(this, function(_state) {
5256
5241
  _this = this;
5257
5242
  if (this.isGamInCooldown()) {
@@ -5277,6 +5262,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5277
5262
  if (this.config.debugAdTiming) {
5278
5263
  console.log("[PRELOAD-POOL] \uD83D\uDCE5 Preloading ad into pool: ".concat(vastUrl));
5279
5264
  }
5265
+ epoch = this.adBreakEpoch;
5280
5266
  loadPromise = function() {
5281
5267
  return _async_to_generator(function() {
5282
5268
  var _this, hasAdError, adErrorPayload, errorListenerCleanup, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, lateErrorListener, error;
@@ -5354,6 +5340,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5354
5340
  2
5355
5341
  ];
5356
5342
  }
5343
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch) {
5344
+ if (this.config.debugAdTiming) {
5345
+ console.log("[PRELOAD-POOL] \uD83D\uDEAB Discarding preloaded ad - break ended during fetch");
5346
+ }
5347
+ if (errorListenerCleanup) {
5348
+ errorListenerCleanup();
5349
+ }
5350
+ try {
5351
+ preloadAd.destroy();
5352
+ } catch (unused) {}
5353
+ return [
5354
+ 2
5355
+ ];
5356
+ }
5357
5357
  poolEntry = {
5358
5358
  vastUrl: vastUrl,
5359
5359
  adController: preloadAd,
@@ -5425,7 +5425,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5425
5425
  key: "preloadPoolLoop",
5426
5426
  value: function preloadPoolLoop(baseVastUrl) {
5427
5427
  return _async_to_generator(function() {
5428
- var remaining, newUrls, newUrl;
5428
+ var epoch, remaining, newUrls, newUrl;
5429
5429
  return _ts_generator(this, function(_state) {
5430
5430
  switch(_state.label){
5431
5431
  case 0:
@@ -5435,12 +5435,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5435
5435
  ];
5436
5436
  }
5437
5437
  this.preloadPoolLoopRunning = true;
5438
+ epoch = this.adBreakEpoch;
5438
5439
  if (this.config.debugAdTiming) {
5439
5440
  console.log("[PRELOAD-POOL] \uD83D\uDD04 Starting continuous preload loop");
5440
5441
  }
5441
5442
  _state.label = 1;
5442
5443
  case 1:
5443
- if (!this.preloadPoolActive) return [
5444
+ if (!(this.preloadPoolActive && epoch === this.adBreakEpoch)) return [
5444
5445
  3,
5445
5446
  10
5446
5447
  ];
@@ -5485,7 +5486,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5485
5486
  3,
5486
5487
  8
5487
5488
  ];
5488
- if (!this.preloadPoolActive || this.isGamInCooldown()) {
5489
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch || this.isGamInCooldown()) {
5489
5490
  return [
5490
5491
  3,
5491
5492
  8
@@ -5612,7 +5613,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5612
5613
  key: "handleAdStart",
5613
5614
  value: function handleAdStart(_marker) {
5614
5615
  return _async_to_generator(function() {
5615
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, adVolume, adVolume1, error, fallbackPreloaded, adVolume2, fallbackError;
5616
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, preservedMuted, preservedVolume, adVolume, adVolume1, error, fallbackPreloaded, preservedMuted1, preservedVolume1, adVolume2, fallbackError;
5616
5617
  return _ts_generator(this, function(_state) {
5617
5618
  switch(_state.label){
5618
5619
  case 0:
@@ -5652,7 +5653,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5652
5653
  this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
5653
5654
  if (!this.video.muted) {
5654
5655
  this.video.muted = true;
5655
- this.video.volume = 0;
5656
5656
  if (this.config.debugAdTiming) {
5657
5657
  console.log("[StormcloudVideoPlayer] Muted video in handleAdStart");
5658
5658
  }
@@ -5722,10 +5722,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5722
5722
  3,
5723
5723
  3
5724
5724
  ];
5725
+ preservedMuted = this.adPlayer.getOriginalMutedState();
5726
+ preservedVolume = this.adPlayer.getOriginalVolume();
5725
5727
  this.adPlayer.destroy();
5726
5728
  this.video.muted = true;
5727
- this.video.volume = 0;
5728
5729
  this.adPlayer = preloadedController;
5730
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
5729
5731
  this.attachImaEventListeners();
5730
5732
  if (this.config.debugAdTiming) {
5731
5733
  console.log("[CONTINUOUS-FETCH] \u2705 Using preloaded ad, resuming and starting playback immediately (no request delay!)");
@@ -5823,11 +5825,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5823
5825
  ,
5824
5826
  12
5825
5827
  ]);
5828
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
5829
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
5826
5830
  this.adPlayer.destroy();
5827
5831
  this.video.muted = true;
5828
- this.video.volume = 0;
5829
5832
  this.adPlayer = fallbackPreloaded.adController;
5830
5833
  this.attachImaEventListeners();
5834
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
5831
5835
  this.adPlayer.resume();
5832
5836
  this.consecutiveFailures = 0;
5833
5837
  this.currentAdIndex++;
@@ -5915,7 +5919,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5915
5919
  key: "continuousFetchLoop",
5916
5920
  value: function continuousFetchLoop(baseVastUrl) {
5917
5921
  return _async_to_generator(function() {
5918
- var _this, _loop, _ret;
5922
+ var _this, _loop, epoch, _ret;
5919
5923
  return _ts_generator(this, function(_state) {
5920
5924
  switch(_state.label){
5921
5925
  case 0:
@@ -6025,9 +6029,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6025
6029
  }
6026
6030
  });
6027
6031
  };
6032
+ epoch = this.adBreakEpoch;
6028
6033
  _state.label = 1;
6029
6034
  case 1:
6030
- if (!(this.continuousFetchingActive && this.inAdBreak)) return [
6035
+ if (!(this.continuousFetchingActive && this.inAdBreak && epoch === this.adBreakEpoch)) return [
6031
6036
  3,
6032
6037
  3
6033
6038
  ];
@@ -6076,10 +6081,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6076
6081
  key: "tryNextAvailableAdWithRateLimit",
6077
6082
  value: function tryNextAvailableAdWithRateLimit() {
6078
6083
  return _async_to_generator(function() {
6079
- var backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6084
+ var epoch, backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6080
6085
  return _ts_generator(this, function(_state) {
6081
6086
  switch(_state.label){
6082
6087
  case 0:
6088
+ if (!this.inAdBreak) {
6089
+ return [
6090
+ 2
6091
+ ];
6092
+ }
6093
+ epoch = this.adBreakEpoch;
6083
6094
  if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
6084
6095
  if (this.config.debugAdTiming) {
6085
6096
  console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive failures (".concat(this.consecutiveFailures, "), ending ad break gracefully"));
@@ -6111,6 +6122,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6111
6122
  _state.sent();
6112
6123
  _state.label = 2;
6113
6124
  case 2:
6125
+ if (!this.inAdBreak || epoch !== this.adBreakEpoch) {
6126
+ return [
6127
+ 2
6128
+ ];
6129
+ }
6114
6130
  return [
6115
6131
  2,
6116
6132
  this.tryNextAvailableAd(0)
@@ -6125,10 +6141,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6125
6141
  value: function tryNextAvailableAd() {
6126
6142
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6127
6143
  return _async_to_generator(function() {
6128
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6144
+ var remaining, preloaded, preservedMuted, preservedVolume, error, nextAdUrl, error1, errorMessage, maxRetries;
6129
6145
  return _ts_generator(this, function(_state) {
6130
6146
  switch(_state.label){
6131
6147
  case 0:
6148
+ if (!this.inAdBreak) {
6149
+ return [
6150
+ 2
6151
+ ];
6152
+ }
6132
6153
  remaining = this.getRemainingAdMs();
6133
6154
  if (remaining <= 500) {
6134
6155
  if (this.config.debugAdTiming) {
@@ -6179,11 +6200,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6179
6200
  ,
6180
6201
  4
6181
6202
  ]);
6203
+ preservedMuted = this.adPlayer.getOriginalMutedState();
6204
+ preservedVolume = this.adPlayer.getOriginalVolume();
6182
6205
  this.adPlayer.destroy();
6183
6206
  this.video.muted = true;
6184
- this.video.volume = 0;
6185
6207
  this.adPlayer = preloaded.adController;
6186
6208
  this.attachImaEventListeners();
6209
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
6187
6210
  this.adPlayer.resume();
6188
6211
  this.currentAdIndex++;
6189
6212
  this.totalAdRequestsInBreak++;
@@ -6197,10 +6220,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6197
6220
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6198
6221
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6199
6222
  }
6200
- currentMuted = this.video.muted;
6201
- currentVolume = this.video.volume;
6202
- adVolume = currentMuted ? 0 : currentVolume;
6203
- this.adPlayer.setAdVolume(adVolume);
6223
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6204
6224
  this.consecutiveFailures = 0;
6205
6225
  return [
6206
6226
  2
@@ -6247,9 +6267,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6247
6267
  if (this.config.debugAdTiming) {
6248
6268
  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)"));
6249
6269
  }
6250
- currentMuted1 = this.video.muted;
6251
- currentVolume1 = this.video.volume;
6252
- this.adPlayer.updateOriginalMutedState(currentMuted1, currentVolume1);
6253
6270
  this.currentAdIndex++;
6254
6271
  this.totalAdRequestsInBreak++;
6255
6272
  this.lastAdRequestTime = Date.now();
@@ -6342,7 +6359,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6342
6359
  key: "showPlaceholderAndWaitForAds",
6343
6360
  value: function showPlaceholderAndWaitForAds() {
6344
6361
  return _async_to_generator(function() {
6345
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
6362
+ var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
6346
6363
  return _ts_generator(this, function(_state) {
6347
6364
  switch(_state.label){
6348
6365
  case 0:
@@ -6438,9 +6455,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6438
6455
  }
6439
6456
  this.isShowingPlaceholder = false;
6440
6457
  this.adPlayer.hidePlaceholder();
6441
- currentMuted = this.video.muted;
6442
- currentVolume = this.video.volume;
6443
- this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
6444
6458
  this.currentAdIndex++;
6445
6459
  this.totalAdRequestsInBreak++;
6446
6460
  this.lastAdRequestTime = Date.now();
@@ -6890,7 +6904,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6890
6904
  key: "playSingleAd",
6891
6905
  value: function playSingleAd(vastTagUrl) {
6892
6906
  return _async_to_generator(function() {
6893
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
6907
+ var requestToken, playError, preloadedFallback, preservedMuted, preservedVolume, fallbackError, error, errorMessage, preloadedFallback1, preservedMuted1, preservedVolume1, fallbackError1;
6894
6908
  return _ts_generator(this, function(_state) {
6895
6909
  switch(_state.label){
6896
6910
  case 0:
@@ -6977,10 +6991,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6977
6991
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6978
6992
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6979
6993
  }
6980
- currentMuted = this.video.muted;
6981
- currentVolume = this.video.volume;
6982
- adVolume = currentMuted ? 0 : currentVolume;
6983
- this.adPlayer.setAdVolume(adVolume);
6994
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6984
6995
  this.consecutiveFailures = 0;
6985
6996
  this.temporaryFailureUrls.delete(vastTagUrl);
6986
6997
  return [
@@ -7009,11 +7020,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7009
7020
  10
7010
7021
  ]);
7011
7022
  this.clearAdFailsafeTimer();
7023
+ preservedMuted = this.adPlayer.getOriginalMutedState();
7024
+ preservedVolume = this.adPlayer.getOriginalVolume();
7012
7025
  this.adPlayer.destroy();
7013
7026
  this.video.muted = true;
7014
- this.video.volume = 0;
7015
7027
  this.adPlayer = preloadedFallback.adController;
7016
7028
  this.attachImaEventListeners();
7029
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
7017
7030
  this.adPlayer.resume();
7018
7031
  this.consecutiveFailures = 0;
7019
7032
  this.currentAdIndex++;
@@ -7027,10 +7040,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7027
7040
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7028
7041
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
7029
7042
  }
7030
- currentMuted1 = this.video.muted;
7031
- currentVolume1 = this.video.volume;
7032
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7033
- this.adPlayer.setAdVolume(adVolume1);
7043
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7034
7044
  return [
7035
7045
  2
7036
7046
  ];
@@ -7089,11 +7099,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7089
7099
  ]);
7090
7100
  this.clearAdRequestWatchdog();
7091
7101
  this.clearAdFailsafeTimer();
7102
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
7103
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
7092
7104
  this.adPlayer.destroy();
7093
7105
  this.video.muted = true;
7094
- this.video.volume = 0;
7095
7106
  this.adPlayer = preloadedFallback1.adController;
7096
7107
  this.attachImaEventListeners();
7108
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
7097
7109
  this.adPlayer.resume();
7098
7110
  this.consecutiveFailures = 0;
7099
7111
  this.currentAdIndex++;
@@ -7104,10 +7116,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7104
7116
  ];
7105
7117
  case 14:
7106
7118
  _state.sent();
7107
- currentMuted2 = this.video.muted;
7108
- currentVolume2 = this.video.volume;
7109
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7110
- this.adPlayer.setAdVolume(adVolume2);
7119
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7111
7120
  return [
7112
7121
  2
7113
7122
  ];
@@ -7153,6 +7162,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7153
7162
  if (this.config.debugAdTiming) {
7154
7163
  console.log("[StormcloudVideoPlayer] \uD83C\uDFC1 Ad pod complete - cleaning up");
7155
7164
  }
7165
+ this.adBreakEpoch++;
7156
7166
  this.clearAdRequestWatchdog();
7157
7167
  this.clearAdFailsafeTimer();
7158
7168
  this.activeAdRequestToken = null;
@@ -7409,10 +7419,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7409
7419
  key: "toggleMute",
7410
7420
  value: function toggleMute() {
7411
7421
  if (this.adPlayer.isAdPlaying()) {
7412
- var currentPerceptualState = this.isMuted();
7413
- var newMutedState = !currentPerceptualState;
7422
+ var newMutedState = !this.adPlayer.getOriginalMutedState();
7423
+ var restoreVolume = this.adPlayer.getOriginalVolume() || 1;
7414
7424
  this.adPlayer.updateOriginalMutedState(newMutedState, this.video.volume);
7415
- this.adPlayer.setAdVolume(newMutedState ? 0 : 1);
7425
+ this.adPlayer.setAdVolume(newMutedState ? 0 : restoreVolume);
7416
7426
  if (this.config.debugAdTiming) {
7417
7427
  console.log("[StormcloudVideoPlayer] Mute toggle during ad - immediately applied:", newMutedState);
7418
7428
  }
@@ -7467,10 +7477,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7467
7477
  key: "isMuted",
7468
7478
  value: function isMuted() {
7469
7479
  if (this.adPlayer.isAdPlaying()) {
7470
- if (this.config.debugAdTiming) {
7471
- console.log("[StormcloudVideoPlayer] isMuted() override during ad playback -> false");
7472
- }
7473
- return false;
7480
+ return this.adPlayer.getOriginalMutedState();
7474
7481
  }
7475
7482
  return this.video.muted;
7476
7483
  }
@@ -7537,6 +7544,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7537
7544
  return this.video.volume;
7538
7545
  }
7539
7546
  },
7547
+ {
7548
+ key: "getAdAudioVolume",
7549
+ value: function getAdAudioVolume() {
7550
+ return this.adPlayer.getOriginalMutedState() ? 0 : this.adPlayer.getOriginalVolume();
7551
+ }
7552
+ },
7540
7553
  {
7541
7554
  key: "isFullscreen",
7542
7555
  value: function isFullscreen() {