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