stormcloud-video-player 0.2.32 → 0.2.34
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 +2 -2
- package/lib/index.cjs +176 -238
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +8 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +176 -238
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +176 -238
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +8 -0
- package/lib/players/HlsPlayer.cjs +176 -238
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +176 -238
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/ima.cjs +47 -68
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +176 -238
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/sdk/ima.cjs
CHANGED
|
@@ -185,7 +185,7 @@ function createImaController(video, options) {
|
|
|
185
185
|
video.muted = true;
|
|
186
186
|
video.volume = 0;
|
|
187
187
|
contentVideoHidden = true;
|
|
188
|
-
console.log("[
|
|
188
|
+
console.log("[DEBUG-LAYER] \u{1F534} Content video HIDDEN | muted=true, volume=0");
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
function showContentVideo() {
|
|
@@ -198,7 +198,7 @@ function createImaController(video, options) {
|
|
|
198
198
|
video.volume = originalVolume;
|
|
199
199
|
contentVideoHidden = false;
|
|
200
200
|
console.log(
|
|
201
|
-
`[
|
|
201
|
+
`[DEBUG-LAYER] \u{1F7E2} Content video RESTORED | muted=${originalMutedState}, volume=${originalVolume}`
|
|
202
202
|
);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
@@ -220,12 +220,12 @@ function createImaController(video, options) {
|
|
|
220
220
|
"canplay",
|
|
221
221
|
() => {
|
|
222
222
|
adVideo.style.opacity = "1";
|
|
223
|
-
console.log("[
|
|
223
|
+
console.log("[DEBUG-LAYER] \u{1F4FA} Ad video element ready (canplay fired)");
|
|
224
224
|
},
|
|
225
225
|
{ once: true }
|
|
226
226
|
);
|
|
227
227
|
console.log(
|
|
228
|
-
`[
|
|
228
|
+
`[DEBUG-AUDIO] \u{1F50A} Ad video created | volume=${adVideo.volume}, muted=${adVideo.muted}`
|
|
229
229
|
);
|
|
230
230
|
return adVideo;
|
|
231
231
|
}
|
|
@@ -315,9 +315,6 @@ function createImaController(video, options) {
|
|
|
315
315
|
const preloadedResponse = preloadedVast.get(vastTagUrl);
|
|
316
316
|
if (preloadedResponse) {
|
|
317
317
|
adsRequest.adsResponse = preloadedResponse;
|
|
318
|
-
console.log(
|
|
319
|
-
"[IMA] Using preloaded VAST response for immediate ad request"
|
|
320
|
-
);
|
|
321
318
|
} else {
|
|
322
319
|
adsRequest.adTagUrl = vastTagUrl;
|
|
323
320
|
}
|
|
@@ -344,7 +341,6 @@ function createImaController(video, options) {
|
|
|
344
341
|
}
|
|
345
342
|
}
|
|
346
343
|
adsRequest.vastLoadTimeout = 5e3;
|
|
347
|
-
console.log(`[IMA] Ads request dimensions: ${videoWidth}x${videoHeight}`);
|
|
348
344
|
adsLoader.requestAds(adsRequest);
|
|
349
345
|
if (preloadedResponse) {
|
|
350
346
|
preloadedVast.delete(vastTagUrl);
|
|
@@ -423,22 +419,24 @@ function createImaController(video, options) {
|
|
|
423
419
|
});
|
|
424
420
|
},
|
|
425
421
|
async requestAds(vastTagUrl) {
|
|
426
|
-
console.log("[IMA]
|
|
422
|
+
console.log("[IMA] \u{1F4E1} === requestAds() called ===");
|
|
423
|
+
console.log("[IMA] VAST URL:", vastTagUrl);
|
|
424
|
+
console.log("[IMA] This will fetch the ad from the server - no visual change yet");
|
|
427
425
|
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
428
426
|
const error = new Error("VAST tag URL is empty or undefined");
|
|
429
|
-
console.warn("[IMA]", error.message);
|
|
427
|
+
console.warn("[IMA] \u274C", error.message);
|
|
430
428
|
return Promise.reject(error);
|
|
431
429
|
}
|
|
432
430
|
try {
|
|
433
431
|
new URL(vastTagUrl);
|
|
434
432
|
} catch (e) {
|
|
435
433
|
const error = new Error(`Invalid VAST tag URL format: ${vastTagUrl}`);
|
|
436
|
-
console.warn("[IMA]", error.message);
|
|
434
|
+
console.warn("[IMA] \u274C", error.message);
|
|
437
435
|
return Promise.reject(error);
|
|
438
436
|
}
|
|
439
437
|
if (adPlaying) {
|
|
440
438
|
console.warn(
|
|
441
|
-
"[IMA] Cannot request new ads while an ad is playing. Call stop() first."
|
|
439
|
+
"[IMA] \u26A0\uFE0F Cannot request new ads while an ad is playing. Call stop() first."
|
|
442
440
|
);
|
|
443
441
|
return Promise.reject(
|
|
444
442
|
new Error("Ad already playing - cannot request new ads")
|
|
@@ -528,20 +526,29 @@ function createImaController(video, options) {
|
|
|
528
526
|
adsLoader.addEventListener(
|
|
529
527
|
google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
|
|
530
528
|
(evt) => {
|
|
531
|
-
console.log(
|
|
532
|
-
"[IMA] Ads manager loaded - enabling preloading for continuous playback"
|
|
533
|
-
);
|
|
529
|
+
console.log("[DEBUG-FLOW] \u2705 ADS_MANAGER_LOADED - Setting up manager");
|
|
534
530
|
try {
|
|
535
531
|
const adsRenderingSettings = new google.ima.AdsRenderingSettings();
|
|
536
532
|
adsRenderingSettings.enablePreloading = true;
|
|
537
533
|
adsManager = evt.getAdsManager(video, adsRenderingSettings);
|
|
538
534
|
const AdEvent = google.ima.AdEvent.Type;
|
|
539
535
|
const AdErrorEvent = google.ima.AdErrorEvent.Type;
|
|
536
|
+
const keyEvents = ["STARTED", "COMPLETE", "CONTENT_PAUSE_REQUESTED", "CONTENT_RESUME_REQUESTED", "ALL_ADS_COMPLETED"];
|
|
537
|
+
keyEvents.forEach((eventType) => {
|
|
538
|
+
if (AdEvent[eventType]) {
|
|
539
|
+
adsManager.addEventListener(AdEvent[eventType], (e) => {
|
|
540
|
+
var _a, _b;
|
|
541
|
+
const ad = (_a = e.getAd) == null ? void 0 : _a.call(e);
|
|
542
|
+
console.log(`[DEBUG-FLOW] \u{1F3AC} ${eventType} | title=${((_b = ad == null ? void 0 : ad.getTitle) == null ? void 0 : _b.call(ad)) || "N/A"}`);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
});
|
|
540
546
|
adsManager.addEventListener(
|
|
541
547
|
AdErrorEvent.AD_ERROR,
|
|
542
548
|
(errorEvent) => {
|
|
543
|
-
var _a;
|
|
544
|
-
|
|
549
|
+
var _a, _b;
|
|
550
|
+
const error = errorEvent.getError();
|
|
551
|
+
console.error("[DEBUG-ERROR] \u274C AD_ERROR:", (_a = error.getMessage) == null ? void 0 : _a.call(error));
|
|
545
552
|
destroyAdsManager();
|
|
546
553
|
adPlaying = false;
|
|
547
554
|
setAdPlayingFlag(false);
|
|
@@ -552,7 +559,7 @@ function createImaController(video, options) {
|
|
|
552
559
|
if (adContainerEl) {
|
|
553
560
|
adContainerEl.style.pointerEvents = "none";
|
|
554
561
|
adContainerEl.style.display = "none";
|
|
555
|
-
console.log("[
|
|
562
|
+
console.log("[DEBUG-LAYER] \u274C Ad container HIDDEN (error)");
|
|
556
563
|
}
|
|
557
564
|
}, 300);
|
|
558
565
|
}
|
|
@@ -564,9 +571,6 @@ function createImaController(video, options) {
|
|
|
564
571
|
}
|
|
565
572
|
if (lastAdTagUrl && retryAttempts < maxRetries) {
|
|
566
573
|
const delay = backoffBaseMs * Math.pow(2, retryAttempts++);
|
|
567
|
-
console.log(
|
|
568
|
-
`[IMA] Retrying ad request in ${delay}ms (attempt ${retryAttempts})`
|
|
569
|
-
);
|
|
570
574
|
window.setTimeout(() => {
|
|
571
575
|
try {
|
|
572
576
|
makeAdsRequest(google, lastAdTagUrl);
|
|
@@ -574,16 +578,10 @@ function createImaController(video, options) {
|
|
|
574
578
|
}
|
|
575
579
|
}, delay);
|
|
576
580
|
} else {
|
|
577
|
-
console.log(
|
|
578
|
-
"[IMA] Max retries reached, emitting ad_error"
|
|
579
|
-
);
|
|
580
581
|
emit("ad_error");
|
|
581
582
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
582
583
|
if (video.paused) {
|
|
583
|
-
|
|
584
|
-
"[IMA] Resuming paused video after ad error"
|
|
585
|
-
);
|
|
586
|
-
(_a = video.play()) == null ? void 0 : _a.catch(() => {
|
|
584
|
+
(_b = video.play()) == null ? void 0 : _b.catch(() => {
|
|
587
585
|
});
|
|
588
586
|
}
|
|
589
587
|
}
|
|
@@ -593,14 +591,9 @@ function createImaController(video, options) {
|
|
|
593
591
|
adsManager.addEventListener(
|
|
594
592
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
595
593
|
() => {
|
|
596
|
-
console.log("[
|
|
594
|
+
console.log("[DEBUG-FLOW] \u{1F3AF} CONTENT_PAUSE_REQUESTED - Ad starting");
|
|
597
595
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
598
596
|
video.pause();
|
|
599
|
-
console.log("[IMA] Content video paused (VOD mode)");
|
|
600
|
-
} else {
|
|
601
|
-
console.log(
|
|
602
|
-
"[IMA] Content video continues in background (Live mode)"
|
|
603
|
-
);
|
|
604
597
|
}
|
|
605
598
|
hideContentVideo();
|
|
606
599
|
if (adContainerEl) {
|
|
@@ -609,7 +602,7 @@ function createImaController(video, options) {
|
|
|
609
602
|
adContainerEl.style.backgroundColor = "#000";
|
|
610
603
|
adContainerEl.offsetHeight;
|
|
611
604
|
adContainerEl.style.opacity = "1";
|
|
612
|
-
console.log("[
|
|
605
|
+
console.log("[DEBUG-LAYER] \u{1F7E1} Ad container VISIBLE");
|
|
613
606
|
}
|
|
614
607
|
adPlaying = true;
|
|
615
608
|
setAdPlayingFlag(true);
|
|
@@ -617,14 +610,14 @@ function createImaController(video, options) {
|
|
|
617
610
|
}
|
|
618
611
|
);
|
|
619
612
|
adsManager.addEventListener(AdEvent.STARTED, () => {
|
|
620
|
-
console.log("[
|
|
613
|
+
console.log("[DEBUG-FLOW] \u25B6\uFE0F STARTED - Ad playing now");
|
|
621
614
|
setAdPlayingFlag(true);
|
|
622
615
|
hideContentVideo();
|
|
623
616
|
if (adVideoElement) {
|
|
624
617
|
adVideoElement.volume = originalMutedState ? 0 : originalVolume;
|
|
625
618
|
adVideoElement.muted = originalMutedState;
|
|
626
619
|
console.log(
|
|
627
|
-
`[
|
|
620
|
+
`[DEBUG-AUDIO] \u{1F50A} Ad audio set | volume=${adVideoElement.volume}, muted=${adVideoElement.muted}`
|
|
628
621
|
);
|
|
629
622
|
}
|
|
630
623
|
if (adContainerEl) {
|
|
@@ -633,20 +626,20 @@ function createImaController(video, options) {
|
|
|
633
626
|
adContainerEl.style.backgroundColor = "#000";
|
|
634
627
|
adContainerEl.offsetHeight;
|
|
635
628
|
adContainerEl.style.opacity = "1";
|
|
636
|
-
console.log("[IMA] Ad container now visible");
|
|
637
629
|
}
|
|
638
630
|
});
|
|
639
631
|
adsManager.addEventListener(
|
|
640
632
|
AdEvent.CONTENT_RESUME_REQUESTED,
|
|
641
633
|
() => {
|
|
642
|
-
console.log("[
|
|
634
|
+
console.log("[DEBUG-FLOW] \u23F8\uFE0F CONTENT_RESUME - Single ad done");
|
|
643
635
|
adPlaying = false;
|
|
644
636
|
setAdPlayingFlag(false);
|
|
637
|
+
console.log("[DEBUG-LAYER] \u26A0\uFE0F Waiting for pod manager decision (more ads or done)");
|
|
645
638
|
emit("content_resume");
|
|
646
639
|
}
|
|
647
640
|
);
|
|
648
641
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
649
|
-
console.log("[
|
|
642
|
+
console.log("[DEBUG-FLOW] \u{1F3C1} ALL_ADS_COMPLETED - Pod finished");
|
|
650
643
|
adPlaying = false;
|
|
651
644
|
setAdPlayingFlag(false);
|
|
652
645
|
if (adContainerEl) {
|
|
@@ -656,15 +649,14 @@ function createImaController(video, options) {
|
|
|
656
649
|
if (adContainerEl) {
|
|
657
650
|
adContainerEl.style.pointerEvents = "none";
|
|
658
651
|
adContainerEl.style.display = "none";
|
|
659
|
-
console.log("[
|
|
652
|
+
console.log("[DEBUG-LAYER] \u26AB Ad container HIDDEN (pod done)");
|
|
660
653
|
}
|
|
661
654
|
}, 300);
|
|
662
655
|
}
|
|
663
656
|
showContentVideo();
|
|
664
657
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds) && video.paused) {
|
|
665
|
-
console.log("[IMA] Resuming content video playback");
|
|
666
658
|
video.play().catch((e) => {
|
|
667
|
-
console.warn("[
|
|
659
|
+
console.warn("[DEBUG-ERROR] Failed to resume video:", e);
|
|
668
660
|
});
|
|
669
661
|
}
|
|
670
662
|
emit("all_ads_completed");
|
|
@@ -686,18 +678,12 @@ function createImaController(video, options) {
|
|
|
686
678
|
if (adContainerEl) {
|
|
687
679
|
adContainerEl.style.pointerEvents = "none";
|
|
688
680
|
adContainerEl.style.display = "none";
|
|
689
|
-
console.log(
|
|
690
|
-
"[IMA] Ad container hidden after setup error"
|
|
691
|
-
);
|
|
692
681
|
}
|
|
693
682
|
}, 300);
|
|
694
683
|
}
|
|
695
684
|
showContentVideo();
|
|
696
685
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
697
686
|
if (video.paused) {
|
|
698
|
-
console.log(
|
|
699
|
-
"[IMA] Resuming paused video after setup error"
|
|
700
|
-
);
|
|
701
687
|
video.play().catch(() => {
|
|
702
688
|
});
|
|
703
689
|
}
|
|
@@ -715,7 +701,9 @@ function createImaController(video, options) {
|
|
|
715
701
|
adsLoader.addEventListener(
|
|
716
702
|
google.ima.AdErrorEvent.Type.AD_ERROR,
|
|
717
703
|
(adErrorEvent) => {
|
|
718
|
-
|
|
704
|
+
var _a;
|
|
705
|
+
const error = adErrorEvent.getError();
|
|
706
|
+
console.error("[DEBUG-ERROR] \u274C ADS_LOADER ERROR:", (_a = error.getMessage) == null ? void 0 : _a.call(error));
|
|
719
707
|
adPlaying = false;
|
|
720
708
|
setAdPlayingFlag(false);
|
|
721
709
|
if (adContainerEl) {
|
|
@@ -725,14 +713,12 @@ function createImaController(video, options) {
|
|
|
725
713
|
if (adContainerEl) {
|
|
726
714
|
adContainerEl.style.pointerEvents = "none";
|
|
727
715
|
adContainerEl.style.display = "none";
|
|
728
|
-
console.log("[IMA] Ad container hidden after loader error");
|
|
729
716
|
}
|
|
730
717
|
}, 300);
|
|
731
718
|
}
|
|
732
719
|
showContentVideo();
|
|
733
720
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
734
721
|
if (video.paused) {
|
|
735
|
-
console.log("[IMA] Resuming paused video after loader error");
|
|
736
722
|
video.play().catch(() => {
|
|
737
723
|
});
|
|
738
724
|
}
|
|
@@ -747,7 +733,6 @@ function createImaController(video, options) {
|
|
|
747
733
|
false
|
|
748
734
|
);
|
|
749
735
|
}
|
|
750
|
-
console.log("[IMA] Making ads request");
|
|
751
736
|
makeAdsRequest(google, vastTagUrl);
|
|
752
737
|
return adsLoadedPromise;
|
|
753
738
|
} catch (error) {
|
|
@@ -786,20 +771,16 @@ function createImaController(video, options) {
|
|
|
786
771
|
},
|
|
787
772
|
async play() {
|
|
788
773
|
var _a, _b;
|
|
774
|
+
console.log("[DEBUG-FLOW] \u25B6\uFE0F play() - Starting ad playback");
|
|
789
775
|
if (!((_a = window.google) == null ? void 0 : _a.ima) || !adDisplayContainer) {
|
|
790
|
-
console.warn(
|
|
791
|
-
"[IMA] Cannot play ad: IMA SDK or ad container not available"
|
|
792
|
-
);
|
|
793
776
|
return Promise.reject(new Error("IMA SDK not available"));
|
|
794
777
|
}
|
|
795
778
|
if (!adsManager) {
|
|
796
|
-
console.warn("[IMA] Cannot play ad: No ads manager available");
|
|
797
779
|
return Promise.reject(new Error("No ads manager"));
|
|
798
780
|
}
|
|
799
781
|
try {
|
|
800
782
|
const width = video.clientWidth || 640;
|
|
801
783
|
const height = video.clientHeight || 360;
|
|
802
|
-
console.log(`[IMA] Initializing ads manager (${width}x${height})`);
|
|
803
784
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
804
785
|
adPlaying = true;
|
|
805
786
|
const adVolume = originalMutedState ? 0 : originalVolume;
|
|
@@ -807,20 +788,18 @@ function createImaController(video, options) {
|
|
|
807
788
|
adVideoElement.volume = adVolume;
|
|
808
789
|
adVideoElement.muted = originalMutedState;
|
|
809
790
|
console.log(
|
|
810
|
-
`[
|
|
791
|
+
`[DEBUG-AUDIO] \u{1F50A} Pre-start ad audio | volume=${adVolume}, muted=${originalMutedState}`
|
|
811
792
|
);
|
|
812
793
|
}
|
|
813
794
|
try {
|
|
814
795
|
adsManager.setVolume(adVolume);
|
|
815
|
-
console.log(`[IMA] Set IMA manager volume to ${adVolume}`);
|
|
816
796
|
} catch (error) {
|
|
817
|
-
console.warn("[
|
|
797
|
+
console.warn("[DEBUG-ERROR] Failed to set IMA manager volume:", error);
|
|
818
798
|
}
|
|
819
|
-
console.log("[IMA] Starting ad playback");
|
|
820
799
|
adsManager.start();
|
|
821
800
|
return Promise.resolve();
|
|
822
801
|
} catch (error) {
|
|
823
|
-
console.error("[
|
|
802
|
+
console.error("[DEBUG-ERROR] \u274C Error starting ad:", error);
|
|
824
803
|
adPlaying = false;
|
|
825
804
|
setAdPlayingFlag(false);
|
|
826
805
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
@@ -832,7 +811,7 @@ function createImaController(video, options) {
|
|
|
832
811
|
},
|
|
833
812
|
async stop() {
|
|
834
813
|
var _a;
|
|
835
|
-
console.log("[
|
|
814
|
+
console.log("[DEBUG-FLOW] \u23F9\uFE0F stop() - Stopping ad playback");
|
|
836
815
|
adPlaying = false;
|
|
837
816
|
setAdPlayingFlag(false);
|
|
838
817
|
if (adContainerEl) {
|
|
@@ -842,7 +821,7 @@ function createImaController(video, options) {
|
|
|
842
821
|
if (adContainerEl) {
|
|
843
822
|
adContainerEl.style.pointerEvents = "none";
|
|
844
823
|
adContainerEl.style.display = "none";
|
|
845
|
-
console.log("[
|
|
824
|
+
console.log("[DEBUG-LAYER] \u26AB Ad container HIDDEN (stop)");
|
|
846
825
|
}
|
|
847
826
|
}, 300);
|
|
848
827
|
}
|
|
@@ -913,7 +892,7 @@ function createImaController(video, options) {
|
|
|
913
892
|
updateOriginalMutedState(muted, volume) {
|
|
914
893
|
const nextVolume = typeof volume === "number" && !Number.isNaN(volume) ? Math.max(0, Math.min(1, volume)) : originalVolume;
|
|
915
894
|
console.log(
|
|
916
|
-
`[
|
|
895
|
+
`[DEBUG-AUDIO] \u{1F4BE} Saved original state | muted: ${originalMutedState}->${muted}, volume: ${originalVolume}->${nextVolume}`
|
|
917
896
|
);
|
|
918
897
|
originalMutedState = muted;
|
|
919
898
|
originalVolume = nextVolume;
|
|
@@ -930,14 +909,14 @@ function createImaController(video, options) {
|
|
|
930
909
|
adVideoElement.volume = clampedVolume;
|
|
931
910
|
adVideoElement.muted = clampedVolume === 0;
|
|
932
911
|
console.log(
|
|
933
|
-
`[
|
|
912
|
+
`[DEBUG-AUDIO] \u{1F50A} Ad volume changed | volume=${clampedVolume}, muted=${clampedVolume === 0}`
|
|
934
913
|
);
|
|
935
914
|
}
|
|
936
915
|
if (adsManager && adPlaying) {
|
|
937
916
|
try {
|
|
938
917
|
adsManager.setVolume(clampedVolume);
|
|
939
918
|
} catch (error) {
|
|
940
|
-
console.warn("[
|
|
919
|
+
console.warn("[DEBUG-ERROR] Failed to set IMA manager volume:", error);
|
|
941
920
|
}
|
|
942
921
|
}
|
|
943
922
|
},
|