stormcloud-video-player 0.2.27 → 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 +119 -41
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +119 -41
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +119 -41
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +119 -41
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +119 -41
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/ima.cjs +119 -36
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +119 -41
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/players/index.cjs
CHANGED
|
@@ -240,11 +240,13 @@ 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();
|
|
246
247
|
const preloadedVast = /* @__PURE__ */ new Map();
|
|
247
248
|
const preloadingVast = /* @__PURE__ */ new Map();
|
|
249
|
+
let adVideoElement;
|
|
248
250
|
function setAdPlayingFlag(isPlaying) {
|
|
249
251
|
if (isPlaying) {
|
|
250
252
|
video.dataset.stormcloudAdPlaying = "true";
|
|
@@ -252,6 +254,53 @@ function createImaController(video, options) {
|
|
|
252
254
|
delete video.dataset.stormcloudAdPlaying;
|
|
253
255
|
}
|
|
254
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
|
+
}
|
|
277
|
+
function createAdVideoElement() {
|
|
278
|
+
const adVideo = document.createElement("video");
|
|
279
|
+
adVideo.style.position = "absolute";
|
|
280
|
+
adVideo.style.top = "0";
|
|
281
|
+
adVideo.style.left = "0";
|
|
282
|
+
adVideo.style.width = "100%";
|
|
283
|
+
adVideo.style.height = "100%";
|
|
284
|
+
adVideo.style.objectFit = "contain";
|
|
285
|
+
adVideo.style.backgroundColor = "transparent";
|
|
286
|
+
adVideo.style.zIndex = "15";
|
|
287
|
+
adVideo.playsInline = true;
|
|
288
|
+
adVideo.muted = false;
|
|
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
|
+
);
|
|
299
|
+
console.log(
|
|
300
|
+
`[IMA] Created dedicated ad video element with volume: ${adVideo.volume}, muted: ${adVideo.muted}`
|
|
301
|
+
);
|
|
302
|
+
return adVideo;
|
|
303
|
+
}
|
|
255
304
|
function emit(event, payload) {
|
|
256
305
|
const set = listeners.get(event);
|
|
257
306
|
if (!set) return;
|
|
@@ -410,6 +459,9 @@ function createImaController(video, options) {
|
|
|
410
459
|
}
|
|
411
460
|
adsManager = void 0;
|
|
412
461
|
}
|
|
462
|
+
if (adVideoElement) {
|
|
463
|
+
adVideoElement.style.opacity = "0";
|
|
464
|
+
}
|
|
413
465
|
}
|
|
414
466
|
return {
|
|
415
467
|
initialize() {
|
|
@@ -418,12 +470,22 @@ function createImaController(video, options) {
|
|
|
418
470
|
const google = window.google;
|
|
419
471
|
ensurePlaceholderContainer();
|
|
420
472
|
if (!adDisplayContainer && adContainerEl) {
|
|
473
|
+
if (!adVideoElement) {
|
|
474
|
+
adVideoElement = createAdVideoElement();
|
|
475
|
+
adContainerEl.appendChild(adVideoElement);
|
|
476
|
+
console.log(
|
|
477
|
+
"[IMA] Dedicated ad video element added to container"
|
|
478
|
+
);
|
|
479
|
+
}
|
|
421
480
|
adDisplayContainer = new google.ima.AdDisplayContainer(
|
|
422
481
|
adContainerEl,
|
|
423
|
-
|
|
482
|
+
adVideoElement
|
|
424
483
|
);
|
|
425
484
|
try {
|
|
426
485
|
(_a = adDisplayContainer.initialize) == null ? void 0 : _a.call(adDisplayContainer);
|
|
486
|
+
console.log(
|
|
487
|
+
"[IMA] AdDisplayContainer initialized with dedicated ad video"
|
|
488
|
+
);
|
|
427
489
|
} catch {
|
|
428
490
|
}
|
|
429
491
|
}
|
|
@@ -492,13 +554,22 @@ function createImaController(video, options) {
|
|
|
492
554
|
}
|
|
493
555
|
video.parentElement.appendChild(container);
|
|
494
556
|
adContainerEl = container;
|
|
557
|
+
if (!adVideoElement) {
|
|
558
|
+
adVideoElement = createAdVideoElement();
|
|
559
|
+
adContainerEl.appendChild(adVideoElement);
|
|
560
|
+
console.log(
|
|
561
|
+
"[IMA] Dedicated ad video element created and added to container"
|
|
562
|
+
);
|
|
563
|
+
}
|
|
495
564
|
adDisplayContainer = new google.ima.AdDisplayContainer(
|
|
496
565
|
container,
|
|
497
|
-
|
|
566
|
+
adVideoElement
|
|
498
567
|
);
|
|
499
568
|
try {
|
|
500
569
|
adDisplayContainer.initialize();
|
|
501
|
-
console.log(
|
|
570
|
+
console.log(
|
|
571
|
+
"[IMA] Ad display container initialized with dedicated ad video"
|
|
572
|
+
);
|
|
502
573
|
} catch (error) {
|
|
503
574
|
console.warn(
|
|
504
575
|
"[IMA] Failed to initialize ad display container:",
|
|
@@ -541,12 +612,8 @@ function createImaController(video, options) {
|
|
|
541
612
|
console.error("[IMA] Ad error:", errorEvent.getError());
|
|
542
613
|
destroyAdsManager();
|
|
543
614
|
adPlaying = false;
|
|
544
|
-
|
|
545
|
-
video.muted = originalMutedState;
|
|
615
|
+
showContentVideo();
|
|
546
616
|
setAdPlayingFlag(false);
|
|
547
|
-
console.log(
|
|
548
|
-
`[IMA] Restored mute state after ad error: ${previousMutedState} -> ${originalMutedState}`
|
|
549
|
-
);
|
|
550
617
|
if (adContainerEl) {
|
|
551
618
|
adContainerEl.style.pointerEvents = "none";
|
|
552
619
|
adContainerEl.style.display = "none";
|
|
@@ -588,37 +655,35 @@ function createImaController(video, options) {
|
|
|
588
655
|
adsManager.addEventListener(
|
|
589
656
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
590
657
|
() => {
|
|
591
|
-
console.log(
|
|
592
|
-
"[IMA] Content pause requested - FORCE MUTING main video"
|
|
593
|
-
);
|
|
658
|
+
console.log("[IMA] Content pause requested");
|
|
594
659
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
595
660
|
video.pause();
|
|
596
|
-
console.log("[IMA]
|
|
661
|
+
console.log("[IMA] Content video paused (VOD mode)");
|
|
597
662
|
} else {
|
|
598
663
|
console.log(
|
|
599
|
-
"[IMA]
|
|
664
|
+
"[IMA] Content video continues in background (Live mode)"
|
|
600
665
|
);
|
|
601
666
|
}
|
|
602
|
-
video.muted = true;
|
|
603
|
-
video.volume = 0;
|
|
604
667
|
adPlaying = true;
|
|
605
668
|
setAdPlayingFlag(true);
|
|
606
669
|
emit("content_pause");
|
|
607
670
|
}
|
|
608
671
|
);
|
|
609
672
|
adsManager.addEventListener(AdEvent.STARTED, () => {
|
|
610
|
-
console.log(
|
|
611
|
-
"[IMA] Ad started playing - FORCE MUTING main video"
|
|
612
|
-
);
|
|
673
|
+
console.log("[IMA] Ad started - showing ad video");
|
|
613
674
|
setAdPlayingFlag(true);
|
|
614
|
-
|
|
615
|
-
|
|
675
|
+
hideContentVideo();
|
|
676
|
+
if (adVideoElement) {
|
|
677
|
+
adVideoElement.volume = originalMutedState ? 0 : originalVolume;
|
|
678
|
+
adVideoElement.muted = originalMutedState;
|
|
679
|
+
console.log(
|
|
680
|
+
`[IMA] Ad video volume: ${adVideoElement.volume}, muted: ${adVideoElement.muted}`
|
|
681
|
+
);
|
|
682
|
+
}
|
|
616
683
|
if (adContainerEl) {
|
|
617
684
|
adContainerEl.style.pointerEvents = "auto";
|
|
618
685
|
adContainerEl.style.display = "flex";
|
|
619
|
-
console.log(
|
|
620
|
-
"[IMA] Ad container visibility set to flex with pointer events enabled"
|
|
621
|
-
);
|
|
686
|
+
console.log("[IMA] Ad container now visible");
|
|
622
687
|
}
|
|
623
688
|
});
|
|
624
689
|
adsManager.addEventListener(
|
|
@@ -627,17 +692,19 @@ function createImaController(video, options) {
|
|
|
627
692
|
console.log("[IMA] Content resume requested");
|
|
628
693
|
adPlaying = false;
|
|
629
694
|
setAdPlayingFlag(false);
|
|
695
|
+
showContentVideo();
|
|
630
696
|
emit("content_resume");
|
|
631
697
|
setTimeout(() => {
|
|
632
698
|
const stillInPod = video.dataset.stormcloudAdPlaying === "true";
|
|
633
699
|
if (stillInPod) {
|
|
634
700
|
console.log(
|
|
635
|
-
"[IMA] Still in ad pod - keeping ad container visible
|
|
701
|
+
"[IMA] Still in ad pod - keeping ad container visible"
|
|
636
702
|
);
|
|
637
703
|
if (adContainerEl) {
|
|
638
704
|
adContainerEl.style.display = "flex";
|
|
639
705
|
adContainerEl.style.pointerEvents = "auto";
|
|
640
706
|
}
|
|
707
|
+
hideContentVideo();
|
|
641
708
|
}
|
|
642
709
|
}, 50);
|
|
643
710
|
}
|
|
@@ -657,7 +724,7 @@ function createImaController(video, options) {
|
|
|
657
724
|
} catch (e) {
|
|
658
725
|
console.error("[IMA] Error setting up ads manager:", e);
|
|
659
726
|
adPlaying = false;
|
|
660
|
-
|
|
727
|
+
showContentVideo();
|
|
661
728
|
setAdPlayingFlag(false);
|
|
662
729
|
if (adContainerEl) {
|
|
663
730
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -688,12 +755,8 @@ function createImaController(video, options) {
|
|
|
688
755
|
(adErrorEvent) => {
|
|
689
756
|
console.error("[IMA] Ads loader error:", adErrorEvent.getError());
|
|
690
757
|
adPlaying = false;
|
|
691
|
-
|
|
692
|
-
video.muted = originalMutedState;
|
|
758
|
+
showContentVideo();
|
|
693
759
|
setAdPlayingFlag(false);
|
|
694
|
-
console.log(
|
|
695
|
-
`[IMA] Restored mute state: ${previousMutedState} -> ${originalMutedState}`
|
|
696
|
-
);
|
|
697
760
|
if (adContainerEl) {
|
|
698
761
|
adContainerEl.style.pointerEvents = "none";
|
|
699
762
|
adContainerEl.style.display = "none";
|
|
@@ -772,11 +835,18 @@ function createImaController(video, options) {
|
|
|
772
835
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
773
836
|
adPlaying = true;
|
|
774
837
|
const adVolume = originalMutedState ? 0 : originalVolume;
|
|
838
|
+
if (adVideoElement) {
|
|
839
|
+
adVideoElement.volume = adVolume;
|
|
840
|
+
adVideoElement.muted = originalMutedState;
|
|
841
|
+
console.log(
|
|
842
|
+
`[IMA] Set dedicated ad video volume to ${adVolume}, muted: ${originalMutedState}`
|
|
843
|
+
);
|
|
844
|
+
}
|
|
775
845
|
try {
|
|
776
846
|
adsManager.setVolume(adVolume);
|
|
777
|
-
console.log(`[IMA] Set
|
|
847
|
+
console.log(`[IMA] Set IMA manager volume to ${adVolume}`);
|
|
778
848
|
} catch (error) {
|
|
779
|
-
console.warn("[IMA] Failed to set
|
|
849
|
+
console.warn("[IMA] Failed to set IMA manager volume:", error);
|
|
780
850
|
}
|
|
781
851
|
console.log("[IMA] Starting ad playback");
|
|
782
852
|
adsManager.start();
|
|
@@ -797,6 +867,7 @@ function createImaController(video, options) {
|
|
|
797
867
|
console.log("[IMA] Stopping ad playback");
|
|
798
868
|
adPlaying = false;
|
|
799
869
|
setAdPlayingFlag(false);
|
|
870
|
+
showContentVideo();
|
|
800
871
|
if (adContainerEl) {
|
|
801
872
|
adContainerEl.style.pointerEvents = "none";
|
|
802
873
|
adContainerEl.style.display = "none";
|
|
@@ -812,8 +883,7 @@ function createImaController(video, options) {
|
|
|
812
883
|
var _a;
|
|
813
884
|
destroyAdsManager();
|
|
814
885
|
adPlaying = false;
|
|
815
|
-
|
|
816
|
-
video.volume = originalVolume;
|
|
886
|
+
showContentVideo();
|
|
817
887
|
setAdPlayingFlag(false);
|
|
818
888
|
if (adContainerEl) {
|
|
819
889
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -829,6 +899,8 @@ function createImaController(video, options) {
|
|
|
829
899
|
adContainerEl = void 0;
|
|
830
900
|
adDisplayContainer = void 0;
|
|
831
901
|
adsLoader = void 0;
|
|
902
|
+
adVideoElement = void 0;
|
|
903
|
+
contentVideoHidden = false;
|
|
832
904
|
preloadedVast.clear();
|
|
833
905
|
preloadingVast.clear();
|
|
834
906
|
},
|
|
@@ -873,15 +945,26 @@ function createImaController(video, options) {
|
|
|
873
945
|
return originalVolume;
|
|
874
946
|
},
|
|
875
947
|
setAdVolume(volume) {
|
|
948
|
+
const clampedVolume = Math.max(0, Math.min(1, volume));
|
|
949
|
+
if (adVideoElement && adPlaying) {
|
|
950
|
+
adVideoElement.volume = clampedVolume;
|
|
951
|
+
adVideoElement.muted = clampedVolume === 0;
|
|
952
|
+
console.log(
|
|
953
|
+
`[IMA] Set dedicated ad video volume to ${clampedVolume}, muted: ${clampedVolume === 0}`
|
|
954
|
+
);
|
|
955
|
+
}
|
|
876
956
|
if (adsManager && adPlaying) {
|
|
877
957
|
try {
|
|
878
|
-
adsManager.setVolume(
|
|
958
|
+
adsManager.setVolume(clampedVolume);
|
|
879
959
|
} catch (error) {
|
|
880
|
-
console.warn("[IMA] Failed to set
|
|
960
|
+
console.warn("[IMA] Failed to set IMA manager volume:", error);
|
|
881
961
|
}
|
|
882
962
|
}
|
|
883
963
|
},
|
|
884
964
|
getAdVolume() {
|
|
965
|
+
if (adVideoElement && adPlaying) {
|
|
966
|
+
return adVideoElement.volume;
|
|
967
|
+
}
|
|
885
968
|
if (adsManager && adPlaying) {
|
|
886
969
|
try {
|
|
887
970
|
return adsManager.getVolume();
|
|
@@ -3498,11 +3581,6 @@ var StormcloudVideoPlayer = class {
|
|
|
3498
3581
|
}
|
|
3499
3582
|
return false;
|
|
3500
3583
|
}
|
|
3501
|
-
if (this.config.debugAdTiming) {
|
|
3502
|
-
console.log(
|
|
3503
|
-
`[StormcloudVideoPlayer] isMuted() no ad playing: video.muted=${this.video.muted}`
|
|
3504
|
-
);
|
|
3505
|
-
}
|
|
3506
3584
|
return this.video.muted;
|
|
3507
3585
|
}
|
|
3508
3586
|
setMuted(muted) {
|