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
package/lib/players/index.cjs
CHANGED
|
@@ -2474,10 +2474,12 @@ var StormcloudVideoPlayer = class {
|
|
|
2474
2474
|
this.handleAdPodComplete();
|
|
2475
2475
|
}
|
|
2476
2476
|
});
|
|
2477
|
-
this.ima.on("ad_error", () => {
|
|
2477
|
+
this.ima.on("ad_error", (errorPayload) => {
|
|
2478
2478
|
const remaining = this.getRemainingAdMs();
|
|
2479
|
-
console.
|
|
2480
|
-
`[DEBUG-POD] \u274C ad_error event | inBreak=${this.inAdBreak}, queue=${this.adPodQueue.length}, remaining=${remaining}ms
|
|
2479
|
+
console.error(
|
|
2480
|
+
`[DEBUG-POD] \u274C ad_error event | inBreak=${this.inAdBreak}, queue=${this.adPodQueue.length}, remaining=${remaining}ms`,
|
|
2481
|
+
errorPayload ? `
|
|
2482
|
+
Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
2481
2483
|
);
|
|
2482
2484
|
if (this.inAdBreak) {
|
|
2483
2485
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
@@ -2504,7 +2506,7 @@ var StormcloudVideoPlayer = class {
|
|
|
2504
2506
|
}
|
|
2505
2507
|
});
|
|
2506
2508
|
this.ima.on("content_pause", () => {
|
|
2507
|
-
console.log(`[DEBUG-POD] \u{1F3AF} content_pause | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}`);
|
|
2509
|
+
console.log(`[DEBUG-POD] \u{1F3AF} content_pause (AD STARTING!) | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}`);
|
|
2508
2510
|
this.clearAdFailsafeTimer();
|
|
2509
2511
|
this.clearAdRequestWatchdog();
|
|
2510
2512
|
this.activeAdRequestToken = null;
|
|
@@ -3226,15 +3228,35 @@ var StormcloudVideoPlayer = class {
|
|
|
3226
3228
|
this.currentAdIndex = 0;
|
|
3227
3229
|
this.totalAdsInBreak = vastTagUrls.length;
|
|
3228
3230
|
this.adPodQueue = [...vastTagUrls];
|
|
3229
|
-
this.
|
|
3231
|
+
if (this.isAdaptiveMode) {
|
|
3230
3232
|
if (this.config.debugAdTiming) {
|
|
3231
|
-
console.
|
|
3232
|
-
"[StormcloudVideoPlayer] Error in background preloading:",
|
|
3233
|
-
error
|
|
3234
|
-
);
|
|
3233
|
+
console.log("[ADAPTIVE-POD] Waiting for sequential preloading to complete...");
|
|
3235
3234
|
}
|
|
3236
|
-
|
|
3237
|
-
|
|
3235
|
+
try {
|
|
3236
|
+
await this.preloadAllAdsInBackground();
|
|
3237
|
+
if (this.config.debugAdTiming) {
|
|
3238
|
+
console.log("[ADAPTIVE-POD] Preloading complete, starting playback");
|
|
3239
|
+
}
|
|
3240
|
+
} catch (error) {
|
|
3241
|
+
if (this.config.debugAdTiming) {
|
|
3242
|
+
console.warn(
|
|
3243
|
+
"[ADAPTIVE-POD] Error in preloading:",
|
|
3244
|
+
error
|
|
3245
|
+
);
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
await this.playAdPod();
|
|
3249
|
+
} else {
|
|
3250
|
+
this.preloadAllAdsInBackground().catch((error) => {
|
|
3251
|
+
if (this.config.debugAdTiming) {
|
|
3252
|
+
console.warn(
|
|
3253
|
+
"[StormcloudVideoPlayer] Error in background preloading:",
|
|
3254
|
+
error
|
|
3255
|
+
);
|
|
3256
|
+
}
|
|
3257
|
+
});
|
|
3258
|
+
await this.playAdPod();
|
|
3259
|
+
}
|
|
3238
3260
|
}
|
|
3239
3261
|
if (this.expectedAdBreakDurationMs == null && (scheduled == null ? void 0 : scheduled.durationMs) != null) {
|
|
3240
3262
|
this.expectedAdBreakDurationMs = scheduled.durationMs;
|
|
@@ -3247,20 +3269,28 @@ var StormcloudVideoPlayer = class {
|
|
|
3247
3269
|
console.log("[DEBUG-POD] \u26A0\uFE0F No ads in pod");
|
|
3248
3270
|
return;
|
|
3249
3271
|
}
|
|
3250
|
-
const waitTime = this.isAdaptiveMode ?
|
|
3272
|
+
const waitTime = this.isAdaptiveMode ? 100 : 500;
|
|
3251
3273
|
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
3274
|
+
if (this.config.debugAdTiming) {
|
|
3275
|
+
console.log(
|
|
3276
|
+
`[DEBUG-POD] \u{1F50D} Looking for preloaded ad in queue of ${this.adPodQueue.length} URLs`
|
|
3277
|
+
);
|
|
3278
|
+
}
|
|
3252
3279
|
const firstPreloaded = this.findNextPreloadedAd();
|
|
3253
3280
|
if (!firstPreloaded) {
|
|
3254
|
-
console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads
|
|
3281
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads found, trying first ad from queue");
|
|
3255
3282
|
const firstAd = this.adPodQueue.shift();
|
|
3256
3283
|
if (firstAd) {
|
|
3257
3284
|
this.currentAdIndex++;
|
|
3285
|
+
console.log(`[DEBUG-POD] \u{1F3AC} Attempting to play first ad (not preloaded): ${firstAd.substring(0, 60)}...`);
|
|
3258
3286
|
try {
|
|
3259
3287
|
await this.playSingleAd(firstAd);
|
|
3260
3288
|
} catch (error) {
|
|
3261
3289
|
console.log("[DEBUG-POD] \u26A0\uFE0F First ad failed, error handler will retry");
|
|
3262
3290
|
return;
|
|
3263
3291
|
}
|
|
3292
|
+
} else {
|
|
3293
|
+
console.log("[DEBUG-POD] \u274C No ads available in queue");
|
|
3264
3294
|
}
|
|
3265
3295
|
return;
|
|
3266
3296
|
}
|
|
@@ -3401,22 +3431,31 @@ var StormcloudVideoPlayer = class {
|
|
|
3401
3431
|
console.log(`[DEBUG-POD] \u{1F4DD} Request token=${requestToken}, preloaded=${wasPreloaded}`);
|
|
3402
3432
|
this.startAdRequestWatchdog(requestToken);
|
|
3403
3433
|
try {
|
|
3434
|
+
console.log(`[DEBUG-POD] \u{1F4E1} Calling ima.requestAds() for token=${requestToken}...`);
|
|
3404
3435
|
await this.ima.requestAds(vastTagUrl);
|
|
3436
|
+
console.log(`[DEBUG-POD] \u2705 ima.requestAds() completed successfully`);
|
|
3405
3437
|
this.clearAdRequestWatchdog();
|
|
3406
3438
|
if (this.activeAdRequestToken !== requestToken) {
|
|
3407
3439
|
console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after requestAds (stale request)`);
|
|
3408
3440
|
return;
|
|
3409
3441
|
}
|
|
3442
|
+
console.log(`[DEBUG-POD] \u{1F4FA} Calling ima.play() to start ad playback...`);
|
|
3443
|
+
console.log(`[DEBUG-POD] \u{1F4CA} Video element state: paused=${this.video.paused}, muted=${this.video.muted}, readyState=${this.video.readyState}`);
|
|
3410
3444
|
try {
|
|
3411
3445
|
this.startAdFailsafeTimer(requestToken);
|
|
3412
3446
|
await this.ima.play();
|
|
3413
3447
|
if (this.activeAdRequestToken === requestToken) {
|
|
3414
|
-
console.log(`[DEBUG-POD] \u2705 Ad play initiated (token=${requestToken})`);
|
|
3448
|
+
console.log(`[DEBUG-POD] \u2705 Ad play initiated successfully (token=${requestToken})`);
|
|
3415
3449
|
} else {
|
|
3416
3450
|
console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after play (stale request)`);
|
|
3417
3451
|
}
|
|
3418
3452
|
} catch (playError) {
|
|
3419
|
-
console.
|
|
3453
|
+
console.error(
|
|
3454
|
+
"[DEBUG-POD] \u274C Failed to play ad:",
|
|
3455
|
+
playError instanceof Error ? playError.message : playError,
|
|
3456
|
+
"\nFull error:",
|
|
3457
|
+
playError
|
|
3458
|
+
);
|
|
3420
3459
|
this.clearAdFailsafeTimer();
|
|
3421
3460
|
if (this.activeAdRequestToken === requestToken) {
|
|
3422
3461
|
this.activeAdRequestToken = null;
|
|
@@ -3935,17 +3974,26 @@ var StormcloudVideoPlayer = class {
|
|
|
3935
3974
|
}
|
|
3936
3975
|
findNextPreloadedAd() {
|
|
3937
3976
|
var _a, _b, _c;
|
|
3977
|
+
if (this.config.debugAdTiming) {
|
|
3978
|
+
console.log(
|
|
3979
|
+
`[DEBUG-POD] \u{1F50E} Searching for preloaded ad in queue (${this.adPodQueue.length} URLs, ${this.preloadedMediaUrls.size} media preloaded, ${this.vastToMediaUrlMap.size} VAST mappings)`
|
|
3980
|
+
);
|
|
3981
|
+
}
|
|
3938
3982
|
for (let i = 0; i < this.adPodQueue.length; i++) {
|
|
3939
3983
|
const vastTagUrl = this.adPodQueue[i];
|
|
3940
3984
|
if (!vastTagUrl) continue;
|
|
3941
3985
|
const hasImaPreload = (_c = (_b = (_a = this.ima).hasPreloadedAd) == null ? void 0 : _b.call(_a, vastTagUrl)) != null ? _c : false;
|
|
3942
3986
|
const mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
3943
3987
|
const hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
|
|
3988
|
+
if (this.config.debugAdTiming) {
|
|
3989
|
+
console.log(
|
|
3990
|
+
`[DEBUG-POD] Ad ${i}: IMA=${hasImaPreload}, Media=${hasMediaPreload}, MediaURLs=${(mediaUrls == null ? void 0 : mediaUrls.length) || 0}, URL=${vastTagUrl.substring(0, 60)}...`
|
|
3991
|
+
);
|
|
3992
|
+
}
|
|
3944
3993
|
if (hasImaPreload || hasMediaPreload) {
|
|
3945
3994
|
if (this.config.debugAdTiming) {
|
|
3946
3995
|
console.log(
|
|
3947
|
-
`[
|
|
3948
|
-
{ hasImaPreload, hasMediaPreload }
|
|
3996
|
+
`[DEBUG-POD] \u2705 Found preloaded ad at index ${i}`
|
|
3949
3997
|
);
|
|
3950
3998
|
}
|
|
3951
3999
|
this.adPodQueue.splice(0, i + 1);
|
|
@@ -3954,7 +4002,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3954
4002
|
}
|
|
3955
4003
|
if (this.config.debugAdTiming) {
|
|
3956
4004
|
console.log(
|
|
3957
|
-
|
|
4005
|
+
`[DEBUG-POD] \u274C No preloaded ads found in queue`
|
|
3958
4006
|
);
|
|
3959
4007
|
}
|
|
3960
4008
|
return void 0;
|