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.
package/lib/index.d.cts CHANGED
@@ -148,6 +148,7 @@ declare class StormcloudVideoPlayer {
148
148
  shouldShowNativeControls(): boolean;
149
149
  private shouldContinueLiveStreamDuringAds;
150
150
  private handleAdStart;
151
+ private playAdPod;
151
152
  private findCurrentOrNextBreak;
152
153
  private onTimeUpdate;
153
154
  private handleMidAdJoin;
package/lib/index.d.ts CHANGED
@@ -148,6 +148,7 @@ declare class StormcloudVideoPlayer {
148
148
  shouldShowNativeControls(): boolean;
149
149
  private shouldContinueLiveStreamDuringAds;
150
150
  private handleAdStart;
151
+ private playAdPod;
151
152
  private findCurrentOrNextBreak;
152
153
  private onTimeUpdate;
153
154
  private handleMidAdJoin;
package/lib/index.js CHANGED
@@ -437,9 +437,13 @@ function createImaController(video, options) {
437
437
  adsLoader.addEventListener(
438
438
  google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
439
439
  (evt) => {
440
- console.log("[IMA] Ads manager loaded");
440
+ console.log(
441
+ "[IMA] Ads manager loaded - enabling preloading for continuous playback"
442
+ );
441
443
  try {
442
- adsManager = evt.getAdsManager(video);
444
+ const adsRenderingSettings = new google.ima.AdsRenderingSettings();
445
+ adsRenderingSettings.enablePreloading = true;
446
+ adsManager = evt.getAdsManager(video, adsRenderingSettings);
443
447
  const AdEvent = google.ima.AdEvent.Type;
444
448
  const AdErrorEvent = google.ima.AdErrorEvent.Type;
445
449
  adsManager.addEventListener(
@@ -2172,7 +2176,7 @@ var StormcloudVideoPlayer = class {
2172
2176
  this.video.volume = 0;
2173
2177
  if (this.config.debugAdTiming) {
2174
2178
  console.log(
2175
- `[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - main video stays muted, ad layer stays visible`
2179
+ `[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - IMMEDIATELY starting next ad`
2176
2180
  );
2177
2181
  }
2178
2182
  this.playSingleAd(next).catch(() => {
@@ -2757,25 +2761,21 @@ var StormcloudVideoPlayer = class {
2757
2761
  this.video.currentTime * 1e3
2758
2762
  );
2759
2763
  const tags = this.selectVastTagsForBreak(scheduled);
2760
- let vastTagUrl;
2764
+ let vastTagUrls = [];
2761
2765
  if (this.apiVastTagUrl) {
2762
- vastTagUrl = this.apiVastTagUrl;
2763
- this.adPodQueue = [];
2764
- this.currentAdIndex = 0;
2765
- this.totalAdsInBreak = 1;
2766
+ vastTagUrls = [this.apiVastTagUrl];
2766
2767
  if (this.config.debugAdTiming) {
2767
- console.log("[StormcloudVideoPlayer] Using VAST endpoint:", vastTagUrl);
2768
+ console.log(
2769
+ "[StormcloudVideoPlayer] Using VAST endpoint:",
2770
+ this.apiVastTagUrl
2771
+ );
2768
2772
  }
2769
2773
  } else if (tags && tags.length > 0) {
2770
- vastTagUrl = tags[0];
2771
- const rest = tags.slice(1);
2772
- this.adPodQueue = rest;
2773
- this.currentAdIndex = 0;
2774
- this.totalAdsInBreak = tags.length;
2774
+ vastTagUrls = tags;
2775
2775
  if (this.config.debugAdTiming) {
2776
2776
  console.log(
2777
- "[StormcloudVideoPlayer] Using scheduled VAST tag:",
2778
- vastTagUrl
2777
+ "[StormcloudVideoPlayer] Using scheduled VAST tags (count: " + tags.length + "):",
2778
+ tags
2779
2779
  );
2780
2780
  }
2781
2781
  } else {
@@ -2784,16 +2784,23 @@ var StormcloudVideoPlayer = class {
2784
2784
  }
2785
2785
  return;
2786
2786
  }
2787
- if (vastTagUrl) {
2787
+ if (vastTagUrls.length > 0) {
2788
2788
  this.inAdBreak = true;
2789
2789
  this.showAds = true;
2790
- this.currentAdIndex++;
2790
+ this.currentAdIndex = 0;
2791
+ this.totalAdsInBreak = vastTagUrls.length;
2792
+ this.adPodQueue = [...vastTagUrls];
2793
+ if (this.config.debugAdTiming) {
2794
+ console.log(
2795
+ `[StormcloudVideoPlayer] Starting ad pod with ${vastTagUrls.length} ads - will play continuously`
2796
+ );
2797
+ }
2791
2798
  try {
2792
- await this.playSingleAd(vastTagUrl);
2799
+ await this.playAdPod();
2793
2800
  } catch (error) {
2794
2801
  if (this.config.debugAdTiming) {
2795
2802
  console.error(
2796
- "[StormcloudVideoPlayer] Ad playback failed in handleAdStart:",
2803
+ "[StormcloudVideoPlayer] Ad pod playback failed:",
2797
2804
  error
2798
2805
  );
2799
2806
  }
@@ -2806,6 +2813,22 @@ var StormcloudVideoPlayer = class {
2806
2813
  this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
2807
2814
  }
2808
2815
  }
2816
+ async playAdPod() {
2817
+ if (this.adPodQueue.length === 0) {
2818
+ if (this.config.debugAdTiming) {
2819
+ console.log("[StormcloudVideoPlayer] No ads in pod to play");
2820
+ }
2821
+ return;
2822
+ }
2823
+ const firstAd = this.adPodQueue.shift();
2824
+ this.currentAdIndex++;
2825
+ if (this.config.debugAdTiming) {
2826
+ console.log(
2827
+ `[StormcloudVideoPlayer] Playing ad ${this.currentAdIndex}/${this.totalAdsInBreak}`
2828
+ );
2829
+ }
2830
+ await this.playSingleAd(firstAd);
2831
+ }
2809
2832
  findCurrentOrNextBreak(nowMs) {
2810
2833
  var _a;
2811
2834
  const schedule = [];