stormcloud-video-player 0.3.7 → 0.3.8

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.
@@ -2091,6 +2091,7 @@ var StormcloudVideoPlayer = class {
2091
2091
  this.fetchedAdDurations = /* @__PURE__ */ new Map();
2092
2092
  this.targetAdBreakDurationMs = null;
2093
2093
  this.isAdaptiveMode = false;
2094
+ this.failedVastUrls = /* @__PURE__ */ new Set();
2094
2095
  initializePolyfills();
2095
2096
  const browserOverrides = getBrowserConfigOverrides();
2096
2097
  this.config = { ...config, ...browserOverrides };
@@ -3070,6 +3071,7 @@ var StormcloudVideoPlayer = class {
3070
3071
  this.vastToMediaUrlMap.clear();
3071
3072
  this.preloadedMediaUrls.clear();
3072
3073
  this.preloadingMediaUrls.clear();
3074
+ this.failedVastUrls.clear();
3073
3075
  const currentMuted = this.video.muted;
3074
3076
  const currentVolume = this.video.volume;
3075
3077
  this.ima.updateOriginalMutedState(currentMuted, currentVolume);
@@ -3270,6 +3272,11 @@ var StormcloudVideoPlayer = class {
3270
3272
  if (this.ima.isAdPlaying()) {
3271
3273
  return;
3272
3274
  }
3275
+ if (this.failedVastUrls.has(vastTagUrl)) {
3276
+ console.warn("[AD-ERROR] Skipping already-failed VAST URL:", vastTagUrl.substring(0, 60));
3277
+ this.handleAdFailure();
3278
+ return;
3279
+ }
3273
3280
  const requestToken = ++this.adRequestTokenCounter;
3274
3281
  this.activeAdRequestToken = requestToken;
3275
3282
  this.startAdRequestWatchdog(requestToken);
@@ -3284,6 +3291,7 @@ var StormcloudVideoPlayer = class {
3284
3291
  await this.ima.play();
3285
3292
  } catch (playError) {
3286
3293
  console.error("[AD-ERROR] Failed to play ad:", playError);
3294
+ this.failedVastUrls.add(vastTagUrl);
3287
3295
  this.clearAdFailsafeTimer();
3288
3296
  if (this.activeAdRequestToken === requestToken) {
3289
3297
  this.activeAdRequestToken = null;
@@ -3293,6 +3301,7 @@ var StormcloudVideoPlayer = class {
3293
3301
  }
3294
3302
  } catch (error) {
3295
3303
  console.error("[AD-ERROR] Ad request failed:", error == null ? void 0 : error.message);
3304
+ this.failedVastUrls.add(vastTagUrl);
3296
3305
  this.clearAdRequestWatchdog();
3297
3306
  this.clearAdFailsafeTimer();
3298
3307
  if (this.activeAdRequestToken === requestToken) {
@@ -3337,7 +3346,8 @@ var StormcloudVideoPlayer = class {
3337
3346
  }
3338
3347
  handleAdFailure() {
3339
3348
  const remaining = this.getRemainingAdMs();
3340
- if (remaining > 500 && this.adPodQueue.length > 0) {
3349
+ const availableAds = this.adPodQueue.filter((url) => !this.failedVastUrls.has(url)).length;
3350
+ if (remaining > 500 && availableAds > 0) {
3341
3351
  if (this.isAdaptiveMode && this.currentAdIndex <= 1) {
3342
3352
  console.log("[ADAPTIVE-POD] \u23F3 First ad failed, waiting for sequential preload to catch up...");
3343
3353
  setTimeout(() => {
@@ -3354,6 +3364,7 @@ var StormcloudVideoPlayer = class {
3354
3364
  return;
3355
3365
  }
3356
3366
  }
3367
+ console.error("[AD-ERROR] All ads failed or time expired. Failed URLs:", this.failedVastUrls.size);
3357
3368
  this.handleAdPodComplete();
3358
3369
  }
3359
3370
  tryNextAdWithRetry(retryCount) {
@@ -3809,6 +3820,10 @@ var StormcloudVideoPlayer = class {
3809
3820
  for (let i = 0; i < this.adPodQueue.length; i++) {
3810
3821
  const vastTagUrl = this.adPodQueue[i];
3811
3822
  if (!vastTagUrl) continue;
3823
+ if (this.failedVastUrls.has(vastTagUrl)) {
3824
+ console.warn("[AD-ERROR] Skipping failed URL in queue");
3825
+ continue;
3826
+ }
3812
3827
  const hasImaPreload = (_c = (_b = (_a = this.ima).hasPreloadedAd) == null ? void 0 : _b.call(_a, vastTagUrl)) != null ? _c : false;
3813
3828
  const mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
3814
3829
  const hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;