stormcloud-video-player 0.3.4 → 0.3.6
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 +42 -11
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +42 -11
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +42 -11
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +42 -11
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +42 -11
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +42 -11
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -3255,21 +3255,38 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3255
3255
|
this.adPodQueue = [...vastTagUrls];
|
|
3256
3256
|
if (this.isAdaptiveMode) {
|
|
3257
3257
|
if (this.config.debugAdTiming) {
|
|
3258
|
-
console.log("[ADAPTIVE-POD]
|
|
3258
|
+
console.log("[ADAPTIVE-POD] \u{1F680} Preloading first 2 ads before starting playback...");
|
|
3259
3259
|
}
|
|
3260
3260
|
try {
|
|
3261
|
-
|
|
3261
|
+
const adsToPreloadBeforeStart = Math.min(2, this.adPodAllUrls.length);
|
|
3262
|
+
for (let i = 0; i < adsToPreloadBeforeStart; i++) {
|
|
3263
|
+
const url = this.adPodAllUrls[i];
|
|
3264
|
+
if (url) {
|
|
3265
|
+
await this.preloadSingleAd(url);
|
|
3266
|
+
if (this.config.debugAdTiming) {
|
|
3267
|
+
console.log(`[ADAPTIVE-POD] \u2705 Preloaded ad ${i + 1}/${adsToPreloadBeforeStart}`);
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3262
3271
|
if (this.config.debugAdTiming) {
|
|
3263
|
-
console.log("[ADAPTIVE-POD]
|
|
3272
|
+
console.log("[ADAPTIVE-POD] \u{1F3AC} First ads preloaded, starting playback immediately");
|
|
3264
3273
|
}
|
|
3265
3274
|
} catch (error) {
|
|
3266
3275
|
if (this.config.debugAdTiming) {
|
|
3267
3276
|
console.warn(
|
|
3268
|
-
"[ADAPTIVE-POD] Error
|
|
3277
|
+
"[ADAPTIVE-POD] \u26A0\uFE0F Error preloading initial ads:",
|
|
3269
3278
|
error
|
|
3270
3279
|
);
|
|
3271
3280
|
}
|
|
3272
3281
|
}
|
|
3282
|
+
this.preloadAllAdsInBackground().catch((error) => {
|
|
3283
|
+
if (this.config.debugAdTiming) {
|
|
3284
|
+
console.warn(
|
|
3285
|
+
"[ADAPTIVE-POD] Error in background preloading:",
|
|
3286
|
+
error
|
|
3287
|
+
);
|
|
3288
|
+
}
|
|
3289
|
+
});
|
|
3273
3290
|
await this.playAdPod();
|
|
3274
3291
|
} else {
|
|
3275
3292
|
this.preloadAllAdsInBackground().catch((error) => {
|
|
@@ -3294,7 +3311,7 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3294
3311
|
console.log("[DEBUG-POD] \u26A0\uFE0F No ads in pod");
|
|
3295
3312
|
return;
|
|
3296
3313
|
}
|
|
3297
|
-
const waitTime = this.isAdaptiveMode ?
|
|
3314
|
+
const waitTime = this.isAdaptiveMode ? 50 : 500;
|
|
3298
3315
|
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
3299
3316
|
if (this.config.debugAdTiming) {
|
|
3300
3317
|
console.log(
|
|
@@ -3776,21 +3793,24 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3776
3793
|
for (const duration of this.fetchedAdDurations.values()) {
|
|
3777
3794
|
totalFetchedDurationMs += duration * 1e3;
|
|
3778
3795
|
}
|
|
3779
|
-
const
|
|
3796
|
+
const fetchedCount = this.fetchedAdDurations.size;
|
|
3797
|
+
const averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
3798
|
+
const queuedButNotFetched = this.adPodAllUrls.length - fetchedCount;
|
|
3799
|
+
const estimatedQueuedDurationMs = queuedButNotFetched * averageDurationMs;
|
|
3800
|
+
const estimatedTotalDurationMs = totalFetchedDurationMs + estimatedQueuedDurationMs;
|
|
3801
|
+
const remainingTimeMs = this.targetAdBreakDurationMs - estimatedTotalDurationMs;
|
|
3780
3802
|
if (remainingTimeMs <= 0) {
|
|
3781
3803
|
if (this.config.debugAdTiming) {
|
|
3782
3804
|
console.log(
|
|
3783
|
-
`[ADAPTIVE-POD] \u2705 Target duration
|
|
3805
|
+
`[ADAPTIVE-POD] \u2705 Target duration met: Fetched=${totalFetchedDurationMs}ms + Queued(${queuedButNotFetched} ads)=${estimatedQueuedDurationMs}ms = ${estimatedTotalDurationMs}ms / Target=${this.targetAdBreakDurationMs}ms`
|
|
3784
3806
|
);
|
|
3785
3807
|
}
|
|
3786
3808
|
return 0;
|
|
3787
3809
|
}
|
|
3788
|
-
const fetchedCount = this.fetchedAdDurations.size;
|
|
3789
|
-
const averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
3790
3810
|
const additionalAds = Math.ceil(remainingTimeMs / averageDurationMs);
|
|
3791
3811
|
if (this.config.debugAdTiming) {
|
|
3792
3812
|
console.log(
|
|
3793
|
-
`[ADAPTIVE-POD] \u{1F4CA} Need ${additionalAds} more ads | Fetched: ${totalFetchedDurationMs}ms
|
|
3813
|
+
`[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`
|
|
3794
3814
|
);
|
|
3795
3815
|
}
|
|
3796
3816
|
return additionalAds;
|
|
@@ -3857,16 +3877,27 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3857
3877
|
}
|
|
3858
3878
|
}
|
|
3859
3879
|
async preloadAllAdsInBackground() {
|
|
3880
|
+
var _a, _b;
|
|
3860
3881
|
if (this.adPodAllUrls.length === 0) {
|
|
3861
3882
|
return;
|
|
3862
3883
|
}
|
|
3863
3884
|
if (this.isAdaptiveMode) {
|
|
3864
3885
|
if (this.config.debugAdTiming) {
|
|
3865
3886
|
console.log(
|
|
3866
|
-
`[ADAPTIVE-POD] \u{1F504} Starting sequential preload of
|
|
3887
|
+
`[ADAPTIVE-POD] \u{1F504} Starting sequential preload of remaining ads`
|
|
3867
3888
|
);
|
|
3868
3889
|
}
|
|
3869
3890
|
const processedUrls = /* @__PURE__ */ new Set();
|
|
3891
|
+
for (const url of this.adPodAllUrls) {
|
|
3892
|
+
if (((_b = (_a = this.ima).hasPreloadedAd) == null ? void 0 : _b.call(_a, url)) || this.fetchedAdDurations.has(url)) {
|
|
3893
|
+
processedUrls.add(url);
|
|
3894
|
+
}
|
|
3895
|
+
}
|
|
3896
|
+
if (this.config.debugAdTiming && processedUrls.size > 0) {
|
|
3897
|
+
console.log(
|
|
3898
|
+
`[ADAPTIVE-POD] \u{1F4E6} Skipping ${processedUrls.size} already-preloaded ads`
|
|
3899
|
+
);
|
|
3900
|
+
}
|
|
3870
3901
|
while (true) {
|
|
3871
3902
|
const nextUrl = this.adPodAllUrls.find((url) => !processedUrls.has(url));
|
|
3872
3903
|
if (!nextUrl) {
|