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