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