stormcloud-video-player 0.2.23 → 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.
@@ -481,9 +481,13 @@ function createImaController(video, options) {
481
481
  adsLoader.addEventListener(
482
482
  google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
483
483
  (evt) => {
484
- console.log("[IMA] Ads manager loaded");
484
+ console.log(
485
+ "[IMA] Ads manager loaded - enabling preloading for continuous playback"
486
+ );
485
487
  try {
486
- adsManager = evt.getAdsManager(video);
488
+ const adsRenderingSettings = new google.ima.AdsRenderingSettings();
489
+ adsRenderingSettings.enablePreloading = true;
490
+ adsManager = evt.getAdsManager(video, adsRenderingSettings);
487
491
  const AdEvent = google.ima.AdEvent.Type;
488
492
  const AdErrorEvent = google.ima.AdErrorEvent.Type;
489
493
  adsManager.addEventListener(
@@ -2216,7 +2220,7 @@ var StormcloudVideoPlayer = class {
2216
2220
  this.video.volume = 0;
2217
2221
  if (this.config.debugAdTiming) {
2218
2222
  console.log(
2219
- `[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - main video stays muted, ad layer stays visible`
2223
+ `[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - IMMEDIATELY starting next ad`
2220
2224
  );
2221
2225
  }
2222
2226
  this.playSingleAd(next).catch(() => {
@@ -2801,25 +2805,21 @@ var StormcloudVideoPlayer = class {
2801
2805
  this.video.currentTime * 1e3
2802
2806
  );
2803
2807
  const tags = this.selectVastTagsForBreak(scheduled);
2804
- let vastTagUrl;
2808
+ let vastTagUrls = [];
2805
2809
  if (this.apiVastTagUrl) {
2806
- vastTagUrl = this.apiVastTagUrl;
2807
- this.adPodQueue = [];
2808
- this.currentAdIndex = 0;
2809
- this.totalAdsInBreak = 1;
2810
+ vastTagUrls = [this.apiVastTagUrl];
2810
2811
  if (this.config.debugAdTiming) {
2811
- console.log("[StormcloudVideoPlayer] Using VAST endpoint:", vastTagUrl);
2812
+ console.log(
2813
+ "[StormcloudVideoPlayer] Using VAST endpoint:",
2814
+ this.apiVastTagUrl
2815
+ );
2812
2816
  }
2813
2817
  } else if (tags && tags.length > 0) {
2814
- vastTagUrl = tags[0];
2815
- const rest = tags.slice(1);
2816
- this.adPodQueue = rest;
2817
- this.currentAdIndex = 0;
2818
- this.totalAdsInBreak = tags.length;
2818
+ vastTagUrls = tags;
2819
2819
  if (this.config.debugAdTiming) {
2820
2820
  console.log(
2821
- "[StormcloudVideoPlayer] Using scheduled VAST tag:",
2822
- vastTagUrl
2821
+ "[StormcloudVideoPlayer] Using scheduled VAST tags (count: " + tags.length + "):",
2822
+ tags
2823
2823
  );
2824
2824
  }
2825
2825
  } else {
@@ -2828,16 +2828,23 @@ var StormcloudVideoPlayer = class {
2828
2828
  }
2829
2829
  return;
2830
2830
  }
2831
- if (vastTagUrl) {
2831
+ if (vastTagUrls.length > 0) {
2832
2832
  this.inAdBreak = true;
2833
2833
  this.showAds = true;
2834
- this.currentAdIndex++;
2834
+ this.currentAdIndex = 0;
2835
+ this.totalAdsInBreak = vastTagUrls.length;
2836
+ this.adPodQueue = [...vastTagUrls];
2837
+ if (this.config.debugAdTiming) {
2838
+ console.log(
2839
+ `[StormcloudVideoPlayer] Starting ad pod with ${vastTagUrls.length} ads - will play continuously`
2840
+ );
2841
+ }
2835
2842
  try {
2836
- await this.playSingleAd(vastTagUrl);
2843
+ await this.playAdPod();
2837
2844
  } catch (error) {
2838
2845
  if (this.config.debugAdTiming) {
2839
2846
  console.error(
2840
- "[StormcloudVideoPlayer] Ad playback failed in handleAdStart:",
2847
+ "[StormcloudVideoPlayer] Ad pod playback failed:",
2841
2848
  error
2842
2849
  );
2843
2850
  }
@@ -2850,6 +2857,22 @@ var StormcloudVideoPlayer = class {
2850
2857
  this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
2851
2858
  }
2852
2859
  }
2860
+ async playAdPod() {
2861
+ if (this.adPodQueue.length === 0) {
2862
+ if (this.config.debugAdTiming) {
2863
+ console.log("[StormcloudVideoPlayer] No ads in pod to play");
2864
+ }
2865
+ return;
2866
+ }
2867
+ const firstAd = this.adPodQueue.shift();
2868
+ this.currentAdIndex++;
2869
+ if (this.config.debugAdTiming) {
2870
+ console.log(
2871
+ `[StormcloudVideoPlayer] Playing ad ${this.currentAdIndex}/${this.totalAdsInBreak}`
2872
+ );
2873
+ }
2874
+ await this.playSingleAd(firstAd);
2875
+ }
2853
2876
  findCurrentOrNextBreak(nowMs) {
2854
2877
  var _a;
2855
2878
  const schedule = [];