stormcloud-video-player 0.2.28 → 0.2.29
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 +49 -30
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +49 -30
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +49 -30
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +49 -30
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +49 -30
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/ima.cjs +49 -30
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +49 -30
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/players/index.cjs
CHANGED
|
@@ -240,6 +240,7 @@ function getBrowserConfigOverrides() {
|
|
|
240
240
|
// src/sdk/ima.ts
|
|
241
241
|
function createImaController(video, options) {
|
|
242
242
|
let adPlaying = false;
|
|
243
|
+
let contentVideoHidden = false;
|
|
243
244
|
let originalMutedState = false;
|
|
244
245
|
let originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
245
246
|
const listeners = /* @__PURE__ */ new Map();
|
|
@@ -253,6 +254,26 @@ function createImaController(video, options) {
|
|
|
253
254
|
delete video.dataset.stormcloudAdPlaying;
|
|
254
255
|
}
|
|
255
256
|
}
|
|
257
|
+
function hideContentVideo() {
|
|
258
|
+
if (!contentVideoHidden) {
|
|
259
|
+
video.style.visibility = "hidden";
|
|
260
|
+
video.muted = true;
|
|
261
|
+
video.volume = 0;
|
|
262
|
+
contentVideoHidden = true;
|
|
263
|
+
console.log("[IMA] Content video hidden and muted");
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function showContentVideo() {
|
|
267
|
+
if (contentVideoHidden) {
|
|
268
|
+
video.style.visibility = "visible";
|
|
269
|
+
video.muted = originalMutedState;
|
|
270
|
+
video.volume = originalVolume;
|
|
271
|
+
contentVideoHidden = false;
|
|
272
|
+
console.log(
|
|
273
|
+
`[IMA] Content video restored (muted: ${originalMutedState}, volume: ${originalVolume})`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
256
277
|
function createAdVideoElement() {
|
|
257
278
|
const adVideo = document.createElement("video");
|
|
258
279
|
adVideo.style.position = "absolute";
|
|
@@ -261,11 +282,20 @@ function createImaController(video, options) {
|
|
|
261
282
|
adVideo.style.width = "100%";
|
|
262
283
|
adVideo.style.height = "100%";
|
|
263
284
|
adVideo.style.objectFit = "contain";
|
|
264
|
-
adVideo.style.backgroundColor = "
|
|
285
|
+
adVideo.style.backgroundColor = "transparent";
|
|
265
286
|
adVideo.style.zIndex = "15";
|
|
266
287
|
adVideo.playsInline = true;
|
|
267
288
|
adVideo.muted = false;
|
|
268
289
|
adVideo.volume = originalMutedState ? 0 : originalVolume;
|
|
290
|
+
adVideo.style.opacity = "0";
|
|
291
|
+
adVideo.addEventListener(
|
|
292
|
+
"canplay",
|
|
293
|
+
() => {
|
|
294
|
+
adVideo.style.opacity = "1";
|
|
295
|
+
console.log("[IMA] Ad video ready to play");
|
|
296
|
+
},
|
|
297
|
+
{ once: true }
|
|
298
|
+
);
|
|
269
299
|
console.log(
|
|
270
300
|
`[IMA] Created dedicated ad video element with volume: ${adVideo.volume}, muted: ${adVideo.muted}`
|
|
271
301
|
);
|
|
@@ -429,6 +459,9 @@ function createImaController(video, options) {
|
|
|
429
459
|
}
|
|
430
460
|
adsManager = void 0;
|
|
431
461
|
}
|
|
462
|
+
if (adVideoElement) {
|
|
463
|
+
adVideoElement.style.opacity = "0";
|
|
464
|
+
}
|
|
432
465
|
}
|
|
433
466
|
return {
|
|
434
467
|
initialize() {
|
|
@@ -579,11 +612,8 @@ function createImaController(video, options) {
|
|
|
579
612
|
console.error("[IMA] Ad error:", errorEvent.getError());
|
|
580
613
|
destroyAdsManager();
|
|
581
614
|
adPlaying = false;
|
|
582
|
-
|
|
615
|
+
showContentVideo();
|
|
583
616
|
setAdPlayingFlag(false);
|
|
584
|
-
console.log(
|
|
585
|
-
"[IMA] Restored main video visibility after ad error"
|
|
586
|
-
);
|
|
587
617
|
if (adContainerEl) {
|
|
588
618
|
adContainerEl.style.pointerEvents = "none";
|
|
589
619
|
adContainerEl.style.display = "none";
|
|
@@ -625,29 +655,24 @@ function createImaController(video, options) {
|
|
|
625
655
|
adsManager.addEventListener(
|
|
626
656
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
627
657
|
() => {
|
|
628
|
-
console.log(
|
|
629
|
-
"[IMA] Content pause requested - hiding main video, showing ad video"
|
|
630
|
-
);
|
|
658
|
+
console.log("[IMA] Content pause requested");
|
|
631
659
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
632
660
|
video.pause();
|
|
633
661
|
console.log("[IMA] Content video paused (VOD mode)");
|
|
634
662
|
} else {
|
|
635
663
|
console.log(
|
|
636
|
-
"[IMA] Content video continues
|
|
664
|
+
"[IMA] Content video continues in background (Live mode)"
|
|
637
665
|
);
|
|
638
666
|
}
|
|
639
|
-
video.style.visibility = "hidden";
|
|
640
667
|
adPlaying = true;
|
|
641
668
|
setAdPlayingFlag(true);
|
|
642
669
|
emit("content_pause");
|
|
643
670
|
}
|
|
644
671
|
);
|
|
645
672
|
adsManager.addEventListener(AdEvent.STARTED, () => {
|
|
646
|
-
console.log(
|
|
647
|
-
"[IMA] Ad started playing - showing dedicated ad video"
|
|
648
|
-
);
|
|
673
|
+
console.log("[IMA] Ad started - showing ad video");
|
|
649
674
|
setAdPlayingFlag(true);
|
|
650
|
-
|
|
675
|
+
hideContentVideo();
|
|
651
676
|
if (adVideoElement) {
|
|
652
677
|
adVideoElement.volume = originalMutedState ? 0 : originalVolume;
|
|
653
678
|
adVideoElement.muted = originalMutedState;
|
|
@@ -658,32 +683,28 @@ function createImaController(video, options) {
|
|
|
658
683
|
if (adContainerEl) {
|
|
659
684
|
adContainerEl.style.pointerEvents = "auto";
|
|
660
685
|
adContainerEl.style.display = "flex";
|
|
661
|
-
console.log(
|
|
662
|
-
"[IMA] Ad container visible with dedicated ad video"
|
|
663
|
-
);
|
|
686
|
+
console.log("[IMA] Ad container now visible");
|
|
664
687
|
}
|
|
665
688
|
});
|
|
666
689
|
adsManager.addEventListener(
|
|
667
690
|
AdEvent.CONTENT_RESUME_REQUESTED,
|
|
668
691
|
() => {
|
|
669
|
-
console.log(
|
|
670
|
-
"[IMA] Content resume requested - showing main video"
|
|
671
|
-
);
|
|
692
|
+
console.log("[IMA] Content resume requested");
|
|
672
693
|
adPlaying = false;
|
|
673
694
|
setAdPlayingFlag(false);
|
|
674
|
-
|
|
695
|
+
showContentVideo();
|
|
675
696
|
emit("content_resume");
|
|
676
697
|
setTimeout(() => {
|
|
677
698
|
const stillInPod = video.dataset.stormcloudAdPlaying === "true";
|
|
678
699
|
if (stillInPod) {
|
|
679
700
|
console.log(
|
|
680
|
-
"[IMA] Still in ad pod - keeping ad
|
|
701
|
+
"[IMA] Still in ad pod - keeping ad container visible"
|
|
681
702
|
);
|
|
682
703
|
if (adContainerEl) {
|
|
683
704
|
adContainerEl.style.display = "flex";
|
|
684
705
|
adContainerEl.style.pointerEvents = "auto";
|
|
685
706
|
}
|
|
686
|
-
|
|
707
|
+
hideContentVideo();
|
|
687
708
|
}
|
|
688
709
|
}, 50);
|
|
689
710
|
}
|
|
@@ -703,7 +724,7 @@ function createImaController(video, options) {
|
|
|
703
724
|
} catch (e) {
|
|
704
725
|
console.error("[IMA] Error setting up ads manager:", e);
|
|
705
726
|
adPlaying = false;
|
|
706
|
-
|
|
727
|
+
showContentVideo();
|
|
707
728
|
setAdPlayingFlag(false);
|
|
708
729
|
if (adContainerEl) {
|
|
709
730
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -734,11 +755,8 @@ function createImaController(video, options) {
|
|
|
734
755
|
(adErrorEvent) => {
|
|
735
756
|
console.error("[IMA] Ads loader error:", adErrorEvent.getError());
|
|
736
757
|
adPlaying = false;
|
|
737
|
-
|
|
758
|
+
showContentVideo();
|
|
738
759
|
setAdPlayingFlag(false);
|
|
739
|
-
console.log(
|
|
740
|
-
"[IMA] Restored main video visibility after loader error"
|
|
741
|
-
);
|
|
742
760
|
if (adContainerEl) {
|
|
743
761
|
adContainerEl.style.pointerEvents = "none";
|
|
744
762
|
adContainerEl.style.display = "none";
|
|
@@ -849,7 +867,7 @@ function createImaController(video, options) {
|
|
|
849
867
|
console.log("[IMA] Stopping ad playback");
|
|
850
868
|
adPlaying = false;
|
|
851
869
|
setAdPlayingFlag(false);
|
|
852
|
-
|
|
870
|
+
showContentVideo();
|
|
853
871
|
if (adContainerEl) {
|
|
854
872
|
adContainerEl.style.pointerEvents = "none";
|
|
855
873
|
adContainerEl.style.display = "none";
|
|
@@ -865,7 +883,7 @@ function createImaController(video, options) {
|
|
|
865
883
|
var _a;
|
|
866
884
|
destroyAdsManager();
|
|
867
885
|
adPlaying = false;
|
|
868
|
-
|
|
886
|
+
showContentVideo();
|
|
869
887
|
setAdPlayingFlag(false);
|
|
870
888
|
if (adContainerEl) {
|
|
871
889
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -882,6 +900,7 @@ function createImaController(video, options) {
|
|
|
882
900
|
adDisplayContainer = void 0;
|
|
883
901
|
adsLoader = void 0;
|
|
884
902
|
adVideoElement = void 0;
|
|
903
|
+
contentVideoHidden = false;
|
|
885
904
|
preloadedVast.clear();
|
|
886
905
|
preloadingVast.clear();
|
|
887
906
|
},
|