stormcloud-video-player 0.3.1 → 0.3.2
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 +67 -12
- 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 +67 -12
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +67 -12
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -0
- package/lib/players/HlsPlayer.cjs +67 -12
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +67 -12
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +67 -12
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/players/index.cjs
CHANGED
|
@@ -3234,12 +3234,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3234
3234
|
);
|
|
3235
3235
|
}
|
|
3236
3236
|
});
|
|
3237
|
-
|
|
3238
|
-
await this.playAdPod();
|
|
3239
|
-
} catch (error) {
|
|
3240
|
-
console.error("[DEBUG-POD] \u274C Pod playback failed:", error);
|
|
3241
|
-
this.handleAdFailure();
|
|
3242
|
-
}
|
|
3237
|
+
await this.playAdPod();
|
|
3243
3238
|
}
|
|
3244
3239
|
if (this.expectedAdBreakDurationMs == null && (scheduled == null ? void 0 : scheduled.durationMs) != null) {
|
|
3245
3240
|
this.expectedAdBreakDurationMs = scheduled.durationMs;
|
|
@@ -3260,13 +3255,22 @@ var StormcloudVideoPlayer = class {
|
|
|
3260
3255
|
const firstAd = this.adPodQueue.shift();
|
|
3261
3256
|
if (firstAd) {
|
|
3262
3257
|
this.currentAdIndex++;
|
|
3263
|
-
|
|
3258
|
+
try {
|
|
3259
|
+
await this.playSingleAd(firstAd);
|
|
3260
|
+
} catch (error) {
|
|
3261
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F First ad failed, error handler will retry");
|
|
3262
|
+
return;
|
|
3263
|
+
}
|
|
3264
3264
|
}
|
|
3265
3265
|
return;
|
|
3266
3266
|
}
|
|
3267
3267
|
this.currentAdIndex++;
|
|
3268
3268
|
console.log(`[DEBUG-POD] \u{1F680} Starting pod with ad ${this.currentAdIndex}/${this.totalAdsInBreak}`);
|
|
3269
|
-
|
|
3269
|
+
try {
|
|
3270
|
+
await this.playSingleAd(firstPreloaded);
|
|
3271
|
+
} catch (error) {
|
|
3272
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F First ad failed, error handler will retry");
|
|
3273
|
+
}
|
|
3270
3274
|
}
|
|
3271
3275
|
findCurrentOrNextBreak(nowMs) {
|
|
3272
3276
|
var _a;
|
|
@@ -3475,6 +3479,13 @@ var StormcloudVideoPlayer = class {
|
|
|
3475
3479
|
console.log("[DEBUG-POD] \u274C handleAdFailure - skipping to next ad or ending break");
|
|
3476
3480
|
const remaining = this.getRemainingAdMs();
|
|
3477
3481
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
3482
|
+
if (this.isAdaptiveMode && this.currentAdIndex <= 1) {
|
|
3483
|
+
console.log("[ADAPTIVE-POD] \u23F3 First ad failed, waiting for sequential preload to catch up...");
|
|
3484
|
+
setTimeout(() => {
|
|
3485
|
+
this.tryNextAdWithRetry(0);
|
|
3486
|
+
}, 1500);
|
|
3487
|
+
return;
|
|
3488
|
+
}
|
|
3478
3489
|
const nextPreloaded = this.findNextPreloadedAd();
|
|
3479
3490
|
if (nextPreloaded) {
|
|
3480
3491
|
this.currentAdIndex++;
|
|
@@ -3488,6 +3499,42 @@ var StormcloudVideoPlayer = class {
|
|
|
3488
3499
|
console.log("[DEBUG-POD] \u23F9\uFE0F Ending ad break after failure");
|
|
3489
3500
|
this.handleAdPodComplete();
|
|
3490
3501
|
}
|
|
3502
|
+
tryNextAdWithRetry(retryCount) {
|
|
3503
|
+
const maxRetries = 3;
|
|
3504
|
+
const remaining = this.getRemainingAdMs();
|
|
3505
|
+
if (this.config.debugAdTiming) {
|
|
3506
|
+
console.log(
|
|
3507
|
+
`[ADAPTIVE-POD] \u{1F50D} Retry attempt ${retryCount}: remaining=${remaining}ms, queue=${this.adPodQueue.length}, totalAds=${this.totalAdsInBreak}`
|
|
3508
|
+
);
|
|
3509
|
+
}
|
|
3510
|
+
if (remaining <= 500 || this.adPodQueue.length === 0) {
|
|
3511
|
+
console.log("[ADAPTIVE-POD] \u23F9\uFE0F No more time or ads available");
|
|
3512
|
+
this.handleAdPodComplete();
|
|
3513
|
+
return;
|
|
3514
|
+
}
|
|
3515
|
+
const nextPreloaded = this.findNextPreloadedAd();
|
|
3516
|
+
if (nextPreloaded) {
|
|
3517
|
+
this.currentAdIndex++;
|
|
3518
|
+
console.log(
|
|
3519
|
+
`[ADAPTIVE-POD] \u2705 Found preloaded ad after retry ${retryCount}, playing (${this.currentAdIndex}/${this.totalAdsInBreak})`
|
|
3520
|
+
);
|
|
3521
|
+
this.playSingleAd(nextPreloaded).catch(() => {
|
|
3522
|
+
this.handleAdPodComplete();
|
|
3523
|
+
});
|
|
3524
|
+
} else if (retryCount < maxRetries) {
|
|
3525
|
+
console.log(
|
|
3526
|
+
`[ADAPTIVE-POD] \u23F3 No preloaded ads yet (queue has ${this.adPodQueue.length} URLs), retry ${retryCount + 1}/${maxRetries} in 1s...`
|
|
3527
|
+
);
|
|
3528
|
+
setTimeout(() => {
|
|
3529
|
+
this.tryNextAdWithRetry(retryCount + 1);
|
|
3530
|
+
}, 1e3);
|
|
3531
|
+
} else {
|
|
3532
|
+
console.log(
|
|
3533
|
+
`[ADAPTIVE-POD] \u274C Max retries reached, no preloaded ads available (queue=${this.adPodQueue.length} URLs)`
|
|
3534
|
+
);
|
|
3535
|
+
this.handleAdPodComplete();
|
|
3536
|
+
}
|
|
3537
|
+
}
|
|
3491
3538
|
startAdRequestWatchdog(token) {
|
|
3492
3539
|
var _a;
|
|
3493
3540
|
this.clearAdRequestWatchdog();
|
|
@@ -3752,22 +3799,30 @@ var StormcloudVideoPlayer = class {
|
|
|
3752
3799
|
if (this.isAdaptiveMode) {
|
|
3753
3800
|
if (this.config.debugAdTiming) {
|
|
3754
3801
|
console.log(
|
|
3755
|
-
`[ADAPTIVE-POD] Starting sequential preload of ${this.adPodAllUrls.length} initial ads`
|
|
3802
|
+
`[ADAPTIVE-POD] \u{1F504} Starting sequential preload of ${this.adPodAllUrls.length} initial ads`
|
|
3756
3803
|
);
|
|
3757
3804
|
}
|
|
3758
3805
|
const processedUrls = /* @__PURE__ */ new Set();
|
|
3759
3806
|
while (true) {
|
|
3760
3807
|
const nextUrl = this.adPodAllUrls.find((url) => !processedUrls.has(url));
|
|
3761
3808
|
if (!nextUrl) {
|
|
3809
|
+
if (this.config.debugAdTiming) {
|
|
3810
|
+
console.log(`[ADAPTIVE-POD] \u2705 All queued ads processed (${processedUrls.size} total)`);
|
|
3811
|
+
}
|
|
3762
3812
|
break;
|
|
3763
3813
|
}
|
|
3764
3814
|
processedUrls.add(nextUrl);
|
|
3815
|
+
if (this.config.debugAdTiming) {
|
|
3816
|
+
console.log(
|
|
3817
|
+
`[ADAPTIVE-POD] \u{1F4E5} Preloading ad ${processedUrls.size}/${this.adPodAllUrls.length}...`
|
|
3818
|
+
);
|
|
3819
|
+
}
|
|
3765
3820
|
try {
|
|
3766
3821
|
await this.preloadSingleAd(nextUrl);
|
|
3767
3822
|
} catch (error) {
|
|
3768
3823
|
if (this.config.debugAdTiming) {
|
|
3769
3824
|
console.warn(
|
|
3770
|
-
`[ADAPTIVE-POD] Preload failed for ${
|
|
3825
|
+
`[ADAPTIVE-POD] \u26A0\uFE0F Preload failed for ad ${processedUrls.size}:`,
|
|
3771
3826
|
error
|
|
3772
3827
|
);
|
|
3773
3828
|
}
|
|
@@ -3775,7 +3830,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3775
3830
|
if (this.calculateAdditionalAdsNeeded() === 0) {
|
|
3776
3831
|
if (this.config.debugAdTiming) {
|
|
3777
3832
|
console.log(
|
|
3778
|
-
`[ADAPTIVE-POD] \u2705 Target duration reached, stopping
|
|
3833
|
+
`[ADAPTIVE-POD] \u2705 Target duration reached (${processedUrls.size} ads preloaded), stopping`
|
|
3779
3834
|
);
|
|
3780
3835
|
}
|
|
3781
3836
|
break;
|
|
@@ -3783,7 +3838,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3783
3838
|
}
|
|
3784
3839
|
if (this.config.debugAdTiming) {
|
|
3785
3840
|
console.log(
|
|
3786
|
-
`[ADAPTIVE-POD] Sequential preloading completed (${processedUrls.size} ads
|
|
3841
|
+
`[ADAPTIVE-POD] \u2705 Sequential preloading completed (${processedUrls.size} ads ready)`
|
|
3787
3842
|
);
|
|
3788
3843
|
}
|
|
3789
3844
|
} else {
|