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.
@@ -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() {
@@ -3282,10 +3280,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3282
3280
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3283
3281
  }
3284
3282
  }
3285
- var currentMuted = _this.video.muted;
3286
- var currentVolume = _this.video.volume;
3287
- var adVolume = currentMuted ? 0 : currentVolume;
3288
- _this.adPlayer.setAdVolume(adVolume);
3283
+ _this.adPlayer.setAdVolume(_this.getAdAudioVolume());
3289
3284
  if (_this.isShowingPlaceholder) {
3290
3285
  if (_this.config.debugAdTiming) {
3291
3286
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -3302,7 +3297,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3302
3297
  }).catch(function() {});
3303
3298
  if (!_this.video.muted) {
3304
3299
  _this.video.muted = true;
3305
- _this.video.volume = 0;
3306
3300
  if (_this.config.debugAdTiming) {
3307
3301
  console.log("[StormcloudVideoPlayer] Muted video on content_resume (ad ended, gap between ads)");
3308
3302
  }
@@ -3350,7 +3344,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3350
3344
  try {
3351
3345
  this.adPlayer.destroy();
3352
3346
  this.video.muted = true;
3353
- this.video.volume = 0;
3354
3347
  } catch (error) {
3355
3348
  if (this.config.debugAdTiming) {
3356
3349
  console.warn("[StormcloudVideoPlayer] Error destroying old AdController:", error);
@@ -3409,7 +3402,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3409
3402
  }
3410
3403
  if (!this.video.muted) {
3411
3404
  this.video.muted = true;
3412
- this.video.volume = 0;
3413
3405
  if (this.config.debugAdTiming) {
3414
3406
  console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
3415
3407
  }
@@ -4031,7 +4023,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4031
4023
  if (marker.type === "end") {
4032
4024
  if (!this.video.muted) {
4033
4025
  this.video.muted = true;
4034
- this.video.volume = 0;
4035
4026
  if (this.config.debugAdTiming) {
4036
4027
  console.log("[StormcloudVideoPlayer] Muted video on SCTE end marker");
4037
4028
  }
@@ -4069,13 +4060,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4069
4060
  {
4070
4061
  key: "startScte35AdBreak",
4071
4062
  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
4063
  this.inAdBreak = true;
4080
4064
  this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
4081
4065
  this.scheduledScte35BreakKey = void 0;
@@ -5662,7 +5646,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5662
5646
  key: "handleAdStart",
5663
5647
  value: function handleAdStart(_marker) {
5664
5648
  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;
5649
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, preservedMuted, preservedVolume, adVolume, adVolume1, error, fallbackPreloaded, preservedMuted1, preservedVolume1, adVolume2, fallbackError;
5666
5650
  return _ts_generator(this, function(_state) {
5667
5651
  switch(_state.label){
5668
5652
  case 0:
@@ -5702,7 +5686,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5702
5686
  this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
5703
5687
  if (!this.video.muted) {
5704
5688
  this.video.muted = true;
5705
- this.video.volume = 0;
5706
5689
  if (this.config.debugAdTiming) {
5707
5690
  console.log("[StormcloudVideoPlayer] Muted video in handleAdStart");
5708
5691
  }
@@ -5772,10 +5755,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5772
5755
  3,
5773
5756
  3
5774
5757
  ];
5758
+ preservedMuted = this.adPlayer.getOriginalMutedState();
5759
+ preservedVolume = this.adPlayer.getOriginalVolume();
5775
5760
  this.adPlayer.destroy();
5776
5761
  this.video.muted = true;
5777
- this.video.volume = 0;
5778
5762
  this.adPlayer = preloadedController;
5763
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
5779
5764
  this.attachImaEventListeners();
5780
5765
  if (this.config.debugAdTiming) {
5781
5766
  console.log("[CONTINUOUS-FETCH] \u2705 Using preloaded ad, resuming and starting playback immediately (no request delay!)");
@@ -5873,11 +5858,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5873
5858
  ,
5874
5859
  12
5875
5860
  ]);
5861
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
5862
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
5876
5863
  this.adPlayer.destroy();
5877
5864
  this.video.muted = true;
5878
- this.video.volume = 0;
5879
5865
  this.adPlayer = fallbackPreloaded.adController;
5880
5866
  this.attachImaEventListeners();
5867
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
5881
5868
  this.adPlayer.resume();
5882
5869
  this.consecutiveFailures = 0;
5883
5870
  this.currentAdIndex++;
@@ -6175,7 +6162,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6175
6162
  value: function tryNextAvailableAd() {
6176
6163
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6177
6164
  return _async_to_generator(function() {
6178
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6165
+ var remaining, preloaded, preservedMuted, preservedVolume, error, nextAdUrl, error1, errorMessage, maxRetries;
6179
6166
  return _ts_generator(this, function(_state) {
6180
6167
  switch(_state.label){
6181
6168
  case 0:
@@ -6229,11 +6216,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6229
6216
  ,
6230
6217
  4
6231
6218
  ]);
6219
+ preservedMuted = this.adPlayer.getOriginalMutedState();
6220
+ preservedVolume = this.adPlayer.getOriginalVolume();
6232
6221
  this.adPlayer.destroy();
6233
6222
  this.video.muted = true;
6234
- this.video.volume = 0;
6235
6223
  this.adPlayer = preloaded.adController;
6236
6224
  this.attachImaEventListeners();
6225
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
6237
6226
  this.adPlayer.resume();
6238
6227
  this.currentAdIndex++;
6239
6228
  this.totalAdRequestsInBreak++;
@@ -6247,10 +6236,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6247
6236
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6248
6237
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6249
6238
  }
6250
- currentMuted = this.video.muted;
6251
- currentVolume = this.video.volume;
6252
- adVolume = currentMuted ? 0 : currentVolume;
6253
- this.adPlayer.setAdVolume(adVolume);
6239
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6254
6240
  this.consecutiveFailures = 0;
6255
6241
  return [
6256
6242
  2
@@ -6297,9 +6283,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6297
6283
  if (this.config.debugAdTiming) {
6298
6284
  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
6285
  }
6300
- currentMuted1 = this.video.muted;
6301
- currentVolume1 = this.video.volume;
6302
- this.adPlayer.updateOriginalMutedState(currentMuted1, currentVolume1);
6303
6286
  this.currentAdIndex++;
6304
6287
  this.totalAdRequestsInBreak++;
6305
6288
  this.lastAdRequestTime = Date.now();
@@ -6392,7 +6375,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6392
6375
  key: "showPlaceholderAndWaitForAds",
6393
6376
  value: function showPlaceholderAndWaitForAds() {
6394
6377
  return _async_to_generator(function() {
6395
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
6378
+ var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
6396
6379
  return _ts_generator(this, function(_state) {
6397
6380
  switch(_state.label){
6398
6381
  case 0:
@@ -6488,9 +6471,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6488
6471
  }
6489
6472
  this.isShowingPlaceholder = false;
6490
6473
  this.adPlayer.hidePlaceholder();
6491
- currentMuted = this.video.muted;
6492
- currentVolume = this.video.volume;
6493
- this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
6494
6474
  this.currentAdIndex++;
6495
6475
  this.totalAdRequestsInBreak++;
6496
6476
  this.lastAdRequestTime = Date.now();
@@ -6940,7 +6920,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6940
6920
  key: "playSingleAd",
6941
6921
  value: function playSingleAd(vastTagUrl) {
6942
6922
  return _async_to_generator(function() {
6943
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
6923
+ var requestToken, playError, preloadedFallback, preservedMuted, preservedVolume, fallbackError, error, errorMessage, preloadedFallback1, preservedMuted1, preservedVolume1, fallbackError1;
6944
6924
  return _ts_generator(this, function(_state) {
6945
6925
  switch(_state.label){
6946
6926
  case 0:
@@ -7027,10 +7007,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7027
7007
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7028
7008
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
7029
7009
  }
7030
- currentMuted = this.video.muted;
7031
- currentVolume = this.video.volume;
7032
- adVolume = currentMuted ? 0 : currentVolume;
7033
- this.adPlayer.setAdVolume(adVolume);
7010
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7034
7011
  this.consecutiveFailures = 0;
7035
7012
  this.temporaryFailureUrls.delete(vastTagUrl);
7036
7013
  return [
@@ -7059,11 +7036,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7059
7036
  10
7060
7037
  ]);
7061
7038
  this.clearAdFailsafeTimer();
7039
+ preservedMuted = this.adPlayer.getOriginalMutedState();
7040
+ preservedVolume = this.adPlayer.getOriginalVolume();
7062
7041
  this.adPlayer.destroy();
7063
7042
  this.video.muted = true;
7064
- this.video.volume = 0;
7065
7043
  this.adPlayer = preloadedFallback.adController;
7066
7044
  this.attachImaEventListeners();
7045
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
7067
7046
  this.adPlayer.resume();
7068
7047
  this.consecutiveFailures = 0;
7069
7048
  this.currentAdIndex++;
@@ -7077,10 +7056,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7077
7056
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7078
7057
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
7079
7058
  }
7080
- currentMuted1 = this.video.muted;
7081
- currentVolume1 = this.video.volume;
7082
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7083
- this.adPlayer.setAdVolume(adVolume1);
7059
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7084
7060
  return [
7085
7061
  2
7086
7062
  ];
@@ -7139,11 +7115,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7139
7115
  ]);
7140
7116
  this.clearAdRequestWatchdog();
7141
7117
  this.clearAdFailsafeTimer();
7118
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
7119
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
7142
7120
  this.adPlayer.destroy();
7143
7121
  this.video.muted = true;
7144
- this.video.volume = 0;
7145
7122
  this.adPlayer = preloadedFallback1.adController;
7146
7123
  this.attachImaEventListeners();
7124
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
7147
7125
  this.adPlayer.resume();
7148
7126
  this.consecutiveFailures = 0;
7149
7127
  this.currentAdIndex++;
@@ -7154,10 +7132,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7154
7132
  ];
7155
7133
  case 14:
7156
7134
  _state.sent();
7157
- currentMuted2 = this.video.muted;
7158
- currentVolume2 = this.video.volume;
7159
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7160
- this.adPlayer.setAdVolume(adVolume2);
7135
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7161
7136
  return [
7162
7137
  2
7163
7138
  ];
@@ -7459,10 +7434,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7459
7434
  key: "toggleMute",
7460
7435
  value: function toggleMute() {
7461
7436
  if (this.adPlayer.isAdPlaying()) {
7462
- var currentPerceptualState = this.isMuted();
7463
- var newMutedState = !currentPerceptualState;
7437
+ var newMutedState = !this.adPlayer.getOriginalMutedState();
7438
+ var restoreVolume = this.adPlayer.getOriginalVolume() || 1;
7464
7439
  this.adPlayer.updateOriginalMutedState(newMutedState, this.video.volume);
7465
- this.adPlayer.setAdVolume(newMutedState ? 0 : 1);
7440
+ this.adPlayer.setAdVolume(newMutedState ? 0 : restoreVolume);
7466
7441
  if (this.config.debugAdTiming) {
7467
7442
  console.log("[StormcloudVideoPlayer] Mute toggle during ad - immediately applied:", newMutedState);
7468
7443
  }
@@ -7517,10 +7492,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7517
7492
  key: "isMuted",
7518
7493
  value: function isMuted() {
7519
7494
  if (this.adPlayer.isAdPlaying()) {
7520
- if (this.config.debugAdTiming) {
7521
- console.log("[StormcloudVideoPlayer] isMuted() override during ad playback -> false");
7522
- }
7523
- return false;
7495
+ return this.adPlayer.getOriginalMutedState();
7524
7496
  }
7525
7497
  return this.video.muted;
7526
7498
  }
@@ -7587,6 +7559,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7587
7559
  return this.video.volume;
7588
7560
  }
7589
7561
  },
7562
+ {
7563
+ key: "getAdAudioVolume",
7564
+ value: function getAdAudioVolume() {
7565
+ return this.adPlayer.getOriginalMutedState() ? 0 : this.adPlayer.getOriginalVolume();
7566
+ }
7567
+ },
7590
7568
  {
7591
7569
  key: "isFullscreen",
7592
7570
  value: function isFullscreen() {