stormcloud-video-player 0.2.33 → 0.2.35
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 +2 -2
- package/lib/index.cjs +186 -357
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +8 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +186 -357
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +186 -357
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +8 -0
- package/lib/players/HlsPlayer.cjs +186 -357
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +186 -357
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/ima.cjs +33 -149
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +186 -357
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/sdk/ima.cjs
CHANGED
|
@@ -185,7 +185,7 @@ function createImaController(video, options) {
|
|
|
185
185
|
video.muted = true;
|
|
186
186
|
video.volume = 0;
|
|
187
187
|
contentVideoHidden = true;
|
|
188
|
-
console.log("[
|
|
188
|
+
console.log("[DEBUG-LAYER] \u{1F534} Content video HIDDEN | muted=true, volume=0");
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
function showContentVideo() {
|
|
@@ -198,7 +198,7 @@ function createImaController(video, options) {
|
|
|
198
198
|
video.volume = originalVolume;
|
|
199
199
|
contentVideoHidden = false;
|
|
200
200
|
console.log(
|
|
201
|
-
`[
|
|
201
|
+
`[DEBUG-LAYER] \u{1F7E2} Content video RESTORED | muted=${originalMutedState}, volume=${originalVolume}`
|
|
202
202
|
);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
@@ -220,12 +220,12 @@ function createImaController(video, options) {
|
|
|
220
220
|
"canplay",
|
|
221
221
|
() => {
|
|
222
222
|
adVideo.style.opacity = "1";
|
|
223
|
-
console.log("[
|
|
223
|
+
console.log("[DEBUG-LAYER] \u{1F4FA} Ad video element ready (canplay fired)");
|
|
224
224
|
},
|
|
225
225
|
{ once: true }
|
|
226
226
|
);
|
|
227
227
|
console.log(
|
|
228
|
-
`[
|
|
228
|
+
`[DEBUG-AUDIO] \u{1F50A} Ad video created | volume=${adVideo.volume}, muted=${adVideo.muted}`
|
|
229
229
|
);
|
|
230
230
|
return adVideo;
|
|
231
231
|
}
|
|
@@ -311,17 +311,12 @@ function createImaController(video, options) {
|
|
|
311
311
|
let adsLoadedResolve;
|
|
312
312
|
let adsLoadedReject;
|
|
313
313
|
function makeAdsRequest(google, vastTagUrl) {
|
|
314
|
-
console.log("[IMA] \u{1F4CB} === makeAdsRequest() - Building IMA request ===");
|
|
315
314
|
const adsRequest = new google.ima.AdsRequest();
|
|
316
315
|
const preloadedResponse = preloadedVast.get(vastTagUrl);
|
|
317
316
|
if (preloadedResponse) {
|
|
318
317
|
adsRequest.adsResponse = preloadedResponse;
|
|
319
|
-
console.log(
|
|
320
|
-
"[IMA] \u26A1 Using preloaded VAST response for immediate ad request"
|
|
321
|
-
);
|
|
322
318
|
} else {
|
|
323
319
|
adsRequest.adTagUrl = vastTagUrl;
|
|
324
|
-
console.log("[IMA] \u{1F310} Will fetch VAST from URL:", vastTagUrl);
|
|
325
320
|
}
|
|
326
321
|
const videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
327
322
|
const videoHeight = video.offsetHeight || video.clientHeight || 360;
|
|
@@ -333,7 +328,6 @@ function createImaController(video, options) {
|
|
|
333
328
|
try {
|
|
334
329
|
const willAutoPlay = !video.paused || video.autoplay;
|
|
335
330
|
adsRequest.setAdWillAutoPlay(willAutoPlay);
|
|
336
|
-
console.log(`[IMA] Ad will autoplay: ${willAutoPlay}`);
|
|
337
331
|
} catch (error) {
|
|
338
332
|
console.warn("[IMA] Failed to call setAdWillAutoPlay:", error);
|
|
339
333
|
}
|
|
@@ -342,17 +336,12 @@ function createImaController(video, options) {
|
|
|
342
336
|
try {
|
|
343
337
|
const willPlayMuted = video.muted || video.volume === 0;
|
|
344
338
|
adsRequest.setAdWillPlayMuted(willPlayMuted);
|
|
345
|
-
console.log(`[IMA] Ad will play muted: ${willPlayMuted}`);
|
|
346
339
|
} catch (error) {
|
|
347
340
|
console.warn("[IMA] Failed to call setAdWillPlayMuted:", error);
|
|
348
341
|
}
|
|
349
342
|
}
|
|
350
343
|
adsRequest.vastLoadTimeout = 5e3;
|
|
351
|
-
console.log(`[IMA] \u{1F4D0} Ads request dimensions: ${videoWidth}x${videoHeight}`);
|
|
352
|
-
console.log("[IMA] \u23F1\uFE0F VAST load timeout: 5000ms");
|
|
353
|
-
console.log("[IMA] \u{1F680} Calling adsLoader.requestAds()...");
|
|
354
344
|
adsLoader.requestAds(adsRequest);
|
|
355
|
-
console.log("[IMA] \u23F3 Waiting for ADS_MANAGER_LOADED or AD_ERROR event...");
|
|
356
345
|
if (preloadedResponse) {
|
|
357
346
|
preloadedVast.delete(vastTagUrl);
|
|
358
347
|
}
|
|
@@ -537,85 +526,29 @@ function createImaController(video, options) {
|
|
|
537
526
|
adsLoader.addEventListener(
|
|
538
527
|
google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
|
|
539
528
|
(evt) => {
|
|
540
|
-
console.log("[
|
|
541
|
-
console.log("[IMA] Setting up ads manager with preloading enabled");
|
|
542
|
-
console.log("[IMA] ========================================");
|
|
543
|
-
console.log("[IMA] EXPECTED EVENT FLOW:");
|
|
544
|
-
console.log("[IMA] 1. requestAds() \u2192 fetch VAST");
|
|
545
|
-
console.log("[IMA] 2. ADS_MANAGER_LOADED \u2192 ads ready");
|
|
546
|
-
console.log("[IMA] 3. play() \u2192 start playback");
|
|
547
|
-
console.log("[IMA] 4. CONTENT_PAUSE_REQUESTED \u2192 show ad layer \u2728");
|
|
548
|
-
console.log("[IMA] 5. STARTED \u2192 ad is playing");
|
|
549
|
-
console.log("[IMA] 6. CONTENT_RESUME_REQUESTED \u2192 ad done");
|
|
550
|
-
console.log("[IMA] 7. ALL_ADS_COMPLETED \u2192 hide ad layer");
|
|
551
|
-
console.log("[IMA] ========================================");
|
|
529
|
+
console.log("[DEBUG-FLOW] \u2705 ADS_MANAGER_LOADED - Setting up manager");
|
|
552
530
|
try {
|
|
553
531
|
const adsRenderingSettings = new google.ima.AdsRenderingSettings();
|
|
554
532
|
adsRenderingSettings.enablePreloading = true;
|
|
555
533
|
adsManager = evt.getAdsManager(video, adsRenderingSettings);
|
|
556
534
|
const AdEvent = google.ima.AdEvent.Type;
|
|
557
535
|
const AdErrorEvent = google.ima.AdErrorEvent.Type;
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const allAdEvents = [
|
|
561
|
-
"AD_BREAK_READY",
|
|
562
|
-
"AD_METADATA",
|
|
563
|
-
"ALL_ADS_COMPLETED",
|
|
564
|
-
"CLICK",
|
|
565
|
-
"COMPLETE",
|
|
566
|
-
"CONTENT_PAUSE_REQUESTED",
|
|
567
|
-
"CONTENT_RESUME_REQUESTED",
|
|
568
|
-
"DURATION_CHANGE",
|
|
569
|
-
"FIRST_QUARTILE",
|
|
570
|
-
"IMPRESSION",
|
|
571
|
-
"INTERACTION",
|
|
572
|
-
"LINEAR_CHANGED",
|
|
573
|
-
"LOADED",
|
|
574
|
-
"LOG",
|
|
575
|
-
"MIDPOINT",
|
|
576
|
-
"PAUSED",
|
|
577
|
-
"RESUMED",
|
|
578
|
-
"SKIPPABLE_STATE_CHANGED",
|
|
579
|
-
"SKIPPED",
|
|
580
|
-
"STARTED",
|
|
581
|
-
"THIRD_QUARTILE",
|
|
582
|
-
"USER_CLOSE",
|
|
583
|
-
"VOLUME_CHANGED",
|
|
584
|
-
"VOLUME_MUTED"
|
|
585
|
-
];
|
|
586
|
-
allAdEvents.forEach((eventType) => {
|
|
536
|
+
const keyEvents = ["STARTED", "COMPLETE", "CONTENT_PAUSE_REQUESTED", "CONTENT_RESUME_REQUESTED", "ALL_ADS_COMPLETED"];
|
|
537
|
+
keyEvents.forEach((eventType) => {
|
|
587
538
|
if (AdEvent[eventType]) {
|
|
588
539
|
adsManager.addEventListener(AdEvent[eventType], (e) => {
|
|
589
|
-
var _a, _b
|
|
540
|
+
var _a, _b;
|
|
590
541
|
const ad = (_a = e.getAd) == null ? void 0 : _a.call(e);
|
|
591
|
-
|
|
592
|
-
adId: (_b = ad.getAdId) == null ? void 0 : _b.call(ad),
|
|
593
|
-
title: (_c = ad.getTitle) == null ? void 0 : _c.call(ad),
|
|
594
|
-
duration: (_d = ad.getDuration) == null ? void 0 : _d.call(ad),
|
|
595
|
-
isLinear: (_e = ad.isLinear) == null ? void 0 : _e.call(ad),
|
|
596
|
-
contentType: (_f = ad.getContentType) == null ? void 0 : _f.call(ad)
|
|
597
|
-
} : null;
|
|
598
|
-
console.log(`[IMA EVENT] ${eventType}`, {
|
|
599
|
-
eventType,
|
|
600
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
601
|
-
adData
|
|
602
|
-
});
|
|
542
|
+
console.log(`[DEBUG-FLOW] \u{1F3AC} ${eventType} | title=${((_b = ad == null ? void 0 : ad.getTitle) == null ? void 0 : _b.call(ad)) || "N/A"}`);
|
|
603
543
|
});
|
|
604
544
|
}
|
|
605
545
|
});
|
|
606
|
-
console.log("[IMA] ========== EVENT LISTENERS ATTACHED ==========");
|
|
607
546
|
adsManager.addEventListener(
|
|
608
547
|
AdErrorEvent.AD_ERROR,
|
|
609
548
|
(errorEvent) => {
|
|
610
|
-
var _a, _b
|
|
549
|
+
var _a, _b;
|
|
611
550
|
const error = errorEvent.getError();
|
|
612
|
-
console.error("[
|
|
613
|
-
message: (_a = error.getMessage) == null ? void 0 : _a.call(error),
|
|
614
|
-
errorCode: (_b = error.getErrorCode) == null ? void 0 : _b.call(error),
|
|
615
|
-
type: (_c = error.getType) == null ? void 0 : _c.call(error),
|
|
616
|
-
vastErrorCode: (_d = error.getVastErrorCode) == null ? void 0 : _d.call(error),
|
|
617
|
-
innerError: (_e = error.getInnerError) == null ? void 0 : _e.call(error)
|
|
618
|
-
});
|
|
551
|
+
console.error("[DEBUG-ERROR] \u274C AD_ERROR:", (_a = error.getMessage) == null ? void 0 : _a.call(error));
|
|
619
552
|
destroyAdsManager();
|
|
620
553
|
adPlaying = false;
|
|
621
554
|
setAdPlayingFlag(false);
|
|
@@ -626,7 +559,7 @@ function createImaController(video, options) {
|
|
|
626
559
|
if (adContainerEl) {
|
|
627
560
|
adContainerEl.style.pointerEvents = "none";
|
|
628
561
|
adContainerEl.style.display = "none";
|
|
629
|
-
console.log("[
|
|
562
|
+
console.log("[DEBUG-LAYER] \u274C Ad container HIDDEN (error)");
|
|
630
563
|
}
|
|
631
564
|
}, 300);
|
|
632
565
|
}
|
|
@@ -638,9 +571,6 @@ function createImaController(video, options) {
|
|
|
638
571
|
}
|
|
639
572
|
if (lastAdTagUrl && retryAttempts < maxRetries) {
|
|
640
573
|
const delay = backoffBaseMs * Math.pow(2, retryAttempts++);
|
|
641
|
-
console.log(
|
|
642
|
-
`[IMA] Retrying ad request in ${delay}ms (attempt ${retryAttempts})`
|
|
643
|
-
);
|
|
644
574
|
window.setTimeout(() => {
|
|
645
575
|
try {
|
|
646
576
|
makeAdsRequest(google, lastAdTagUrl);
|
|
@@ -648,16 +578,10 @@ function createImaController(video, options) {
|
|
|
648
578
|
}
|
|
649
579
|
}, delay);
|
|
650
580
|
} else {
|
|
651
|
-
console.log(
|
|
652
|
-
"[IMA] Max retries reached, emitting ad_error"
|
|
653
|
-
);
|
|
654
581
|
emit("ad_error");
|
|
655
582
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
656
583
|
if (video.paused) {
|
|
657
|
-
|
|
658
|
-
"[IMA] Resuming paused video after ad error"
|
|
659
|
-
);
|
|
660
|
-
(_f = video.play()) == null ? void 0 : _f.catch(() => {
|
|
584
|
+
(_b = video.play()) == null ? void 0 : _b.catch(() => {
|
|
661
585
|
});
|
|
662
586
|
}
|
|
663
587
|
}
|
|
@@ -667,15 +591,9 @@ function createImaController(video, options) {
|
|
|
667
591
|
adsManager.addEventListener(
|
|
668
592
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
669
593
|
() => {
|
|
670
|
-
console.log("[
|
|
671
|
-
console.log("[IMA] This is the event that triggers the ad layer to appear");
|
|
594
|
+
console.log("[DEBUG-FLOW] \u{1F3AF} CONTENT_PAUSE_REQUESTED - Ad starting");
|
|
672
595
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
673
596
|
video.pause();
|
|
674
|
-
console.log("[IMA] Content video paused (VOD mode)");
|
|
675
|
-
} else {
|
|
676
|
-
console.log(
|
|
677
|
-
"[IMA] Content video continues in background (Live mode)"
|
|
678
|
-
);
|
|
679
597
|
}
|
|
680
598
|
hideContentVideo();
|
|
681
599
|
if (adContainerEl) {
|
|
@@ -684,23 +602,22 @@ function createImaController(video, options) {
|
|
|
684
602
|
adContainerEl.style.backgroundColor = "#000";
|
|
685
603
|
adContainerEl.offsetHeight;
|
|
686
604
|
adContainerEl.style.opacity = "1";
|
|
687
|
-
console.log("[
|
|
605
|
+
console.log("[DEBUG-LAYER] \u{1F7E1} Ad container VISIBLE");
|
|
688
606
|
}
|
|
689
607
|
adPlaying = true;
|
|
690
608
|
setAdPlayingFlag(true);
|
|
691
|
-
console.log("[IMA] Emitting 'content_pause' event to player");
|
|
692
609
|
emit("content_pause");
|
|
693
610
|
}
|
|
694
611
|
);
|
|
695
612
|
adsManager.addEventListener(AdEvent.STARTED, () => {
|
|
696
|
-
console.log("[
|
|
613
|
+
console.log("[DEBUG-FLOW] \u25B6\uFE0F STARTED - Ad playing now");
|
|
697
614
|
setAdPlayingFlag(true);
|
|
698
615
|
hideContentVideo();
|
|
699
616
|
if (adVideoElement) {
|
|
700
617
|
adVideoElement.volume = originalMutedState ? 0 : originalVolume;
|
|
701
618
|
adVideoElement.muted = originalMutedState;
|
|
702
619
|
console.log(
|
|
703
|
-
`[
|
|
620
|
+
`[DEBUG-AUDIO] \u{1F50A} Ad audio set | volume=${adVideoElement.volume}, muted=${adVideoElement.muted}`
|
|
704
621
|
);
|
|
705
622
|
}
|
|
706
623
|
if (adContainerEl) {
|
|
@@ -709,21 +626,20 @@ function createImaController(video, options) {
|
|
|
709
626
|
adContainerEl.style.backgroundColor = "#000";
|
|
710
627
|
adContainerEl.offsetHeight;
|
|
711
628
|
adContainerEl.style.opacity = "1";
|
|
712
|
-
console.log("[IMA] Ad container now visible (STARTED event)");
|
|
713
629
|
}
|
|
714
630
|
});
|
|
715
631
|
adsManager.addEventListener(
|
|
716
632
|
AdEvent.CONTENT_RESUME_REQUESTED,
|
|
717
633
|
() => {
|
|
718
|
-
console.log("[
|
|
634
|
+
console.log("[DEBUG-FLOW] \u23F8\uFE0F CONTENT_RESUME - Single ad done");
|
|
719
635
|
adPlaying = false;
|
|
720
636
|
setAdPlayingFlag(false);
|
|
721
|
-
console.log("[
|
|
637
|
+
console.log("[DEBUG-LAYER] \u26A0\uFE0F Waiting for pod manager (more ads, placeholder, or done)");
|
|
722
638
|
emit("content_resume");
|
|
723
639
|
}
|
|
724
640
|
);
|
|
725
641
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
726
|
-
console.log("[
|
|
642
|
+
console.log("[DEBUG-FLOW] \u{1F3C1} ALL_ADS_COMPLETED - Pod finished");
|
|
727
643
|
adPlaying = false;
|
|
728
644
|
setAdPlayingFlag(false);
|
|
729
645
|
if (adContainerEl) {
|
|
@@ -733,18 +649,16 @@ function createImaController(video, options) {
|
|
|
733
649
|
if (adContainerEl) {
|
|
734
650
|
adContainerEl.style.pointerEvents = "none";
|
|
735
651
|
adContainerEl.style.display = "none";
|
|
736
|
-
console.log("[
|
|
652
|
+
console.log("[DEBUG-LAYER] \u26AB Ad container HIDDEN (pod done)");
|
|
737
653
|
}
|
|
738
654
|
}, 300);
|
|
739
655
|
}
|
|
740
656
|
showContentVideo();
|
|
741
657
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds) && video.paused) {
|
|
742
|
-
console.log("[IMA] Resuming content video playback");
|
|
743
658
|
video.play().catch((e) => {
|
|
744
|
-
console.warn("[
|
|
659
|
+
console.warn("[DEBUG-ERROR] Failed to resume video:", e);
|
|
745
660
|
});
|
|
746
661
|
}
|
|
747
|
-
console.log("[IMA] Emitting 'all_ads_completed' event to player");
|
|
748
662
|
emit("all_ads_completed");
|
|
749
663
|
});
|
|
750
664
|
console.log("[IMA] Ads manager event listeners attached");
|
|
@@ -764,18 +678,12 @@ function createImaController(video, options) {
|
|
|
764
678
|
if (adContainerEl) {
|
|
765
679
|
adContainerEl.style.pointerEvents = "none";
|
|
766
680
|
adContainerEl.style.display = "none";
|
|
767
|
-
console.log(
|
|
768
|
-
"[IMA] Ad container hidden after setup error"
|
|
769
|
-
);
|
|
770
681
|
}
|
|
771
682
|
}, 300);
|
|
772
683
|
}
|
|
773
684
|
showContentVideo();
|
|
774
685
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
775
686
|
if (video.paused) {
|
|
776
|
-
console.log(
|
|
777
|
-
"[IMA] Resuming paused video after setup error"
|
|
778
|
-
);
|
|
779
687
|
video.play().catch(() => {
|
|
780
688
|
});
|
|
781
689
|
}
|
|
@@ -793,17 +701,9 @@ function createImaController(video, options) {
|
|
|
793
701
|
adsLoader.addEventListener(
|
|
794
702
|
google.ima.AdErrorEvent.Type.AD_ERROR,
|
|
795
703
|
(adErrorEvent) => {
|
|
796
|
-
var _a
|
|
704
|
+
var _a;
|
|
797
705
|
const error = adErrorEvent.getError();
|
|
798
|
-
console.error("[
|
|
799
|
-
message: (_a = error.getMessage) == null ? void 0 : _a.call(error),
|
|
800
|
-
errorCode: (_b = error.getErrorCode) == null ? void 0 : _b.call(error),
|
|
801
|
-
type: (_c = error.getType) == null ? void 0 : _c.call(error),
|
|
802
|
-
vastErrorCode: (_d = error.getVastErrorCode) == null ? void 0 : _d.call(error)
|
|
803
|
-
});
|
|
804
|
-
console.error("[IMA] This means the ad server didn't return valid ads");
|
|
805
|
-
console.error("[IMA] Ad layer will NOT appear (no flicker)");
|
|
806
|
-
console.error("[IMA] Full error object:", adErrorEvent.getError());
|
|
706
|
+
console.error("[DEBUG-ERROR] \u274C ADS_LOADER ERROR:", (_a = error.getMessage) == null ? void 0 : _a.call(error));
|
|
807
707
|
adPlaying = false;
|
|
808
708
|
setAdPlayingFlag(false);
|
|
809
709
|
if (adContainerEl) {
|
|
@@ -813,14 +713,12 @@ function createImaController(video, options) {
|
|
|
813
713
|
if (adContainerEl) {
|
|
814
714
|
adContainerEl.style.pointerEvents = "none";
|
|
815
715
|
adContainerEl.style.display = "none";
|
|
816
|
-
console.log("[IMA] Ad container hidden after loader error");
|
|
817
716
|
}
|
|
818
717
|
}, 300);
|
|
819
718
|
}
|
|
820
719
|
showContentVideo();
|
|
821
720
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
822
721
|
if (video.paused) {
|
|
823
|
-
console.log("[IMA] Resuming paused video after loader error");
|
|
824
722
|
video.play().catch(() => {
|
|
825
723
|
});
|
|
826
724
|
}
|
|
@@ -835,10 +733,7 @@ function createImaController(video, options) {
|
|
|
835
733
|
false
|
|
836
734
|
);
|
|
837
735
|
}
|
|
838
|
-
console.log("[IMA] \u{1F680} Making ads request to IMA SDK");
|
|
839
|
-
console.log("[IMA] Waiting for IMA SDK response (LOADED or ERROR event)...");
|
|
840
736
|
makeAdsRequest(google, vastTagUrl);
|
|
841
|
-
console.log("[IMA] \u23F3 Returning promise that will resolve when ads are loaded");
|
|
842
737
|
return adsLoadedPromise;
|
|
843
738
|
} catch (error) {
|
|
844
739
|
console.error("[IMA] Failed to request ads:", error);
|
|
@@ -876,23 +771,16 @@ function createImaController(video, options) {
|
|
|
876
771
|
},
|
|
877
772
|
async play() {
|
|
878
773
|
var _a, _b;
|
|
879
|
-
console.log("[
|
|
880
|
-
console.log("[IMA] This initializes and starts the ad");
|
|
881
|
-
console.log("[IMA] Ad layer will appear when CONTENT_PAUSE_REQUESTED fires");
|
|
774
|
+
console.log("[DEBUG-FLOW] \u25B6\uFE0F play() - Starting ad playback");
|
|
882
775
|
if (!((_a = window.google) == null ? void 0 : _a.ima) || !adDisplayContainer) {
|
|
883
|
-
console.warn(
|
|
884
|
-
"[IMA] \u274C Cannot play ad: IMA SDK or ad container not available"
|
|
885
|
-
);
|
|
886
776
|
return Promise.reject(new Error("IMA SDK not available"));
|
|
887
777
|
}
|
|
888
778
|
if (!adsManager) {
|
|
889
|
-
console.warn("[IMA] \u274C Cannot play ad: No ads manager available");
|
|
890
779
|
return Promise.reject(new Error("No ads manager"));
|
|
891
780
|
}
|
|
892
781
|
try {
|
|
893
782
|
const width = video.clientWidth || 640;
|
|
894
783
|
const height = video.clientHeight || 360;
|
|
895
|
-
console.log(`[IMA] \u{1F3AC} Initializing ads manager (${width}x${height})`);
|
|
896
784
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
897
785
|
adPlaying = true;
|
|
898
786
|
const adVolume = originalMutedState ? 0 : originalVolume;
|
|
@@ -900,22 +788,18 @@ function createImaController(video, options) {
|
|
|
900
788
|
adVideoElement.volume = adVolume;
|
|
901
789
|
adVideoElement.muted = originalMutedState;
|
|
902
790
|
console.log(
|
|
903
|
-
`[
|
|
791
|
+
`[DEBUG-AUDIO] \u{1F50A} Pre-start ad audio | volume=${adVolume}, muted=${originalMutedState}`
|
|
904
792
|
);
|
|
905
793
|
}
|
|
906
794
|
try {
|
|
907
795
|
adsManager.setVolume(adVolume);
|
|
908
|
-
console.log(`[IMA] Set IMA manager volume to ${adVolume}`);
|
|
909
796
|
} catch (error) {
|
|
910
|
-
console.warn("[
|
|
797
|
+
console.warn("[DEBUG-ERROR] Failed to set IMA manager volume:", error);
|
|
911
798
|
}
|
|
912
|
-
console.log("[IMA] \u{1F3AF} Calling adsManager.start()");
|
|
913
|
-
console.log("[IMA] If successful, IMA will fire CONTENT_PAUSE_REQUESTED");
|
|
914
799
|
adsManager.start();
|
|
915
|
-
console.log("[IMA] \u2705 play() completed successfully");
|
|
916
800
|
return Promise.resolve();
|
|
917
801
|
} catch (error) {
|
|
918
|
-
console.error("[
|
|
802
|
+
console.error("[DEBUG-ERROR] \u274C Error starting ad:", error);
|
|
919
803
|
adPlaying = false;
|
|
920
804
|
setAdPlayingFlag(false);
|
|
921
805
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
@@ -927,7 +811,7 @@ function createImaController(video, options) {
|
|
|
927
811
|
},
|
|
928
812
|
async stop() {
|
|
929
813
|
var _a;
|
|
930
|
-
console.log("[
|
|
814
|
+
console.log("[DEBUG-FLOW] \u23F9\uFE0F stop() - Stopping ad playback");
|
|
931
815
|
adPlaying = false;
|
|
932
816
|
setAdPlayingFlag(false);
|
|
933
817
|
if (adContainerEl) {
|
|
@@ -937,7 +821,7 @@ function createImaController(video, options) {
|
|
|
937
821
|
if (adContainerEl) {
|
|
938
822
|
adContainerEl.style.pointerEvents = "none";
|
|
939
823
|
adContainerEl.style.display = "none";
|
|
940
|
-
console.log("[
|
|
824
|
+
console.log("[DEBUG-LAYER] \u26AB Ad container HIDDEN (stop)");
|
|
941
825
|
}
|
|
942
826
|
}, 300);
|
|
943
827
|
}
|
|
@@ -1008,7 +892,7 @@ function createImaController(video, options) {
|
|
|
1008
892
|
updateOriginalMutedState(muted, volume) {
|
|
1009
893
|
const nextVolume = typeof volume === "number" && !Number.isNaN(volume) ? Math.max(0, Math.min(1, volume)) : originalVolume;
|
|
1010
894
|
console.log(
|
|
1011
|
-
`[
|
|
895
|
+
`[DEBUG-AUDIO] \u{1F4BE} Saved original state | muted: ${originalMutedState}->${muted}, volume: ${originalVolume}->${nextVolume}`
|
|
1012
896
|
);
|
|
1013
897
|
originalMutedState = muted;
|
|
1014
898
|
originalVolume = nextVolume;
|
|
@@ -1025,14 +909,14 @@ function createImaController(video, options) {
|
|
|
1025
909
|
adVideoElement.volume = clampedVolume;
|
|
1026
910
|
adVideoElement.muted = clampedVolume === 0;
|
|
1027
911
|
console.log(
|
|
1028
|
-
`[
|
|
912
|
+
`[DEBUG-AUDIO] \u{1F50A} Ad volume changed | volume=${clampedVolume}, muted=${clampedVolume === 0}`
|
|
1029
913
|
);
|
|
1030
914
|
}
|
|
1031
915
|
if (adsManager && adPlaying) {
|
|
1032
916
|
try {
|
|
1033
917
|
adsManager.setVolume(clampedVolume);
|
|
1034
918
|
} catch (error) {
|
|
1035
|
-
console.warn("[
|
|
919
|
+
console.warn("[DEBUG-ERROR] Failed to set IMA manager volume:", error);
|
|
1036
920
|
}
|
|
1037
921
|
}
|
|
1038
922
|
},
|