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
|
@@ -201,11 +201,13 @@ 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();
|
|
207
208
|
const preloadedVast = /* @__PURE__ */ new Map();
|
|
208
209
|
const preloadingVast = /* @__PURE__ */ new Map();
|
|
210
|
+
let adVideoElement;
|
|
209
211
|
function setAdPlayingFlag(isPlaying) {
|
|
210
212
|
if (isPlaying) {
|
|
211
213
|
video.dataset.stormcloudAdPlaying = "true";
|
|
@@ -213,6 +215,53 @@ function createImaController(video, options) {
|
|
|
213
215
|
delete video.dataset.stormcloudAdPlaying;
|
|
214
216
|
}
|
|
215
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
|
+
}
|
|
238
|
+
function createAdVideoElement() {
|
|
239
|
+
const adVideo = document.createElement("video");
|
|
240
|
+
adVideo.style.position = "absolute";
|
|
241
|
+
adVideo.style.top = "0";
|
|
242
|
+
adVideo.style.left = "0";
|
|
243
|
+
adVideo.style.width = "100%";
|
|
244
|
+
adVideo.style.height = "100%";
|
|
245
|
+
adVideo.style.objectFit = "contain";
|
|
246
|
+
adVideo.style.backgroundColor = "transparent";
|
|
247
|
+
adVideo.style.zIndex = "15";
|
|
248
|
+
adVideo.playsInline = true;
|
|
249
|
+
adVideo.muted = false;
|
|
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
|
+
);
|
|
260
|
+
console.log(
|
|
261
|
+
`[IMA] Created dedicated ad video element with volume: ${adVideo.volume}, muted: ${adVideo.muted}`
|
|
262
|
+
);
|
|
263
|
+
return adVideo;
|
|
264
|
+
}
|
|
216
265
|
function emit(event, payload) {
|
|
217
266
|
const set = listeners.get(event);
|
|
218
267
|
if (!set) return;
|
|
@@ -371,6 +420,9 @@ function createImaController(video, options) {
|
|
|
371
420
|
}
|
|
372
421
|
adsManager = void 0;
|
|
373
422
|
}
|
|
423
|
+
if (adVideoElement) {
|
|
424
|
+
adVideoElement.style.opacity = "0";
|
|
425
|
+
}
|
|
374
426
|
}
|
|
375
427
|
return {
|
|
376
428
|
initialize() {
|
|
@@ -379,12 +431,22 @@ function createImaController(video, options) {
|
|
|
379
431
|
const google = window.google;
|
|
380
432
|
ensurePlaceholderContainer();
|
|
381
433
|
if (!adDisplayContainer && adContainerEl) {
|
|
434
|
+
if (!adVideoElement) {
|
|
435
|
+
adVideoElement = createAdVideoElement();
|
|
436
|
+
adContainerEl.appendChild(adVideoElement);
|
|
437
|
+
console.log(
|
|
438
|
+
"[IMA] Dedicated ad video element added to container"
|
|
439
|
+
);
|
|
440
|
+
}
|
|
382
441
|
adDisplayContainer = new google.ima.AdDisplayContainer(
|
|
383
442
|
adContainerEl,
|
|
384
|
-
|
|
443
|
+
adVideoElement
|
|
385
444
|
);
|
|
386
445
|
try {
|
|
387
446
|
(_a = adDisplayContainer.initialize) == null ? void 0 : _a.call(adDisplayContainer);
|
|
447
|
+
console.log(
|
|
448
|
+
"[IMA] AdDisplayContainer initialized with dedicated ad video"
|
|
449
|
+
);
|
|
388
450
|
} catch {
|
|
389
451
|
}
|
|
390
452
|
}
|
|
@@ -453,13 +515,22 @@ function createImaController(video, options) {
|
|
|
453
515
|
}
|
|
454
516
|
video.parentElement.appendChild(container);
|
|
455
517
|
adContainerEl = container;
|
|
518
|
+
if (!adVideoElement) {
|
|
519
|
+
adVideoElement = createAdVideoElement();
|
|
520
|
+
adContainerEl.appendChild(adVideoElement);
|
|
521
|
+
console.log(
|
|
522
|
+
"[IMA] Dedicated ad video element created and added to container"
|
|
523
|
+
);
|
|
524
|
+
}
|
|
456
525
|
adDisplayContainer = new google.ima.AdDisplayContainer(
|
|
457
526
|
container,
|
|
458
|
-
|
|
527
|
+
adVideoElement
|
|
459
528
|
);
|
|
460
529
|
try {
|
|
461
530
|
adDisplayContainer.initialize();
|
|
462
|
-
console.log(
|
|
531
|
+
console.log(
|
|
532
|
+
"[IMA] Ad display container initialized with dedicated ad video"
|
|
533
|
+
);
|
|
463
534
|
} catch (error) {
|
|
464
535
|
console.warn(
|
|
465
536
|
"[IMA] Failed to initialize ad display container:",
|
|
@@ -502,12 +573,8 @@ function createImaController(video, options) {
|
|
|
502
573
|
console.error("[IMA] Ad error:", errorEvent.getError());
|
|
503
574
|
destroyAdsManager();
|
|
504
575
|
adPlaying = false;
|
|
505
|
-
|
|
506
|
-
video.muted = originalMutedState;
|
|
576
|
+
showContentVideo();
|
|
507
577
|
setAdPlayingFlag(false);
|
|
508
|
-
console.log(
|
|
509
|
-
`[IMA] Restored mute state after ad error: ${previousMutedState} -> ${originalMutedState}`
|
|
510
|
-
);
|
|
511
578
|
if (adContainerEl) {
|
|
512
579
|
adContainerEl.style.pointerEvents = "none";
|
|
513
580
|
adContainerEl.style.display = "none";
|
|
@@ -549,37 +616,35 @@ function createImaController(video, options) {
|
|
|
549
616
|
adsManager.addEventListener(
|
|
550
617
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
551
618
|
() => {
|
|
552
|
-
console.log(
|
|
553
|
-
"[IMA] Content pause requested - FORCE MUTING main video"
|
|
554
|
-
);
|
|
619
|
+
console.log("[IMA] Content pause requested");
|
|
555
620
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
556
621
|
video.pause();
|
|
557
|
-
console.log("[IMA]
|
|
622
|
+
console.log("[IMA] Content video paused (VOD mode)");
|
|
558
623
|
} else {
|
|
559
624
|
console.log(
|
|
560
|
-
"[IMA]
|
|
625
|
+
"[IMA] Content video continues in background (Live mode)"
|
|
561
626
|
);
|
|
562
627
|
}
|
|
563
|
-
video.muted = true;
|
|
564
|
-
video.volume = 0;
|
|
565
628
|
adPlaying = true;
|
|
566
629
|
setAdPlayingFlag(true);
|
|
567
630
|
emit("content_pause");
|
|
568
631
|
}
|
|
569
632
|
);
|
|
570
633
|
adsManager.addEventListener(AdEvent.STARTED, () => {
|
|
571
|
-
console.log(
|
|
572
|
-
"[IMA] Ad started playing - FORCE MUTING main video"
|
|
573
|
-
);
|
|
634
|
+
console.log("[IMA] Ad started - showing ad video");
|
|
574
635
|
setAdPlayingFlag(true);
|
|
575
|
-
|
|
576
|
-
|
|
636
|
+
hideContentVideo();
|
|
637
|
+
if (adVideoElement) {
|
|
638
|
+
adVideoElement.volume = originalMutedState ? 0 : originalVolume;
|
|
639
|
+
adVideoElement.muted = originalMutedState;
|
|
640
|
+
console.log(
|
|
641
|
+
`[IMA] Ad video volume: ${adVideoElement.volume}, muted: ${adVideoElement.muted}`
|
|
642
|
+
);
|
|
643
|
+
}
|
|
577
644
|
if (adContainerEl) {
|
|
578
645
|
adContainerEl.style.pointerEvents = "auto";
|
|
579
646
|
adContainerEl.style.display = "flex";
|
|
580
|
-
console.log(
|
|
581
|
-
"[IMA] Ad container visibility set to flex with pointer events enabled"
|
|
582
|
-
);
|
|
647
|
+
console.log("[IMA] Ad container now visible");
|
|
583
648
|
}
|
|
584
649
|
});
|
|
585
650
|
adsManager.addEventListener(
|
|
@@ -588,17 +653,19 @@ function createImaController(video, options) {
|
|
|
588
653
|
console.log("[IMA] Content resume requested");
|
|
589
654
|
adPlaying = false;
|
|
590
655
|
setAdPlayingFlag(false);
|
|
656
|
+
showContentVideo();
|
|
591
657
|
emit("content_resume");
|
|
592
658
|
setTimeout(() => {
|
|
593
659
|
const stillInPod = video.dataset.stormcloudAdPlaying === "true";
|
|
594
660
|
if (stillInPod) {
|
|
595
661
|
console.log(
|
|
596
|
-
"[IMA] Still in ad pod - keeping ad container visible
|
|
662
|
+
"[IMA] Still in ad pod - keeping ad container visible"
|
|
597
663
|
);
|
|
598
664
|
if (adContainerEl) {
|
|
599
665
|
adContainerEl.style.display = "flex";
|
|
600
666
|
adContainerEl.style.pointerEvents = "auto";
|
|
601
667
|
}
|
|
668
|
+
hideContentVideo();
|
|
602
669
|
}
|
|
603
670
|
}, 50);
|
|
604
671
|
}
|
|
@@ -618,7 +685,7 @@ function createImaController(video, options) {
|
|
|
618
685
|
} catch (e) {
|
|
619
686
|
console.error("[IMA] Error setting up ads manager:", e);
|
|
620
687
|
adPlaying = false;
|
|
621
|
-
|
|
688
|
+
showContentVideo();
|
|
622
689
|
setAdPlayingFlag(false);
|
|
623
690
|
if (adContainerEl) {
|
|
624
691
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -649,12 +716,8 @@ function createImaController(video, options) {
|
|
|
649
716
|
(adErrorEvent) => {
|
|
650
717
|
console.error("[IMA] Ads loader error:", adErrorEvent.getError());
|
|
651
718
|
adPlaying = false;
|
|
652
|
-
|
|
653
|
-
video.muted = originalMutedState;
|
|
719
|
+
showContentVideo();
|
|
654
720
|
setAdPlayingFlag(false);
|
|
655
|
-
console.log(
|
|
656
|
-
`[IMA] Restored mute state: ${previousMutedState} -> ${originalMutedState}`
|
|
657
|
-
);
|
|
658
721
|
if (adContainerEl) {
|
|
659
722
|
adContainerEl.style.pointerEvents = "none";
|
|
660
723
|
adContainerEl.style.display = "none";
|
|
@@ -733,11 +796,18 @@ function createImaController(video, options) {
|
|
|
733
796
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
734
797
|
adPlaying = true;
|
|
735
798
|
const adVolume = originalMutedState ? 0 : originalVolume;
|
|
799
|
+
if (adVideoElement) {
|
|
800
|
+
adVideoElement.volume = adVolume;
|
|
801
|
+
adVideoElement.muted = originalMutedState;
|
|
802
|
+
console.log(
|
|
803
|
+
`[IMA] Set dedicated ad video volume to ${adVolume}, muted: ${originalMutedState}`
|
|
804
|
+
);
|
|
805
|
+
}
|
|
736
806
|
try {
|
|
737
807
|
adsManager.setVolume(adVolume);
|
|
738
|
-
console.log(`[IMA] Set
|
|
808
|
+
console.log(`[IMA] Set IMA manager volume to ${adVolume}`);
|
|
739
809
|
} catch (error) {
|
|
740
|
-
console.warn("[IMA] Failed to set
|
|
810
|
+
console.warn("[IMA] Failed to set IMA manager volume:", error);
|
|
741
811
|
}
|
|
742
812
|
console.log("[IMA] Starting ad playback");
|
|
743
813
|
adsManager.start();
|
|
@@ -758,6 +828,7 @@ function createImaController(video, options) {
|
|
|
758
828
|
console.log("[IMA] Stopping ad playback");
|
|
759
829
|
adPlaying = false;
|
|
760
830
|
setAdPlayingFlag(false);
|
|
831
|
+
showContentVideo();
|
|
761
832
|
if (adContainerEl) {
|
|
762
833
|
adContainerEl.style.pointerEvents = "none";
|
|
763
834
|
adContainerEl.style.display = "none";
|
|
@@ -773,8 +844,7 @@ function createImaController(video, options) {
|
|
|
773
844
|
var _a;
|
|
774
845
|
destroyAdsManager();
|
|
775
846
|
adPlaying = false;
|
|
776
|
-
|
|
777
|
-
video.volume = originalVolume;
|
|
847
|
+
showContentVideo();
|
|
778
848
|
setAdPlayingFlag(false);
|
|
779
849
|
if (adContainerEl) {
|
|
780
850
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -790,6 +860,8 @@ function createImaController(video, options) {
|
|
|
790
860
|
adContainerEl = void 0;
|
|
791
861
|
adDisplayContainer = void 0;
|
|
792
862
|
adsLoader = void 0;
|
|
863
|
+
adVideoElement = void 0;
|
|
864
|
+
contentVideoHidden = false;
|
|
793
865
|
preloadedVast.clear();
|
|
794
866
|
preloadingVast.clear();
|
|
795
867
|
},
|
|
@@ -834,15 +906,26 @@ function createImaController(video, options) {
|
|
|
834
906
|
return originalVolume;
|
|
835
907
|
},
|
|
836
908
|
setAdVolume(volume) {
|
|
909
|
+
const clampedVolume = Math.max(0, Math.min(1, volume));
|
|
910
|
+
if (adVideoElement && adPlaying) {
|
|
911
|
+
adVideoElement.volume = clampedVolume;
|
|
912
|
+
adVideoElement.muted = clampedVolume === 0;
|
|
913
|
+
console.log(
|
|
914
|
+
`[IMA] Set dedicated ad video volume to ${clampedVolume}, muted: ${clampedVolume === 0}`
|
|
915
|
+
);
|
|
916
|
+
}
|
|
837
917
|
if (adsManager && adPlaying) {
|
|
838
918
|
try {
|
|
839
|
-
adsManager.setVolume(
|
|
919
|
+
adsManager.setVolume(clampedVolume);
|
|
840
920
|
} catch (error) {
|
|
841
|
-
console.warn("[IMA] Failed to set
|
|
921
|
+
console.warn("[IMA] Failed to set IMA manager volume:", error);
|
|
842
922
|
}
|
|
843
923
|
}
|
|
844
924
|
},
|
|
845
925
|
getAdVolume() {
|
|
926
|
+
if (adVideoElement && adPlaying) {
|
|
927
|
+
return adVideoElement.volume;
|
|
928
|
+
}
|
|
846
929
|
if (adsManager && adPlaying) {
|
|
847
930
|
try {
|
|
848
931
|
return adsManager.getVolume();
|
|
@@ -3459,11 +3542,6 @@ var StormcloudVideoPlayer = class {
|
|
|
3459
3542
|
}
|
|
3460
3543
|
return false;
|
|
3461
3544
|
}
|
|
3462
|
-
if (this.config.debugAdTiming) {
|
|
3463
|
-
console.log(
|
|
3464
|
-
`[StormcloudVideoPlayer] isMuted() no ad playing: video.muted=${this.video.muted}`
|
|
3465
|
-
);
|
|
3466
|
-
}
|
|
3467
3545
|
return this.video.muted;
|
|
3468
3546
|
}
|
|
3469
3547
|
setMuted(muted) {
|