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.
package/lib/index.cjs CHANGED
@@ -506,9 +506,13 @@ function createImaController(video, options) {
506
506
  adsLoader.addEventListener(
507
507
  google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
508
508
  (evt) => {
509
- console.log("[IMA] Ads manager loaded");
509
+ console.log(
510
+ "[IMA] Ads manager loaded - enabling preloading for continuous playback"
511
+ );
510
512
  try {
511
- adsManager = evt.getAdsManager(video);
513
+ const adsRenderingSettings = new google.ima.AdsRenderingSettings();
514
+ adsRenderingSettings.enablePreloading = true;
515
+ adsManager = evt.getAdsManager(video, adsRenderingSettings);
512
516
  const AdEvent = google.ima.AdEvent.Type;
513
517
  const AdErrorEvent = google.ima.AdErrorEvent.Type;
514
518
  adsManager.addEventListener(
@@ -605,6 +609,18 @@ function createImaController(video, options) {
605
609
  adPlaying = false;
606
610
  setAdPlayingFlag(false);
607
611
  emit("content_resume");
612
+ setTimeout(() => {
613
+ const stillInPod = video.dataset.stormcloudAdPlaying === "true";
614
+ if (stillInPod) {
615
+ console.log(
616
+ "[IMA] Still in ad pod - keeping ad container visible (black screen)"
617
+ );
618
+ if (adContainerEl) {
619
+ adContainerEl.style.display = "flex";
620
+ adContainerEl.style.pointerEvents = "auto";
621
+ }
622
+ }
623
+ }, 50);
608
624
  }
609
625
  );
610
626
  adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
@@ -1154,6 +1170,18 @@ function createHlsAdPlayer(contentVideo, options) {
1154
1170
  adPlaying = false;
1155
1171
  setAdPlayingFlag(false);
1156
1172
  emit("content_resume");
1173
+ setTimeout(() => {
1174
+ const stillInPod = contentVideo.dataset.stormcloudAdPlaying === "true";
1175
+ if (stillInPod) {
1176
+ console.log(
1177
+ "[HlsAdPlayer] Still in ad pod - keeping ad container visible (black screen)"
1178
+ );
1179
+ if (adContainerEl) {
1180
+ adContainerEl.style.display = "flex";
1181
+ adContainerEl.style.pointerEvents = "auto";
1182
+ }
1183
+ }
1184
+ }, 50);
1157
1185
  }
1158
1186
  function handleAdError() {
1159
1187
  console.log("[HlsAdPlayer] Handling ad error");
@@ -2212,9 +2240,12 @@ var StormcloudVideoPlayer = class {
2212
2240
  if (remaining > 500 && this.adPodQueue.length > 0) {
2213
2241
  const next = this.adPodQueue.shift();
2214
2242
  this.currentAdIndex++;
2243
+ this.video.dataset.stormcloudAdPlaying = "true";
2244
+ this.video.muted = true;
2245
+ this.video.volume = 0;
2215
2246
  if (this.config.debugAdTiming) {
2216
2247
  console.log(
2217
- `[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - main video stays muted, ad layer stays visible`
2248
+ `[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - IMMEDIATELY starting next ad`
2218
2249
  );
2219
2250
  }
2220
2251
  this.playSingleAd(next).catch(() => {
@@ -2799,25 +2830,21 @@ var StormcloudVideoPlayer = class {
2799
2830
  this.video.currentTime * 1e3
2800
2831
  );
2801
2832
  const tags = this.selectVastTagsForBreak(scheduled);
2802
- let vastTagUrl;
2833
+ let vastTagUrls = [];
2803
2834
  if (this.apiVastTagUrl) {
2804
- vastTagUrl = this.apiVastTagUrl;
2805
- this.adPodQueue = [];
2806
- this.currentAdIndex = 0;
2807
- this.totalAdsInBreak = 1;
2835
+ vastTagUrls = [this.apiVastTagUrl];
2808
2836
  if (this.config.debugAdTiming) {
2809
- console.log("[StormcloudVideoPlayer] Using VAST endpoint:", vastTagUrl);
2837
+ console.log(
2838
+ "[StormcloudVideoPlayer] Using VAST endpoint:",
2839
+ this.apiVastTagUrl
2840
+ );
2810
2841
  }
2811
2842
  } else if (tags && tags.length > 0) {
2812
- vastTagUrl = tags[0];
2813
- const rest = tags.slice(1);
2814
- this.adPodQueue = rest;
2815
- this.currentAdIndex = 0;
2816
- this.totalAdsInBreak = tags.length;
2843
+ vastTagUrls = tags;
2817
2844
  if (this.config.debugAdTiming) {
2818
2845
  console.log(
2819
- "[StormcloudVideoPlayer] Using scheduled VAST tag:",
2820
- vastTagUrl
2846
+ "[StormcloudVideoPlayer] Using scheduled VAST tags (count: " + tags.length + "):",
2847
+ tags
2821
2848
  );
2822
2849
  }
2823
2850
  } else {
@@ -2826,16 +2853,23 @@ var StormcloudVideoPlayer = class {
2826
2853
  }
2827
2854
  return;
2828
2855
  }
2829
- if (vastTagUrl) {
2856
+ if (vastTagUrls.length > 0) {
2830
2857
  this.inAdBreak = true;
2831
2858
  this.showAds = true;
2832
- this.currentAdIndex++;
2859
+ this.currentAdIndex = 0;
2860
+ this.totalAdsInBreak = vastTagUrls.length;
2861
+ this.adPodQueue = [...vastTagUrls];
2862
+ if (this.config.debugAdTiming) {
2863
+ console.log(
2864
+ `[StormcloudVideoPlayer] Starting ad pod with ${vastTagUrls.length} ads - will play continuously`
2865
+ );
2866
+ }
2833
2867
  try {
2834
- await this.playSingleAd(vastTagUrl);
2868
+ await this.playAdPod();
2835
2869
  } catch (error) {
2836
2870
  if (this.config.debugAdTiming) {
2837
2871
  console.error(
2838
- "[StormcloudVideoPlayer] Ad playback failed in handleAdStart:",
2872
+ "[StormcloudVideoPlayer] Ad pod playback failed:",
2839
2873
  error
2840
2874
  );
2841
2875
  }
@@ -2848,6 +2882,22 @@ var StormcloudVideoPlayer = class {
2848
2882
  this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
2849
2883
  }
2850
2884
  }
2885
+ async playAdPod() {
2886
+ if (this.adPodQueue.length === 0) {
2887
+ if (this.config.debugAdTiming) {
2888
+ console.log("[StormcloudVideoPlayer] No ads in pod to play");
2889
+ }
2890
+ return;
2891
+ }
2892
+ const firstAd = this.adPodQueue.shift();
2893
+ this.currentAdIndex++;
2894
+ if (this.config.debugAdTiming) {
2895
+ console.log(
2896
+ `[StormcloudVideoPlayer] Playing ad ${this.currentAdIndex}/${this.totalAdsInBreak}`
2897
+ );
2898
+ }
2899
+ await this.playSingleAd(firstAd);
2900
+ }
2851
2901
  findCurrentOrNextBreak(nowMs) {
2852
2902
  var _a;
2853
2903
  const schedule = [];