stormcloud-video-player 0.3.3 → 0.3.5
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 +25 -11
- package/lib/index.cjs.map +1 -1
- 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/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/ui/StormcloudVideoPlayer.cjs +25 -11
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2430,10 +2430,12 @@ var StormcloudVideoPlayer = class {
|
|
|
2430
2430
|
this.handleAdPodComplete();
|
|
2431
2431
|
}
|
|
2432
2432
|
});
|
|
2433
|
-
this.ima.on("ad_error", () => {
|
|
2433
|
+
this.ima.on("ad_error", (errorPayload) => {
|
|
2434
2434
|
const remaining = this.getRemainingAdMs();
|
|
2435
|
-
console.
|
|
2436
|
-
`[DEBUG-POD] \u274C ad_error event | inBreak=${this.inAdBreak}, queue=${this.adPodQueue.length}, remaining=${remaining}ms
|
|
2435
|
+
console.error(
|
|
2436
|
+
`[DEBUG-POD] \u274C ad_error event | inBreak=${this.inAdBreak}, queue=${this.adPodQueue.length}, remaining=${remaining}ms`,
|
|
2437
|
+
errorPayload ? `
|
|
2438
|
+
Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
2437
2439
|
);
|
|
2438
2440
|
if (this.inAdBreak) {
|
|
2439
2441
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
@@ -2460,7 +2462,7 @@ var StormcloudVideoPlayer = class {
|
|
|
2460
2462
|
}
|
|
2461
2463
|
});
|
|
2462
2464
|
this.ima.on("content_pause", () => {
|
|
2463
|
-
console.log(`[DEBUG-POD] \u{1F3AF} content_pause | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}`);
|
|
2465
|
+
console.log(`[DEBUG-POD] \u{1F3AF} content_pause (AD STARTING!) | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}`);
|
|
2464
2466
|
this.clearAdFailsafeTimer();
|
|
2465
2467
|
this.clearAdRequestWatchdog();
|
|
2466
2468
|
this.activeAdRequestToken = null;
|
|
@@ -3385,22 +3387,31 @@ var StormcloudVideoPlayer = class {
|
|
|
3385
3387
|
console.log(`[DEBUG-POD] \u{1F4DD} Request token=${requestToken}, preloaded=${wasPreloaded}`);
|
|
3386
3388
|
this.startAdRequestWatchdog(requestToken);
|
|
3387
3389
|
try {
|
|
3390
|
+
console.log(`[DEBUG-POD] \u{1F4E1} Calling ima.requestAds() for token=${requestToken}...`);
|
|
3388
3391
|
await this.ima.requestAds(vastTagUrl);
|
|
3392
|
+
console.log(`[DEBUG-POD] \u2705 ima.requestAds() completed successfully`);
|
|
3389
3393
|
this.clearAdRequestWatchdog();
|
|
3390
3394
|
if (this.activeAdRequestToken !== requestToken) {
|
|
3391
3395
|
console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after requestAds (stale request)`);
|
|
3392
3396
|
return;
|
|
3393
3397
|
}
|
|
3398
|
+
console.log(`[DEBUG-POD] \u{1F4FA} Calling ima.play() to start ad playback...`);
|
|
3399
|
+
console.log(`[DEBUG-POD] \u{1F4CA} Video element state: paused=${this.video.paused}, muted=${this.video.muted}, readyState=${this.video.readyState}`);
|
|
3394
3400
|
try {
|
|
3395
3401
|
this.startAdFailsafeTimer(requestToken);
|
|
3396
3402
|
await this.ima.play();
|
|
3397
3403
|
if (this.activeAdRequestToken === requestToken) {
|
|
3398
|
-
console.log(`[DEBUG-POD] \u2705 Ad play initiated (token=${requestToken})`);
|
|
3404
|
+
console.log(`[DEBUG-POD] \u2705 Ad play initiated successfully (token=${requestToken})`);
|
|
3399
3405
|
} else {
|
|
3400
3406
|
console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after play (stale request)`);
|
|
3401
3407
|
}
|
|
3402
3408
|
} catch (playError) {
|
|
3403
|
-
console.
|
|
3409
|
+
console.error(
|
|
3410
|
+
"[DEBUG-POD] \u274C Failed to play ad:",
|
|
3411
|
+
playError instanceof Error ? playError.message : playError,
|
|
3412
|
+
"\nFull error:",
|
|
3413
|
+
playError
|
|
3414
|
+
);
|
|
3404
3415
|
this.clearAdFailsafeTimer();
|
|
3405
3416
|
if (this.activeAdRequestToken === requestToken) {
|
|
3406
3417
|
this.activeAdRequestToken = null;
|
|
@@ -3696,21 +3707,24 @@ var StormcloudVideoPlayer = class {
|
|
|
3696
3707
|
for (const duration of this.fetchedAdDurations.values()) {
|
|
3697
3708
|
totalFetchedDurationMs += duration * 1e3;
|
|
3698
3709
|
}
|
|
3699
|
-
const
|
|
3710
|
+
const fetchedCount = this.fetchedAdDurations.size;
|
|
3711
|
+
const averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
3712
|
+
const queuedButNotFetched = this.adPodAllUrls.length - fetchedCount;
|
|
3713
|
+
const estimatedQueuedDurationMs = queuedButNotFetched * averageDurationMs;
|
|
3714
|
+
const estimatedTotalDurationMs = totalFetchedDurationMs + estimatedQueuedDurationMs;
|
|
3715
|
+
const remainingTimeMs = this.targetAdBreakDurationMs - estimatedTotalDurationMs;
|
|
3700
3716
|
if (remainingTimeMs <= 0) {
|
|
3701
3717
|
if (this.config.debugAdTiming) {
|
|
3702
3718
|
console.log(
|
|
3703
|
-
`[ADAPTIVE-POD] \u2705 Target duration
|
|
3719
|
+
`[ADAPTIVE-POD] \u2705 Target duration met: Fetched=${totalFetchedDurationMs}ms + Queued(${queuedButNotFetched} ads)=${estimatedQueuedDurationMs}ms = ${estimatedTotalDurationMs}ms / Target=${this.targetAdBreakDurationMs}ms`
|
|
3704
3720
|
);
|
|
3705
3721
|
}
|
|
3706
3722
|
return 0;
|
|
3707
3723
|
}
|
|
3708
|
-
const fetchedCount = this.fetchedAdDurations.size;
|
|
3709
|
-
const averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
3710
3724
|
const additionalAds = Math.ceil(remainingTimeMs / averageDurationMs);
|
|
3711
3725
|
if (this.config.debugAdTiming) {
|
|
3712
3726
|
console.log(
|
|
3713
|
-
`[ADAPTIVE-POD] \u{1F4CA} Need ${additionalAds} more ads | Fetched: ${totalFetchedDurationMs}ms
|
|
3727
|
+
`[ADAPTIVE-POD] \u{1F4CA} Need ${additionalAds} more ads | Fetched: ${totalFetchedDurationMs}ms (${fetchedCount} ads) | Queued: ${estimatedQueuedDurationMs}ms (${queuedButNotFetched} ads) | Target: ${this.targetAdBreakDurationMs}ms | Remaining: ${remainingTimeMs}ms | Avg duration: ${averageDurationMs}ms`
|
|
3714
3728
|
);
|
|
3715
3729
|
}
|
|
3716
3730
|
return additionalAds;
|