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
|
@@ -198,6 +198,7 @@ function getBrowserConfigOverrides() {
|
|
|
198
198
|
// src/sdk/ima.ts
|
|
199
199
|
function createImaController(video, options) {
|
|
200
200
|
let adPlaying = false;
|
|
201
|
+
let contentVideoHidden = false;
|
|
201
202
|
let originalMutedState = false;
|
|
202
203
|
let originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
203
204
|
const listeners = /* @__PURE__ */ new Map();
|
|
@@ -211,6 +212,26 @@ function createImaController(video, options) {
|
|
|
211
212
|
delete video.dataset.stormcloudAdPlaying;
|
|
212
213
|
}
|
|
213
214
|
}
|
|
215
|
+
function hideContentVideo() {
|
|
216
|
+
if (!contentVideoHidden) {
|
|
217
|
+
video.style.visibility = "hidden";
|
|
218
|
+
video.muted = true;
|
|
219
|
+
video.volume = 0;
|
|
220
|
+
contentVideoHidden = true;
|
|
221
|
+
console.log("[IMA] Content video hidden and muted");
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function showContentVideo() {
|
|
225
|
+
if (contentVideoHidden) {
|
|
226
|
+
video.style.visibility = "visible";
|
|
227
|
+
video.muted = originalMutedState;
|
|
228
|
+
video.volume = originalVolume;
|
|
229
|
+
contentVideoHidden = false;
|
|
230
|
+
console.log(
|
|
231
|
+
`[IMA] Content video restored (muted: ${originalMutedState}, volume: ${originalVolume})`
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
214
235
|
function createAdVideoElement() {
|
|
215
236
|
const adVideo = document.createElement("video");
|
|
216
237
|
adVideo.style.position = "absolute";
|
|
@@ -219,11 +240,20 @@ function createImaController(video, options) {
|
|
|
219
240
|
adVideo.style.width = "100%";
|
|
220
241
|
adVideo.style.height = "100%";
|
|
221
242
|
adVideo.style.objectFit = "contain";
|
|
222
|
-
adVideo.style.backgroundColor = "
|
|
243
|
+
adVideo.style.backgroundColor = "transparent";
|
|
223
244
|
adVideo.style.zIndex = "15";
|
|
224
245
|
adVideo.playsInline = true;
|
|
225
246
|
adVideo.muted = false;
|
|
226
247
|
adVideo.volume = originalMutedState ? 0 : originalVolume;
|
|
248
|
+
adVideo.style.opacity = "0";
|
|
249
|
+
adVideo.addEventListener(
|
|
250
|
+
"canplay",
|
|
251
|
+
() => {
|
|
252
|
+
adVideo.style.opacity = "1";
|
|
253
|
+
console.log("[IMA] Ad video ready to play");
|
|
254
|
+
},
|
|
255
|
+
{ once: true }
|
|
256
|
+
);
|
|
227
257
|
console.log(
|
|
228
258
|
`[IMA] Created dedicated ad video element with volume: ${adVideo.volume}, muted: ${adVideo.muted}`
|
|
229
259
|
);
|
|
@@ -387,6 +417,9 @@ function createImaController(video, options) {
|
|
|
387
417
|
}
|
|
388
418
|
adsManager = void 0;
|
|
389
419
|
}
|
|
420
|
+
if (adVideoElement) {
|
|
421
|
+
adVideoElement.style.opacity = "0";
|
|
422
|
+
}
|
|
390
423
|
}
|
|
391
424
|
return {
|
|
392
425
|
initialize() {
|
|
@@ -537,11 +570,8 @@ function createImaController(video, options) {
|
|
|
537
570
|
console.error("[IMA] Ad error:", errorEvent.getError());
|
|
538
571
|
destroyAdsManager();
|
|
539
572
|
adPlaying = false;
|
|
540
|
-
|
|
573
|
+
showContentVideo();
|
|
541
574
|
setAdPlayingFlag(false);
|
|
542
|
-
console.log(
|
|
543
|
-
"[IMA] Restored main video visibility after ad error"
|
|
544
|
-
);
|
|
545
575
|
if (adContainerEl) {
|
|
546
576
|
adContainerEl.style.pointerEvents = "none";
|
|
547
577
|
adContainerEl.style.display = "none";
|
|
@@ -583,29 +613,24 @@ function createImaController(video, options) {
|
|
|
583
613
|
adsManager.addEventListener(
|
|
584
614
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
585
615
|
() => {
|
|
586
|
-
console.log(
|
|
587
|
-
"[IMA] Content pause requested - hiding main video, showing ad video"
|
|
588
|
-
);
|
|
616
|
+
console.log("[IMA] Content pause requested");
|
|
589
617
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
590
618
|
video.pause();
|
|
591
619
|
console.log("[IMA] Content video paused (VOD mode)");
|
|
592
620
|
} else {
|
|
593
621
|
console.log(
|
|
594
|
-
"[IMA] Content video continues
|
|
622
|
+
"[IMA] Content video continues in background (Live mode)"
|
|
595
623
|
);
|
|
596
624
|
}
|
|
597
|
-
video.style.visibility = "hidden";
|
|
598
625
|
adPlaying = true;
|
|
599
626
|
setAdPlayingFlag(true);
|
|
600
627
|
emit("content_pause");
|
|
601
628
|
}
|
|
602
629
|
);
|
|
603
630
|
adsManager.addEventListener(AdEvent.STARTED, () => {
|
|
604
|
-
console.log(
|
|
605
|
-
"[IMA] Ad started playing - showing dedicated ad video"
|
|
606
|
-
);
|
|
631
|
+
console.log("[IMA] Ad started - showing ad video");
|
|
607
632
|
setAdPlayingFlag(true);
|
|
608
|
-
|
|
633
|
+
hideContentVideo();
|
|
609
634
|
if (adVideoElement) {
|
|
610
635
|
adVideoElement.volume = originalMutedState ? 0 : originalVolume;
|
|
611
636
|
adVideoElement.muted = originalMutedState;
|
|
@@ -616,40 +641,34 @@ function createImaController(video, options) {
|
|
|
616
641
|
if (adContainerEl) {
|
|
617
642
|
adContainerEl.style.pointerEvents = "auto";
|
|
618
643
|
adContainerEl.style.display = "flex";
|
|
619
|
-
console.log(
|
|
620
|
-
"[IMA] Ad container visible with dedicated ad video"
|
|
621
|
-
);
|
|
644
|
+
console.log("[IMA] Ad container now visible");
|
|
622
645
|
}
|
|
623
646
|
});
|
|
624
647
|
adsManager.addEventListener(
|
|
625
648
|
AdEvent.CONTENT_RESUME_REQUESTED,
|
|
626
649
|
() => {
|
|
627
|
-
console.log(
|
|
628
|
-
"[IMA] Content resume requested - showing main video"
|
|
629
|
-
);
|
|
650
|
+
console.log("[IMA] Content resume requested");
|
|
630
651
|
adPlaying = false;
|
|
631
652
|
setAdPlayingFlag(false);
|
|
632
|
-
video.style.visibility = "visible";
|
|
633
653
|
emit("content_resume");
|
|
634
|
-
setTimeout(() => {
|
|
635
|
-
const stillInPod = video.dataset.stormcloudAdPlaying === "true";
|
|
636
|
-
if (stillInPod) {
|
|
637
|
-
console.log(
|
|
638
|
-
"[IMA] Still in ad pod - keeping ad video visible"
|
|
639
|
-
);
|
|
640
|
-
if (adContainerEl) {
|
|
641
|
-
adContainerEl.style.display = "flex";
|
|
642
|
-
adContainerEl.style.pointerEvents = "auto";
|
|
643
|
-
}
|
|
644
|
-
video.style.visibility = "hidden";
|
|
645
|
-
}
|
|
646
|
-
}, 50);
|
|
647
654
|
}
|
|
648
655
|
);
|
|
649
656
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
650
|
-
console.log("[IMA] All ads completed -
|
|
657
|
+
console.log("[IMA] All ads completed - restoring content");
|
|
651
658
|
adPlaying = false;
|
|
652
659
|
setAdPlayingFlag(false);
|
|
660
|
+
showContentVideo();
|
|
661
|
+
if (adContainerEl) {
|
|
662
|
+
adContainerEl.style.pointerEvents = "none";
|
|
663
|
+
adContainerEl.style.display = "none";
|
|
664
|
+
console.log("[IMA] Ad container hidden");
|
|
665
|
+
}
|
|
666
|
+
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds) && video.paused) {
|
|
667
|
+
console.log("[IMA] Resuming content video playback");
|
|
668
|
+
video.play().catch((e) => {
|
|
669
|
+
console.warn("[IMA] Failed to resume content video:", e);
|
|
670
|
+
});
|
|
671
|
+
}
|
|
653
672
|
emit("all_ads_completed");
|
|
654
673
|
});
|
|
655
674
|
console.log("[IMA] Ads manager event listeners attached");
|
|
@@ -661,7 +680,7 @@ function createImaController(video, options) {
|
|
|
661
680
|
} catch (e) {
|
|
662
681
|
console.error("[IMA] Error setting up ads manager:", e);
|
|
663
682
|
adPlaying = false;
|
|
664
|
-
|
|
683
|
+
showContentVideo();
|
|
665
684
|
setAdPlayingFlag(false);
|
|
666
685
|
if (adContainerEl) {
|
|
667
686
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -692,11 +711,8 @@ function createImaController(video, options) {
|
|
|
692
711
|
(adErrorEvent) => {
|
|
693
712
|
console.error("[IMA] Ads loader error:", adErrorEvent.getError());
|
|
694
713
|
adPlaying = false;
|
|
695
|
-
|
|
714
|
+
showContentVideo();
|
|
696
715
|
setAdPlayingFlag(false);
|
|
697
|
-
console.log(
|
|
698
|
-
"[IMA] Restored main video visibility after loader error"
|
|
699
|
-
);
|
|
700
716
|
if (adContainerEl) {
|
|
701
717
|
adContainerEl.style.pointerEvents = "none";
|
|
702
718
|
adContainerEl.style.display = "none";
|
|
@@ -807,7 +823,7 @@ function createImaController(video, options) {
|
|
|
807
823
|
console.log("[IMA] Stopping ad playback");
|
|
808
824
|
adPlaying = false;
|
|
809
825
|
setAdPlayingFlag(false);
|
|
810
|
-
|
|
826
|
+
showContentVideo();
|
|
811
827
|
if (adContainerEl) {
|
|
812
828
|
adContainerEl.style.pointerEvents = "none";
|
|
813
829
|
adContainerEl.style.display = "none";
|
|
@@ -823,7 +839,7 @@ function createImaController(video, options) {
|
|
|
823
839
|
var _a;
|
|
824
840
|
destroyAdsManager();
|
|
825
841
|
adPlaying = false;
|
|
826
|
-
|
|
842
|
+
showContentVideo();
|
|
827
843
|
setAdPlayingFlag(false);
|
|
828
844
|
if (adContainerEl) {
|
|
829
845
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -840,6 +856,7 @@ function createImaController(video, options) {
|
|
|
840
856
|
adDisplayContainer = void 0;
|
|
841
857
|
adsLoader = void 0;
|
|
842
858
|
adVideoElement = void 0;
|
|
859
|
+
contentVideoHidden = false;
|
|
843
860
|
preloadedVast.clear();
|
|
844
861
|
preloadingVast.clear();
|
|
845
862
|
},
|