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.
@@ -814,7 +814,6 @@ function createHlsAdPlayer(contentVideo, options) {
814
814
  adPlaying = false;
815
815
  setAdPlayingFlag(false);
816
816
  contentVideo.muted = true;
817
- contentVideo.volume = 0;
818
817
  if (adContainerEl) {
819
818
  adContainerEl.style.display = "none";
820
819
  adContainerEl.style.pointerEvents = "none";
@@ -834,7 +833,6 @@ function createHlsAdPlayer(contentVideo, options) {
834
833
  adPlaying = false;
835
834
  setAdPlayingFlag(false);
836
835
  contentVideo.muted = true;
837
- contentVideo.volume = 0;
838
836
  if (adContainerEl) {
839
837
  adContainerEl.style.display = "none";
840
838
  adContainerEl.style.pointerEvents = "none";
@@ -939,7 +937,7 @@ function createHlsAdPlayer(contentVideo, options) {
939
937
  },
940
938
  play: function play() {
941
939
  return _async_to_generator(function() {
942
- var contentVolume, adVolume, mediaFile, isHlsAd;
940
+ var contentVolume, mediaFile, isHlsAd;
943
941
  return _ts_generator(this, function(_state) {
944
942
  if (!currentAd) {
945
943
  console.warn("[HlsAdPlayer] Cannot play: No ad loaded (no ads available)");
@@ -973,13 +971,11 @@ function createHlsAdPlayer(contentVideo, options) {
973
971
  }
974
972
  console.log("[HlsAdPlayer] FORCE MUTING main video");
975
973
  contentVideo.muted = true;
976
- contentVideo.volume = 0;
977
974
  adPlaying = true;
978
975
  setAdPlayingFlag(true);
979
976
  if (adVideoElement) {
980
- adVolume = originalMutedState ? 0 : originalVolume;
981
- adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
982
- adVideoElement.muted = false;
977
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
978
+ adVideoElement.muted = originalMutedState;
983
979
  console.log("[HlsAdPlayer] Set ad video volume to ".concat(adVideoElement.volume, ", muted: ").concat(adVideoElement.muted, ", originalMutedState: ").concat(originalMutedState, ", contentVolume: ").concat(contentVolume));
984
980
  }
985
981
  if (adContainerEl) {
@@ -1087,8 +1083,8 @@ function createHlsAdPlayer(contentVideo, options) {
1087
1083
  setAdPlayingFlag(false);
1088
1084
  previousMutedState = contentVideo.muted;
1089
1085
  contentVideo.muted = originalMutedState;
1090
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1091
- console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState));
1086
+ contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1087
+ console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState, ", volume: ").concat(contentVideo.volume));
1092
1088
  if (adContainerEl) {
1093
1089
  adContainerEl.style.display = "none";
1094
1090
  adContainerEl.style.pointerEvents = "none";
@@ -1143,7 +1139,7 @@ function createHlsAdPlayer(contentVideo, options) {
1143
1139
  adPlaying = false;
1144
1140
  setAdPlayingFlag(false);
1145
1141
  contentVideo.muted = originalMutedState;
1146
- contentVideo.volume = originalMutedState ? 0 : originalVolume;
1142
+ contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
1147
1143
  if (adHls) {
1148
1144
  adHls.destroy();
1149
1145
  adHls = void 0;
@@ -1199,7 +1195,9 @@ function createHlsAdPlayer(contentVideo, options) {
1199
1195
  },
1200
1196
  setAdVolume: function setAdVolume(volume) {
1201
1197
  if (adVideoElement && adPlaying) {
1202
- adVideoElement.volume = Math.max(0, Math.min(1, volume));
1198
+ var clamped = Math.max(0, Math.min(1, volume));
1199
+ adVideoElement.volume = clamped;
1200
+ adVideoElement.muted = clamped === 0;
1203
1201
  }
1204
1202
  },
1205
1203
  getAdVolume: function getAdVolume() {
@@ -3194,10 +3192,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3194
3192
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3195
3193
  }
3196
3194
  }
3197
- var currentMuted = _this.video.muted;
3198
- var currentVolume = _this.video.volume;
3199
- var adVolume = currentMuted ? 0 : currentVolume;
3200
- _this.adPlayer.setAdVolume(adVolume);
3195
+ _this.adPlayer.setAdVolume(_this.getAdAudioVolume());
3201
3196
  if (_this.isShowingPlaceholder) {
3202
3197
  if (_this.config.debugAdTiming) {
3203
3198
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -3214,7 +3209,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3214
3209
  }).catch(function() {});
3215
3210
  if (!_this.video.muted) {
3216
3211
  _this.video.muted = true;
3217
- _this.video.volume = 0;
3218
3212
  if (_this.config.debugAdTiming) {
3219
3213
  console.log("[StormcloudVideoPlayer] Muted video on content_resume (ad ended, gap between ads)");
3220
3214
  }
@@ -3262,7 +3256,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3262
3256
  try {
3263
3257
  this.adPlayer.destroy();
3264
3258
  this.video.muted = true;
3265
- this.video.volume = 0;
3266
3259
  } catch (error) {
3267
3260
  if (this.config.debugAdTiming) {
3268
3261
  console.warn("[StormcloudVideoPlayer] Error destroying old AdController:", error);
@@ -3321,7 +3314,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3321
3314
  }
3322
3315
  if (!this.video.muted) {
3323
3316
  this.video.muted = true;
3324
- this.video.volume = 0;
3325
3317
  if (this.config.debugAdTiming) {
3326
3318
  console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
3327
3319
  }
@@ -3943,7 +3935,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3943
3935
  if (marker.type === "end") {
3944
3936
  if (!this.video.muted) {
3945
3937
  this.video.muted = true;
3946
- this.video.volume = 0;
3947
3938
  if (this.config.debugAdTiming) {
3948
3939
  console.log("[StormcloudVideoPlayer] Muted video on SCTE end marker");
3949
3940
  }
@@ -3981,13 +3972,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3981
3972
  {
3982
3973
  key: "startScte35AdBreak",
3983
3974
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
3984
- if (!this.video.muted) {
3985
- this.video.muted = true;
3986
- this.video.volume = 0;
3987
- if (this.config.debugAdTiming) {
3988
- console.log("[StormcloudVideoPlayer] Muted video on SCTE start marker");
3989
- }
3990
- }
3991
3975
  this.inAdBreak = true;
3992
3976
  this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
3993
3977
  this.scheduledScte35BreakKey = void 0;
@@ -5574,7 +5558,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5574
5558
  key: "handleAdStart",
5575
5559
  value: function handleAdStart(_marker) {
5576
5560
  return _async_to_generator(function() {
5577
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, adVolume, adVolume1, error, fallbackPreloaded, adVolume2, fallbackError;
5561
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, preservedMuted, preservedVolume, adVolume, adVolume1, error, fallbackPreloaded, preservedMuted1, preservedVolume1, adVolume2, fallbackError;
5578
5562
  return _ts_generator(this, function(_state) {
5579
5563
  switch(_state.label){
5580
5564
  case 0:
@@ -5614,7 +5598,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5614
5598
  this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
5615
5599
  if (!this.video.muted) {
5616
5600
  this.video.muted = true;
5617
- this.video.volume = 0;
5618
5601
  if (this.config.debugAdTiming) {
5619
5602
  console.log("[StormcloudVideoPlayer] Muted video in handleAdStart");
5620
5603
  }
@@ -5684,10 +5667,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5684
5667
  3,
5685
5668
  3
5686
5669
  ];
5670
+ preservedMuted = this.adPlayer.getOriginalMutedState();
5671
+ preservedVolume = this.adPlayer.getOriginalVolume();
5687
5672
  this.adPlayer.destroy();
5688
5673
  this.video.muted = true;
5689
- this.video.volume = 0;
5690
5674
  this.adPlayer = preloadedController;
5675
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
5691
5676
  this.attachImaEventListeners();
5692
5677
  if (this.config.debugAdTiming) {
5693
5678
  console.log("[CONTINUOUS-FETCH] \u2705 Using preloaded ad, resuming and starting playback immediately (no request delay!)");
@@ -5785,11 +5770,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5785
5770
  ,
5786
5771
  12
5787
5772
  ]);
5773
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
5774
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
5788
5775
  this.adPlayer.destroy();
5789
5776
  this.video.muted = true;
5790
- this.video.volume = 0;
5791
5777
  this.adPlayer = fallbackPreloaded.adController;
5792
5778
  this.attachImaEventListeners();
5779
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
5793
5780
  this.adPlayer.resume();
5794
5781
  this.consecutiveFailures = 0;
5795
5782
  this.currentAdIndex++;
@@ -6087,7 +6074,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6087
6074
  value: function tryNextAvailableAd() {
6088
6075
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6089
6076
  return _async_to_generator(function() {
6090
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6077
+ var remaining, preloaded, preservedMuted, preservedVolume, error, nextAdUrl, error1, errorMessage, maxRetries;
6091
6078
  return _ts_generator(this, function(_state) {
6092
6079
  switch(_state.label){
6093
6080
  case 0:
@@ -6141,11 +6128,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6141
6128
  ,
6142
6129
  4
6143
6130
  ]);
6131
+ preservedMuted = this.adPlayer.getOriginalMutedState();
6132
+ preservedVolume = this.adPlayer.getOriginalVolume();
6144
6133
  this.adPlayer.destroy();
6145
6134
  this.video.muted = true;
6146
- this.video.volume = 0;
6147
6135
  this.adPlayer = preloaded.adController;
6148
6136
  this.attachImaEventListeners();
6137
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
6149
6138
  this.adPlayer.resume();
6150
6139
  this.currentAdIndex++;
6151
6140
  this.totalAdRequestsInBreak++;
@@ -6159,10 +6148,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6159
6148
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6160
6149
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6161
6150
  }
6162
- currentMuted = this.video.muted;
6163
- currentVolume = this.video.volume;
6164
- adVolume = currentMuted ? 0 : currentVolume;
6165
- this.adPlayer.setAdVolume(adVolume);
6151
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6166
6152
  this.consecutiveFailures = 0;
6167
6153
  return [
6168
6154
  2
@@ -6209,9 +6195,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6209
6195
  if (this.config.debugAdTiming) {
6210
6196
  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)"));
6211
6197
  }
6212
- currentMuted1 = this.video.muted;
6213
- currentVolume1 = this.video.volume;
6214
- this.adPlayer.updateOriginalMutedState(currentMuted1, currentVolume1);
6215
6198
  this.currentAdIndex++;
6216
6199
  this.totalAdRequestsInBreak++;
6217
6200
  this.lastAdRequestTime = Date.now();
@@ -6304,7 +6287,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6304
6287
  key: "showPlaceholderAndWaitForAds",
6305
6288
  value: function showPlaceholderAndWaitForAds() {
6306
6289
  return _async_to_generator(function() {
6307
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
6290
+ var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
6308
6291
  return _ts_generator(this, function(_state) {
6309
6292
  switch(_state.label){
6310
6293
  case 0:
@@ -6400,9 +6383,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6400
6383
  }
6401
6384
  this.isShowingPlaceholder = false;
6402
6385
  this.adPlayer.hidePlaceholder();
6403
- currentMuted = this.video.muted;
6404
- currentVolume = this.video.volume;
6405
- this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
6406
6386
  this.currentAdIndex++;
6407
6387
  this.totalAdRequestsInBreak++;
6408
6388
  this.lastAdRequestTime = Date.now();
@@ -6852,7 +6832,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6852
6832
  key: "playSingleAd",
6853
6833
  value: function playSingleAd(vastTagUrl) {
6854
6834
  return _async_to_generator(function() {
6855
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
6835
+ var requestToken, playError, preloadedFallback, preservedMuted, preservedVolume, fallbackError, error, errorMessage, preloadedFallback1, preservedMuted1, preservedVolume1, fallbackError1;
6856
6836
  return _ts_generator(this, function(_state) {
6857
6837
  switch(_state.label){
6858
6838
  case 0:
@@ -6939,10 +6919,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6939
6919
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6940
6920
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6941
6921
  }
6942
- currentMuted = this.video.muted;
6943
- currentVolume = this.video.volume;
6944
- adVolume = currentMuted ? 0 : currentVolume;
6945
- this.adPlayer.setAdVolume(adVolume);
6922
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6946
6923
  this.consecutiveFailures = 0;
6947
6924
  this.temporaryFailureUrls.delete(vastTagUrl);
6948
6925
  return [
@@ -6971,11 +6948,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6971
6948
  10
6972
6949
  ]);
6973
6950
  this.clearAdFailsafeTimer();
6951
+ preservedMuted = this.adPlayer.getOriginalMutedState();
6952
+ preservedVolume = this.adPlayer.getOriginalVolume();
6974
6953
  this.adPlayer.destroy();
6975
6954
  this.video.muted = true;
6976
- this.video.volume = 0;
6977
6955
  this.adPlayer = preloadedFallback.adController;
6978
6956
  this.attachImaEventListeners();
6957
+ this.adPlayer.updateOriginalMutedState(preservedMuted, preservedVolume);
6979
6958
  this.adPlayer.resume();
6980
6959
  this.consecutiveFailures = 0;
6981
6960
  this.currentAdIndex++;
@@ -6989,10 +6968,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6989
6968
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6990
6969
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
6991
6970
  }
6992
- currentMuted1 = this.video.muted;
6993
- currentVolume1 = this.video.volume;
6994
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
6995
- this.adPlayer.setAdVolume(adVolume1);
6971
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
6996
6972
  return [
6997
6973
  2
6998
6974
  ];
@@ -7051,11 +7027,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7051
7027
  ]);
7052
7028
  this.clearAdRequestWatchdog();
7053
7029
  this.clearAdFailsafeTimer();
7030
+ preservedMuted1 = this.adPlayer.getOriginalMutedState();
7031
+ preservedVolume1 = this.adPlayer.getOriginalVolume();
7054
7032
  this.adPlayer.destroy();
7055
7033
  this.video.muted = true;
7056
- this.video.volume = 0;
7057
7034
  this.adPlayer = preloadedFallback1.adController;
7058
7035
  this.attachImaEventListeners();
7036
+ this.adPlayer.updateOriginalMutedState(preservedMuted1, preservedVolume1);
7059
7037
  this.adPlayer.resume();
7060
7038
  this.consecutiveFailures = 0;
7061
7039
  this.currentAdIndex++;
@@ -7066,10 +7044,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7066
7044
  ];
7067
7045
  case 14:
7068
7046
  _state.sent();
7069
- currentMuted2 = this.video.muted;
7070
- currentVolume2 = this.video.volume;
7071
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7072
- this.adPlayer.setAdVolume(adVolume2);
7047
+ this.adPlayer.setAdVolume(this.getAdAudioVolume());
7073
7048
  return [
7074
7049
  2
7075
7050
  ];
@@ -7371,10 +7346,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7371
7346
  key: "toggleMute",
7372
7347
  value: function toggleMute() {
7373
7348
  if (this.adPlayer.isAdPlaying()) {
7374
- var currentPerceptualState = this.isMuted();
7375
- var newMutedState = !currentPerceptualState;
7349
+ var newMutedState = !this.adPlayer.getOriginalMutedState();
7350
+ var restoreVolume = this.adPlayer.getOriginalVolume() || 1;
7376
7351
  this.adPlayer.updateOriginalMutedState(newMutedState, this.video.volume);
7377
- this.adPlayer.setAdVolume(newMutedState ? 0 : 1);
7352
+ this.adPlayer.setAdVolume(newMutedState ? 0 : restoreVolume);
7378
7353
  if (this.config.debugAdTiming) {
7379
7354
  console.log("[StormcloudVideoPlayer] Mute toggle during ad - immediately applied:", newMutedState);
7380
7355
  }
@@ -7429,10 +7404,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7429
7404
  key: "isMuted",
7430
7405
  value: function isMuted() {
7431
7406
  if (this.adPlayer.isAdPlaying()) {
7432
- if (this.config.debugAdTiming) {
7433
- console.log("[StormcloudVideoPlayer] isMuted() override during ad playback -> false");
7434
- }
7435
- return false;
7407
+ return this.adPlayer.getOriginalMutedState();
7436
7408
  }
7437
7409
  return this.video.muted;
7438
7410
  }
@@ -7499,6 +7471,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7499
7471
  return this.video.volume;
7500
7472
  }
7501
7473
  },
7474
+ {
7475
+ key: "getAdAudioVolume",
7476
+ value: function getAdAudioVolume() {
7477
+ return this.adPlayer.getOriginalMutedState() ? 0 : this.adPlayer.getOriginalVolume();
7478
+ }
7479
+ },
7502
7480
  {
7503
7481
  key: "isFullscreen",
7504
7482
  value: function isFullscreen() {