stormcloud-video-player 0.2.22 → 0.2.24

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.
@@ -52,6 +52,7 @@ declare class StormcloudVideoPlayer {
52
52
  shouldShowNativeControls(): boolean;
53
53
  private shouldContinueLiveStreamDuringAds;
54
54
  private handleAdStart;
55
+ private playAdPod;
55
56
  private findCurrentOrNextBreak;
56
57
  private onTimeUpdate;
57
58
  private handleMidAdJoin;
@@ -442,9 +442,13 @@ function createImaController(video, options) {
442
442
  adsLoader.addEventListener(
443
443
  google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
444
444
  (evt) => {
445
- console.log("[IMA] Ads manager loaded");
445
+ console.log(
446
+ "[IMA] Ads manager loaded - enabling preloading for continuous playback"
447
+ );
446
448
  try {
447
- adsManager = evt.getAdsManager(video);
449
+ const adsRenderingSettings = new google.ima.AdsRenderingSettings();
450
+ adsRenderingSettings.enablePreloading = true;
451
+ adsManager = evt.getAdsManager(video, adsRenderingSettings);
448
452
  const AdEvent = google.ima.AdEvent.Type;
449
453
  const AdErrorEvent = google.ima.AdErrorEvent.Type;
450
454
  adsManager.addEventListener(
@@ -541,6 +545,18 @@ function createImaController(video, options) {
541
545
  adPlaying = false;
542
546
  setAdPlayingFlag(false);
543
547
  emit("content_resume");
548
+ setTimeout(() => {
549
+ const stillInPod = video.dataset.stormcloudAdPlaying === "true";
550
+ if (stillInPod) {
551
+ console.log(
552
+ "[IMA] Still in ad pod - keeping ad container visible (black screen)"
553
+ );
554
+ if (adContainerEl) {
555
+ adContainerEl.style.display = "flex";
556
+ adContainerEl.style.pointerEvents = "auto";
557
+ }
558
+ }
559
+ }, 50);
544
560
  }
545
561
  );
546
562
  adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
@@ -1090,6 +1106,18 @@ function createHlsAdPlayer(contentVideo, options) {
1090
1106
  adPlaying = false;
1091
1107
  setAdPlayingFlag(false);
1092
1108
  emit("content_resume");
1109
+ setTimeout(() => {
1110
+ const stillInPod = contentVideo.dataset.stormcloudAdPlaying === "true";
1111
+ if (stillInPod) {
1112
+ console.log(
1113
+ "[HlsAdPlayer] Still in ad pod - keeping ad container visible (black screen)"
1114
+ );
1115
+ if (adContainerEl) {
1116
+ adContainerEl.style.display = "flex";
1117
+ adContainerEl.style.pointerEvents = "auto";
1118
+ }
1119
+ }
1120
+ }, 50);
1093
1121
  }
1094
1122
  function handleAdError() {
1095
1123
  console.log("[HlsAdPlayer] Handling ad error");
@@ -2148,9 +2176,12 @@ var StormcloudVideoPlayer = class {
2148
2176
  if (remaining > 500 && this.adPodQueue.length > 0) {
2149
2177
  const next = this.adPodQueue.shift();
2150
2178
  this.currentAdIndex++;
2179
+ this.video.dataset.stormcloudAdPlaying = "true";
2180
+ this.video.muted = true;
2181
+ this.video.volume = 0;
2151
2182
  if (this.config.debugAdTiming) {
2152
2183
  console.log(
2153
- `[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - main video stays muted, ad layer stays visible`
2184
+ `[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - IMMEDIATELY starting next ad`
2154
2185
  );
2155
2186
  }
2156
2187
  this.playSingleAd(next).catch(() => {
@@ -2735,25 +2766,21 @@ var StormcloudVideoPlayer = class {
2735
2766
  this.video.currentTime * 1e3
2736
2767
  );
2737
2768
  const tags = this.selectVastTagsForBreak(scheduled);
2738
- let vastTagUrl;
2769
+ let vastTagUrls = [];
2739
2770
  if (this.apiVastTagUrl) {
2740
- vastTagUrl = this.apiVastTagUrl;
2741
- this.adPodQueue = [];
2742
- this.currentAdIndex = 0;
2743
- this.totalAdsInBreak = 1;
2771
+ vastTagUrls = [this.apiVastTagUrl];
2744
2772
  if (this.config.debugAdTiming) {
2745
- console.log("[StormcloudVideoPlayer] Using VAST endpoint:", vastTagUrl);
2773
+ console.log(
2774
+ "[StormcloudVideoPlayer] Using VAST endpoint:",
2775
+ this.apiVastTagUrl
2776
+ );
2746
2777
  }
2747
2778
  } else if (tags && tags.length > 0) {
2748
- vastTagUrl = tags[0];
2749
- const rest = tags.slice(1);
2750
- this.adPodQueue = rest;
2751
- this.currentAdIndex = 0;
2752
- this.totalAdsInBreak = tags.length;
2779
+ vastTagUrls = tags;
2753
2780
  if (this.config.debugAdTiming) {
2754
2781
  console.log(
2755
- "[StormcloudVideoPlayer] Using scheduled VAST tag:",
2756
- vastTagUrl
2782
+ "[StormcloudVideoPlayer] Using scheduled VAST tags (count: " + tags.length + "):",
2783
+ tags
2757
2784
  );
2758
2785
  }
2759
2786
  } else {
@@ -2762,16 +2789,23 @@ var StormcloudVideoPlayer = class {
2762
2789
  }
2763
2790
  return;
2764
2791
  }
2765
- if (vastTagUrl) {
2792
+ if (vastTagUrls.length > 0) {
2766
2793
  this.inAdBreak = true;
2767
2794
  this.showAds = true;
2768
- this.currentAdIndex++;
2795
+ this.currentAdIndex = 0;
2796
+ this.totalAdsInBreak = vastTagUrls.length;
2797
+ this.adPodQueue = [...vastTagUrls];
2798
+ if (this.config.debugAdTiming) {
2799
+ console.log(
2800
+ `[StormcloudVideoPlayer] Starting ad pod with ${vastTagUrls.length} ads - will play continuously`
2801
+ );
2802
+ }
2769
2803
  try {
2770
- await this.playSingleAd(vastTagUrl);
2804
+ await this.playAdPod();
2771
2805
  } catch (error) {
2772
2806
  if (this.config.debugAdTiming) {
2773
2807
  console.error(
2774
- "[StormcloudVideoPlayer] Ad playback failed in handleAdStart:",
2808
+ "[StormcloudVideoPlayer] Ad pod playback failed:",
2775
2809
  error
2776
2810
  );
2777
2811
  }
@@ -2784,6 +2818,22 @@ var StormcloudVideoPlayer = class {
2784
2818
  this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
2785
2819
  }
2786
2820
  }
2821
+ async playAdPod() {
2822
+ if (this.adPodQueue.length === 0) {
2823
+ if (this.config.debugAdTiming) {
2824
+ console.log("[StormcloudVideoPlayer] No ads in pod to play");
2825
+ }
2826
+ return;
2827
+ }
2828
+ const firstAd = this.adPodQueue.shift();
2829
+ this.currentAdIndex++;
2830
+ if (this.config.debugAdTiming) {
2831
+ console.log(
2832
+ `[StormcloudVideoPlayer] Playing ad ${this.currentAdIndex}/${this.totalAdsInBreak}`
2833
+ );
2834
+ }
2835
+ await this.playSingleAd(firstAd);
2836
+ }
2787
2837
  findCurrentOrNextBreak(nowMs) {
2788
2838
  var _a;
2789
2839
  const schedule = [];