stormcloud-video-player 0.2.33 → 0.2.34
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 +162 -315
- 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 +162 -315
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +162 -315
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +8 -0
- package/lib/players/HlsPlayer.cjs +162 -315
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +162 -315
- 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 +162 -315
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -225,7 +225,7 @@ function createImaController(video, options) {
|
|
|
225
225
|
video.muted = true;
|
|
226
226
|
video.volume = 0;
|
|
227
227
|
contentVideoHidden = true;
|
|
228
|
-
console.log("[
|
|
228
|
+
console.log("[DEBUG-LAYER] \u{1F534} Content video HIDDEN | muted=true, volume=0");
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
function showContentVideo() {
|
|
@@ -238,7 +238,7 @@ function createImaController(video, options) {
|
|
|
238
238
|
video.volume = originalVolume;
|
|
239
239
|
contentVideoHidden = false;
|
|
240
240
|
console.log(
|
|
241
|
-
`[
|
|
241
|
+
`[DEBUG-LAYER] \u{1F7E2} Content video RESTORED | muted=${originalMutedState}, volume=${originalVolume}`
|
|
242
242
|
);
|
|
243
243
|
}
|
|
244
244
|
}
|
|
@@ -260,12 +260,12 @@ function createImaController(video, options) {
|
|
|
260
260
|
"canplay",
|
|
261
261
|
() => {
|
|
262
262
|
adVideo.style.opacity = "1";
|
|
263
|
-
console.log("[
|
|
263
|
+
console.log("[DEBUG-LAYER] \u{1F4FA} Ad video element ready (canplay fired)");
|
|
264
264
|
},
|
|
265
265
|
{ once: true }
|
|
266
266
|
);
|
|
267
267
|
console.log(
|
|
268
|
-
`[
|
|
268
|
+
`[DEBUG-AUDIO] \u{1F50A} Ad video created | volume=${adVideo.volume}, muted=${adVideo.muted}`
|
|
269
269
|
);
|
|
270
270
|
return adVideo;
|
|
271
271
|
}
|
|
@@ -351,17 +351,12 @@ function createImaController(video, options) {
|
|
|
351
351
|
let adsLoadedResolve;
|
|
352
352
|
let adsLoadedReject;
|
|
353
353
|
function makeAdsRequest(google, vastTagUrl) {
|
|
354
|
-
console.log("[IMA] \u{1F4CB} === makeAdsRequest() - Building IMA request ===");
|
|
355
354
|
const adsRequest = new google.ima.AdsRequest();
|
|
356
355
|
const preloadedResponse = preloadedVast.get(vastTagUrl);
|
|
357
356
|
if (preloadedResponse) {
|
|
358
357
|
adsRequest.adsResponse = preloadedResponse;
|
|
359
|
-
console.log(
|
|
360
|
-
"[IMA] \u26A1 Using preloaded VAST response for immediate ad request"
|
|
361
|
-
);
|
|
362
358
|
} else {
|
|
363
359
|
adsRequest.adTagUrl = vastTagUrl;
|
|
364
|
-
console.log("[IMA] \u{1F310} Will fetch VAST from URL:", vastTagUrl);
|
|
365
360
|
}
|
|
366
361
|
const videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
367
362
|
const videoHeight = video.offsetHeight || video.clientHeight || 360;
|
|
@@ -373,7 +368,6 @@ function createImaController(video, options) {
|
|
|
373
368
|
try {
|
|
374
369
|
const willAutoPlay = !video.paused || video.autoplay;
|
|
375
370
|
adsRequest.setAdWillAutoPlay(willAutoPlay);
|
|
376
|
-
console.log(`[IMA] Ad will autoplay: ${willAutoPlay}`);
|
|
377
371
|
} catch (error) {
|
|
378
372
|
console.warn("[IMA] Failed to call setAdWillAutoPlay:", error);
|
|
379
373
|
}
|
|
@@ -382,17 +376,12 @@ function createImaController(video, options) {
|
|
|
382
376
|
try {
|
|
383
377
|
const willPlayMuted = video.muted || video.volume === 0;
|
|
384
378
|
adsRequest.setAdWillPlayMuted(willPlayMuted);
|
|
385
|
-
console.log(`[IMA] Ad will play muted: ${willPlayMuted}`);
|
|
386
379
|
} catch (error) {
|
|
387
380
|
console.warn("[IMA] Failed to call setAdWillPlayMuted:", error);
|
|
388
381
|
}
|
|
389
382
|
}
|
|
390
383
|
adsRequest.vastLoadTimeout = 5e3;
|
|
391
|
-
console.log(`[IMA] \u{1F4D0} Ads request dimensions: ${videoWidth}x${videoHeight}`);
|
|
392
|
-
console.log("[IMA] \u23F1\uFE0F VAST load timeout: 5000ms");
|
|
393
|
-
console.log("[IMA] \u{1F680} Calling adsLoader.requestAds()...");
|
|
394
384
|
adsLoader.requestAds(adsRequest);
|
|
395
|
-
console.log("[IMA] \u23F3 Waiting for ADS_MANAGER_LOADED or AD_ERROR event...");
|
|
396
385
|
if (preloadedResponse) {
|
|
397
386
|
preloadedVast.delete(vastTagUrl);
|
|
398
387
|
}
|
|
@@ -577,85 +566,29 @@ function createImaController(video, options) {
|
|
|
577
566
|
adsLoader.addEventListener(
|
|
578
567
|
google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
|
|
579
568
|
(evt) => {
|
|
580
|
-
console.log("[
|
|
581
|
-
console.log("[IMA] Setting up ads manager with preloading enabled");
|
|
582
|
-
console.log("[IMA] ========================================");
|
|
583
|
-
console.log("[IMA] EXPECTED EVENT FLOW:");
|
|
584
|
-
console.log("[IMA] 1. requestAds() \u2192 fetch VAST");
|
|
585
|
-
console.log("[IMA] 2. ADS_MANAGER_LOADED \u2192 ads ready");
|
|
586
|
-
console.log("[IMA] 3. play() \u2192 start playback");
|
|
587
|
-
console.log("[IMA] 4. CONTENT_PAUSE_REQUESTED \u2192 show ad layer \u2728");
|
|
588
|
-
console.log("[IMA] 5. STARTED \u2192 ad is playing");
|
|
589
|
-
console.log("[IMA] 6. CONTENT_RESUME_REQUESTED \u2192 ad done");
|
|
590
|
-
console.log("[IMA] 7. ALL_ADS_COMPLETED \u2192 hide ad layer");
|
|
591
|
-
console.log("[IMA] ========================================");
|
|
569
|
+
console.log("[DEBUG-FLOW] \u2705 ADS_MANAGER_LOADED - Setting up manager");
|
|
592
570
|
try {
|
|
593
571
|
const adsRenderingSettings = new google.ima.AdsRenderingSettings();
|
|
594
572
|
adsRenderingSettings.enablePreloading = true;
|
|
595
573
|
adsManager = evt.getAdsManager(video, adsRenderingSettings);
|
|
596
574
|
const AdEvent = google.ima.AdEvent.Type;
|
|
597
575
|
const AdErrorEvent = google.ima.AdErrorEvent.Type;
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
const allAdEvents = [
|
|
601
|
-
"AD_BREAK_READY",
|
|
602
|
-
"AD_METADATA",
|
|
603
|
-
"ALL_ADS_COMPLETED",
|
|
604
|
-
"CLICK",
|
|
605
|
-
"COMPLETE",
|
|
606
|
-
"CONTENT_PAUSE_REQUESTED",
|
|
607
|
-
"CONTENT_RESUME_REQUESTED",
|
|
608
|
-
"DURATION_CHANGE",
|
|
609
|
-
"FIRST_QUARTILE",
|
|
610
|
-
"IMPRESSION",
|
|
611
|
-
"INTERACTION",
|
|
612
|
-
"LINEAR_CHANGED",
|
|
613
|
-
"LOADED",
|
|
614
|
-
"LOG",
|
|
615
|
-
"MIDPOINT",
|
|
616
|
-
"PAUSED",
|
|
617
|
-
"RESUMED",
|
|
618
|
-
"SKIPPABLE_STATE_CHANGED",
|
|
619
|
-
"SKIPPED",
|
|
620
|
-
"STARTED",
|
|
621
|
-
"THIRD_QUARTILE",
|
|
622
|
-
"USER_CLOSE",
|
|
623
|
-
"VOLUME_CHANGED",
|
|
624
|
-
"VOLUME_MUTED"
|
|
625
|
-
];
|
|
626
|
-
allAdEvents.forEach((eventType) => {
|
|
576
|
+
const keyEvents = ["STARTED", "COMPLETE", "CONTENT_PAUSE_REQUESTED", "CONTENT_RESUME_REQUESTED", "ALL_ADS_COMPLETED"];
|
|
577
|
+
keyEvents.forEach((eventType) => {
|
|
627
578
|
if (AdEvent[eventType]) {
|
|
628
579
|
adsManager.addEventListener(AdEvent[eventType], (e) => {
|
|
629
|
-
var _a, _b
|
|
580
|
+
var _a, _b;
|
|
630
581
|
const ad = (_a = e.getAd) == null ? void 0 : _a.call(e);
|
|
631
|
-
|
|
632
|
-
adId: (_b = ad.getAdId) == null ? void 0 : _b.call(ad),
|
|
633
|
-
title: (_c = ad.getTitle) == null ? void 0 : _c.call(ad),
|
|
634
|
-
duration: (_d = ad.getDuration) == null ? void 0 : _d.call(ad),
|
|
635
|
-
isLinear: (_e = ad.isLinear) == null ? void 0 : _e.call(ad),
|
|
636
|
-
contentType: (_f = ad.getContentType) == null ? void 0 : _f.call(ad)
|
|
637
|
-
} : null;
|
|
638
|
-
console.log(`[IMA EVENT] ${eventType}`, {
|
|
639
|
-
eventType,
|
|
640
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
641
|
-
adData
|
|
642
|
-
});
|
|
582
|
+
console.log(`[DEBUG-FLOW] \u{1F3AC} ${eventType} | title=${((_b = ad == null ? void 0 : ad.getTitle) == null ? void 0 : _b.call(ad)) || "N/A"}`);
|
|
643
583
|
});
|
|
644
584
|
}
|
|
645
585
|
});
|
|
646
|
-
console.log("[IMA] ========== EVENT LISTENERS ATTACHED ==========");
|
|
647
586
|
adsManager.addEventListener(
|
|
648
587
|
AdErrorEvent.AD_ERROR,
|
|
649
588
|
(errorEvent) => {
|
|
650
|
-
var _a, _b
|
|
589
|
+
var _a, _b;
|
|
651
590
|
const error = errorEvent.getError();
|
|
652
|
-
console.error("[
|
|
653
|
-
message: (_a = error.getMessage) == null ? void 0 : _a.call(error),
|
|
654
|
-
errorCode: (_b = error.getErrorCode) == null ? void 0 : _b.call(error),
|
|
655
|
-
type: (_c = error.getType) == null ? void 0 : _c.call(error),
|
|
656
|
-
vastErrorCode: (_d = error.getVastErrorCode) == null ? void 0 : _d.call(error),
|
|
657
|
-
innerError: (_e = error.getInnerError) == null ? void 0 : _e.call(error)
|
|
658
|
-
});
|
|
591
|
+
console.error("[DEBUG-ERROR] \u274C AD_ERROR:", (_a = error.getMessage) == null ? void 0 : _a.call(error));
|
|
659
592
|
destroyAdsManager();
|
|
660
593
|
adPlaying = false;
|
|
661
594
|
setAdPlayingFlag(false);
|
|
@@ -666,7 +599,7 @@ function createImaController(video, options) {
|
|
|
666
599
|
if (adContainerEl) {
|
|
667
600
|
adContainerEl.style.pointerEvents = "none";
|
|
668
601
|
adContainerEl.style.display = "none";
|
|
669
|
-
console.log("[
|
|
602
|
+
console.log("[DEBUG-LAYER] \u274C Ad container HIDDEN (error)");
|
|
670
603
|
}
|
|
671
604
|
}, 300);
|
|
672
605
|
}
|
|
@@ -678,9 +611,6 @@ function createImaController(video, options) {
|
|
|
678
611
|
}
|
|
679
612
|
if (lastAdTagUrl && retryAttempts < maxRetries) {
|
|
680
613
|
const delay = backoffBaseMs * Math.pow(2, retryAttempts++);
|
|
681
|
-
console.log(
|
|
682
|
-
`[IMA] Retrying ad request in ${delay}ms (attempt ${retryAttempts})`
|
|
683
|
-
);
|
|
684
614
|
window.setTimeout(() => {
|
|
685
615
|
try {
|
|
686
616
|
makeAdsRequest(google, lastAdTagUrl);
|
|
@@ -688,16 +618,10 @@ function createImaController(video, options) {
|
|
|
688
618
|
}
|
|
689
619
|
}, delay);
|
|
690
620
|
} else {
|
|
691
|
-
console.log(
|
|
692
|
-
"[IMA] Max retries reached, emitting ad_error"
|
|
693
|
-
);
|
|
694
621
|
emit("ad_error");
|
|
695
622
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
696
623
|
if (video.paused) {
|
|
697
|
-
|
|
698
|
-
"[IMA] Resuming paused video after ad error"
|
|
699
|
-
);
|
|
700
|
-
(_f = video.play()) == null ? void 0 : _f.catch(() => {
|
|
624
|
+
(_b = video.play()) == null ? void 0 : _b.catch(() => {
|
|
701
625
|
});
|
|
702
626
|
}
|
|
703
627
|
}
|
|
@@ -707,15 +631,9 @@ function createImaController(video, options) {
|
|
|
707
631
|
adsManager.addEventListener(
|
|
708
632
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
709
633
|
() => {
|
|
710
|
-
console.log("[
|
|
711
|
-
console.log("[IMA] This is the event that triggers the ad layer to appear");
|
|
634
|
+
console.log("[DEBUG-FLOW] \u{1F3AF} CONTENT_PAUSE_REQUESTED - Ad starting");
|
|
712
635
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
713
636
|
video.pause();
|
|
714
|
-
console.log("[IMA] Content video paused (VOD mode)");
|
|
715
|
-
} else {
|
|
716
|
-
console.log(
|
|
717
|
-
"[IMA] Content video continues in background (Live mode)"
|
|
718
|
-
);
|
|
719
637
|
}
|
|
720
638
|
hideContentVideo();
|
|
721
639
|
if (adContainerEl) {
|
|
@@ -724,23 +642,22 @@ function createImaController(video, options) {
|
|
|
724
642
|
adContainerEl.style.backgroundColor = "#000";
|
|
725
643
|
adContainerEl.offsetHeight;
|
|
726
644
|
adContainerEl.style.opacity = "1";
|
|
727
|
-
console.log("[
|
|
645
|
+
console.log("[DEBUG-LAYER] \u{1F7E1} Ad container VISIBLE");
|
|
728
646
|
}
|
|
729
647
|
adPlaying = true;
|
|
730
648
|
setAdPlayingFlag(true);
|
|
731
|
-
console.log("[IMA] Emitting 'content_pause' event to player");
|
|
732
649
|
emit("content_pause");
|
|
733
650
|
}
|
|
734
651
|
);
|
|
735
652
|
adsManager.addEventListener(AdEvent.STARTED, () => {
|
|
736
|
-
console.log("[
|
|
653
|
+
console.log("[DEBUG-FLOW] \u25B6\uFE0F STARTED - Ad playing now");
|
|
737
654
|
setAdPlayingFlag(true);
|
|
738
655
|
hideContentVideo();
|
|
739
656
|
if (adVideoElement) {
|
|
740
657
|
adVideoElement.volume = originalMutedState ? 0 : originalVolume;
|
|
741
658
|
adVideoElement.muted = originalMutedState;
|
|
742
659
|
console.log(
|
|
743
|
-
`[
|
|
660
|
+
`[DEBUG-AUDIO] \u{1F50A} Ad audio set | volume=${adVideoElement.volume}, muted=${adVideoElement.muted}`
|
|
744
661
|
);
|
|
745
662
|
}
|
|
746
663
|
if (adContainerEl) {
|
|
@@ -749,21 +666,20 @@ function createImaController(video, options) {
|
|
|
749
666
|
adContainerEl.style.backgroundColor = "#000";
|
|
750
667
|
adContainerEl.offsetHeight;
|
|
751
668
|
adContainerEl.style.opacity = "1";
|
|
752
|
-
console.log("[IMA] Ad container now visible (STARTED event)");
|
|
753
669
|
}
|
|
754
670
|
});
|
|
755
671
|
adsManager.addEventListener(
|
|
756
672
|
AdEvent.CONTENT_RESUME_REQUESTED,
|
|
757
673
|
() => {
|
|
758
|
-
console.log("[
|
|
674
|
+
console.log("[DEBUG-FLOW] \u23F8\uFE0F CONTENT_RESUME - Single ad done");
|
|
759
675
|
adPlaying = false;
|
|
760
676
|
setAdPlayingFlag(false);
|
|
761
|
-
console.log("[
|
|
677
|
+
console.log("[DEBUG-LAYER] \u26A0\uFE0F Waiting for pod manager decision (more ads or done)");
|
|
762
678
|
emit("content_resume");
|
|
763
679
|
}
|
|
764
680
|
);
|
|
765
681
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
766
|
-
console.log("[
|
|
682
|
+
console.log("[DEBUG-FLOW] \u{1F3C1} ALL_ADS_COMPLETED - Pod finished");
|
|
767
683
|
adPlaying = false;
|
|
768
684
|
setAdPlayingFlag(false);
|
|
769
685
|
if (adContainerEl) {
|
|
@@ -773,18 +689,16 @@ function createImaController(video, options) {
|
|
|
773
689
|
if (adContainerEl) {
|
|
774
690
|
adContainerEl.style.pointerEvents = "none";
|
|
775
691
|
adContainerEl.style.display = "none";
|
|
776
|
-
console.log("[
|
|
692
|
+
console.log("[DEBUG-LAYER] \u26AB Ad container HIDDEN (pod done)");
|
|
777
693
|
}
|
|
778
694
|
}, 300);
|
|
779
695
|
}
|
|
780
696
|
showContentVideo();
|
|
781
697
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds) && video.paused) {
|
|
782
|
-
console.log("[IMA] Resuming content video playback");
|
|
783
698
|
video.play().catch((e) => {
|
|
784
|
-
console.warn("[
|
|
699
|
+
console.warn("[DEBUG-ERROR] Failed to resume video:", e);
|
|
785
700
|
});
|
|
786
701
|
}
|
|
787
|
-
console.log("[IMA] Emitting 'all_ads_completed' event to player");
|
|
788
702
|
emit("all_ads_completed");
|
|
789
703
|
});
|
|
790
704
|
console.log("[IMA] Ads manager event listeners attached");
|
|
@@ -804,18 +718,12 @@ function createImaController(video, options) {
|
|
|
804
718
|
if (adContainerEl) {
|
|
805
719
|
adContainerEl.style.pointerEvents = "none";
|
|
806
720
|
adContainerEl.style.display = "none";
|
|
807
|
-
console.log(
|
|
808
|
-
"[IMA] Ad container hidden after setup error"
|
|
809
|
-
);
|
|
810
721
|
}
|
|
811
722
|
}, 300);
|
|
812
723
|
}
|
|
813
724
|
showContentVideo();
|
|
814
725
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
815
726
|
if (video.paused) {
|
|
816
|
-
console.log(
|
|
817
|
-
"[IMA] Resuming paused video after setup error"
|
|
818
|
-
);
|
|
819
727
|
video.play().catch(() => {
|
|
820
728
|
});
|
|
821
729
|
}
|
|
@@ -833,17 +741,9 @@ function createImaController(video, options) {
|
|
|
833
741
|
adsLoader.addEventListener(
|
|
834
742
|
google.ima.AdErrorEvent.Type.AD_ERROR,
|
|
835
743
|
(adErrorEvent) => {
|
|
836
|
-
var _a
|
|
744
|
+
var _a;
|
|
837
745
|
const error = adErrorEvent.getError();
|
|
838
|
-
console.error("[
|
|
839
|
-
message: (_a = error.getMessage) == null ? void 0 : _a.call(error),
|
|
840
|
-
errorCode: (_b = error.getErrorCode) == null ? void 0 : _b.call(error),
|
|
841
|
-
type: (_c = error.getType) == null ? void 0 : _c.call(error),
|
|
842
|
-
vastErrorCode: (_d = error.getVastErrorCode) == null ? void 0 : _d.call(error)
|
|
843
|
-
});
|
|
844
|
-
console.error("[IMA] This means the ad server didn't return valid ads");
|
|
845
|
-
console.error("[IMA] Ad layer will NOT appear (no flicker)");
|
|
846
|
-
console.error("[IMA] Full error object:", adErrorEvent.getError());
|
|
746
|
+
console.error("[DEBUG-ERROR] \u274C ADS_LOADER ERROR:", (_a = error.getMessage) == null ? void 0 : _a.call(error));
|
|
847
747
|
adPlaying = false;
|
|
848
748
|
setAdPlayingFlag(false);
|
|
849
749
|
if (adContainerEl) {
|
|
@@ -853,14 +753,12 @@ function createImaController(video, options) {
|
|
|
853
753
|
if (adContainerEl) {
|
|
854
754
|
adContainerEl.style.pointerEvents = "none";
|
|
855
755
|
adContainerEl.style.display = "none";
|
|
856
|
-
console.log("[IMA] Ad container hidden after loader error");
|
|
857
756
|
}
|
|
858
757
|
}, 300);
|
|
859
758
|
}
|
|
860
759
|
showContentVideo();
|
|
861
760
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
862
761
|
if (video.paused) {
|
|
863
|
-
console.log("[IMA] Resuming paused video after loader error");
|
|
864
762
|
video.play().catch(() => {
|
|
865
763
|
});
|
|
866
764
|
}
|
|
@@ -875,10 +773,7 @@ function createImaController(video, options) {
|
|
|
875
773
|
false
|
|
876
774
|
);
|
|
877
775
|
}
|
|
878
|
-
console.log("[IMA] \u{1F680} Making ads request to IMA SDK");
|
|
879
|
-
console.log("[IMA] Waiting for IMA SDK response (LOADED or ERROR event)...");
|
|
880
776
|
makeAdsRequest(google, vastTagUrl);
|
|
881
|
-
console.log("[IMA] \u23F3 Returning promise that will resolve when ads are loaded");
|
|
882
777
|
return adsLoadedPromise;
|
|
883
778
|
} catch (error) {
|
|
884
779
|
console.error("[IMA] Failed to request ads:", error);
|
|
@@ -916,23 +811,16 @@ function createImaController(video, options) {
|
|
|
916
811
|
},
|
|
917
812
|
async play() {
|
|
918
813
|
var _a, _b;
|
|
919
|
-
console.log("[
|
|
920
|
-
console.log("[IMA] This initializes and starts the ad");
|
|
921
|
-
console.log("[IMA] Ad layer will appear when CONTENT_PAUSE_REQUESTED fires");
|
|
814
|
+
console.log("[DEBUG-FLOW] \u25B6\uFE0F play() - Starting ad playback");
|
|
922
815
|
if (!((_a = window.google) == null ? void 0 : _a.ima) || !adDisplayContainer) {
|
|
923
|
-
console.warn(
|
|
924
|
-
"[IMA] \u274C Cannot play ad: IMA SDK or ad container not available"
|
|
925
|
-
);
|
|
926
816
|
return Promise.reject(new Error("IMA SDK not available"));
|
|
927
817
|
}
|
|
928
818
|
if (!adsManager) {
|
|
929
|
-
console.warn("[IMA] \u274C Cannot play ad: No ads manager available");
|
|
930
819
|
return Promise.reject(new Error("No ads manager"));
|
|
931
820
|
}
|
|
932
821
|
try {
|
|
933
822
|
const width = video.clientWidth || 640;
|
|
934
823
|
const height = video.clientHeight || 360;
|
|
935
|
-
console.log(`[IMA] \u{1F3AC} Initializing ads manager (${width}x${height})`);
|
|
936
824
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
937
825
|
adPlaying = true;
|
|
938
826
|
const adVolume = originalMutedState ? 0 : originalVolume;
|
|
@@ -940,22 +828,18 @@ function createImaController(video, options) {
|
|
|
940
828
|
adVideoElement.volume = adVolume;
|
|
941
829
|
adVideoElement.muted = originalMutedState;
|
|
942
830
|
console.log(
|
|
943
|
-
`[
|
|
831
|
+
`[DEBUG-AUDIO] \u{1F50A} Pre-start ad audio | volume=${adVolume}, muted=${originalMutedState}`
|
|
944
832
|
);
|
|
945
833
|
}
|
|
946
834
|
try {
|
|
947
835
|
adsManager.setVolume(adVolume);
|
|
948
|
-
console.log(`[IMA] Set IMA manager volume to ${adVolume}`);
|
|
949
836
|
} catch (error) {
|
|
950
|
-
console.warn("[
|
|
837
|
+
console.warn("[DEBUG-ERROR] Failed to set IMA manager volume:", error);
|
|
951
838
|
}
|
|
952
|
-
console.log("[IMA] \u{1F3AF} Calling adsManager.start()");
|
|
953
|
-
console.log("[IMA] If successful, IMA will fire CONTENT_PAUSE_REQUESTED");
|
|
954
839
|
adsManager.start();
|
|
955
|
-
console.log("[IMA] \u2705 play() completed successfully");
|
|
956
840
|
return Promise.resolve();
|
|
957
841
|
} catch (error) {
|
|
958
|
-
console.error("[
|
|
842
|
+
console.error("[DEBUG-ERROR] \u274C Error starting ad:", error);
|
|
959
843
|
adPlaying = false;
|
|
960
844
|
setAdPlayingFlag(false);
|
|
961
845
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
@@ -967,7 +851,7 @@ function createImaController(video, options) {
|
|
|
967
851
|
},
|
|
968
852
|
async stop() {
|
|
969
853
|
var _a;
|
|
970
|
-
console.log("[
|
|
854
|
+
console.log("[DEBUG-FLOW] \u23F9\uFE0F stop() - Stopping ad playback");
|
|
971
855
|
adPlaying = false;
|
|
972
856
|
setAdPlayingFlag(false);
|
|
973
857
|
if (adContainerEl) {
|
|
@@ -977,7 +861,7 @@ function createImaController(video, options) {
|
|
|
977
861
|
if (adContainerEl) {
|
|
978
862
|
adContainerEl.style.pointerEvents = "none";
|
|
979
863
|
adContainerEl.style.display = "none";
|
|
980
|
-
console.log("[
|
|
864
|
+
console.log("[DEBUG-LAYER] \u26AB Ad container HIDDEN (stop)");
|
|
981
865
|
}
|
|
982
866
|
}, 300);
|
|
983
867
|
}
|
|
@@ -1048,7 +932,7 @@ function createImaController(video, options) {
|
|
|
1048
932
|
updateOriginalMutedState(muted, volume) {
|
|
1049
933
|
const nextVolume = typeof volume === "number" && !Number.isNaN(volume) ? Math.max(0, Math.min(1, volume)) : originalVolume;
|
|
1050
934
|
console.log(
|
|
1051
|
-
`[
|
|
935
|
+
`[DEBUG-AUDIO] \u{1F4BE} Saved original state | muted: ${originalMutedState}->${muted}, volume: ${originalVolume}->${nextVolume}`
|
|
1052
936
|
);
|
|
1053
937
|
originalMutedState = muted;
|
|
1054
938
|
originalVolume = nextVolume;
|
|
@@ -1065,14 +949,14 @@ function createImaController(video, options) {
|
|
|
1065
949
|
adVideoElement.volume = clampedVolume;
|
|
1066
950
|
adVideoElement.muted = clampedVolume === 0;
|
|
1067
951
|
console.log(
|
|
1068
|
-
`[
|
|
952
|
+
`[DEBUG-AUDIO] \u{1F50A} Ad volume changed | volume=${clampedVolume}, muted=${clampedVolume === 0}`
|
|
1069
953
|
);
|
|
1070
954
|
}
|
|
1071
955
|
if (adsManager && adPlaying) {
|
|
1072
956
|
try {
|
|
1073
957
|
adsManager.setVolume(clampedVolume);
|
|
1074
958
|
} catch (error) {
|
|
1075
|
-
console.warn("[
|
|
959
|
+
console.warn("[DEBUG-ERROR] Failed to set IMA manager volume:", error);
|
|
1076
960
|
}
|
|
1077
961
|
}
|
|
1078
962
|
},
|
|
@@ -2283,6 +2167,10 @@ var StormcloudVideoPlayer = class {
|
|
|
2283
2167
|
this.vastToMediaUrlMap = /* @__PURE__ */ new Map();
|
|
2284
2168
|
this.preloadedMediaUrls = /* @__PURE__ */ new Set();
|
|
2285
2169
|
this.preloadingMediaUrls = /* @__PURE__ */ new Set();
|
|
2170
|
+
this.adRequestTokenCounter = 0;
|
|
2171
|
+
this.activeAdRequestToken = null;
|
|
2172
|
+
this.adRequestWatchdogToken = null;
|
|
2173
|
+
this.adFailsafeToken = null;
|
|
2286
2174
|
initializePolyfills();
|
|
2287
2175
|
const browserOverrides = getBrowserConfigOverrides();
|
|
2288
2176
|
this.config = { ...config, ...browserOverrides };
|
|
@@ -2596,29 +2484,21 @@ var StormcloudVideoPlayer = class {
|
|
|
2596
2484
|
}
|
|
2597
2485
|
});
|
|
2598
2486
|
this.ima.on("content_pause", () => {
|
|
2599
|
-
|
|
2600
|
-
console.log("[StormcloudVideoPlayer] IMA content_pause event received");
|
|
2601
|
-
}
|
|
2487
|
+
console.log(`[DEBUG-POD] \u{1F3AF} content_pause | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}`);
|
|
2602
2488
|
this.clearAdFailsafeTimer();
|
|
2489
|
+
this.clearAdRequestWatchdog();
|
|
2490
|
+
this.activeAdRequestToken = null;
|
|
2491
|
+
this.showAds = true;
|
|
2603
2492
|
this.enforceAdHoldState();
|
|
2604
2493
|
});
|
|
2605
2494
|
this.ima.on("content_resume", () => {
|
|
2606
|
-
|
|
2607
|
-
console.log(
|
|
2608
|
-
"[StormcloudVideoPlayer] IMA content_resume event received",
|
|
2609
|
-
{
|
|
2610
|
-
inAdBreak: this.inAdBreak,
|
|
2611
|
-
pendingAds: this.adPodQueue.length
|
|
2612
|
-
}
|
|
2613
|
-
);
|
|
2614
|
-
}
|
|
2495
|
+
console.log(`[DEBUG-POD] \u23F8\uFE0F content_resume | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}, remaining=${this.getRemainingAdMs()}ms`);
|
|
2615
2496
|
this.clearAdFailsafeTimer();
|
|
2497
|
+
this.clearAdRequestWatchdog();
|
|
2498
|
+
this.activeAdRequestToken = null;
|
|
2499
|
+
this.showAds = false;
|
|
2616
2500
|
if (!this.inAdBreak) {
|
|
2617
|
-
|
|
2618
|
-
console.log(
|
|
2619
|
-
"[StormcloudVideoPlayer] Not in ad break - this shouldn't happen during pod"
|
|
2620
|
-
);
|
|
2621
|
-
}
|
|
2501
|
+
console.warn("[DEBUG-POD] \u26A0\uFE0F Not in ad break - shouldn't happen");
|
|
2622
2502
|
return;
|
|
2623
2503
|
}
|
|
2624
2504
|
const remaining = this.getRemainingAdMs();
|
|
@@ -2626,33 +2506,17 @@ var StormcloudVideoPlayer = class {
|
|
|
2626
2506
|
const nextPreloaded = this.findNextPreloadedAd();
|
|
2627
2507
|
if (nextPreloaded) {
|
|
2628
2508
|
this.currentAdIndex++;
|
|
2629
|
-
|
|
2630
|
-
console.log(
|
|
2631
|
-
`[StormcloudVideoPlayer] Playing next preloaded ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - layer will stay visible if ad loads`
|
|
2632
|
-
);
|
|
2633
|
-
}
|
|
2509
|
+
console.log(`[DEBUG-POD] \u27A1\uFE0F Playing next ad ${this.currentAdIndex}/${this.totalAdsInBreak} (preloaded)`);
|
|
2634
2510
|
this.playSingleAd(nextPreloaded).catch(() => {
|
|
2635
|
-
|
|
2636
|
-
console.error(
|
|
2637
|
-
"[StormcloudVideoPlayer] Failed to play next ad in pod"
|
|
2638
|
-
);
|
|
2639
|
-
}
|
|
2511
|
+
console.error("[DEBUG-POD] \u274C Failed to play next ad");
|
|
2640
2512
|
this.handleAdPodComplete();
|
|
2641
2513
|
});
|
|
2642
2514
|
} else {
|
|
2643
|
-
|
|
2644
|
-
console.log(
|
|
2645
|
-
"[StormcloudVideoPlayer] No preloaded ads available - completing ad break"
|
|
2646
|
-
);
|
|
2647
|
-
}
|
|
2515
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads - ending pod");
|
|
2648
2516
|
this.handleAdPodComplete();
|
|
2649
2517
|
}
|
|
2650
2518
|
} else {
|
|
2651
|
-
|
|
2652
|
-
console.log(
|
|
2653
|
-
"[StormcloudVideoPlayer] No more ads in pod - completing ad break"
|
|
2654
|
-
);
|
|
2655
|
-
}
|
|
2519
|
+
console.log("[DEBUG-POD] \u2705 Pod complete (no more ads or time expired)");
|
|
2656
2520
|
this.handleAdPodComplete();
|
|
2657
2521
|
}
|
|
2658
2522
|
});
|
|
@@ -3227,52 +3091,27 @@ var StormcloudVideoPlayer = class {
|
|
|
3227
3091
|
let vastTagUrls = [];
|
|
3228
3092
|
if (this.apiVastTagUrl) {
|
|
3229
3093
|
vastTagUrls = [this.apiVastTagUrl];
|
|
3230
|
-
if (this.config.debugAdTiming) {
|
|
3231
|
-
console.log(
|
|
3232
|
-
"[StormcloudVideoPlayer] Using VAST endpoint:",
|
|
3233
|
-
this.apiVastTagUrl
|
|
3234
|
-
);
|
|
3235
|
-
}
|
|
3236
3094
|
} else if (tags && tags.length > 0) {
|
|
3237
3095
|
vastTagUrls = tags;
|
|
3238
|
-
if (this.config.debugAdTiming) {
|
|
3239
|
-
console.log(
|
|
3240
|
-
"[StormcloudVideoPlayer] Using scheduled VAST tags (count: " + tags.length + "):",
|
|
3241
|
-
tags
|
|
3242
|
-
);
|
|
3243
|
-
}
|
|
3244
3096
|
} else {
|
|
3245
|
-
|
|
3246
|
-
console.log("[StormcloudVideoPlayer] No VAST tag available for ad");
|
|
3247
|
-
}
|
|
3097
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F No VAST tag available");
|
|
3248
3098
|
return;
|
|
3249
3099
|
}
|
|
3250
3100
|
if (vastTagUrls.length > 0) {
|
|
3101
|
+
console.log(`[DEBUG-POD] \u{1F3AF} Starting ad break with ${vastTagUrls.length} ads`);
|
|
3251
3102
|
this.adPodAllUrls = [...vastTagUrls];
|
|
3252
3103
|
this.preloadingAdUrls.clear();
|
|
3253
3104
|
this.vastToMediaUrlMap.clear();
|
|
3254
3105
|
this.preloadedMediaUrls.clear();
|
|
3255
3106
|
this.preloadingMediaUrls.clear();
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
`[StormcloudVideoPlayer] Capturing original audio state before ad break:`,
|
|
3260
|
-
{
|
|
3261
|
-
videoMuted: this.video.muted,
|
|
3262
|
-
videoVolume: this.video.volume
|
|
3263
|
-
}
|
|
3264
|
-
);
|
|
3265
|
-
}
|
|
3107
|
+
console.log(
|
|
3108
|
+
`[DEBUG-AUDIO] \u{1F4BE} Capturing original state | muted=${this.video.muted}, volume=${this.video.volume}`
|
|
3109
|
+
);
|
|
3266
3110
|
this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3267
3111
|
this.inAdBreak = true;
|
|
3268
3112
|
this.currentAdIndex = 0;
|
|
3269
3113
|
this.totalAdsInBreak = vastTagUrls.length;
|
|
3270
3114
|
this.adPodQueue = [...vastTagUrls];
|
|
3271
|
-
if (this.config.debugAdTiming) {
|
|
3272
|
-
console.log(
|
|
3273
|
-
`[StormcloudVideoPlayer] Starting ad pod with ${vastTagUrls.length} ads - preloading all ads in parallel (ad layer will show after ad loads)`
|
|
3274
|
-
);
|
|
3275
|
-
}
|
|
3276
3115
|
this.preloadAllAdsInBackground().catch((error) => {
|
|
3277
3116
|
if (this.config.debugAdTiming) {
|
|
3278
3117
|
console.warn(
|
|
@@ -3284,12 +3123,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3284
3123
|
try {
|
|
3285
3124
|
await this.playAdPod();
|
|
3286
3125
|
} catch (error) {
|
|
3287
|
-
|
|
3288
|
-
console.error(
|
|
3289
|
-
"[StormcloudVideoPlayer] Ad pod playback failed:",
|
|
3290
|
-
error
|
|
3291
|
-
);
|
|
3292
|
-
}
|
|
3126
|
+
console.error("[DEBUG-POD] \u274C Pod playback failed:", error);
|
|
3293
3127
|
this.handleAdFailure();
|
|
3294
3128
|
}
|
|
3295
3129
|
}
|
|
@@ -3301,19 +3135,13 @@ var StormcloudVideoPlayer = class {
|
|
|
3301
3135
|
}
|
|
3302
3136
|
async playAdPod() {
|
|
3303
3137
|
if (this.adPodQueue.length === 0) {
|
|
3304
|
-
|
|
3305
|
-
console.log("[StormcloudVideoPlayer] No ads in pod to play");
|
|
3306
|
-
}
|
|
3138
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F No ads in pod");
|
|
3307
3139
|
return;
|
|
3308
3140
|
}
|
|
3309
3141
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
3310
3142
|
const firstPreloaded = this.findNextPreloadedAd();
|
|
3311
3143
|
if (!firstPreloaded) {
|
|
3312
|
-
|
|
3313
|
-
console.log(
|
|
3314
|
-
"[StormcloudVideoPlayer] No preloaded ads available after waiting, trying first ad anyway"
|
|
3315
|
-
);
|
|
3316
|
-
}
|
|
3144
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads after wait, trying first ad");
|
|
3317
3145
|
const firstAd = this.adPodQueue.shift();
|
|
3318
3146
|
if (firstAd) {
|
|
3319
3147
|
this.currentAdIndex++;
|
|
@@ -3322,11 +3150,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3322
3150
|
return;
|
|
3323
3151
|
}
|
|
3324
3152
|
this.currentAdIndex++;
|
|
3325
|
-
|
|
3326
|
-
console.log(
|
|
3327
|
-
`[StormcloudVideoPlayer] Playing first preloaded ad ${this.currentAdIndex}/${this.totalAdsInBreak}`
|
|
3328
|
-
);
|
|
3329
|
-
}
|
|
3153
|
+
console.log(`[DEBUG-POD] \u{1F680} Starting pod with ad ${this.currentAdIndex}/${this.totalAdsInBreak}`);
|
|
3330
3154
|
await this.playSingleAd(firstPreloaded);
|
|
3331
3155
|
}
|
|
3332
3156
|
findCurrentOrNextBreak(nowMs) {
|
|
@@ -3463,62 +3287,56 @@ var StormcloudVideoPlayer = class {
|
|
|
3463
3287
|
this.ptsDriftEmaMs = this.ptsDriftEmaMs * (1 - alpha) + sampleMs * alpha;
|
|
3464
3288
|
}
|
|
3465
3289
|
async playSingleAd(vastTagUrl) {
|
|
3466
|
-
|
|
3467
|
-
console.log("[StormcloudVideoPlayer] Attempting to play ad:", vastTagUrl);
|
|
3468
|
-
}
|
|
3290
|
+
console.log(`[DEBUG-POD] \u{1F3AC} playSingleAd | url=${vastTagUrl.substring(0, 60)}...`);
|
|
3469
3291
|
if (this.ima.isAdPlaying()) {
|
|
3470
|
-
|
|
3471
|
-
console.warn(
|
|
3472
|
-
"[StormcloudVideoPlayer] Ad already playing - skipping new ad request"
|
|
3473
|
-
);
|
|
3474
|
-
}
|
|
3292
|
+
console.warn("[DEBUG-POD] \u26A0\uFE0F Ad already playing - skipping request");
|
|
3475
3293
|
return;
|
|
3476
3294
|
}
|
|
3295
|
+
const requestToken = ++this.adRequestTokenCounter;
|
|
3477
3296
|
const wasPreloaded = this.ima.hasPreloadedAd(vastTagUrl);
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
);
|
|
3482
|
-
}
|
|
3483
|
-
this.startAdFailsafeTimer();
|
|
3297
|
+
this.activeAdRequestToken = requestToken;
|
|
3298
|
+
console.log(`[DEBUG-POD] \u{1F4DD} Request token=${requestToken}, preloaded=${wasPreloaded}`);
|
|
3299
|
+
this.startAdRequestWatchdog(requestToken);
|
|
3484
3300
|
try {
|
|
3485
3301
|
await this.ima.requestAds(vastTagUrl);
|
|
3302
|
+
this.clearAdRequestWatchdog();
|
|
3303
|
+
if (this.activeAdRequestToken !== requestToken) {
|
|
3304
|
+
console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after requestAds (stale request)`);
|
|
3305
|
+
return;
|
|
3306
|
+
}
|
|
3486
3307
|
try {
|
|
3487
|
-
|
|
3488
|
-
console.log(
|
|
3489
|
-
"[StormcloudVideoPlayer] Ad request completed, attempting playback (ad layer will show when IMA triggers content pause)"
|
|
3490
|
-
);
|
|
3491
|
-
}
|
|
3308
|
+
this.startAdFailsafeTimer(requestToken);
|
|
3492
3309
|
await this.ima.play();
|
|
3493
|
-
this.
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
);
|
|
3310
|
+
if (this.activeAdRequestToken === requestToken) {
|
|
3311
|
+
console.log(`[DEBUG-POD] \u2705 Ad play initiated (token=${requestToken})`);
|
|
3312
|
+
} else {
|
|
3313
|
+
console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after play (stale request)`);
|
|
3498
3314
|
}
|
|
3499
3315
|
} catch (playError) {
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3316
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F No ads available from play()");
|
|
3317
|
+
this.clearAdFailsafeTimer();
|
|
3318
|
+
if (this.activeAdRequestToken === requestToken) {
|
|
3319
|
+
this.activeAdRequestToken = null;
|
|
3504
3320
|
}
|
|
3505
3321
|
this.handleAdFailure();
|
|
3506
3322
|
return;
|
|
3507
3323
|
}
|
|
3508
3324
|
} catch (error) {
|
|
3509
|
-
|
|
3510
|
-
|
|
3325
|
+
console.error("[DEBUG-POD] \u274C Ad request failed:", error == null ? void 0 : error.message);
|
|
3326
|
+
this.clearAdRequestWatchdog();
|
|
3327
|
+
this.clearAdFailsafeTimer();
|
|
3328
|
+
if (this.activeAdRequestToken === requestToken) {
|
|
3329
|
+
this.activeAdRequestToken = null;
|
|
3511
3330
|
}
|
|
3512
3331
|
this.handleAdFailure();
|
|
3513
3332
|
}
|
|
3514
3333
|
}
|
|
3515
3334
|
handleAdPodComplete() {
|
|
3516
3335
|
var _a;
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
}
|
|
3336
|
+
console.log("[DEBUG-POD] \u{1F3C1} handleAdPodComplete - Ending ad break, restoring content");
|
|
3337
|
+
this.clearAdRequestWatchdog();
|
|
3338
|
+
this.clearAdFailsafeTimer();
|
|
3339
|
+
this.activeAdRequestToken = null;
|
|
3522
3340
|
this.releaseAdHoldState();
|
|
3523
3341
|
this.preloadingAdUrls.clear();
|
|
3524
3342
|
this.vastToMediaUrlMap.clear();
|
|
@@ -3529,7 +3347,6 @@ var StormcloudVideoPlayer = class {
|
|
|
3529
3347
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
3530
3348
|
this.clearAdStartTimer();
|
|
3531
3349
|
this.clearAdStopTimer();
|
|
3532
|
-
this.clearAdFailsafeTimer();
|
|
3533
3350
|
this.adPodQueue = [];
|
|
3534
3351
|
this.adPodAllUrls = [];
|
|
3535
3352
|
this.showAds = false;
|
|
@@ -3541,70 +3358,84 @@ var StormcloudVideoPlayer = class {
|
|
|
3541
3358
|
const originalVolume = typeof this.ima.getOriginalVolume === "function" ? this.ima.getOriginalVolume() : this.video.volume;
|
|
3542
3359
|
this.video.muted = originalMutedState;
|
|
3543
3360
|
this.video.volume = originalVolume;
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
);
|
|
3548
|
-
}
|
|
3361
|
+
console.log(
|
|
3362
|
+
`[DEBUG-AUDIO] \u{1F50A} Main video restored | muted=${originalMutedState}, volume=${originalVolume}`
|
|
3363
|
+
);
|
|
3549
3364
|
if (!this.shouldContinueLiveStreamDuringAds() && this.video.paused) {
|
|
3550
|
-
|
|
3551
|
-
console.log("[StormcloudVideoPlayer] Resuming paused video");
|
|
3552
|
-
}
|
|
3365
|
+
console.log("[DEBUG-FLOW] \u25B6\uFE0F Resuming main video playback");
|
|
3553
3366
|
(_a = this.video.play()) == null ? void 0 : _a.catch((error) => {
|
|
3554
|
-
|
|
3555
|
-
console.error(
|
|
3556
|
-
"[StormcloudVideoPlayer] Failed to resume video:",
|
|
3557
|
-
error
|
|
3558
|
-
);
|
|
3559
|
-
}
|
|
3367
|
+
console.error("[DEBUG-ERROR] Failed to resume video:", error);
|
|
3560
3368
|
});
|
|
3561
3369
|
}
|
|
3562
3370
|
}
|
|
3563
3371
|
handleAdFailure() {
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
{
|
|
3568
|
-
inAdBreak: this.inAdBreak,
|
|
3569
|
-
showAds: this.showAds,
|
|
3570
|
-
videoPaused: this.video.paused,
|
|
3571
|
-
adPlaying: this.ima.isAdPlaying()
|
|
3572
|
-
}
|
|
3573
|
-
);
|
|
3574
|
-
}
|
|
3372
|
+
console.log(
|
|
3373
|
+
`[DEBUG-POD] \u274C handleAdFailure | inBreak=${this.inAdBreak}, showAds=${this.showAds}, paused=${this.video.paused}`
|
|
3374
|
+
);
|
|
3575
3375
|
this.handleAdPodComplete();
|
|
3576
3376
|
}
|
|
3577
|
-
|
|
3377
|
+
startAdRequestWatchdog(token) {
|
|
3378
|
+
var _a;
|
|
3379
|
+
this.clearAdRequestWatchdog();
|
|
3380
|
+
const timeoutMs = (_a = this.config.adFailsafeTimeoutMs) != null ? _a : 1e4;
|
|
3381
|
+
this.adRequestWatchdogToken = token;
|
|
3382
|
+
this.adRequestWatchdogId = window.setTimeout(() => {
|
|
3383
|
+
if (this.adRequestWatchdogToken !== token) {
|
|
3384
|
+
return;
|
|
3385
|
+
}
|
|
3386
|
+
this.adRequestWatchdogId = void 0;
|
|
3387
|
+
this.adRequestWatchdogToken = null;
|
|
3388
|
+
if (this.activeAdRequestToken === token) {
|
|
3389
|
+
this.activeAdRequestToken = null;
|
|
3390
|
+
}
|
|
3391
|
+
this.logAdState("ad_request_timeout", { token, timeoutMs });
|
|
3392
|
+
this.handleAdFailure();
|
|
3393
|
+
}, timeoutMs);
|
|
3394
|
+
this.logAdState("ad_request_watchdog_started", { token, timeoutMs });
|
|
3395
|
+
}
|
|
3396
|
+
clearAdRequestWatchdog() {
|
|
3397
|
+
if (this.adRequestWatchdogId != null) {
|
|
3398
|
+
clearTimeout(this.adRequestWatchdogId);
|
|
3399
|
+
this.adRequestWatchdogId = void 0;
|
|
3400
|
+
}
|
|
3401
|
+
if (this.adRequestWatchdogToken != null) {
|
|
3402
|
+
this.logAdState("ad_request_watchdog_cleared", {
|
|
3403
|
+
token: this.adRequestWatchdogToken
|
|
3404
|
+
});
|
|
3405
|
+
this.adRequestWatchdogToken = null;
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
startAdFailsafeTimer(token) {
|
|
3578
3409
|
var _a;
|
|
3579
3410
|
this.clearAdFailsafeTimer();
|
|
3580
3411
|
const failsafeMs = (_a = this.config.adFailsafeTimeoutMs) != null ? _a : 1e4;
|
|
3581
|
-
|
|
3582
|
-
console.log(
|
|
3583
|
-
`[StormcloudVideoPlayer] Starting failsafe timer (${failsafeMs}ms)`
|
|
3584
|
-
);
|
|
3585
|
-
}
|
|
3412
|
+
this.adFailsafeToken = token;
|
|
3586
3413
|
this.adFailsafeTimerId = window.setTimeout(() => {
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
if (this.config.debugAdTiming) {
|
|
3590
|
-
console.warn(
|
|
3591
|
-
"[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume",
|
|
3592
|
-
{
|
|
3593
|
-
paused: this.video.paused,
|
|
3594
|
-
showAds: this.showAds,
|
|
3595
|
-
adPlaying: this.ima.isAdPlaying()
|
|
3596
|
-
}
|
|
3597
|
-
);
|
|
3598
|
-
}
|
|
3599
|
-
this.handleAdFailure();
|
|
3414
|
+
if (this.adFailsafeToken !== token) {
|
|
3415
|
+
return;
|
|
3600
3416
|
}
|
|
3417
|
+
this.adFailsafeTimerId = void 0;
|
|
3418
|
+
this.adFailsafeToken = null;
|
|
3419
|
+
if (this.activeAdRequestToken === token) {
|
|
3420
|
+
this.activeAdRequestToken = null;
|
|
3421
|
+
}
|
|
3422
|
+
this.logAdState("ad_failsafe_triggered", {
|
|
3423
|
+
token,
|
|
3424
|
+
failsafeMs,
|
|
3425
|
+
videoPaused: this.video.paused,
|
|
3426
|
+
imaAdPlaying: this.ima.isAdPlaying()
|
|
3427
|
+
});
|
|
3428
|
+
this.handleAdFailure();
|
|
3601
3429
|
}, failsafeMs);
|
|
3430
|
+
this.logAdState("ad_failsafe_started", { token, failsafeMs });
|
|
3602
3431
|
}
|
|
3603
3432
|
clearAdFailsafeTimer() {
|
|
3604
3433
|
if (this.adFailsafeTimerId != null) {
|
|
3605
3434
|
clearTimeout(this.adFailsafeTimerId);
|
|
3435
|
+
this.logAdState("ad_failsafe_cleared", { token: this.adFailsafeToken });
|
|
3606
3436
|
this.adFailsafeTimerId = void 0;
|
|
3607
3437
|
}
|
|
3438
|
+
this.adFailsafeToken = null;
|
|
3608
3439
|
}
|
|
3609
3440
|
selectVastTagsForBreak(b) {
|
|
3610
3441
|
if (!b || !b.vastTagUrl) return void 0;
|
|
@@ -3619,16 +3450,32 @@ var StormcloudVideoPlayer = class {
|
|
|
3619
3450
|
}
|
|
3620
3451
|
console.log("[StormcloudVideoPlayer] ALL ad URLs queued:", urls);
|
|
3621
3452
|
}
|
|
3453
|
+
logAdState(event, extra = {}) {
|
|
3454
|
+
if (!this.config.debugAdTiming) {
|
|
3455
|
+
return;
|
|
3456
|
+
}
|
|
3457
|
+
console.log("[StormcloudVideoPlayer][AdState]", {
|
|
3458
|
+
event,
|
|
3459
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3460
|
+
showAds: this.showAds,
|
|
3461
|
+
adPlaying: this.ima.isAdPlaying(),
|
|
3462
|
+
inAdBreak: this.inAdBreak,
|
|
3463
|
+
activeAdRequestToken: this.activeAdRequestToken,
|
|
3464
|
+
...extra
|
|
3465
|
+
});
|
|
3466
|
+
}
|
|
3622
3467
|
enforceAdHoldState() {
|
|
3623
3468
|
this.video.dataset.stormcloudAdPlaying = "true";
|
|
3624
3469
|
this.video.muted = true;
|
|
3625
3470
|
this.video.volume = 0;
|
|
3471
|
+
console.log("[DEBUG-LAYER] \u{1F512} Enforced ad hold state (main video muted)");
|
|
3626
3472
|
if (typeof this.ima.showPlaceholder === "function") {
|
|
3627
3473
|
this.ima.showPlaceholder();
|
|
3628
3474
|
}
|
|
3629
3475
|
}
|
|
3630
3476
|
releaseAdHoldState() {
|
|
3631
3477
|
delete this.video.dataset.stormcloudAdPlaying;
|
|
3478
|
+
console.log("[DEBUG-LAYER] \u{1F513} Released ad hold state");
|
|
3632
3479
|
if (typeof this.ima.hidePlaceholder === "function") {
|
|
3633
3480
|
this.ima.hidePlaceholder();
|
|
3634
3481
|
}
|