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/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;
|
|
@@ -3429,22 +3431,31 @@ var StormcloudVideoPlayer = class {
|
|
|
3429
3431
|
console.log(`[DEBUG-POD] \u{1F4DD} Request token=${requestToken}, preloaded=${wasPreloaded}`);
|
|
3430
3432
|
this.startAdRequestWatchdog(requestToken);
|
|
3431
3433
|
try {
|
|
3434
|
+
console.log(`[DEBUG-POD] \u{1F4E1} Calling ima.requestAds() for token=${requestToken}...`);
|
|
3432
3435
|
await this.ima.requestAds(vastTagUrl);
|
|
3436
|
+
console.log(`[DEBUG-POD] \u2705 ima.requestAds() completed successfully`);
|
|
3433
3437
|
this.clearAdRequestWatchdog();
|
|
3434
3438
|
if (this.activeAdRequestToken !== requestToken) {
|
|
3435
3439
|
console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after requestAds (stale request)`);
|
|
3436
3440
|
return;
|
|
3437
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}`);
|
|
3438
3444
|
try {
|
|
3439
3445
|
this.startAdFailsafeTimer(requestToken);
|
|
3440
3446
|
await this.ima.play();
|
|
3441
3447
|
if (this.activeAdRequestToken === requestToken) {
|
|
3442
|
-
console.log(`[DEBUG-POD] \u2705 Ad play initiated (token=${requestToken})`);
|
|
3448
|
+
console.log(`[DEBUG-POD] \u2705 Ad play initiated successfully (token=${requestToken})`);
|
|
3443
3449
|
} else {
|
|
3444
3450
|
console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after play (stale request)`);
|
|
3445
3451
|
}
|
|
3446
3452
|
} catch (playError) {
|
|
3447
|
-
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
|
+
);
|
|
3448
3459
|
this.clearAdFailsafeTimer();
|
|
3449
3460
|
if (this.activeAdRequestToken === requestToken) {
|
|
3450
3461
|
this.activeAdRequestToken = null;
|
|
@@ -3740,21 +3751,24 @@ var StormcloudVideoPlayer = class {
|
|
|
3740
3751
|
for (const duration of this.fetchedAdDurations.values()) {
|
|
3741
3752
|
totalFetchedDurationMs += duration * 1e3;
|
|
3742
3753
|
}
|
|
3743
|
-
const
|
|
3754
|
+
const fetchedCount = this.fetchedAdDurations.size;
|
|
3755
|
+
const averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
3756
|
+
const queuedButNotFetched = this.adPodAllUrls.length - fetchedCount;
|
|
3757
|
+
const estimatedQueuedDurationMs = queuedButNotFetched * averageDurationMs;
|
|
3758
|
+
const estimatedTotalDurationMs = totalFetchedDurationMs + estimatedQueuedDurationMs;
|
|
3759
|
+
const remainingTimeMs = this.targetAdBreakDurationMs - estimatedTotalDurationMs;
|
|
3744
3760
|
if (remainingTimeMs <= 0) {
|
|
3745
3761
|
if (this.config.debugAdTiming) {
|
|
3746
3762
|
console.log(
|
|
3747
|
-
`[ADAPTIVE-POD] \u2705 Target duration
|
|
3763
|
+
`[ADAPTIVE-POD] \u2705 Target duration met: Fetched=${totalFetchedDurationMs}ms + Queued(${queuedButNotFetched} ads)=${estimatedQueuedDurationMs}ms = ${estimatedTotalDurationMs}ms / Target=${this.targetAdBreakDurationMs}ms`
|
|
3748
3764
|
);
|
|
3749
3765
|
}
|
|
3750
3766
|
return 0;
|
|
3751
3767
|
}
|
|
3752
|
-
const fetchedCount = this.fetchedAdDurations.size;
|
|
3753
|
-
const averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
3754
3768
|
const additionalAds = Math.ceil(remainingTimeMs / averageDurationMs);
|
|
3755
3769
|
if (this.config.debugAdTiming) {
|
|
3756
3770
|
console.log(
|
|
3757
|
-
`[ADAPTIVE-POD] \u{1F4CA} Need ${additionalAds} more ads | Fetched: ${totalFetchedDurationMs}ms
|
|
3771
|
+
`[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`
|
|
3758
3772
|
);
|
|
3759
3773
|
}
|
|
3760
3774
|
return additionalAds;
|