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.
@@ -202,6 +202,7 @@ declare class StormcloudVideoPlayer {
202
202
  setMuted(muted: boolean): void;
203
203
  setVolume(volume: number): void;
204
204
  getVolume(): number;
205
+ private getAdAudioVolume;
205
206
  isFullscreen(): boolean;
206
207
  isLive(): boolean;
207
208
  get videoElement(): HTMLVideoElement;
@@ -866,7 +866,6 @@ function createHlsAdPlayer(contentVideo, options) {
866
866
  adPlaying = false;
867
867
  setAdPlayingFlag(false);
868
868
  contentVideo.muted = true;
869
- contentVideo.volume = 0;
870
869
  if (adContainerEl) {
871
870
  adContainerEl.style.display = "none";
872
871
  adContainerEl.style.pointerEvents = "none";
@@ -886,7 +885,6 @@ function createHlsAdPlayer(contentVideo, options) {
886
885
  adPlaying = false;
887
886
  setAdPlayingFlag(false);
888
887
  contentVideo.muted = true;
889
- contentVideo.volume = 0;
890
888
  if (adContainerEl) {
891
889
  adContainerEl.style.display = "none";
892
890
  adContainerEl.style.pointerEvents = "none";
@@ -991,7 +989,7 @@ function createHlsAdPlayer(contentVideo, options) {
991
989
  },
992
990
  play: function play() {
993
991
  return _async_to_generator(function() {
994
- var contentVolume, adVolume, mediaFile, isHlsAd;
992
+ var contentVolume, mediaFile, isHlsAd;
995
993
  return _ts_generator(this, function(_state) {
996
994
  if (!currentAd) {
997
995
  console.warn("[HlsAdPlayer] Cannot play: No ad loaded (no ads available)");
@@ -1025,13 +1023,11 @@ function createHlsAdPlayer(contentVideo, options) {
1025
1023
  }
1026
1024
  console.log("[HlsAdPlayer] FORCE MUTING main video");
1027
1025
  contentVideo.muted = true;
1028
- contentVideo.volume = 0;
1029
1026
  adPlaying = true;
1030
1027
  setAdPlayingFlag(true);
1031
1028
  if (adVideoElement) {
1032
- adVolume = originalMutedState ? 0 : originalVolume;
1033
- adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
1034
- adVideoElement.muted = false;
1029
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
1030
+ adVideoElement.muted = originalMutedState;
1035
1031
  console.log("[HlsAdPlayer] Set ad video volume to ".concat(adVideoElement.volume, ", muted: ").concat(adVideoElement.muted, ", originalMutedState: ").concat(originalMutedState, ", contentVolume: ").concat(contentVolume));
1036
1032
  }
1037
1033
  if (adContainerEl) {
@@ -1139,8 +1135,8 @@ function createHlsAdPlayer(contentVideo, options) {
1139
1135
  setAdPlayingFlag(false);
1140
1136
  previousMutedState = contentVideo.muted;
1141
1137
  contentVideo.muted = originalMutedState;
1142
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1143
- console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState));
1138
+ contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1139
+ console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState, ", volume: ").concat(contentVideo.volume));
1144
1140
  if (adContainerEl) {
1145
1141
  adContainerEl.style.display = "none";
1146
1142
  adContainerEl.style.pointerEvents = "none";
@@ -1195,7 +1191,7 @@ function createHlsAdPlayer(contentVideo, options) {
1195
1191
  adPlaying = false;
1196
1192
  setAdPlayingFlag(false);
1197
1193
  contentVideo.muted = originalMutedState;
1198
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1194
+ contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1199
1195
  if (adHls) {
1200
1196
  adHls.destroy();
1201
1197
  adHls = void 0;
@@ -1251,7 +1247,9 @@ function createHlsAdPlayer(contentVideo, options) {
1251
1247
  },
1252
1248
  setAdVolume: function setAdVolume(volume) {
1253
1249
  if (adVideoElement && adPlaying) {
1254
- adVideoElement.volume = Math.max(0, Math.min(1, volume));
1250
+ var clamped = Math.max(0, Math.min(1, volume));
1251
+ adVideoElement.volume = clamped;
1252
+ adVideoElement.muted = clamped === 0;
1255
1253
  }
1256
1254
  },
1257
1255
  getAdVolume: function getAdVolume() {
@@ -3246,10 +3244,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3246
3244
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3247
3245
  }
3248
3246
  }
3249
- var currentMuted = _this.video.muted;
3250
- var currentVolume = _this.video.volume;
3251
- var adVolume = currentMuted ? 0 : currentVolume;
3252
- _this.adPlayer.setAdVolume(adVolume);
3247
+ _this.adPlayer.setAdVolume(_this.getAdAudioVolume());
3253
3248
  if (_this.isShowingPlaceholder) {
3254
3249
  if (_this.config.debugAdTiming) {
3255
3250
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -3266,7 +3261,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3266
3261
  }).catch(function() {});
3267
3262
  if (!_this.video.muted) {
3268
3263
  _this.video.muted = true;
3269
- _this.video.volume = 0;
3270
3264
  if (_this.config.debugAdTiming) {
3271
3265
  console.log("[StormcloudVideoPlayer] Muted video on content_resume (ad ended, gap between ads)");
3272
3266
  }
@@ -3314,7 +3308,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3314
3308
  try {
3315
3309
  this.adPlayer.destroy();
3316
3310
  this.video.muted = true;
3317
- this.video.volume = 0;
3318
3311
  } catch (error) {
3319
3312
  if (this.config.debugAdTiming) {
3320
3313
  console.warn("[StormcloudVideoPlayer] Error destroying old AdController:", error);
@@ -3373,7 +3366,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3373
3366
  }
3374
3367
  if (!this.video.muted) {
3375
3368
  this.video.muted = true;
3376
- this.video.volume = 0;
3377
3369
  if (this.config.debugAdTiming) {
3378
3370
  console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
3379
3371
  }
@@ -3995,7 +3987,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3995
3987
  if (marker.type === "end") {
3996
3988
  if (!this.video.muted) {
3997
3989
  this.video.muted = true;
3998
- this.video.volume = 0;
3999
3990
  if (this.config.debugAdTiming) {
4000
3991
  console.log("[StormcloudVideoPlayer] Muted video on SCTE end marker");
4001
3992
  }
@@ -4033,13 +4024,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4033
4024
  {
4034
4025
  key: "startScte35AdBreak",
4035
4026
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
4036
- if (!this.video.muted) {
4037
- this.video.muted = true;
4038
- this.video.volume = 0;
4039
- if (this.config.debugAdTiming) {
4040
- console.log("[StormcloudVideoPlayer] Muted video on SCTE start marker");
4041
- }
4042
- }
4043
4027
  this.inAdBreak = true;
4044
4028
  this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
4045
4029
  this.scheduledScte35BreakKey = void 0;
@@ -5626,7 +5610,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5626
5610
  key: "handleAdStart",
5627
5611
  value: function handleAdStart(_marker) {
5628
5612
  return _async_to_generator(function() {
5629
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, adVolume, adVolume1, error, fallbackPreloaded, adVolume2, fallbackError;
5613
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, preservedMuted, preservedVolume, adVolume, adVolume1, error, fallbackPreloaded, preservedMuted1, preservedVolume1, adVolume2, fallbackError;
5630
5614
  return _ts_generator(this, function(_state) {
5631
5615
  switch(_state.label){
5632
5616
  case 0:
@@ -5666,7 +5650,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5666
5650
  this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
5667
5651
  if (!this.video.muted) {
5668
5652
  this.video.muted = true;
5669
- this.video.volume = 0;
5670
5653
  if (this.config.debugAdTiming) {
5671
5654
  console.log("[StormcloudVideoPlayer] Muted video in handleAdStart");
5672
5655
  }
@@ -5736,10 +5719,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5736
5719
  3,
5737
5720
  3
5738
5721
  ];
5722
+ preservedMuted = this.adPlayer.getOriginalMutedState();
5723
+ preservedVolume = this.adPlayer.getOriginalVolume();
5739
5724
  this.adPlayer.destroy();
5740
5725
  this.video.muted = true;
5741
- this.video.volume = 0;
5742
5726
  this.adPlayer = preloadedController;
5727
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
5743
5728
  this.attachImaEventListeners();
5744
5729
  if (this.config.debugAdTiming) {
5745
5730
  console.log("[CONTINUOUS-FETCH] \u2705 Using preloaded ad, resuming and starting playback immediately (no request delay!)");
@@ -5837,11 +5822,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5837
5822
  ,
5838
5823
  12
5839
5824
  ]);
5825
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
5826
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
5840
5827
  this.adPlayer.destroy();
5841
5828
  this.video.muted = true;
5842
- this.video.volume = 0;
5843
5829
  this.adPlayer = fallbackPreloaded.adController;
5844
5830
  this.attachImaEventListeners();
5831
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
5845
5832
  this.adPlayer.resume();
5846
5833
  this.consecutiveFailures = 0;
5847
5834
  this.currentAdIndex++;
@@ -6139,7 +6126,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6139
6126
  value: function tryNextAvailableAd() {
6140
6127
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6141
6128
  return _async_to_generator(function() {
6142
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6129
+ var remaining, preloaded, preservedMuted, preservedVolume, error, nextAdUrl, error1, errorMessage, maxRetries;
6143
6130
  return _ts_generator(this, function(_state) {
6144
6131
  switch(_state.label){
6145
6132
  case 0:
@@ -6193,11 +6180,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6193
6180
  ,
6194
6181
  4
6195
6182
  ]);
6183
+ preservedMuted = this.adPlayer.getOriginalMutedState();
6184
+ preservedVolume = this.adPlayer.getOriginalVolume();
6196
6185
  this.adPlayer.destroy();
6197
6186
  this.video.muted = true;
6198
- this.video.volume = 0;
6199
6187
  this.adPlayer = preloaded.adController;
6200
6188
  this.attachImaEventListeners();
6189
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
6201
6190
  this.adPlayer.resume();
6202
6191
  this.currentAdIndex++;
6203
6192
  this.totalAdRequestsInBreak++;
@@ -6211,10 +6200,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6211
6200
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6212
6201
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6213
6202
  }
6214
- currentMuted = this.video.muted;
6215
- currentVolume = this.video.volume;
6216
- adVolume = currentMuted ? 0 : currentVolume;
6217
- this.adPlayer.setAdVolume(adVolume);
6203
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6218
6204
  this.consecutiveFailures = 0;
6219
6205
  return [
6220
6206
  2
@@ -6261,9 +6247,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6261
6247
  if (this.config.debugAdTiming) {
6262
6248
  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)"));
6263
6249
  }
6264
- currentMuted1 = this.video.muted;
6265
- currentVolume1 = this.video.volume;
6266
- this.adPlayer.updateOriginalMutedState(currentMuted1, currentVolume1);
6267
6250
  this.currentAdIndex++;
6268
6251
  this.totalAdRequestsInBreak++;
6269
6252
  this.lastAdRequestTime = Date.now();
@@ -6356,7 +6339,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6356
6339
  key: "showPlaceholderAndWaitForAds",
6357
6340
  value: function showPlaceholderAndWaitForAds() {
6358
6341
  return _async_to_generator(function() {
6359
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
6342
+ var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
6360
6343
  return _ts_generator(this, function(_state) {
6361
6344
  switch(_state.label){
6362
6345
  case 0:
@@ -6452,9 +6435,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6452
6435
  }
6453
6436
  this.isShowingPlaceholder = false;
6454
6437
  this.adPlayer.hidePlaceholder();
6455
- currentMuted = this.video.muted;
6456
- currentVolume = this.video.volume;
6457
- this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
6458
6438
  this.currentAdIndex++;
6459
6439
  this.totalAdRequestsInBreak++;
6460
6440
  this.lastAdRequestTime = Date.now();
@@ -6904,7 +6884,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6904
6884
  key: "playSingleAd",
6905
6885
  value: function playSingleAd(vastTagUrl) {
6906
6886
  return _async_to_generator(function() {
6907
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
6887
+ var requestToken, playError, preloadedFallback, preservedMuted, preservedVolume, fallbackError, error, errorMessage, preloadedFallback1, preservedMuted1, preservedVolume1, fallbackError1;
6908
6888
  return _ts_generator(this, function(_state) {
6909
6889
  switch(_state.label){
6910
6890
  case 0:
@@ -6991,10 +6971,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6991
6971
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6992
6972
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6993
6973
  }
6994
- currentMuted = this.video.muted;
6995
- currentVolume = this.video.volume;
6996
- adVolume = currentMuted ? 0 : currentVolume;
6997
- this.adPlayer.setAdVolume(adVolume);
6974
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6998
6975
  this.consecutiveFailures = 0;
6999
6976
  this.temporaryFailureUrls.delete(vastTagUrl);
7000
6977
  return [
@@ -7023,11 +7000,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7023
7000
  10
7024
7001
  ]);
7025
7002
  this.clearAdFailsafeTimer();
7003
+ preservedMuted = this.adPlayer.getOriginalMutedState();
7004
+ preservedVolume = this.adPlayer.getOriginalVolume();
7026
7005
  this.adPlayer.destroy();
7027
7006
  this.video.muted = true;
7028
- this.video.volume = 0;
7029
7007
  this.adPlayer = preloadedFallback.adController;
7030
7008
  this.attachImaEventListeners();
7009
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
7031
7010
  this.adPlayer.resume();
7032
7011
  this.consecutiveFailures = 0;
7033
7012
  this.currentAdIndex++;
@@ -7041,10 +7020,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7041
7020
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7042
7021
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
7043
7022
  }
7044
- currentMuted1 = this.video.muted;
7045
- currentVolume1 = this.video.volume;
7046
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7047
- this.adPlayer.setAdVolume(adVolume1);
7023
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7048
7024
  return [
7049
7025
  2
7050
7026
  ];
@@ -7103,11 +7079,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7103
7079
  ]);
7104
7080
  this.clearAdRequestWatchdog();
7105
7081
  this.clearAdFailsafeTimer();
7082
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
7083
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
7106
7084
  this.adPlayer.destroy();
7107
7085
  this.video.muted = true;
7108
- this.video.volume = 0;
7109
7086
  this.adPlayer = preloadedFallback1.adController;
7110
7087
  this.attachImaEventListeners();
7088
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
7111
7089
  this.adPlayer.resume();
7112
7090
  this.consecutiveFailures = 0;
7113
7091
  this.currentAdIndex++;
@@ -7118,10 +7096,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7118
7096
  ];
7119
7097
  case 14:
7120
7098
  _state.sent();
7121
- currentMuted2 = this.video.muted;
7122
- currentVolume2 = this.video.volume;
7123
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7124
- this.adPlayer.setAdVolume(adVolume2);
7099
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7125
7100
  return [
7126
7101
  2
7127
7102
  ];
@@ -7423,10 +7398,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7423
7398
  key: "toggleMute",
7424
7399
  value: function toggleMute() {
7425
7400
  if (this.adPlayer.isAdPlaying()) {
7426
- var currentPerceptualState = this.isMuted();
7427
- var newMutedState = !currentPerceptualState;
7401
+ var newMutedState = !this.adPlayer.getOriginalMutedState();
7402
+ var restoreVolume = this.adPlayer.getOriginalVolume() || 1;
7428
7403
  this.adPlayer.updateOriginalMutedState(newMutedState, this.video.volume);
7429
- this.adPlayer.setAdVolume(newMutedState ? 0 : 1);
7404
+ this.adPlayer.setAdVolume(newMutedState ? 0 : restoreVolume);
7430
7405
  if (this.config.debugAdTiming) {
7431
7406
  console.log("[StormcloudVideoPlayer] Mute toggle during ad - immediately applied:", newMutedState);
7432
7407
  }
@@ -7481,10 +7456,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7481
7456
  key: "isMuted",
7482
7457
  value: function isMuted() {
7483
7458
  if (this.adPlayer.isAdPlaying()) {
7484
- if (this.config.debugAdTiming) {
7485
- console.log("[StormcloudVideoPlayer] isMuted() override during ad playback -> false");
7486
- }
7487
- return false;
7459
+ return this.adPlayer.getOriginalMutedState();
7488
7460
  }
7489
7461
  return this.video.muted;
7490
7462
  }
@@ -7551,6 +7523,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7551
7523
  return this.video.volume;
7552
7524
  }
7553
7525
  },
7526
+ {
7527
+ key: "getAdAudioVolume",
7528
+ value: function getAdAudioVolume() {
7529
+ return this.adPlayer.getOriginalMutedState() ? 0 : this.adPlayer.getOriginalVolume();
7530
+ }
7531
+ },
7554
7532
  {
7555
7533
  key: "isFullscreen",
7556
7534
  value: function isFullscreen() {