stormcloud-video-player 0.3.2 → 0.3.3

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.
@@ -3184,15 +3184,35 @@ var StormcloudVideoPlayer = class {
3184
3184
  this.currentAdIndex = 0;
3185
3185
  this.totalAdsInBreak = vastTagUrls.length;
3186
3186
  this.adPodQueue = [...vastTagUrls];
3187
- this.preloadAllAdsInBackground().catch((error) => {
3187
+ if (this.isAdaptiveMode) {
3188
3188
  if (this.config.debugAdTiming) {
3189
- console.warn(
3190
- "[StormcloudVideoPlayer] Error in background preloading:",
3191
- error
3192
- );
3189
+ console.log("[ADAPTIVE-POD] Waiting for sequential preloading to complete...");
3193
3190
  }
3194
- });
3195
- await this.playAdPod();
3191
+ try {
3192
+ await this.preloadAllAdsInBackground();
3193
+ if (this.config.debugAdTiming) {
3194
+ console.log("[ADAPTIVE-POD] Preloading complete, starting playback");
3195
+ }
3196
+ } catch (error) {
3197
+ if (this.config.debugAdTiming) {
3198
+ console.warn(
3199
+ "[ADAPTIVE-POD] Error in preloading:",
3200
+ error
3201
+ );
3202
+ }
3203
+ }
3204
+ await this.playAdPod();
3205
+ } else {
3206
+ this.preloadAllAdsInBackground().catch((error) => {
3207
+ if (this.config.debugAdTiming) {
3208
+ console.warn(
3209
+ "[StormcloudVideoPlayer] Error in background preloading:",
3210
+ error
3211
+ );
3212
+ }
3213
+ });
3214
+ await this.playAdPod();
3215
+ }
3196
3216
  }
3197
3217
  if (this.expectedAdBreakDurationMs == null && (scheduled == null ? void 0 : scheduled.durationMs) != null) {
3198
3218
  this.expectedAdBreakDurationMs = scheduled.durationMs;
@@ -3205,20 +3225,28 @@ var StormcloudVideoPlayer = class {
3205
3225
  console.log("[DEBUG-POD] \u26A0\uFE0F No ads in pod");
3206
3226
  return;
3207
3227
  }
3208
- const waitTime = this.isAdaptiveMode ? 1500 : 500;
3228
+ const waitTime = this.isAdaptiveMode ? 100 : 500;
3209
3229
  await new Promise((resolve) => setTimeout(resolve, waitTime));
3230
+ if (this.config.debugAdTiming) {
3231
+ console.log(
3232
+ `[DEBUG-POD] \u{1F50D} Looking for preloaded ad in queue of ${this.adPodQueue.length} URLs`
3233
+ );
3234
+ }
3210
3235
  const firstPreloaded = this.findNextPreloadedAd();
3211
3236
  if (!firstPreloaded) {
3212
- console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads after wait, trying first ad");
3237
+ console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads found, trying first ad from queue");
3213
3238
  const firstAd = this.adPodQueue.shift();
3214
3239
  if (firstAd) {
3215
3240
  this.currentAdIndex++;
3241
+ console.log(`[DEBUG-POD] \u{1F3AC} Attempting to play first ad (not preloaded): ${firstAd.substring(0, 60)}...`);
3216
3242
  try {
3217
3243
  await this.playSingleAd(firstAd);
3218
3244
  } catch (error) {
3219
3245
  console.log("[DEBUG-POD] \u26A0\uFE0F First ad failed, error handler will retry");
3220
3246
  return;
3221
3247
  }
3248
+ } else {
3249
+ console.log("[DEBUG-POD] \u274C No ads available in queue");
3222
3250
  }
3223
3251
  return;
3224
3252
  }
@@ -3893,17 +3921,26 @@ var StormcloudVideoPlayer = class {
3893
3921
  }
3894
3922
  findNextPreloadedAd() {
3895
3923
  var _a, _b, _c;
3924
+ if (this.config.debugAdTiming) {
3925
+ console.log(
3926
+ `[DEBUG-POD] \u{1F50E} Searching for preloaded ad in queue (${this.adPodQueue.length} URLs, ${this.preloadedMediaUrls.size} media preloaded, ${this.vastToMediaUrlMap.size} VAST mappings)`
3927
+ );
3928
+ }
3896
3929
  for (let i = 0; i < this.adPodQueue.length; i++) {
3897
3930
  const vastTagUrl = this.adPodQueue[i];
3898
3931
  if (!vastTagUrl) continue;
3899
3932
  const hasImaPreload = (_c = (_b = (_a = this.ima).hasPreloadedAd) == null ? void 0 : _b.call(_a, vastTagUrl)) != null ? _c : false;
3900
3933
  const mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
3901
3934
  const hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
3935
+ if (this.config.debugAdTiming) {
3936
+ console.log(
3937
+ `[DEBUG-POD] Ad ${i}: IMA=${hasImaPreload}, Media=${hasMediaPreload}, MediaURLs=${(mediaUrls == null ? void 0 : mediaUrls.length) || 0}, URL=${vastTagUrl.substring(0, 60)}...`
3938
+ );
3939
+ }
3902
3940
  if (hasImaPreload || hasMediaPreload) {
3903
3941
  if (this.config.debugAdTiming) {
3904
3942
  console.log(
3905
- `[StormcloudVideoPlayer] Found preloaded ad at index ${i}: ${vastTagUrl}`,
3906
- { hasImaPreload, hasMediaPreload }
3943
+ `[DEBUG-POD] \u2705 Found preloaded ad at index ${i}`
3907
3944
  );
3908
3945
  }
3909
3946
  this.adPodQueue.splice(0, i + 1);
@@ -3912,7 +3949,7 @@ var StormcloudVideoPlayer = class {
3912
3949
  }
3913
3950
  if (this.config.debugAdTiming) {
3914
3951
  console.log(
3915
- "[StormcloudVideoPlayer] No preloaded ads found in queue"
3952
+ `[DEBUG-POD] \u274C No preloaded ads found in queue`
3916
3953
  );
3917
3954
  }
3918
3955
  return void 0;