stormcloud-video-player 0.3.7 → 0.3.9

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.
@@ -341,12 +341,8 @@ function createImaController(video, options) {
341
341
  let adsLoadedReject;
342
342
  function makeAdsRequest(google, vastTagUrl) {
343
343
  const adsRequest = new google.ima.AdsRequest();
344
- const preloadedResponse = preloadedVast.get(vastTagUrl);
345
- if (preloadedResponse) {
346
- adsRequest.adsResponse = preloadedResponse;
347
- } else {
348
- adsRequest.adTagUrl = vastTagUrl;
349
- }
344
+ console.log("[IMA] \u{1F4E1} Requesting VAST from URL (letting IMA fetch fresh)");
345
+ adsRequest.adTagUrl = vastTagUrl;
350
346
  const videoWidth = video.offsetWidth || video.clientWidth || 640;
351
347
  const videoHeight = video.offsetHeight || video.clientHeight || 360;
352
348
  adsRequest.linearAdSlotWidth = videoWidth;
@@ -369,11 +365,8 @@ function createImaController(video, options) {
369
365
  console.warn("[IMA] Failed to call setAdWillPlayMuted:", error);
370
366
  }
371
367
  }
372
- adsRequest.vastLoadTimeout = 5e3;
368
+ adsRequest.vastLoadTimeout = 1e4;
373
369
  adsLoader.requestAds(adsRequest);
374
- if (preloadedResponse) {
375
- preloadedVast.delete(vastTagUrl);
376
- }
377
370
  }
378
371
  function ensurePlaceholderContainer() {
379
372
  var _a;
@@ -2088,6 +2081,7 @@ var StormcloudVideoPlayer = class {
2088
2081
  this.fetchedAdDurations = /* @__PURE__ */ new Map();
2089
2082
  this.targetAdBreakDurationMs = null;
2090
2083
  this.isAdaptiveMode = false;
2084
+ this.failedVastUrls = /* @__PURE__ */ new Set();
2091
2085
  initializePolyfills();
2092
2086
  const browserOverrides = getBrowserConfigOverrides();
2093
2087
  this.config = { ...config, ...browserOverrides };
@@ -3067,6 +3061,7 @@ var StormcloudVideoPlayer = class {
3067
3061
  this.vastToMediaUrlMap.clear();
3068
3062
  this.preloadedMediaUrls.clear();
3069
3063
  this.preloadingMediaUrls.clear();
3064
+ this.failedVastUrls.clear();
3070
3065
  const currentMuted = this.video.muted;
3071
3066
  const currentVolume = this.video.volume;
3072
3067
  this.ima.updateOriginalMutedState(currentMuted, currentVolume);
@@ -3267,6 +3262,11 @@ var StormcloudVideoPlayer = class {
3267
3262
  if (this.ima.isAdPlaying()) {
3268
3263
  return;
3269
3264
  }
3265
+ if (this.failedVastUrls.has(vastTagUrl)) {
3266
+ console.warn("[AD-ERROR] Skipping already-failed VAST URL:", vastTagUrl.substring(0, 60));
3267
+ this.handleAdFailure();
3268
+ return;
3269
+ }
3270
3270
  const requestToken = ++this.adRequestTokenCounter;
3271
3271
  this.activeAdRequestToken = requestToken;
3272
3272
  this.startAdRequestWatchdog(requestToken);
@@ -3281,6 +3281,7 @@ var StormcloudVideoPlayer = class {
3281
3281
  await this.ima.play();
3282
3282
  } catch (playError) {
3283
3283
  console.error("[AD-ERROR] Failed to play ad:", playError);
3284
+ this.failedVastUrls.add(vastTagUrl);
3284
3285
  this.clearAdFailsafeTimer();
3285
3286
  if (this.activeAdRequestToken === requestToken) {
3286
3287
  this.activeAdRequestToken = null;
@@ -3290,6 +3291,7 @@ var StormcloudVideoPlayer = class {
3290
3291
  }
3291
3292
  } catch (error) {
3292
3293
  console.error("[AD-ERROR] Ad request failed:", error == null ? void 0 : error.message);
3294
+ this.failedVastUrls.add(vastTagUrl);
3293
3295
  this.clearAdRequestWatchdog();
3294
3296
  this.clearAdFailsafeTimer();
3295
3297
  if (this.activeAdRequestToken === requestToken) {
@@ -3334,7 +3336,8 @@ var StormcloudVideoPlayer = class {
3334
3336
  }
3335
3337
  handleAdFailure() {
3336
3338
  const remaining = this.getRemainingAdMs();
3337
- if (remaining > 500 && this.adPodQueue.length > 0) {
3339
+ const availableAds = this.adPodQueue.filter((url) => !this.failedVastUrls.has(url)).length;
3340
+ if (remaining > 500 && availableAds > 0) {
3338
3341
  if (this.isAdaptiveMode && this.currentAdIndex <= 1) {
3339
3342
  console.log("[ADAPTIVE-POD] \u23F3 First ad failed, waiting for sequential preload to catch up...");
3340
3343
  setTimeout(() => {
@@ -3351,6 +3354,7 @@ var StormcloudVideoPlayer = class {
3351
3354
  return;
3352
3355
  }
3353
3356
  }
3357
+ console.error("[AD-ERROR] All ads failed or time expired. Failed URLs:", this.failedVastUrls.size);
3354
3358
  this.handleAdPodComplete();
3355
3359
  }
3356
3360
  tryNextAdWithRetry(retryCount) {
@@ -3782,6 +3786,12 @@ var StormcloudVideoPlayer = class {
3782
3786
  );
3783
3787
  }
3784
3788
  mediaUrls = await this.fetchAndParseVastXml(vastTagUrl);
3789
+ if (this.config.debugAdTiming) {
3790
+ console.log(
3791
+ `[StormcloudVideoPlayer] Extracted ${mediaUrls.length} media URLs:`,
3792
+ mediaUrls
3793
+ );
3794
+ }
3785
3795
  if (mediaUrls.length > 0) {
3786
3796
  this.vastToMediaUrlMap.set(vastTagUrl, mediaUrls);
3787
3797
  }
@@ -3806,6 +3816,10 @@ var StormcloudVideoPlayer = class {
3806
3816
  for (let i = 0; i < this.adPodQueue.length; i++) {
3807
3817
  const vastTagUrl = this.adPodQueue[i];
3808
3818
  if (!vastTagUrl) continue;
3819
+ if (this.failedVastUrls.has(vastTagUrl)) {
3820
+ console.warn("[AD-ERROR] Skipping failed URL in queue");
3821
+ continue;
3822
+ }
3809
3823
  const hasImaPreload = (_c = (_b = (_a = this.ima).hasPreloadedAd) == null ? void 0 : _b.call(_a, vastTagUrl)) != null ? _c : false;
3810
3824
  const mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
3811
3825
  const hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;