stormcloud-video-player 0.3.0 → 0.3.1
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 +60 -30
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +60 -30
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +60 -30
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +60 -30
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +60 -30
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +60 -30
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/players/index.cjs
CHANGED
|
@@ -3252,7 +3252,8 @@ var StormcloudVideoPlayer = class {
|
|
|
3252
3252
|
console.log("[DEBUG-POD] \u26A0\uFE0F No ads in pod");
|
|
3253
3253
|
return;
|
|
3254
3254
|
}
|
|
3255
|
-
|
|
3255
|
+
const waitTime = this.isAdaptiveMode ? 1500 : 500;
|
|
3256
|
+
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
3256
3257
|
const firstPreloaded = this.findNextPreloadedAd();
|
|
3257
3258
|
if (!firstPreloaded) {
|
|
3258
3259
|
console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads after wait, trying first ad");
|
|
@@ -3697,22 +3698,12 @@ var StormcloudVideoPlayer = class {
|
|
|
3697
3698
|
);
|
|
3698
3699
|
if (this.config.debugAdTiming) {
|
|
3699
3700
|
console.log(
|
|
3700
|
-
`[ADAPTIVE-POD] \u{1F504} Adding ${newUrls.length} additional VAST URLs to queue`
|
|
3701
|
+
`[ADAPTIVE-POD] \u{1F504} Adding ${newUrls.length} additional VAST URLs to queue (will be preloaded sequentially)`
|
|
3701
3702
|
);
|
|
3702
3703
|
}
|
|
3703
3704
|
this.adPodAllUrls.push(...newUrls);
|
|
3704
3705
|
this.adPodQueue.push(...newUrls);
|
|
3705
3706
|
this.totalAdsInBreak += newUrls.length;
|
|
3706
|
-
for (const url of newUrls) {
|
|
3707
|
-
this.preloadSingleAd(url).catch((error) => {
|
|
3708
|
-
if (this.config.debugAdTiming) {
|
|
3709
|
-
console.warn(
|
|
3710
|
-
`[ADAPTIVE-POD] Failed to preload adaptive ad:`,
|
|
3711
|
-
error
|
|
3712
|
-
);
|
|
3713
|
-
}
|
|
3714
|
-
});
|
|
3715
|
-
}
|
|
3716
3707
|
}
|
|
3717
3708
|
async preloadMediaFile(mediaUrl) {
|
|
3718
3709
|
if (this.preloadedMediaUrls.has(mediaUrl)) {
|
|
@@ -3758,26 +3749,65 @@ var StormcloudVideoPlayer = class {
|
|
|
3758
3749
|
if (this.adPodAllUrls.length === 0) {
|
|
3759
3750
|
return;
|
|
3760
3751
|
}
|
|
3761
|
-
if (this.
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
);
|
|
3752
|
+
if (this.isAdaptiveMode) {
|
|
3753
|
+
if (this.config.debugAdTiming) {
|
|
3754
|
+
console.log(
|
|
3755
|
+
`[ADAPTIVE-POD] Starting sequential preload of ${this.adPodAllUrls.length} initial ads`
|
|
3756
|
+
);
|
|
3757
|
+
}
|
|
3758
|
+
const processedUrls = /* @__PURE__ */ new Set();
|
|
3759
|
+
while (true) {
|
|
3760
|
+
const nextUrl = this.adPodAllUrls.find((url) => !processedUrls.has(url));
|
|
3761
|
+
if (!nextUrl) {
|
|
3762
|
+
break;
|
|
3773
3763
|
}
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3764
|
+
processedUrls.add(nextUrl);
|
|
3765
|
+
try {
|
|
3766
|
+
await this.preloadSingleAd(nextUrl);
|
|
3767
|
+
} catch (error) {
|
|
3768
|
+
if (this.config.debugAdTiming) {
|
|
3769
|
+
console.warn(
|
|
3770
|
+
`[ADAPTIVE-POD] Preload failed for ${nextUrl}:`,
|
|
3771
|
+
error
|
|
3772
|
+
);
|
|
3773
|
+
}
|
|
3774
|
+
}
|
|
3775
|
+
if (this.calculateAdditionalAdsNeeded() === 0) {
|
|
3776
|
+
if (this.config.debugAdTiming) {
|
|
3777
|
+
console.log(
|
|
3778
|
+
`[ADAPTIVE-POD] \u2705 Target duration reached, stopping preload`
|
|
3779
|
+
);
|
|
3780
|
+
}
|
|
3781
|
+
break;
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
if (this.config.debugAdTiming) {
|
|
3785
|
+
console.log(
|
|
3786
|
+
`[ADAPTIVE-POD] Sequential preloading completed (${processedUrls.size} ads preloaded)`
|
|
3787
|
+
);
|
|
3788
|
+
}
|
|
3789
|
+
} else {
|
|
3790
|
+
if (this.config.debugAdTiming) {
|
|
3791
|
+
console.log(
|
|
3792
|
+
`[StormcloudVideoPlayer] Starting parallel preload of ${this.adPodAllUrls.length} ads`
|
|
3793
|
+
);
|
|
3794
|
+
}
|
|
3795
|
+
const preloadPromises = this.adPodAllUrls.map(
|
|
3796
|
+
(vastTagUrl) => this.preloadSingleAd(vastTagUrl).catch((error) => {
|
|
3797
|
+
if (this.config.debugAdTiming) {
|
|
3798
|
+
console.warn(
|
|
3799
|
+
`[StormcloudVideoPlayer] Preload failed for ${vastTagUrl}:`,
|
|
3800
|
+
error
|
|
3801
|
+
);
|
|
3802
|
+
}
|
|
3803
|
+
})
|
|
3780
3804
|
);
|
|
3805
|
+
await Promise.all(preloadPromises);
|
|
3806
|
+
if (this.config.debugAdTiming) {
|
|
3807
|
+
console.log(
|
|
3808
|
+
`[StormcloudVideoPlayer] Background preloading completed for all ads`
|
|
3809
|
+
);
|
|
3810
|
+
}
|
|
3781
3811
|
}
|
|
3782
3812
|
}
|
|
3783
3813
|
async preloadSingleAd(vastTagUrl) {
|