stormcloud-video-player 0.3.56 → 0.3.57

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.
@@ -96,6 +96,7 @@ declare class StormcloudVideoPlayer {
96
96
  private resolveBreakStartMs;
97
97
  getCurrentAdIndex(): number;
98
98
  getTotalAdsInBreak(): number;
99
+ getAdRemainingMs(): number;
99
100
  private generateVastUrlsWithCorrelators;
100
101
  isAdPlaying(): boolean;
101
102
  isShowingAds(): boolean;
@@ -706,7 +706,7 @@ function createImaController(video, options) {
706
706
  adVideo.style.height = "100%";
707
707
  adVideo.style.objectFit = "contain";
708
708
  adVideo.style.backgroundColor = "transparent";
709
- adVideo.style.zIndex = "15";
709
+ adVideo.style.zIndex = "2";
710
710
  adVideo.playsInline = true;
711
711
  adVideo.volume = originalVolume;
712
712
  adVideo.muted = originalMutedState;
@@ -999,7 +999,7 @@ function createImaController(video, options) {
999
999
  container.style.alignItems = "center";
1000
1000
  container.style.justifyContent = "center";
1001
1001
  container.style.pointerEvents = "none";
1002
- container.style.zIndex = "10";
1002
+ container.style.zIndex = "30";
1003
1003
  container.style.backgroundColor = "#000";
1004
1004
  container.style.transition = "opacity 0.3s ease-in-out";
1005
1005
  container.style.opacity = "0";
@@ -1114,7 +1114,7 @@ function createImaController(video, options) {
1114
1114
  container.style.alignItems = "center";
1115
1115
  container.style.justifyContent = "center";
1116
1116
  container.style.pointerEvents = "none";
1117
- container.style.zIndex = "10";
1117
+ container.style.zIndex = "30";
1118
1118
  container.style.backgroundColor = "transparent";
1119
1119
  container.style.transition = "opacity 0.3s ease-in-out, background-color 0.3s ease-in-out";
1120
1120
  container.style.opacity = "0";
@@ -2029,7 +2029,7 @@ function createHlsAdPlayer(contentVideo, options) {
2029
2029
  container.style.alignItems = "center";
2030
2030
  container.style.justifyContent = "center";
2031
2031
  container.style.pointerEvents = "none";
2032
- container.style.zIndex = "10";
2032
+ container.style.zIndex = "30";
2033
2033
  container.style.backgroundColor = "#000";
2034
2034
  (_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
2035
2035
  adContainerEl = container;
@@ -3809,13 +3809,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3809
3809
  _this.activeAdRequestToken = null;
3810
3810
  _this.showAds = true;
3811
3811
  _this.resetGamNoFillCounter();
3812
- if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null) {
3813
- if (_this.adStopTimerId == null) {
3814
- _this.currentAdBreakStartWallClockMs = Date.now();
3815
- _this.scheduleAdStopCountdown(_this.expectedAdBreakDurationMs);
3816
- if (_this.config.debugAdTiming) {
3817
- console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3818
- }
3812
+ if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
3813
+ _this.scheduleAdStopCountdown(_this.getRemainingAdMs());
3814
+ if (_this.config.debugAdTiming) {
3815
+ console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3819
3816
  }
3820
3817
  }
3821
3818
  var currentMuted = _this.video.muted;
@@ -3878,6 +3875,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3878
3875
  this.ima.showPlaceholder();
3879
3876
  this.isShowingPlaceholder = true;
3880
3877
  }
3878
+ var preservedMutedState = this.ima.getOriginalMutedState();
3879
+ var preservedVolumeState = this.ima.getOriginalVolume();
3881
3880
  if (this.ima) {
3882
3881
  try {
3883
3882
  this.ima.destroy();
@@ -3892,7 +3891,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3892
3891
  var continueLiveStreamDuringAds = this.shouldContinueLiveStreamDuringAds();
3893
3892
  this.ima = this.createAdPlayer(continueLiveStreamDuringAds);
3894
3893
  this.ima.initialize();
3895
- this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
3894
+ this.ima.updateOriginalMutedState(preservedMutedState, preservedVolumeState);
3896
3895
  this.attachImaEventListeners();
3897
3896
  if (shouldShowPlaceholder) {
3898
3897
  this.showPlaceholderLayer();
@@ -4208,12 +4207,17 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4208
4207
  }
4209
4208
  }
4210
4209
  if (this.inAdBreak) {
4211
- if (this.expectedAdBreakDurationMs == null && marker.durationSeconds != null) {
4212
- this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
4213
- if (this.config.debugAdTiming) {
4214
- console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(this.expectedAdBreakDurationMs, "ms"));
4210
+ if (marker.durationSeconds != null) {
4211
+ var newDurationMs = marker.durationSeconds * 1e3;
4212
+ if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
4213
+ this.expectedAdBreakDurationMs = newDurationMs;
4214
+ var elapsedMs = this.currentAdBreakStartWallClockMs != null ? Date.now() - this.currentAdBreakStartWallClockMs : 0;
4215
+ var remainingMs = Math.max(0, newDurationMs - elapsedMs);
4216
+ this.scheduleAdStopCountdown(remainingMs);
4217
+ if (this.config.debugAdTiming) {
4218
+ console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(remainingMs, "ms"));
4219
+ }
4215
4220
  }
4216
- this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
4217
4221
  }
4218
4222
  return;
4219
4223
  }
@@ -4289,9 +4293,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4289
4293
  this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
4290
4294
  }
4291
4295
  if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
4292
- var elapsedMs = Date.now() - this.currentAdBreakStartWallClockMs;
4293
- var remainingMs = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs);
4294
- this.scheduleAdStopCountdown(remainingMs);
4296
+ var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
4297
+ var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
4298
+ this.scheduleAdStopCountdown(remainingMs1);
4295
4299
  }
4296
4300
  if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
4297
4301
  this.tryNextAvailableAdWithRateLimit();
@@ -4859,6 +4863,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4859
4863
  return this.totalAdsInBreak;
4860
4864
  }
4861
4865
  },
