stormcloud-video-player 0.3.66 → 0.3.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3923,10 +3923,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3923
3923
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3924
3924
  }
3925
3925
  }
3926
- var currentMuted = _this.video.muted;
3927
- var currentVolume = _this.video.volume;
3928
- var adVolume = currentMuted ? 0 : currentVolume;
3929
- _this.ima.setAdVolume(adVolume);
3926
+ _this.ima.setAdVolume(_this.getPreAdBreakAdVolume());
3930
3927
  if (_this.isShowingPlaceholder) {
3931
3928
  if (_this.config.debugAdTiming) {
3932
3929
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -4680,6 +4677,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4680
4677
  {
4681
4678
  key: "startScte35AdBreak",
4682
4679
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
4680
+ this.capturePreAdBreakAudio();
4683
4681
  if (!this.video.muted) {
4684
4682
  this.video.muted = true;
4685
4683
  this.video.volume = 0;
@@ -6361,9 +6359,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6361
6359
  this.continuousFetchingActive = true;
6362
6360
  this.isShowingPlaceholder = false;
6363
6361
  this.totalAdRequestsInBreak = 0;
6364
- currentMuted = this.video.muted;
6365
- currentVolume = this.video.volume;
6366
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
6362
+ this.capturePreAdBreakAudio();
6363
+ currentMuted = this.preAdBreakAudio.muted;
6364
+ currentVolume = this.preAdBreakAudio.volume;
6367
6365
  if (!this.video.muted) {
6368
6366
  this.video.muted = true;
6369
6367
  this.video.volume = 0;
@@ -6838,7 +6836,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6838
6836
  value: function tryNextAvailableAd() {
6839
6837
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6840
6838
  return _async_to_generator(function() {
6841
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6839
+ var remaining, preloaded, error, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error1, errorMessage, maxRetries;
6842
6840
  return _ts_generator(this, function(_state) {
6843
6841
  switch(_state.label){
6844
6842
  case 0:
@@ -6910,10 +6908,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6910
6908
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6911
6909
  this.scheduleAdStopAtBreakBoundary();
6912
6910
  }
6913
- currentMuted = this.video.muted;
6914
- currentVolume = this.video.volume;
6915
- adVolume = currentMuted ? 0 : currentVolume;
6916
- this.ima.setAdVolume(adVolume);
6911
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
6917
6912
  this.consecutiveFailures = 0;
6918
6913
  return [
6919
6914
  2
@@ -6960,9 +6955,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6960
6955
  if (this.config.debugAdTiming) {
6961
6956
  console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC Requesting next ad via IMA SDK (".concat(this.currentAdIndex + 1, "/").concat(this.totalAdsInBreak, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
6962
6957
  }
6963
- currentMuted1 = this.video.muted;
6964
- currentVolume1 = this.video.volume;
6965
- this.ima.updateOriginalMutedState(currentMuted1, currentVolume1);
6958
+ this.ima.updateOriginalMutedState((_ref = (_this_preAdBreakAudio = this.preAdBreakAudio) === null || _this_preAdBreakAudio === void 0 ? void 0 : _this_preAdBreakAudio.muted) !== null && _ref !== void 0 ? _ref : this.video.muted, (_ref1 = (_this_preAdBreakAudio1 = this.preAdBreakAudio) === null || _this_preAdBreakAudio1 === void 0 ? void 0 : _this_preAdBreakAudio1.volume) !== null && _ref1 !== void 0 ? _ref1 : this.video.volume);
6966
6959
  this.currentAdIndex++;
6967
6960
  this.totalAdRequestsInBreak++;
6968
6961
  this.lastAdRequestTime = Date.now();
@@ -7055,7 +7048,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7055
7048
  key: "showPlaceholderAndWaitForAds",
7056
7049
  value: function showPlaceholderAndWaitForAds() {
7057
7050
  return _async_to_generator(function() {
7058
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
7051
+ var remaining, waitTime, checkInterval, maxChecks, i, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error, errorMessage;
7059
7052
  return _ts_generator(this, function(_state) {
7060
7053
  switch(_state.label){
7061
7054
  case 0:
@@ -7151,9 +7144,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7151
7144
  }
7152
7145
  this.isShowingPlaceholder = false;
7153
7146
  this.ima.hidePlaceholder();
7154
- currentMuted = this.video.muted;
7155
- currentVolume = this.video.volume;
7156
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
7147
+ this.ima.updateOriginalMutedState((_ref = (_this_preAdBreakAudio = this.preAdBreakAudio) === null || _this_preAdBreakAudio === void 0 ? void 0 : _this_preAdBreakAudio.muted) !== null && _ref !== void 0 ? _ref : this.video.muted, (_ref1 = (_this_preAdBreakAudio1 = this.preAdBreakAudio) === null || _this_preAdBreakAudio1 === void 0 ? void 0 : _this_preAdBreakAudio1.volume) !== null && _ref1 !== void 0 ? _ref1 : this.video.volume);
7157
7148
  this.currentAdIndex++;
7158
7149
  this.totalAdRequestsInBreak++;
7159
7150
  this.lastAdRequestTime = Date.now();
@@ -7335,7 +7326,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7335
7326
  first = tags[0];
7336
7327
  rest = tags.slice(1);
7337
7328
  this.adPodQueue = rest;
7338
- this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
7329
+ this.capturePreAdBreakAudio();
7339
7330
  this.showAds = true;
7340
7331
  this.inAdBreak = true;
7341
7332
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -7362,12 +7353,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7362
7353
  ];
7363
7354
  case 3:
7364
7355
  error = _state.sent();
7365
- this.adPodQueue = [];
7366
- this.inAdBreak = false;
7367
- this.showAds = false;
7368
7356
  if (this.config.debugAdTiming) {
7369
7357
  console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
7370
7358
  }
7359
+ this.handleAdPodComplete();
7371
7360
  return [
7372
7361
  3,
7373
7362
  4
@@ -7598,7 +7587,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7598
7587
  key: "playSingleAd",
7599
7588
  value: function playSingleAd(vastTagUrl) {
7600
7589
  return _async_to_generator(function() {
7601
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
7590
+ var requestToken, playError, preloadedFallback, fallbackError, error, errorMessage, preloadedFallback1, fallbackError1;
7602
7591
  return _ts_generator(this, function(_state) {
7603
7592
  switch(_state.label){
7604
7593
  case 0:
@@ -7685,10 +7674,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7685
7674
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7686
7675
  this.scheduleAdStopAtBreakBoundary();
7687
7676
  }
7688
- currentMuted = this.video.muted;
7689
- currentVolume = this.video.volume;
7690
- adVolume = currentMuted ? 0 : currentVolume;
7691
- this.ima.setAdVolume(adVolume);
7677
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7692
7678
  this.consecutiveFailures = 0;
7693
7679
  this.temporaryFailureUrls.delete(vastTagUrl);
7694
7680
  return [
@@ -7735,10 +7721,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7735
7721
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7736
7722
  this.scheduleAdStopAtBreakBoundary();
7737
7723
  }
7738
- currentMuted1 = this.video.muted;
7739
- currentVolume1 = this.video.volume;
7740
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7741
- this.ima.setAdVolume(adVolume1);
7724
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7742
7725
  return [
7743
7726
  2
7744
7727
  ];
@@ -7812,10 +7795,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7812
7795
  ];
7813
7796
  case 14:
7814
7797
  _state.sent();
7815
- currentMuted2 = this.video.muted;
7816
- currentVolume2 = this.video.volume;
7817
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7818
- this.ima.setAdVolume(adVolume2);
7798
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7819
7799
  return [
7820
7800
  2
7821
7801
  ];
@@ -7855,6 +7835,33 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7855
7835
  }).call(this);
7856
7836
  }
7857
7837
  },
7838
+ {
7839
+ key: "capturePreAdBreakAudio",
7840
+ value: function capturePreAdBreakAudio() {
7841
+ if (this.preAdBreakAudio) {
7842
+ return;
7843
+ }
7844
+ var captured = {
7845
+ muted: this.video.muted,
7846
+ volume: typeof this.video.volume === "number" && !Number.isNaN(this.video.volume) ? Math.max(0, Math.min(1, this.video.volume)) : 1
7847
+ };
7848
+ this.preAdBreakAudio = captured;
7849
+ this.ima.updateOriginalMutedState(captured.muted, captured.volume);
7850
+ if (this.config.debugAdTiming) {
7851
+ console.log("[StormcloudVideoPlayer] Captured pre-ad-break audio state: muted=".concat(captured.muted, ", volume=").concat(captured.volume));
7852
+ }
7853
+ }
7854
+ },
7855
+ {
7856
+ key: "getPreAdBreakAdVolume",
7857
+ value: function getPreAdBreakAdVolume() {
7858
+ var state = this.preAdBreakAudio;
7859
+ if (state) {
7860
+ return state.muted ? 0 : state.volume;
7861
+ }
7862
+ return this.ima.getOriginalMutedState() ? 0 : this.ima.getOriginalVolume();
7863
+ }
7864
+ },
7858
7865
  {
7859
7866
  key: "handleAdPodComplete",
7860
7867
  value: function handleAdPodComplete() {
@@ -7888,14 +7895,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7888
7895
  this.consecutiveFailures = 0;
7889
7896
  this.globalConsecutiveNoFills = 0;
7890
7897
  this.ima.stop().catch(function() {});
7891
- var restoredMuted = this.ima.getOriginalMutedState();
7892
- var restoredVolume = this.ima.getOriginalVolume();
7898
+ var restoredMuted = this.preAdBreakAudio ? this.preAdBreakAudio.muted : this.ima.getOriginalMutedState();
7899
+ var restoredVolume = this.preAdBreakAudio ? this.preAdBreakAudio.volume : this.ima.getOriginalVolume();
7900
+ this.ima.updateOriginalMutedState(restoredMuted, restoredVolume);
7893
7901
  if (this.video.muted !== restoredMuted) {
7894
7902
  this.video.muted = restoredMuted;
7895
7903
  }
7896
7904
  if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
7897
7905
  this.video.volume = restoredVolume;
7898
7906
  }
7907
+ this.preAdBreakAudio = void 0;
7908
+ if (this.config.debugAdTiming) {
7909
+ console.log("[StormcloudVideoPlayer] Restored post-ad-break audio state: muted=".concat(restoredMuted, ", volume=").concat(restoredVolume));
7910
+ }
7899
7911
  if (this.shouldContinueLiveStreamDuringAds()) {
7900
7912
  if (this.video.paused) {
7901
7913
  var _this_video_play;
@@ -8305,6 +8317,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8305
8317
  this.clearAdFailsafeTimer();
8306
8318
  this.clearAdRequestWatchdog();
8307
8319
  this.clearPendingAdBreak();
8320
+ this.preAdBreakAudio = void 0;
8308
8321
  if (this.placeholderContainer) {
8309
8322
  if (this.placeholderContainer.parentElement) {
8310
8323
  this.placeholderContainer.parentElement.removeChild(this.placeholderContainer);