stormcloud-video-player 0.8.7 → 0.8.8

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() {
@@ -3232,10 +3230,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3232
3230
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3233
3231
  }
3234
3232
  }
3235
- var currentMuted = _this.video.muted;
3236
- var currentVolume = _this.video.volume;
3237
- var adVolume = currentMuted ? 0 : currentVolume;
3238
- _this.adPlayer.setAdVolume(adVolume);
3233
+ _this.adPlayer.setAdVolume(_this.getAdAudioVolume());
3239
3234
  if (_this.isShowingPlaceholder) {
3240
3235
  if (_this.config.debugAdTiming) {
3241
3236
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -3252,7 +3247,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3252
3247
  }).catch(function() {});
3253
3248
  if (!_this.video.muted) {
3254
3249
  _this.video.muted = true;
3255
- _this.video.volume = 0;
3256
3250
  if (_this.config.debugAdTiming) {
3257
3251
  console.log("[StormcloudVideoPlayer] Muted video on content_resume (ad ended, gap between ads)");
3258
3252
  }
@@ -3300,7 +3294,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3300
3294
  try {
3301
3295
  this.adPlayer.destroy();
3302
3296
  this.video.muted = true;
3303
- this.video.volume = 0;
3304
3297
  } catch (error) {
3305
3298
  if (this.config.debugAdTiming) {
3306
3299
  console.warn("[StormcloudVideoPlayer] Error destroying old AdController:", error);
@@ -3359,7 +3352,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3359
3352
  }
3360
3353
  if (!this.video.muted) {
3361
3354
  this.video.muted = true;
3362
- this.video.volume = 0;
3363
3355
  if (this.config.debugAdTiming) {
3364
3356
  console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
3365
3357
  }
@@ -3981,7 +3973,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3981
3973
  if (marker.type === "end") {
3982
3974
  if (!this.video.muted) {
3983
3975
  this.video.muted = true;
3984
- this.video.volume = 0;
3985
3976
  if (this.config.debugAdTiming) {
3986
3977
  console.log("[StormcloudVideoPlayer] Muted video on SCTE end marker");
3987
3978
  }
@@ -4019,13 +4010,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4019
4010
  {
4020
4011
  key: "startScte35AdBreak",
4021
4012
  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
4013
  this.inAdBreak = true;
4030
4014
  this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
4031
4015
  this.scheduledScte35BreakKey = void 0;
@@ -5612,7 +5596,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5612
5596
  key: "handleAdStart",
5613
5597
  value: function handleAdStart(_marker) {
5614
5598
  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;
5599
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, preservedMuted, preservedVolume, adVolume, adVolume1, error, fallbackPreloaded, preservedMuted1, preservedVolume1, adVolume2, fallbackError;
5616
5600
  return _ts_generator(this, function(_state) {
5617
5601
  switch(_state.label){
5618
5602
  case 0:
@@ -5652,7 +5636,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5652
5636
  this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
5653
5637
  if (!this.video.muted) {
5654
5638
  this.video.muted = true;
5655
- this.video.volume = 0;
5656
5639
  if (this.config.debugAdTiming) {
5657
5640
  console.log("[StormcloudVideoPlayer] Muted video in handleAdStart");
5658
5641
  }
@@ -5722,10 +5705,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5722
5705
  3,
5723
5706
  3
5724
5707
  ];
5708
+ preservedMuted = this.adPlayer.getOriginalMutedState();
5709
+ preservedVolume = this.adPlayer.getOriginalVolume();
5725
5710
  this.adPlayer.destroy();
5726
5711
  this.video.muted = true;
5727
- this.video.volume = 0;
5728
5712
  this.adPlayer = preloadedController;
5713
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
5729
5714
  this.attachImaEventListeners();
5730
5715
  if (this.config.debugAdTiming) {
5731
5716
  console.log("[CONTINUOUS-FETCH] \u2705 Using preloaded ad, resuming and starting playback immediately (no request delay!)");
@@ -5823,11 +5808,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5823
5808
  ,
5824
5809
  12
5825
5810
  ]);
5811
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
5812
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
5826
5813
  this.adPlayer.destroy();
5827
5814
  this.video.muted = true;
5828
- this.video.volume = 0;
5829
5815
  this.adPlayer = fallbackPreloaded.adController;
5830
5816
  this.attachImaEventListeners();
5817
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
5831
5818
  this.adPlayer.resume();
5832
5819
  this.consecutiveFailures = 0;
5833
5820
  this.currentAdIndex++;
@@ -6125,7 +6112,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6125
6112
  value: function tryNextAvailableAd() {
6126
6113
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6127
6114
  return _async_to_generator(function() {
6128
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6115
+ var remaining, preloaded, preservedMuted, preservedVolume, error, nextAdUrl, error1, errorMessage, maxRetries;
6129
6116
  return _ts_generator(this, function(_state) {
6130
6117
  switch(_state.label){
6131
6118
  case 0:
@@ -6179,11 +6166,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6179
6166
  ,
6180
6167
  4
6181
6168
  ]);
6169
+ preservedMuted = this.adPlayer.getOriginalMutedState();
6170
+ preservedVolume = this.adPlayer.getOriginalVolume();
6182
6171
  this.adPlayer.destroy();
6183
6172
  this.video.muted = true;
6184
- this.video.volume = 0;
6185
6173
  this.adPlayer = preloaded.adController;
6186
6174
  this.attachImaEventListeners();
6175
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
6187
6176
  this.adPlayer.resume();
6188
6177
  this.currentAdIndex++;
6189
6178
  this.totalAdRequestsInBreak++;
@@ -6197,10 +6186,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6197
6186
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6198
6187
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6199
6188
  }
6200
- currentMuted = this.video.muted;
6201
- currentVolume = this.video.volume;
6202
- adVolume = currentMuted ? 0 : currentVolume;
6203
- this.adPlayer.setAdVolume(adVolume);
6189
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6204
6190
  this.consecutiveFailures = 0;
6205
6191
  return [
6206
6192
  2
@@ -6247,9 +6233,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6247
6233
  if (this.config.debugAdTiming) {
6248
6234
  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
6235
  }
6250
- currentMuted1 = this.video.muted;
6251
- currentVolume1 = this.video.volume;
6252
- this.adPlayer.updateOriginalMutedState(currentMuted1, currentVolume1);
6253
6236
  this.currentAdIndex++;
6254
6237
  this.totalAdRequestsInBreak++;
6255
6238
  this.lastAdRequestTime = Date.now();
@@ -6342,7 +6325,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6342
6325
  key: "showPlaceholderAndWaitForAds",
6343
6326
  value: function showPlaceholderAndWaitForAds() {
6344
6327
  return _async_to_generator(function() {
6345
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
6328
+ var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
6346
6329
  return _ts_generator(this, function(_state) {
6347
6330
  switch(_state.label){
6348
6331
  case 0:
@@ -6438,9 +6421,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6438
6421
  }
6439
6422
  this.isShowingPlaceholder = false;
6440
6423
  this.adPlayer.hidePlaceholder();
6441
- currentMuted = this.video.muted;
6442
- currentVolume = this.video.volume;
6443
- this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
6444
6424
  this.currentAdIndex++;
6445
6425
  this.totalAdRequestsInBreak++;
6446
6426
  this.lastAdRequestTime = Date.now();
@@ -6890,7 +6870,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6890
6870
  key: "playSingleAd",
6891
6871
  value: function playSingleAd(vastTagUrl) {
6892
6872
  return _async_to_generator(function() {
6893
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
6873
+ var requestToken, playError, preloadedFallback, preservedMuted, preservedVolume, fallbackError, error, errorMessage, preloadedFallback1, preservedMuted1, preservedVolume1, fallbackError1;
6894
6874
  return _ts_generator(this, function(_state) {
6895
6875
  switch(_state.label){
6896
6876
  case 0:
@@ -6977,10 +6957,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6977
6957
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6978
6958
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6979
6959
  }
6980
- currentMuted = this.video.muted;
6981
- currentVolume = this.video.volume;
6982
- adVolume = currentMuted ? 0 : currentVolume;
6983
- this.adPlayer.setAdVolume(adVolume);
6960
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6984
6961
  this.consecutiveFailures = 0;
6985
6962
  this.temporaryFailureUrls.delete(vastTagUrl);
6986
6963
  return [
@@ -7009,11 +6986,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7009
6986
  10
7010
6987
  ]);
7011
6988
  this.clearAdFailsafeTimer();
6989
+ preservedMuted = this.adPlayer.getOriginalMutedState();
6990
+ preservedVolume = this.adPlayer.getOriginalVolume();
7012
6991
  this.adPlayer.destroy();
7013
6992
  this.video.muted = true;
7014
- this.video.volume = 0;
7015
6993
  this.adPlayer = preloadedFallback.adController;
7016
6994
  this.attachImaEventListeners();
6995
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
7017
6996
  this.adPlayer.resume();
7018
6997
  this.consecutiveFailures = 0;
7019
6998
  this.currentAdIndex++;
@@ -7027,10 +7006,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7027
7006
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7028
7007
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
7029
7008
  }
7030
- currentMuted1 = this.video.muted;
7031
- currentVolume1 = this.video.volume;
7032
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7033
- this.adPlayer.setAdVolume(adVolume1);
7009
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7034
7010
  return [
7035
7011
  2
7036
7012
  ];
@@ -7089,11 +7065,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7089
7065
  ]);
7090
7066
  this.clearAdRequestWatchdog();
7091
7067
  this.clearAdFailsafeTimer();
7068
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
7069
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
7092
7070
  this.adPlayer.destroy();
7093
7071
  this.video.muted = true;
7094
- this.video.volume = 0;
7095
7072
  this.adPlayer = preloadedFallback1.adController;
7096
7073
  this.attachImaEventListeners();
7074
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
7097
7075
  this.adPlayer.resume();
7098
7076
  this.consecutiveFailures = 0;
7099
7077
  this.currentAdIndex++;
@@ -7104,10 +7082,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7104
7082
  ];
7105
7083
  case 14:
7106
7084
  _state.sent();
7107
- currentMuted2 = this.video.muted;
7108
- currentVolume2 = this.video.volume;
7109
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7110
- this.adPlayer.setAdVolume(adVolume2);
7085
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7111
7086
  return [
7112
7087
  2
7113
7088
  ];
@@ -7409,10 +7384,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7409
7384
  key: "toggleMute",
7410
7385
  value: function toggleMute() {
7411
7386
  if (this.adPlayer.isAdPlaying()) {
7412
- var currentPerceptualState = this.isMuted();
7413
- var newMutedState = !currentPerceptualState;
7387
+ var newMutedState = !this.adPlayer.getOriginalMutedState();
7388
+ var restoreVolume = this.adPlayer.getOriginalVolume() || 1;
7414
7389
  this.adPlayer.updateOriginalMutedState(newMutedState, this.video.volume);
7415
- this.adPlayer.setAdVolume(newMutedState ? 0 : 1);
7390
+ this.adPlayer.setAdVolume(newMutedState ? 0 : restoreVolume);
7416
7391
  if (this.config.debugAdTiming) {
7417
7392
  console.log("[StormcloudVideoPlayer] Mute toggle during ad - immediately applied:", newMutedState);
7418
7393
  }
@@ -7467,10 +7442,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7467
7442
  key: "isMuted",
7468
7443
  value: function isMuted() {
7469
7444
  if (this.adPlayer.isAdPlaying()) {
7470
- if (this.config.debugAdTiming) {
7471
- console.log("[StormcloudVideoPlayer] isMuted() override during ad playback -> false");
7472
- }
7473
- return false;
7445
+ return this.adPlayer.getOriginalMutedState();
7474
7446
  }
7475
7447
  return this.video.muted;
7476
7448
  }
@@ -7537,6 +7509,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7537
7509
  return this.video.volume;
7538
7510
  }
7539
7511
  },
7512
+ {
7513
+ key: "getAdAudioVolume",
7514
+ value: function getAdAudioVolume() {
7515
+ return this.adPlayer.getOriginalMutedState() ? 0 : this.adPlayer.getOriginalVolume();
7516
+ }
7517
+ },
7540
7518
  {
7541
7519
  key: "isFullscreen",
7542
7520
  value: function isFullscreen() {