stormcloud-video-player 0.2.22 → 0.2.24
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 +70 -20
- 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 +70 -20
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +70 -20
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -0
- package/lib/players/HlsPlayer.cjs +70 -20
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +70 -20
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +12 -0
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/ima.cjs +18 -2
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +70 -20
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/players/index.cjs
CHANGED
|
@@ -481,9 +481,13 @@ function createImaController(video, options) {
|
|
|
481
481
|
adsLoader.addEventListener(
|
|
482
482
|
google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
|
|
483
483
|
(evt) => {
|
|
484
|
-
console.log(
|
|
484
|
+
console.log(
|
|
485
|
+
"[IMA] Ads manager loaded - enabling preloading for continuous playback"
|
|
486
|
+
);
|
|
485
487
|
try {
|
|
486
|
-
|
|
488
|
+
const adsRenderingSettings = new google.ima.AdsRenderingSettings();
|
|
489
|
+
adsRenderingSettings.enablePreloading = true;
|
|
490
|
+
adsManager = evt.getAdsManager(video, adsRenderingSettings);
|
|
487
491
|
const AdEvent = google.ima.AdEvent.Type;
|
|
488
492
|
const AdErrorEvent = google.ima.AdErrorEvent.Type;
|
|
489
493
|
adsManager.addEventListener(
|
|
@@ -580,6 +584,18 @@ function createImaController(video, options) {
|
|
|
580
584
|
adPlaying = false;
|
|
581
585
|
setAdPlayingFlag(false);
|
|
582
586
|
emit("content_resume");
|
|
587
|
+
setTimeout(() => {
|
|
588
|
+
const stillInPod = video.dataset.stormcloudAdPlaying === "true";
|
|
589
|
+
if (stillInPod) {
|
|
590
|
+
console.log(
|
|
591
|
+
"[IMA] Still in ad pod - keeping ad container visible (black screen)"
|
|
592
|
+
);
|
|
593
|
+
if (adContainerEl) {
|
|
594
|
+
adContainerEl.style.display = "flex";
|
|
595
|
+
adContainerEl.style.pointerEvents = "auto";
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}, 50);
|
|
583
599
|
}
|
|
584
600
|
);
|
|
585
601
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
@@ -1129,6 +1145,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1129
1145
|
adPlaying = false;
|
|
1130
1146
|
setAdPlayingFlag(false);
|
|
1131
1147
|
emit("content_resume");
|
|
1148
|
+
setTimeout(() => {
|
|
1149
|
+
const stillInPod = contentVideo.dataset.stormcloudAdPlaying === "true";
|
|
1150
|
+
if (stillInPod) {
|
|
1151
|
+
console.log(
|
|
1152
|
+
"[HlsAdPlayer] Still in ad pod - keeping ad container visible (black screen)"
|
|
1153
|
+
);
|
|
1154
|
+
if (adContainerEl) {
|
|
1155
|
+
adContainerEl.style.display = "flex";
|
|
1156
|
+
adContainerEl.style.pointerEvents = "auto";
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}, 50);
|
|
1132
1160
|
}
|
|
1133
1161
|
function handleAdError() {
|
|
1134
1162
|
console.log("[HlsAdPlayer] Handling ad error");
|
|
@@ -2187,9 +2215,12 @@ var StormcloudVideoPlayer = class {
|
|
|
2187
2215
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
2188
2216
|
const next = this.adPodQueue.shift();
|
|
2189
2217
|
this.currentAdIndex++;
|
|
2218
|
+
this.video.dataset.stormcloudAdPlaying = "true";
|
|
2219
|
+
this.video.muted = true;
|
|
2220
|
+
this.video.volume = 0;
|
|
2190
2221
|
if (this.config.debugAdTiming) {
|
|
2191
2222
|
console.log(
|
|
2192
|
-
`[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) -
|
|
2223
|
+
`[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - IMMEDIATELY starting next ad`
|
|
2193
2224
|
);
|
|
2194
2225
|
}
|
|
2195
2226
|
this.playSingleAd(next).catch(() => {
|
|
@@ -2774,25 +2805,21 @@ var StormcloudVideoPlayer = class {
|
|
|
2774
2805
|
this.video.currentTime * 1e3
|
|
2775
2806
|
);
|
|
2776
2807
|
const tags = this.selectVastTagsForBreak(scheduled);
|
|
2777
|
-
let
|
|
2808
|
+
let vastTagUrls = [];
|
|
2778
2809
|
if (this.apiVastTagUrl) {
|
|
2779
|
-
|
|
2780
|
-
this.adPodQueue = [];
|
|
2781
|
-
this.currentAdIndex = 0;
|
|
2782
|
-
this.totalAdsInBreak = 1;
|
|
2810
|
+
vastTagUrls = [this.apiVastTagUrl];
|
|
2783
2811
|
if (this.config.debugAdTiming) {
|
|
2784
|
-
console.log(
|
|
2812
|
+
console.log(
|
|
2813
|
+
"[StormcloudVideoPlayer] Using VAST endpoint:",
|
|
2814
|
+
this.apiVastTagUrl
|
|
2815
|
+
);
|
|
2785
2816
|
}
|
|
2786
2817
|
} else if (tags && tags.length > 0) {
|
|
2787
|
-
|
|
2788
|
-
const rest = tags.slice(1);
|
|
2789
|
-
this.adPodQueue = rest;
|
|
2790
|
-
this.currentAdIndex = 0;
|
|
2791
|
-
this.totalAdsInBreak = tags.length;
|
|
2818
|
+
vastTagUrls = tags;
|
|
2792
2819
|
if (this.config.debugAdTiming) {
|
|
2793
2820
|
console.log(
|
|
2794
|
-
"[StormcloudVideoPlayer] Using scheduled VAST
|
|
2795
|
-
|
|
2821
|
+
"[StormcloudVideoPlayer] Using scheduled VAST tags (count: " + tags.length + "):",
|
|
2822
|
+
tags
|
|
2796
2823
|
);
|
|
2797
2824
|
}
|
|
2798
2825
|
} else {
|
|
@@ -2801,16 +2828,23 @@ var StormcloudVideoPlayer = class {
|
|
|
2801
2828
|
}
|
|
2802
2829
|
return;
|
|
2803
2830
|
}
|
|
2804
|
-
if (
|
|
2831
|
+
if (vastTagUrls.length > 0) {
|
|
2805
2832
|
this.inAdBreak = true;
|
|
2806
2833
|
this.showAds = true;
|
|
2807
|
-
this.currentAdIndex
|
|
2834
|
+
this.currentAdIndex = 0;
|
|
2835
|
+
this.totalAdsInBreak = vastTagUrls.length;
|
|
2836
|
+
this.adPodQueue = [...vastTagUrls];
|
|
2837
|
+
if (this.config.debugAdTiming) {
|
|
2838
|
+
console.log(
|
|
2839
|
+
`[StormcloudVideoPlayer] Starting ad pod with ${vastTagUrls.length} ads - will play continuously`
|
|
2840
|
+
);
|
|
2841
|
+
}
|
|
2808
2842
|
try {
|
|
2809
|
-
await this.
|
|
2843
|
+
await this.playAdPod();
|
|
2810
2844
|
} catch (error) {
|
|
2811
2845
|
if (this.config.debugAdTiming) {
|
|
2812
2846
|
console.error(
|
|
2813
|
-
"[StormcloudVideoPlayer] Ad playback failed
|
|
2847
|
+
"[StormcloudVideoPlayer] Ad pod playback failed:",
|
|
2814
2848
|
error
|
|
2815
2849
|
);
|
|
2816
2850
|
}
|
|
@@ -2823,6 +2857,22 @@ var StormcloudVideoPlayer = class {
|
|
|
2823
2857
|
this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
|
|
2824
2858
|
}
|
|
2825
2859
|
}
|
|
2860
|
+
async playAdPod() {
|
|
2861
|
+
if (this.adPodQueue.length === 0) {
|
|
2862
|
+
if (this.config.debugAdTiming) {
|
|
2863
|
+
console.log("[StormcloudVideoPlayer] No ads in pod to play");
|
|
2864
|
+
}
|
|
2865
|
+
return;
|
|
2866
|
+
}
|
|
2867
|
+
const firstAd = this.adPodQueue.shift();
|
|
2868
|
+
this.currentAdIndex++;
|
|
2869
|
+
if (this.config.debugAdTiming) {
|
|
2870
|
+
console.log(
|
|
2871
|
+
`[StormcloudVideoPlayer] Playing ad ${this.currentAdIndex}/${this.totalAdsInBreak}`
|
|
2872
|
+
);
|
|
2873
|
+
}
|
|
2874
|
+
await this.playSingleAd(firstAd);
|
|
2875
|
+
}
|
|
2826
2876
|
findCurrentOrNextBreak(nowMs) {
|
|
2827
2877
|
var _a;
|
|
2828
2878
|
const schedule = [];
|