stormcloud-video-player 0.3.2 → 0.3.4
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 +1 -1
- package/lib/index.cjs +66 -18
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +66 -18
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +66 -18
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +66 -18
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +66 -18
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +66 -18
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -2435,10 +2435,12 @@ var StormcloudVideoPlayer = class {
|
|
|
2435
2435
|
this.handleAdPodComplete();
|
|
2436
2436
|
}
|
|
2437
2437
|
});
|
|
2438
|
-
this.ima.on("ad_error", () => {
|
|
2438
|
+
this.ima.on("ad_error", (errorPayload) => {
|
|
2439
2439
|
const remaining = this.getRemainingAdMs();
|
|
2440
|
-
console.
|
|
2441
|
-
`[DEBUG-POD] \u274C ad_error event | inBreak=${this.inAdBreak}, queue=${this.adPodQueue.length}, remaining=${remaining}ms
|
|
2440
|
+
console.error(
|
|
2441
|
+
`[DEBUG-POD] \u274C ad_error event | inBreak=${this.inAdBreak}, queue=${this.adPodQueue.length}, remaining=${remaining}ms`,
|
|
2442
|
+
errorPayload ? `
|
|
2443
|
+
Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
2442
2444
|
);
|
|
2443
2445
|
if (this.inAdBreak) {
|
|
2444
2446
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
@@ -2465,7 +2467,7 @@ var StormcloudVideoPlayer = class {
|
|
|
2465
2467
|
}
|
|
2466
2468
|
});
|
|
2467
2469
|
this.ima.on("content_pause", () => {
|
|
2468
|
-
console.log(`[DEBUG-POD] \u{1F3AF} content_pause | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}`);
|
|
2470
|
+
console.log(`[DEBUG-POD] \u{1F3AF} content_pause (AD STARTING!) | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}`);
|
|
2469
2471
|
this.clearAdFailsafeTimer();
|
|
2470
2472
|
this.clearAdRequestWatchdog();
|
|
2471
2473
|
this.activeAdRequestToken = null;
|
|
@@ -3187,15 +3189,35 @@ var StormcloudVideoPlayer = class {
|
|
|
3187
3189
|
this.currentAdIndex = 0;
|
|
3188
3190
|
this.totalAdsInBreak = vastTagUrls.length;
|
|
3189
3191
|
this.adPodQueue = [...vastTagUrls];
|
|
3190
|
-
this.
|
|
3192
|
+
if (this.isAdaptiveMode) {
|
|
3191
3193
|
if (this.config.debugAdTiming) {
|
|
3192
|
-
console.
|
|
3193
|
-
"[StormcloudVideoPlayer] Error in background preloading:",
|
|
3194
|
-
error
|
|
3195
|
-
);
|
|
3194
|
+
console.log("[ADAPTIVE-POD] Waiting for sequential preloading to complete...");
|
|
3196
3195
|
}
|
|
3197
|
-
|
|
3198
|
-
|
|
3196
|
+
try {
|
|
3197
|
+
await this.preloadAllAdsInBackground();
|
|
3198
|
+
if (this.config.debugAdTiming) {
|
|
3199
|
+
console.log("[ADAPTIVE-POD] Preloading complete, starting playback");
|
|
3200
|
+
}
|
|
3201
|
+
} catch (error) {
|
|
3202
|
+
if (this.config.debugAdTiming) {
|
|
3203
|
+
console.warn(
|
|
3204
|
+
"[ADAPTIVE-POD] Error in preloading:",
|
|
3205
|
+
error
|
|
3206
|
+
);
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
await this.playAdPod();
|
|
3210
|
+
} else {
|
|
3211
|
+
this.preloadAllAdsInBackground().catch((error) => {
|
|
3212
|
+
if (this.config.debugAdTiming) {
|
|
3213
|
+
console.warn(
|
|
3214
|
+
"[StormcloudVideoPlayer] Error in background preloading:",
|
|
3215
|
+
error
|
|
3216
|
+
);
|
|
3217
|
+
}
|
|
3218
|
+
});
|
|
3219
|
+
await this.playAdPod();
|
|
3220
|
+
}
|
|
3199
3221
|
}
|
|
3200
3222
|
if (this.expectedAdBreakDurationMs == null && (scheduled == null ? void 0 : scheduled.durationMs) != null) {
|
|
3201
3223
|
this.expectedAdBreakDurationMs = scheduled.durationMs;
|
|
@@ -3208,20 +3230,28 @@ var StormcloudVideoPlayer = class {
|
|
|
3208
3230
|
console.log("[DEBUG-POD] \u26A0\uFE0F No ads in pod");
|
|
3209
3231
|
return;
|
|
3210
3232
|
}
|
|
3211
|
-
const waitTime = this.isAdaptiveMode ?
|
|
3233
|
+
const waitTime = this.isAdaptiveMode ? 100 : 500;
|
|
3212
3234
|
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
3235
|
+
if (this.config.debugAdTiming) {
|
|
3236
|
+
console.log(
|
|
3237
|
+
`[DEBUG-POD] \u{1F50D} Looking for preloaded ad in queue of ${this.adPodQueue.length} URLs`
|
|
3238
|
+
);
|
|
3239
|
+
}
|
|
3213
3240
|
const firstPreloaded = this.findNextPreloadedAd();
|
|
3214
3241
|
if (!firstPreloaded) {
|
|
3215
|
-
console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads
|
|
3242
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads found, trying first ad from queue");
|
|
3216
3243
|
const firstAd = this.adPodQueue.shift();
|
|
3217
3244
|
if (firstAd) {
|
|
3218
3245
|
this.currentAdIndex++;
|
|
3246
|
+
console.log(`[DEBUG-POD] \u{1F3AC} Attempting to play first ad (not preloaded): ${firstAd.substring(0, 60)}...`);
|
|
3219
3247
|
try {
|
|
3220
3248
|
await this.playSingleAd(firstAd);
|
|
3221
3249
|
} catch (error) {
|
|
3222
3250
|
console.log("[DEBUG-POD] \u26A0\uFE0F First ad failed, error handler will retry");
|
|
3223
3251
|
return;
|
|
3224
3252
|
}
|
|
3253
|
+
} else {
|
|
3254
|
+
console.log("[DEBUG-POD] \u274C No ads available in queue");
|
|
3225
3255
|
}
|
|
3226
3256
|
return;
|
|
3227
3257
|
}
|
|
@@ -3362,22 +3392,31 @@ var StormcloudVideoPlayer = class {
|
|
|
3362
3392
|
console.log(`[DEBUG-POD] \u{1F4DD} Request token=${requestToken}, preloaded=${wasPreloaded}`);
|
|
3363
3393
|
this.startAdRequestWatchdog(requestToken);
|
|
3364
3394
|
try {
|
|
3395
|
+
console.log(`[DEBUG-POD] \u{1F4E1} Calling ima.requestAds() for token=${requestToken}...`);
|
|
3365
3396
|
await this.ima.requestAds(vastTagUrl);
|
|
3397
|
+
console.log(`[DEBUG-POD] \u2705 ima.requestAds() completed successfully`);
|
|
3366
3398
|
this.clearAdRequestWatchdog();
|
|
3367
3399
|
if (this.activeAdRequestToken !== requestToken) {
|
|
3368
3400
|
console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after requestAds (stale request)`);
|
|
3369
3401
|
return;
|
|
3370
3402
|
}
|
|
3403
|
+
console.log(`[DEBUG-POD] \u{1F4FA} Calling ima.play() to start ad playback...`);
|
|
3404
|
+
console.log(`[DEBUG-POD] \u{1F4CA} Video element state: paused=${this.video.paused}, muted=${this.video.muted}, readyState=${this.video.readyState}`);
|
|
3371
3405
|
try {
|
|
3372
3406
|
this.startAdFailsafeTimer(requestToken);
|
|
3373
3407
|
await this.ima.play();
|
|
3374
3408
|
if (this.activeAdRequestToken === requestToken) {
|
|
3375
|
-
console.log(`[DEBUG-POD] \u2705 Ad play initiated (token=${requestToken})`);
|
|
3409
|
+
console.log(`[DEBUG-POD] \u2705 Ad play initiated successfully (token=${requestToken})`);
|
|
3376
3410
|
} else {
|
|
3377
3411
|
console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after play (stale request)`);
|
|
3378
3412
|
}
|
|
3379
3413
|
} catch (playError) {
|
|
3380
|
-
console.
|
|
3414
|
+
console.error(
|
|
3415
|
+
"[DEBUG-POD] \u274C Failed to play ad:",
|
|
3416
|
+
playError instanceof Error ? playError.message : playError,
|
|
3417
|
+
"\nFull error:",
|
|
3418
|
+
playError
|
|
3419
|
+
);
|
|
3381
3420
|
this.clearAdFailsafeTimer();
|
|
3382
3421
|
if (this.activeAdRequestToken === requestToken) {
|
|
3383
3422
|
this.activeAdRequestToken = null;
|
|
@@ -3896,17 +3935,26 @@ var StormcloudVideoPlayer = class {
|
|
|
3896
3935
|
}
|
|
3897
3936
|
findNextPreloadedAd() {
|
|
3898
3937
|
var _a, _b, _c;
|
|
3938
|
+
if (this.config.debugAdTiming) {
|
|
3939
|
+
console.log(
|
|
3940
|
+
`[DEBUG-POD] \u{1F50E} Searching for preloaded ad in queue (${this.adPodQueue.length} URLs, ${this.preloadedMediaUrls.size} media preloaded, ${this.vastToMediaUrlMap.size} VAST mappings)`
|
|
3941
|
+
);
|
|
3942
|
+
}
|
|
3899
3943
|
for (let i = 0; i < this.adPodQueue.length; i++) {
|
|
3900
3944
|
const vastTagUrl = this.adPodQueue[i];
|
|
3901
3945
|
if (!vastTagUrl) continue;
|
|
3902
3946
|
const hasImaPreload = (_c = (_b = (_a = this.ima).hasPreloadedAd) == null ? void 0 : _b.call(_a, vastTagUrl)) != null ? _c : false;
|
|
3903
3947
|
const mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
3904
3948
|
const hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
|
|
3949
|
+
if (this.config.debugAdTiming) {
|
|
3950
|
+
console.log(
|
|
3951
|
+
`[DEBUG-POD] Ad ${i}: IMA=${hasImaPreload}, Media=${hasMediaPreload}, MediaURLs=${(mediaUrls == null ? void 0 : mediaUrls.length) || 0}, URL=${vastTagUrl.substring(0, 60)}...`
|
|
3952
|
+
);
|
|
3953
|
+
}
|
|
3905
3954
|
if (hasImaPreload || hasMediaPreload) {
|
|
3906
3955
|
if (this.config.debugAdTiming) {
|
|
3907
3956
|
console.log(
|
|
3908
|
-
`[
|
|
3909
|
-
{ hasImaPreload, hasMediaPreload }
|
|
3957
|
+
`[DEBUG-POD] \u2705 Found preloaded ad at index ${i}`
|
|
3910
3958
|
);
|
|
3911
3959
|
}
|
|
3912
3960
|
this.adPodQueue.splice(0, i + 1);
|
|
@@ -3915,7 +3963,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3915
3963
|
}
|
|
3916
3964
|
if (this.config.debugAdTiming) {
|
|
3917
3965
|
console.log(
|
|
3918
|
-
|
|
3966
|
+
`[DEBUG-POD] \u274C No preloaded ads found in queue`
|
|
3919
3967
|
);
|
|
3920
3968
|
}
|
|
3921
3969
|
return void 0;
|