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.
@@ -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(
@@ -2177,7 +2181,7 @@ var StormcloudVideoPlayer = class {
2177
2181
  this.video.volume = 0;
2178
2182
  if (this.config.debugAdTiming) {
2179
2183
  console.log(
2180
- `[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`
2181
2185
  );
2182
2186
  }
2183
2187
  this.playSingleAd(next).catch(() => {
@@ -2762,25 +2766,21 @@ var StormcloudVideoPlayer = class {
2762
2766
  this.video.currentTime * 1e3
2763
2767
  );
2764
2768
  const tags = this.selectVastTagsForBreak(scheduled);
2765
- let vastTagUrl;
2769
+ let vastTagUrls = [];
2766
2770
  if (this.apiVastTagUrl) {
2767
- vastTagUrl = this.apiVastTagUrl;
2768
- this.adPodQueue = [];
2769
- this.currentAdIndex = 0;
2770
- this.totalAdsInBreak = 1;
2771
+ vastTagUrls = [this.apiVastTagUrl];
2771
2772
  if (this.config.debugAdTiming) {
2772
- console.log("[StormcloudVideoPlayer] Using VAST endpoint:", vastTagUrl);
2773
+ console.log(
2774
+ "[StormcloudVideoPlayer] Using VAST endpoint:",
2775
+ this.apiVastTagUrl
2776
+ );
2773
2777
  }
2774
2778
  } else if (tags && tags.length > 0) {
2775
- vastTagUrl = tags[0];
2776
- const rest = tags.slice(1);
2777
- this.adPodQueue = rest;
2778
- this.currentAdIndex = 0;
2779
- this.totalAdsInBreak = tags.length;
2779
+ vastTagUrls = tags;
2780
2780
  if (this.config.debugAdTiming) {
2781
2781
  console.log(
2782
- "[StormcloudVideoPlayer] Using scheduled VAST tag:",
2783
- vastTagUrl
2782
+ "[StormcloudVideoPlayer] Using scheduled VAST tags (count: " + tags.length + "):",
2783
+ tags
2784
2784
  );
2785
2785
  }
2786
2786
  } else {
@@ -2789,16 +2789,23 @@ var StormcloudVideoPlayer = class {
2789
2789
  }
2790
2790
  return;
2791
2791
  }
2792
- if (vastTagUrl) {
2792
+ if (vastTagUrls.length > 0) {
2793
2793
  this.inAdBreak = true;
2794
2794
  this.showAds = true;
2795
- 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
+ }
2796
2803
  try {
2797
- await this.playSingleAd(vastTagUrl);
2804
+ await this.playAdPod();
2798
2805
  } catch (error) {
2799
2806
  if (this.config.debugAdTiming) {
2800
2807
  console.error(
2801
- "[StormcloudVideoPlayer] Ad playback failed in handleAdStart:",
2808
+ "[StormcloudVideoPlayer] Ad pod playback failed:",
2802
2809
  error
2803
2810
  );
2804
2811
  }
@@ -2811,6 +2818,22 @@ var StormcloudVideoPlayer = class {
2811
2818
  this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
2812
2819
  }
2813
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
+ }
2814
2837
  findCurrentOrNextBreak(nowMs) {
2815
2838
  var _a;
2816
2839
  const schedule = [];