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
|
@@ -40,6 +40,7 @@ declare class StormcloudVideoPlayer {
|
|
|
40
40
|
private fetchedAdDurations;
|
|
41
41
|
private targetAdBreakDurationMs;
|
|
42
42
|
private isAdaptiveMode;
|
|
43
|
+
private failedVastUrls;
|
|
43
44
|
constructor(config: StormcloudVideoPlayerConfig);
|
|
44
45
|
private createAdPlayer;
|
|
45
46
|
load(): Promise<void>;
|
|
@@ -344,12 +344,8 @@ function createImaController(video, options) {
|
|
|
344
344
|
let adsLoadedReject;
|
|
345
345
|
function makeAdsRequest(google, vastTagUrl) {
|
|
346
346
|
const adsRequest = new google.ima.AdsRequest();
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
adsRequest.adsResponse = preloadedResponse;
|
|
350
|
-
} else {
|
|
351
|
-
adsRequest.adTagUrl = vastTagUrl;
|
|
352
|
-
}
|
|
347
|
+
console.log("[IMA] \u{1F4E1} Requesting VAST from URL (letting IMA fetch fresh)");
|
|
348
|
+
adsRequest.adTagUrl = vastTagUrl;
|
|
353
349
|
const videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
354
350
|
const videoHeight = video.offsetHeight || video.clientHeight || 360;
|
|
355
351
|
adsRequest.linearAdSlotWidth = videoWidth;
|
|
@@ -372,11 +368,8 @@ function createImaController(video, options) {
|
|
|
372
368
|
console.warn("[IMA] Failed to call setAdWillPlayMuted:", error);
|
|
373
369
|
}
|
|
374
370
|
}
|
|
375
|
-
adsRequest.vastLoadTimeout =
|
|
371
|
+
adsRequest.vastLoadTimeout = 1e4;
|
|
376
372
|
adsLoader.requestAds(adsRequest);
|
|
377
|
-
if (preloadedResponse) {
|
|
378
|
-
preloadedVast.delete(vastTagUrl);
|
|
379
|
-
}
|
|
380
373
|
}
|
|
381
374
|
function ensurePlaceholderContainer() {
|
|
382
375
|
var _a;
|
|
@@ -2091,6 +2084,7 @@ var StormcloudVideoPlayer = class {
|
|
|
2091
2084
|
this.fetchedAdDurations = /* @__PURE__ */ new Map();
|
|
2092
2085
|
this.targetAdBreakDurationMs = null;
|
|
2093
2086
|
this.isAdaptiveMode = false;
|
|
2087
|
+
this.failedVastUrls = /* @__PURE__ */ new Set();
|
|
2094
2088
|
initializePolyfills();
|
|
2095
2089
|
const browserOverrides = getBrowserConfigOverrides();
|
|
2096
2090
|
this.config = { ...config, ...browserOverrides };
|
|
@@ -3070,6 +3064,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3070
3064
|
this.vastToMediaUrlMap.clear();
|
|
3071
3065
|
this.preloadedMediaUrls.clear();
|
|
3072
3066
|
this.preloadingMediaUrls.clear();
|
|
3067
|
+
this.failedVastUrls.clear();
|
|
3073
3068
|
const currentMuted = this.video.muted;
|
|
3074
3069
|
const currentVolume = this.video.volume;
|
|
3075
3070
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
@@ -3270,6 +3265,11 @@ var StormcloudVideoPlayer = class {
|
|
|
3270
3265
|
if (this.ima.isAdPlaying()) {
|
|
3271
3266
|
return;
|
|
3272
3267
|
}
|
|
3268
|
+
if (this.failedVastUrls.has(vastTagUrl)) {
|
|
3269
|
+
console.warn("[AD-ERROR] Skipping already-failed VAST URL:", vastTagUrl.substring(0, 60));
|
|
3270
|
+
this.handleAdFailure();
|
|
3271
|
+
return;
|
|
3272
|
+
}
|
|
3273
3273
|
const requestToken = ++this.adRequestTokenCounter;
|
|
3274
3274
|
this.activeAdRequestToken = requestToken;
|
|
3275
3275
|
this.startAdRequestWatchdog(requestToken);
|
|
@@ -3284,6 +3284,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3284
3284
|
await this.ima.play();
|
|
3285
3285
|
} catch (playError) {
|
|
3286
3286
|
console.error("[AD-ERROR] Failed to play ad:", playError);
|
|
3287
|
+
this.failedVastUrls.add(vastTagUrl);
|
|
3287
3288
|
this.clearAdFailsafeTimer();
|
|
3288
3289
|
if (this.activeAdRequestToken === requestToken) {
|
|
3289
3290
|
this.activeAdRequestToken = null;
|
|
@@ -3293,6 +3294,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3293
3294
|
}
|
|
3294
3295
|
} catch (error) {
|
|
3295
3296
|
console.error("[AD-ERROR] Ad request failed:", error == null ? void 0 : error.message);
|
|
3297
|
+
this.failedVastUrls.add(vastTagUrl);
|
|
3296
3298
|
this.clearAdRequestWatchdog();
|
|
3297
3299
|
this.clearAdFailsafeTimer();
|
|
3298
3300
|
if (this.activeAdRequestToken === requestToken) {
|
|
@@ -3337,7 +3339,8 @@ var StormcloudVideoPlayer = class {
|
|
|
3337
3339
|
}
|
|
3338
3340
|
handleAdFailure() {
|
|
3339
3341
|
const remaining = this.getRemainingAdMs();
|
|
3340
|
-
|
|
3342
|
+
const availableAds = this.adPodQueue.filter((url) => !this.failedVastUrls.has(url)).length;
|
|
3343
|
+
if (remaining > 500 && availableAds > 0) {
|
|
3341
3344
|
if (this.isAdaptiveMode && this.currentAdIndex <= 1) {
|
|
3342
3345
|
console.log("[ADAPTIVE-POD] \u23F3 First ad failed, waiting for sequential preload to catch up...");
|
|
3343
3346
|
setTimeout(() => {
|
|
@@ -3354,6 +3357,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3354
3357
|
return;
|
|
3355
3358
|
}
|
|
3356
3359
|
}
|
|
3360
|
+
console.error("[AD-ERROR] All ads failed or time expired. Failed URLs:", this.failedVastUrls.size);
|
|
3357
3361
|
this.handleAdPodComplete();
|
|
3358
3362
|
}
|
|
3359
3363
|
tryNextAdWithRetry(retryCount) {
|
|
@@ -3785,6 +3789,12 @@ var StormcloudVideoPlayer = class {
|
|
|
3785
3789
|
);
|
|
3786
3790
|
}
|
|
3787
3791
|
mediaUrls = await this.fetchAndParseVastXml(vastTagUrl);
|
|
3792
|
+
if (this.config.debugAdTiming) {
|
|
3793
|
+
console.log(
|
|
3794
|
+
`[StormcloudVideoPlayer] Extracted ${mediaUrls.length} media URLs:`,
|
|
3795
|
+
mediaUrls
|
|
3796
|
+
);
|
|
3797
|
+
}
|
|
3788
3798
|
if (mediaUrls.length > 0) {
|
|
3789
3799
|
this.vastToMediaUrlMap.set(vastTagUrl, mediaUrls);
|
|
3790
3800
|
}
|
|
@@ -3809,6 +3819,10 @@ var StormcloudVideoPlayer = class {
|
|
|
3809
3819
|
for (let i = 0; i < this.adPodQueue.length; i++) {
|
|
3810
3820
|
const vastTagUrl = this.adPodQueue[i];
|
|
3811
3821
|
if (!vastTagUrl) continue;
|
|
3822
|
+
if (this.failedVastUrls.has(vastTagUrl)) {
|
|
3823
|
+
console.warn("[AD-ERROR] Skipping failed URL in queue");
|
|
3824
|
+
continue;
|
|
3825
|
+
}
|
|
3812
3826
|
const hasImaPreload = (_c = (_b = (_a = this.ima).hasPreloadedAd) == null ? void 0 : _b.call(_a, vastTagUrl)) != null ? _c : false;
|
|
3813
3827
|
const mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
3814
3828
|
const hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
|