stormcloud-video-player 0.3.5 → 0.3.6

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.
@@ -3188,21 +3188,38 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3188
3188
  this.adPodQueue = [...vastTagUrls];
3189
3189
  if (this.isAdaptiveMode) {
3190
3190
  if (this.config.debugAdTiming) {
3191
- console.log("[ADAPTIVE-POD] Waiting for sequential preloading to complete...");
3191
+ console.log("[ADAPTIVE-POD] \u{1F680} Preloading first 2 ads before starting playback...");
3192
3192
  }
3193
3193
  try {
3194
- await this.preloadAllAdsInBackground();
3194
+ const adsToPreloadBeforeStart = Math.min(2, this.adPodAllUrls.length);
3195
+ for (let i = 0; i < adsToPreloadBeforeStart; i++) {
3196
+ const url = this.adPodAllUrls[i];
3197
+ if (url) {
3198
+ await this.preloadSingleAd(url);
3199
+ if (this.config.debugAdTiming) {
3200
+ console.log(`[ADAPTIVE-POD] \u2705 Preloaded ad ${i + 1}/${adsToPreloadBeforeStart}`);
3201
+ }
3202
+ }
3203
+ }
3195
3204
  if (this.config.debugAdTiming) {
3196
- console.log("[ADAPTIVE-POD] Preloading complete, starting playback");
3205
+ console.log("[ADAPTIVE-POD] \u{1F3AC} First ads preloaded, starting playback immediately");
3197
3206
  }
3198
3207
  } catch (error) {
3199
3208
  if (this.config.debugAdTiming) {
3200
3209
  console.warn(
3201
- "[ADAPTIVE-POD] Error in preloading:",
3210
+ "[ADAPTIVE-POD] \u26A0\uFE0F Error preloading initial ads:",
3202
3211
  error
3203
3212
  );
3204
3213
  }
3205
3214
  }
3215
+ this.preloadAllAdsInBackground().catch((error) => {
3216
+ if (this.config.debugAdTiming) {
3217
+ console.warn(
3218
+ "[ADAPTIVE-POD] Error in background preloading:",
3219
+ error
3220
+ );
3221
+ }
3222
+ });
3206
3223
  await this.playAdPod();
3207
3224
  } else {
3208
3225
  this.preloadAllAdsInBackground().catch((error) => {
@@ -3227,7 +3244,7 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3227
3244
  console.log("[DEBUG-POD] \u26A0\uFE0F No ads in pod");
3228
3245
  return;
3229
3246
  }
3230
- const waitTime = this.isAdaptiveMode ? 100 : 500;
3247
+ const waitTime = this.isAdaptiveMode ? 50 : 500;
3231
3248
  await new Promise((resolve) => setTimeout(resolve, waitTime));
3232
3249
  if (this.config.debugAdTiming) {
3233
3250
  console.log(
@@ -3793,16 +3810,27 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3793
3810
  }
3794
3811
  }
3795
3812
  async preloadAllAdsInBackground() {
3813
+ var _a, _b;
3796
3814
  if (this.adPodAllUrls.length === 0) {
3797
3815
  return;
3798
3816
  }
3799
3817
  if (this.isAdaptiveMode) {
3800
3818
  if (this.config.debugAdTiming) {
3801
3819
  console.log(
3802
- `[ADAPTIVE-POD] \u{1F504} Starting sequential preload of ${this.adPodAllUrls.length} initial ads`
3820
+ `[ADAPTIVE-POD] \u{1F504} Starting sequential preload of remaining ads`
3803
3821
  );
3804
3822
  }
3805
3823
  const processedUrls = /* @__PURE__ */ new Set();
3824
+ for (const url of this.adPodAllUrls) {
3825
+ if (((_b = (_a = this.ima).hasPreloadedAd) == null ? void 0 : _b.call(_a, url)) || this.fetchedAdDurations.has(url)) {
3826
+ processedUrls.add(url);
3827
+ }
3828
+ }
3829
+ if (this.config.debugAdTiming && processedUrls.size > 0) {
3830
+ console.log(
3831
+ `[ADAPTIVE-POD] \u{1F4E6} Skipping ${processedUrls.size} already-preloaded ads`
3832
+ );
3833
+ }
3806
3834
  while (true) {
3807
3835
  const nextUrl = this.adPodAllUrls.find((url) => !processedUrls.has(url));
3808
3836
  if (!nextUrl) {