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.
package/lib/index.d.cts CHANGED
@@ -141,6 +141,7 @@ declare class StormcloudVideoPlayer {
141
141
  private fetchedAdDurations;
142
142
  private targetAdBreakDurationMs;
143
143
  private isAdaptiveMode;
144
+ private failedVastUrls;
144
145
  constructor(config: StormcloudVideoPlayerConfig);
145
146
  private createAdPlayer;
146
147
  load(): Promise<void>;
package/lib/index.d.ts CHANGED
@@ -141,6 +141,7 @@ declare class StormcloudVideoPlayer {
141
141
  private fetchedAdDurations;
142
142
  private targetAdBreakDurationMs;
143
143
  private isAdaptiveMode;
144
+ private failedVastUrls;
144
145
  constructor(config: StormcloudVideoPlayerConfig);
145
146
  private createAdPlayer;
146
147
  load(): Promise<void>;
package/lib/index.js CHANGED
@@ -2086,6 +2086,7 @@ var StormcloudVideoPlayer = class {
2086
2086
  this.fetchedAdDurations = /* @__PURE__ */ new Map();
2087
2087
  this.targetAdBreakDurationMs = null;
2088
2088
  this.isAdaptiveMode = false;
2089
+ this.failedVastUrls = /* @__PURE__ */ new Set();
2089
2090
  initializePolyfills();
2090
2091
  const browserOverrides = getBrowserConfigOverrides();
2091
2092
  this.config = { ...config, ...browserOverrides };
@@ -3065,6 +3066,7 @@ var StormcloudVideoPlayer = class {
3065
3066
  this.vastToMediaUrlMap.clear();
3066
3067
  this.preloadedMediaUrls.clear();
3067
3068
  this.preloadingMediaUrls.clear();
3069
+ this.failedVastUrls.clear();
3068
3070
  const currentMuted = this.video.muted;
3069
3071
  const currentVolume = this.video.volume;
3070
3072
  this.ima.updateOriginalMutedState(currentMuted, currentVolume);
@@ -3265,6 +3267,11 @@ var StormcloudVideoPlayer = class {
3265
3267
  if (this.ima.isAdPlaying()) {
3266
3268
  return;
3267
3269
  }
3270
+ if (this.failedVastUrls.has(vastTagUrl)) {
3271
+ console.warn("[AD-ERROR] Skipping already-failed VAST URL:", vastTagUrl.substring(0, 60));
3272
+ this.handleAdFailure();
3273
+ return;
3274
+ }
3268
3275
  const requestToken = ++this.adRequestTokenCounter;
3269
3276
  this.activeAdRequestToken = requestToken;
3270
3277
  this.startAdRequestWatchdog(requestToken);
@@ -3279,6 +3286,7 @@ var StormcloudVideoPlayer = class {
3279
3286
  await this.ima.play();
3280
3287
  } catch (playError) {
3281
3288
  console.error("[AD-ERROR] Failed to play ad:", playError);
3289
+ this.failedVastUrls.add(vastTagUrl);
3282
3290
  this.clearAdFailsafeTimer();
3283
3291
  if (this.activeAdRequestToken === requestToken) {
3284
3292
  this.activeAdRequestToken = null;
@@ -3288,6 +3296,7 @@ var StormcloudVideoPlayer = class {
3288
3296
  }
3289
3297
  } catch (error) {
3290
3298
  console.error("[AD-ERROR] Ad request failed:", error == null ? void 0 : error.message);
3299
+ this.failedVastUrls.add(vastTagUrl);
3291
3300
  this.clearAdRequestWatchdog();
3292
3301
  this.clearAdFailsafeTimer();
3293
3302
  if (this.activeAdRequestToken === requestToken) {
@@ -3332,7 +3341,8 @@ var StormcloudVideoPlayer = class {
3332
3341
  }
3333
3342
  handleAdFailure() {
3334
3343
  const remaining = this.getRemainingAdMs();
3335
- if (remaining > 500 && this.adPodQueue.length > 0) {
3344
+ const availableAds = this.adPodQueue.filter((url) => !this.failedVastUrls.has(url)).length;
3345
+ if (remaining > 500 && availableAds > 0) {
3336
3346
  if (this.isAdaptiveMode && this.currentAdIndex <= 1) {
3337
3347
  console.log("[ADAPTIVE-POD] \u23F3 First ad failed, waiting for sequential preload to catch up...");
3338
3348
  setTimeout(() => {
@@ -3349,6 +3359,7 @@ var StormcloudVideoPlayer = class {
3349
3359
  return;
3350
3360
  }
3351
3361
  }
3362
+ console.error("[AD-ERROR] All ads failed or time expired. Failed URLs:", this.failedVastUrls.size);
3352
3363
  this.handleAdPodComplete();
3353
3364
  }
3354
3365
  tryNextAdWithRetry(retryCount) {
@@ -3804,6 +3815,10 @@ var StormcloudVideoPlayer = class {
3804
3815
  for (let i = 0; i < this.adPodQueue.length; i++) {
3805
3816
  const vastTagUrl = this.adPodQueue[i];
3806
3817
  if (!vastTagUrl) continue;
3818
+ if (this.failedVastUrls.has(vastTagUrl)) {
3819
+ console.warn("[AD-ERROR] Skipping failed URL in queue");
3820
+ continue;
3821
+ }
3807
3822
  const hasImaPreload = (_c = (_b = (_a = this.ima).hasPreloadedAd) == null ? void 0 : _b.call(_a, vastTagUrl)) != null ? _c : false;
3808
3823
  const mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
3809
3824
  const hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;