4866
+ {
4867
+ key: "getAdRemainingMs",
4868
+ value: function getAdRemainingMs() {
4869
+ return this.getRemainingAdMs();
4870
+ }
4871
+ },
4862
4872
  {
4863
4873
  key: "generateVastUrlsWithCorrelators",
4864
4874
  value: function generateVastUrlsWithCorrelators(baseUrl, count) {
@@ -5511,9 +5521,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5511
5521
  ];
5512
5522
  case 2:
5513
5523
  _state.sent();
5514
- if (this.expectedAdBreakDurationMs != null) {
5515
- this.currentAdBreakStartWallClockMs = Date.now();
5516
- this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
5524
+ if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
5525
+ this.scheduleAdStopCountdown(this.getRemainingAdMs());
5517
5526
  }
5518
5527
  adVolume = currentMuted ? 0 : currentVolume;
5519
5528
  this.ima.setAdVolume(adVolume);
@@ -5554,9 +5563,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5554
5563
  ];
5555
5564
  case 6:
5556
5565
  _state.sent();
5557
- if (this.expectedAdBreakDurationMs != null) {
5558
- this.currentAdBreakStartWallClockMs = Date.now();
5559
- this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
5566
+ if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
5567
+ this.scheduleAdStopCountdown(this.getRemainingAdMs());
5560
5568
  }
5561
5569
  adVolume1 = currentMuted ? 0 : currentVolume;
5562
5570
  this.ima.setAdVolume(adVolume1);
@@ -5610,9 +5618,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5610
5618
  ];
5611
5619
  case 10:
5612
5620
  _state.sent();
5613
- if (this.expectedAdBreakDurationMs != null) {
5614
- this.currentAdBreakStartWallClockMs = Date.now();
5615
- this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
5621
+ if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
5622
+ this.scheduleAdStopCountdown(this.getRemainingAdMs());
5616
5623
  }
5617
5624
  adVolume2 = currentMuted ? 0 : currentVolume;
5618
5625
  this.ima.setAdVolume(adVolume2);
@@ -5963,8 +5970,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5963
5970
  case 2:
5964
5971
  _state.sent();
5965
5972
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
5966
- this.currentAdBreakStartWallClockMs = Date.now();
5967
- this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
5973
+ this.scheduleAdStopCountdown(this.getRemainingAdMs());
5968
5974
  }
5969
5975
  currentMuted = this.video.muted;
5970
5976
  currentVolume = this.video.volume;
@@ -6717,8 +6723,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6717
6723
  case 5:
6718
6724
  _state.sent();
6719
6725
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6720
- this.currentAdBreakStartWallClockMs = Date.now();
6721
- this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
6726
+ this.scheduleAdStopCountdown(this.getRemainingAdMs());
6722
6727
  }
6723
6728
  currentMuted = this.video.muted;
6724
6729
  currentVolume = this.video.volume;
@@ -6768,8 +6773,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6768
6773
  case 8:
6769
6774
  _state.sent();
6770
6775
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6771
- this.currentAdBreakStartWallClockMs = Date.now();
6772
- this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
6776
+ this.scheduleAdStopCountdown(this.getRemainingAdMs());
6773
6777
  }
6774
6778
  currentMuted1 = this.video.muted;
6775
6779
  currentVolume1 = this.video.volume;