stormcloud-video-player 0.2.28 → 0.2.30
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 +59 -42
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +59 -42
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +59 -42
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +59 -42
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +59 -42
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/ima.cjs +59 -42
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +59 -42
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -201,6 +201,7 @@ function getBrowserConfigOverrides() {
|
|
|
201
201
|
// src/sdk/ima.ts
|
|
202
202
|
function createImaController(video, options) {
|
|
203
203
|
let adPlaying = false;
|
|
204
|
+
let contentVideoHidden = false;
|
|
204
205
|
let originalMutedState = false;
|
|
205
206
|
let originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
206
207
|
const listeners = /* @__PURE__ */ new Map();
|
|
@@ -214,6 +215,26 @@ function createImaController(video, options) {
|
|
|
214
215
|
delete video.dataset.stormcloudAdPlaying;
|
|
215
216
|
}
|
|
216
217
|
}
|
|
218
|
+
function hideContentVideo() {
|
|
219
|
+
if (!contentVideoHidden) {
|
|
220
|
+
video.style.visibility = "hidden";
|
|
221
|
+
video.muted = true;
|
|
222
|
+
video.volume = 0;
|
|
223
|
+
contentVideoHidden = true;
|
|
224
|
+
console.log("[IMA] Content video hidden and muted");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function showContentVideo() {
|
|
228
|
+
if (contentVideoHidden) {
|
|
229
|
+
video.style.visibility = "visible";
|
|
230
|
+
video.muted = originalMutedState;
|
|
231
|
+
video.volume = originalVolume;
|
|
232
|
+
contentVideoHidden = false;
|
|
233
|
+
console.log(
|
|
234
|
+
`[IMA] Content video restored (muted: ${originalMutedState}, volume: ${originalVolume})`
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
217
238
|
function createAdVideoElement() {
|
|
218
239
|
const adVideo = document.createElement("video");
|
|
219
240
|
adVideo.style.position = "absolute";
|
|
@@ -222,11 +243,20 @@ function createImaController(video, options) {
|
|
|
222
243
|
adVideo.style.width = "100%";
|
|
223
244
|
adVideo.style.height = "100%";
|
|
224
245
|
adVideo.style.objectFit = "contain";
|
|
225
|
-
adVideo.style.backgroundColor = "
|
|
246
|
+
adVideo.style.backgroundColor = "transparent";
|
|
226
247
|
adVideo.style.zIndex = "15";
|
|
227
248
|
adVideo.playsInline = true;
|
|
228
249
|
adVideo.muted = false;
|
|
229
250
|
adVideo.volume = originalMutedState ? 0 : originalVolume;
|
|
251
|
+
adVideo.style.opacity = "0";
|
|
252
|
+
adVideo.addEventListener(
|
|
253
|
+
"canplay",
|
|
254
|
+
() => {
|
|
255
|
+
adVideo.style.opacity = "1";
|
|
256
|
+
console.log("[IMA] Ad video ready to play");
|
|
257
|
+
},
|
|
258
|
+
{ once: true }
|
|
259
|
+
);
|
|
230
260
|
console.log(
|
|
231
261
|
`[IMA] Created dedicated ad video element with volume: ${adVideo.volume}, muted: ${adVideo.muted}`
|
|
232
262
|
);
|
|
@@ -390,6 +420,9 @@ function createImaController(video, options) {
|
|
|
390
420
|
}
|
|
391
421
|
adsManager = void 0;
|
|
392
422
|
}
|
|
423
|
+
if (adVideoElement) {
|
|
424
|
+
adVideoElement.style.opacity = "0";
|
|
425
|
+
}
|
|
393
426
|
}
|
|
394
427
|
return {
|
|
395
428
|
initialize() {
|
|
@@ -540,11 +573,8 @@ function createImaController(video, options) {
|
|
|
540
573
|
console.error("[IMA] Ad error:", errorEvent.getError());
|
|
541
574
|
destroyAdsManager();
|
|
542
575
|
adPlaying = false;
|
|
543
|
-
|
|
576
|
+
showContentVideo();
|
|
544
577
|
setAdPlayingFlag(false);
|
|
545
|
-
console.log(
|
|
546
|
-
"[IMA] Restored main video visibility after ad error"
|
|
547
|
-
);
|
|
548
578
|
if (adContainerEl) {
|
|
549
579
|
adContainerEl.style.pointerEvents = "none";
|
|
550
580
|
adContainerEl.style.display = "none";
|
|
@@ -586,29 +616,24 @@ function createImaController(video, options) {
|
|
|
586
616
|
adsManager.addEventListener(
|
|
587
617
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
588
618
|
() => {
|
|
589
|
-
console.log(
|
|
590
|
-
"[IMA] Content pause requested - hiding main video, showing ad video"
|
|
591
|
-
);
|
|
619
|
+
console.log("[IMA] Content pause requested");
|
|
592
620
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
593
621
|
video.pause();
|
|
594
622
|
console.log("[IMA] Content video paused (VOD mode)");
|
|
595
623
|
} else {
|
|
596
624
|
console.log(
|
|
597
|
-
"[IMA] Content video continues
|
|
625
|
+
"[IMA] Content video continues in background (Live mode)"
|
|
598
626
|
);
|
|
599
627
|
}
|
|
600
|
-
video.style.visibility = "hidden";
|
|
601
628
|
adPlaying = true;
|
|
602
629
|
setAdPlayingFlag(true);
|
|
603
630
|
emit("content_pause");
|
|
604
631
|
}
|
|
605
632
|
);
|
|
606
633
|
adsManager.addEventListener(AdEvent.STARTED, () => {
|
|
607
|
-
console.log(
|
|
608
|
-
"[IMA] Ad started playing - showing dedicated ad video"
|
|
609
|
-
);
|
|
634
|
+
console.log("[IMA] Ad started - showing ad video");
|
|
610
635
|
setAdPlayingFlag(true);
|
|
611
|
-
|
|
636
|
+
hideContentVideo();
|
|
612
637
|
if (adVideoElement) {
|
|
613
638
|
adVideoElement.volume = originalMutedState ? 0 : originalVolume;
|
|
614
639
|
adVideoElement.muted = originalMutedState;
|
|
@@ -619,40 +644,34 @@ function createImaController(video, options) {
|
|
|
619
644
|
if (adContainerEl) {
|
|
620
645
|
adContainerEl.style.pointerEvents = "auto";
|
|
621
646
|
adContainerEl.style.display = "flex";
|
|
622
|
-
console.log(
|
|
623
|
-
"[IMA] Ad container visible with dedicated ad video"
|
|
624
|
-
);
|
|
647
|
+
console.log("[IMA] Ad container now visible");
|
|
625
648
|
}
|
|
626
649
|
});
|
|
627
650
|
adsManager.addEventListener(
|
|
628
651
|
AdEvent.CONTENT_RESUME_REQUESTED,
|
|
629
652
|
() => {
|
|
630
|
-
console.log(
|
|
631
|
-
"[IMA] Content resume requested - showing main video"
|
|
632
|
-
);
|
|
653
|
+
console.log("[IMA] Content resume requested");
|
|
633
654
|
adPlaying = false;
|
|
634
655
|
setAdPlayingFlag(false);
|
|
635
|
-
video.style.visibility = "visible";
|
|
636
656
|
emit("content_resume");
|
|
637
|
-
setTimeout(() => {
|
|
638
|
-
const stillInPod = video.dataset.stormcloudAdPlaying === "true";
|
|
639
|
-
if (stillInPod) {
|
|
640
|
-
console.log(
|
|
641
|
-
"[IMA] Still in ad pod - keeping ad video visible"
|
|
642
|
-
);
|
|
643
|
-
if (adContainerEl) {
|
|
644
|
-
adContainerEl.style.display = "flex";
|
|
645
|
-
adContainerEl.style.pointerEvents = "auto";
|
|
646
|
-
}
|
|
647
|
-
video.style.visibility = "hidden";
|
|
648
|
-
}
|
|
649
|
-
}, 50);
|
|
650
657
|
}
|
|
651
658
|
);
|
|
652
659
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
653
|
-
console.log("[IMA] All ads completed -
|
|
660
|
+
console.log("[IMA] All ads completed - restoring content");
|
|
654
661
|
adPlaying = false;
|
|
655
662
|
setAdPlayingFlag(false);
|
|
663
|
+
showContentVideo();
|
|
664
|
+
if (adContainerEl) {
|
|
665
|
+
adContainerEl.style.pointerEvents = "none";
|
|
666
|
+
adContainerEl.style.display = "none";
|
|
667
|
+
console.log("[IMA] Ad container hidden");
|
|
668
|
+
}
|
|
669
|
+
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds) && video.paused) {
|
|
670
|
+
console.log("[IMA] Resuming content video playback");
|
|
671
|
+
video.play().catch((e) => {
|
|
672
|
+
console.warn("[IMA] Failed to resume content video:", e);
|
|
673
|
+
});
|
|
674
|
+
}
|
|
656
675
|
emit("all_ads_completed");
|
|
657
676
|
});
|
|
658
677
|
console.log("[IMA] Ads manager event listeners attached");
|
|
@@ -664,7 +683,7 @@ function createImaController(video, options) {
|
|
|
664
683
|
} catch (e) {
|
|
665
684
|
console.error("[IMA] Error setting up ads manager:", e);
|
|
666
685
|
adPlaying = false;
|
|
667
|
-
|
|
686
|
+
showContentVideo();
|
|
668
687
|
setAdPlayingFlag(false);
|
|
669
688
|
if (adContainerEl) {
|
|
670
689
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -695,11 +714,8 @@ function createImaController(video, options) {
|
|
|
695
714
|
(adErrorEvent) => {
|
|
696
715
|
console.error("[IMA] Ads loader error:", adErrorEvent.getError());
|
|
697
716
|
adPlaying = false;
|
|
698
|
-
|
|
717
|
+
showContentVideo();
|
|
699
718
|
setAdPlayingFlag(false);
|
|
700
|
-
console.log(
|
|
701
|
-
"[IMA] Restored main video visibility after loader error"
|
|
702
|
-
);
|
|
703
719
|
if (adContainerEl) {
|
|
704
720
|
adContainerEl.style.pointerEvents = "none";
|
|
705
721
|
adContainerEl.style.display = "none";
|
|
@@ -810,7 +826,7 @@ function createImaController(video, options) {
|
|
|
810
826
|
console.log("[IMA] Stopping ad playback");
|
|
811
827
|
adPlaying = false;
|
|
812
828
|
setAdPlayingFlag(false);
|
|
813
|
-
|
|
829
|
+
showContentVideo();
|
|
814
830
|
if (adContainerEl) {
|
|
815
831
|
adContainerEl.style.pointerEvents = "none";
|
|
816
832
|
adContainerEl.style.display = "none";
|
|
@@ -826,7 +842,7 @@ function createImaController(video, options) {
|
|
|
826
842
|
var _a;
|
|
827
843
|
destroyAdsManager();
|
|
828
844
|
adPlaying = false;
|
|
829
|
-
|
|
845
|
+
showContentVideo();
|
|
830
846
|
setAdPlayingFlag(false);
|
|
831
847
|
if (adContainerEl) {
|
|
832
848
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -843,6 +859,7 @@ function createImaController(video, options) {
|
|
|
843
859
|
adDisplayContainer = void 0;
|
|
844
860
|
adsLoader = void 0;
|
|
845
861
|
adVideoElement = void 0;
|
|
862
|
+
contentVideoHidden = false;
|
|
846
863
|
preloadedVast.clear();
|
|
847
864
|
preloadingVast.clear();
|
|
848
865
|
},
|