stormcloud-video-player 0.3.5 → 0.3.7
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 +44 -196
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +44 -196
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +44 -196
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +44 -196
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +44 -196
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/ima.cjs +6 -80
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +44 -196
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/players/index.cjs
CHANGED
|
@@ -264,7 +264,6 @@ function createImaController(video, options) {
|
|
|
264
264
|
video.muted = true;
|
|
265
265
|
video.volume = 0;
|
|
266
266
|
contentVideoHidden = true;
|
|
267
|
-
console.log("[DEBUG-LAYER] \u{1F534} Content video HIDDEN | muted=true, volume=0");
|
|
268
267
|
}
|
|
269
268
|
}
|
|
270
269
|
function showContentVideo() {
|
|
@@ -276,9 +275,6 @@ function createImaController(video, options) {
|
|
|
276
275
|
video.muted = originalMutedState;
|
|
277
276
|
video.volume = originalVolume;
|
|
278
277
|
contentVideoHidden = false;
|
|
279
|
-
console.log(
|
|
280
|
-
`[DEBUG-LAYER] \u{1F7E2} Content video RESTORED | muted=${originalMutedState}, volume=${originalVolume}`
|
|
281
|
-
);
|
|
282
278
|
}
|
|
283
279
|
}
|
|
284
280
|
function createAdVideoElement() {
|
|
@@ -299,13 +295,9 @@ function createImaController(video, options) {
|
|
|
299
295
|
"canplay",
|
|
300
296
|
() => {
|
|
301
297
|
adVideo.style.opacity = "1";
|
|
302
|
-
console.log("[DEBUG-LAYER] \u{1F4FA} Ad video element ready (canplay fired)");
|
|
303
298
|
},
|
|
304
299
|
{ once: true }
|
|
305
300
|
);
|
|
306
|
-
console.log(
|
|
307
|
-
`[DEBUG-AUDIO] \u{1F50A} Ad video created | volume=${adVideo.volume}, muted=${adVideo.muted}`
|
|
308
|
-
);
|
|
309
301
|
return adVideo;
|
|
310
302
|
}
|
|
311
303
|
function emit(event, payload) {
|
|
@@ -457,10 +449,8 @@ function createImaController(video, options) {
|
|
|
457
449
|
function destroyAdsManager() {
|
|
458
450
|
if (adsManager) {
|
|
459
451
|
try {
|
|
460
|
-
console.log("[IMA] Destroying existing ads manager");
|
|
461
452
|
adsManager.destroy();
|
|
462
|
-
} catch
|
|
463
|
-
console.warn("[IMA] Error destroying ads manager:", error);
|
|
453
|
+
} catch {
|
|
464
454
|
}
|
|
465
455
|
adsManager = void 0;
|
|
466
456
|
}
|
|
@@ -478,9 +468,6 @@ function createImaController(video, options) {
|
|
|
478
468
|
if (!adVideoElement) {
|
|
479
469
|
adVideoElement = createAdVideoElement();
|
|
480
470
|
adContainerEl.appendChild(adVideoElement);
|
|
481
|
-
console.log(
|
|
482
|
-
"[IMA] Dedicated ad video element added to container"
|
|
483
|
-
);
|
|
484
471
|
}
|
|
485
472
|
adDisplayContainer = new google.ima.AdDisplayContainer(
|
|
486
473
|
adContainerEl,
|
|
@@ -488,9 +475,6 @@ function createImaController(video, options) {
|
|
|
488
475
|
);
|
|
489
476
|
try {
|
|
490
477
|
(_a = adDisplayContainer.initialize) == null ? void 0 : _a.call(adDisplayContainer);
|
|
491
|
-
console.log(
|
|
492
|
-
"[IMA] AdDisplayContainer initialized with dedicated ad video"
|
|
493
|
-
);
|
|
494
478
|
} catch {
|
|
495
479
|
}
|
|
496
480
|
}
|
|
@@ -498,9 +482,6 @@ function createImaController(video, options) {
|
|
|
498
482
|
});
|
|
499
483
|
},
|
|
500
484
|
async requestAds(vastTagUrl) {
|
|
501
|
-
console.log("[IMA] \u{1F4E1} === requestAds() called ===");
|
|
502
|
-
console.log("[IMA] VAST URL:", vastTagUrl);
|
|
503
|
-
console.log("[IMA] This will fetch the ad from the server - no visual change yet");
|
|
504
485
|
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
505
486
|
const error = new Error("VAST tag URL is empty or undefined");
|
|
506
487
|
console.warn("[IMA] \u274C", error.message);
|
|
@@ -543,7 +524,6 @@ function createImaController(video, options) {
|
|
|
543
524
|
lastAdTagUrl = vastTagUrl;
|
|
544
525
|
retryAttempts = 0;
|
|
545
526
|
if (!adDisplayContainer) {
|
|
546
|
-
console.log("[IMA] Creating ad display container");
|
|
547
527
|
const container = document.createElement("div");
|
|
548
528
|
container.style.position = "absolute";
|
|
549
529
|
container.style.left = "0";
|
|
@@ -566,25 +546,11 @@ function createImaController(video, options) {
|
|
|
566
546
|
if (!adVideoElement) {
|
|
567
547
|
adVideoElement = createAdVideoElement();
|
|
568
548
|
adContainerEl.appendChild(adVideoElement);
|
|
569
|
-
console.log(
|
|
570
|
-
"[IMA] Dedicated ad video element created and added to container"
|
|
571
|
-
);
|
|
572
549
|
}
|
|
573
550
|
adDisplayContainer = new google.ima.AdDisplayContainer(
|
|
574
551
|
container,
|
|
575
552
|
adVideoElement
|
|
576
553
|
);
|
|
577
|
-
try {
|
|
578
|
-
adDisplayContainer.initialize();
|
|
579
|
-
console.log(
|
|
580
|
-
"[IMA] Ad display container initialized with dedicated ad video"
|
|
581
|
-
);
|
|
582
|
-
} catch (error) {
|
|
583
|
-
console.warn(
|
|
584
|
-
"[IMA] Failed to initialize ad display container:",
|
|
585
|
-
error
|
|
586
|
-
);
|
|
587
|
-
}
|
|
588
554
|
}
|
|
589
555
|
const videoWidth = video.offsetWidth || video.clientWidth;
|
|
590
556
|
const videoHeight = video.offsetHeight || video.clientHeight;
|
|
@@ -599,29 +565,17 @@ function createImaController(video, options) {
|
|
|
599
565
|
return Promise.reject(error);
|
|
600
566
|
}
|
|
601
567
|
if (!adsLoader) {
|
|
602
|
-
console.log("[IMA] Creating ads loader");
|
|
603
568
|
const adsLoaderCls = new google.ima.AdsLoader(adDisplayContainer);
|
|
604
569
|
adsLoader = adsLoaderCls;
|
|
605
570
|
adsLoader.addEventListener(
|
|
606
571
|
google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
|
|
607
572
|
(evt) => {
|
|
608
|
-
console.log("[DEBUG-FLOW] \u2705 ADS_MANAGER_LOADED - Setting up manager");
|
|
609
573
|
try {
|
|
610
574
|
const adsRenderingSettings = new google.ima.AdsRenderingSettings();
|
|
611
575
|
adsRenderingSettings.enablePreloading = true;
|
|
612
576
|
adsManager = evt.getAdsManager(video, adsRenderingSettings);
|
|
613
577
|
const AdEvent = google.ima.AdEvent.Type;
|
|
614
578
|
const AdErrorEvent = google.ima.AdErrorEvent.Type;
|
|
615
|
-
const keyEvents = ["STARTED", "COMPLETE", "CONTENT_PAUSE_REQUESTED", "CONTENT_RESUME_REQUESTED", "ALL_ADS_COMPLETED"];
|
|
616
|
-
keyEvents.forEach((eventType) => {
|
|
617
|
-
if (AdEvent[eventType]) {
|
|
618
|
-
adsManager.addEventListener(AdEvent[eventType], (e) => {
|
|
619
|
-
var _a, _b;
|
|
620
|
-
const ad = (_a = e.getAd) == null ? void 0 : _a.call(e);
|
|
621
|
-
console.log(`[DEBUG-FLOW] \u{1F3AC} ${eventType} | title=${((_b = ad == null ? void 0 : ad.getTitle) == null ? void 0 : _b.call(ad)) || "N/A"}`);
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
});
|
|
625
579
|
adsManager.addEventListener(
|
|
626
580
|
AdErrorEvent.AD_ERROR,
|
|
627
581
|
(errorEvent) => {
|
|
@@ -638,7 +592,6 @@ function createImaController(video, options) {
|
|
|
638
592
|
if (adContainerEl) {
|
|
639
593
|
adContainerEl.style.pointerEvents = "none";
|
|
640
594
|
adContainerEl.style.display = "none";
|
|
641
|
-
console.log("[DEBUG-LAYER] \u274C Ad container HIDDEN (error)");
|
|
642
595
|
}
|
|
643
596
|
}, 300);
|
|
644
597
|
}
|
|
@@ -670,7 +623,6 @@ function createImaController(video, options) {
|
|
|
670
623
|
adsManager.addEventListener(
|
|
671
624
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
672
625
|
() => {
|
|
673
|
-
console.log("[DEBUG-FLOW] \u{1F3AF} CONTENT_PAUSE_REQUESTED - Ad request accepted");
|
|
674
626
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
675
627
|
video.pause();
|
|
676
628
|
}
|
|
@@ -680,15 +632,11 @@ function createImaController(video, options) {
|
|
|
680
632
|
}
|
|
681
633
|
);
|
|
682
634
|
adsManager.addEventListener(AdEvent.STARTED, () => {
|
|
683
|
-
console.log("[DEBUG-FLOW] \u25B6\uFE0F STARTED - Ad playing now");
|
|
684
635
|
setAdPlayingFlag(true);
|
|
685
636
|
hideContentVideo();
|
|
686
637
|
if (adVideoElement) {
|
|
687
638
|
adVideoElement.volume = originalMutedState ? 0 : originalVolume;
|
|
688
639
|
adVideoElement.muted = originalMutedState;
|
|
689
|
-
console.log(
|
|
690
|
-
`[DEBUG-AUDIO] \u{1F50A} Ad audio set | volume=${adVideoElement.volume}, muted=${adVideoElement.muted}`
|
|
691
|
-
);
|
|
692
640
|
}
|
|
693
641
|
if (adContainerEl) {
|
|
694
642
|
adContainerEl.style.pointerEvents = "auto";
|
|
@@ -701,15 +649,12 @@ function createImaController(video, options) {
|
|
|
701
649
|
adsManager.addEventListener(
|
|
702
650
|
AdEvent.CONTENT_RESUME_REQUESTED,
|
|
703
651
|
() => {
|
|
704
|
-
console.log("[DEBUG-FLOW] \u23F8\uFE0F CONTENT_RESUME - Single ad done");
|
|
705
652
|
adPlaying = false;
|
|
706
653
|
setAdPlayingFlag(false);
|
|
707
|
-
console.log("[DEBUG-LAYER] \u26A0\uFE0F Waiting for pod manager (more ads, placeholder, or done)");
|
|
708
654
|
emit("content_resume");
|
|
709
655
|
}
|
|
710
656
|
);
|
|
711
657
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
712
|
-
console.log("[DEBUG-FLOW] \u{1F3C1} ALL_ADS_COMPLETED - Pod finished");
|
|
713
658
|
adPlaying = false;
|
|
714
659
|
setAdPlayingFlag(false);
|
|
715
660
|
if (adContainerEl) {
|
|
@@ -719,19 +664,16 @@ function createImaController(video, options) {
|
|
|
719
664
|
if (adContainerEl) {
|
|
720
665
|
adContainerEl.style.pointerEvents = "none";
|
|
721
666
|
adContainerEl.style.display = "none";
|
|
722
|
-
console.log("[DEBUG-LAYER] \u26AB Ad container HIDDEN (pod done)");
|
|
723
667
|
}
|
|
724
668
|
}, 300);
|
|
725
669
|
}
|
|
726
670
|
showContentVideo();
|
|
727
671
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds) && video.paused) {
|
|
728
|
-
video.play().catch((
|
|
729
|
-
console.warn("[DEBUG-ERROR] Failed to resume video:", e);
|
|
672
|
+
video.play().catch(() => {
|
|
730
673
|
});
|
|
731
674
|
}
|
|
732
675
|
emit("all_ads_completed");
|
|
733
676
|
});
|
|
734
|
-
console.log("[IMA] Ads manager event listeners attached");
|
|
735
677
|
if (adsLoadedResolve) {
|
|
736
678
|
adsLoadedResolve();
|
|
737
679
|
adsLoadedResolve = void 0;
|
|
@@ -826,9 +768,7 @@ function createImaController(video, options) {
|
|
|
826
768
|
}
|
|
827
769
|
const preloadPromise = fetchVastDocument(vastTagUrl).then((xml) => {
|
|
828
770
|
preloadedVast.set(vastTagUrl, xml);
|
|
829
|
-
|
|
830
|
-
}).catch((error) => {
|
|
831
|
-
console.warn("[IMA] Failed to preload VAST response:", error);
|
|
771
|
+
}).catch(() => {
|
|
832
772
|
preloadedVast.delete(vastTagUrl);
|
|
833
773
|
}).finally(() => {
|
|
834
774
|
preloadingVast.delete(vastTagUrl);
|
|
@@ -841,7 +781,6 @@ function createImaController(video, options) {
|
|
|
841
781
|
},
|
|
842
782
|
async play() {
|
|
843
783
|
var _a, _b;
|
|
844
|
-
console.log("[DEBUG-FLOW] \u25B6\uFE0F play() - Starting ad playback");
|
|
845
784
|
if (!((_a = window.google) == null ? void 0 : _a.ima) || !adDisplayContainer) {
|
|
846
785
|
return Promise.reject(new Error("IMA SDK not available"));
|
|
847
786
|
}
|
|
@@ -857,19 +796,15 @@ function createImaController(video, options) {
|
|
|
857
796
|
if (adVideoElement) {
|
|
858
797
|
adVideoElement.volume = adVolume;
|
|
859
798
|
adVideoElement.muted = originalMutedState;
|
|
860
|
-
console.log(
|
|
861
|
-
`[DEBUG-AUDIO] \u{1F50A} Pre-start ad audio | volume=${adVolume}, muted=${originalMutedState}`
|
|
862
|
-
);
|
|
863
799
|
}
|
|
864
800
|
try {
|
|
865
801
|
adsManager.setVolume(adVolume);
|
|
866
|
-
} catch
|
|
867
|
-
console.warn("[DEBUG-ERROR] Failed to set IMA manager volume:", error);
|
|
802
|
+
} catch {
|
|
868
803
|
}
|
|
869
804
|
adsManager.start();
|
|
870
805
|
return Promise.resolve();
|
|
871
806
|
} catch (error) {
|
|
872
|
-
console.error("[
|
|
807
|
+
console.error("[IMA] \u274C Error starting ad:", error);
|
|
873
808
|
adPlaying = false;
|
|
874
809
|
setAdPlayingFlag(false);
|
|
875
810
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
@@ -881,7 +816,6 @@ function createImaController(video, options) {
|
|
|
881
816
|
},
|
|
882
817
|
async stop() {
|
|
883
818
|
var _a;
|
|
884
|
-
console.log("[DEBUG-FLOW] \u23F9\uFE0F stop() - Stopping ad playback");
|
|
885
819
|
adPlaying = false;
|
|
886
820
|
setAdPlayingFlag(false);
|
|
887
821
|
if (adContainerEl) {
|
|
@@ -891,7 +825,6 @@ function createImaController(video, options) {
|
|
|
891
825
|
if (adContainerEl) {
|
|
892
826
|
adContainerEl.style.pointerEvents = "none";
|
|
893
827
|
adContainerEl.style.display = "none";
|
|
894
|
-
console.log("[DEBUG-LAYER] \u26AB Ad container HIDDEN (stop)");
|
|
895
828
|
}
|
|
896
829
|
}, 300);
|
|
897
830
|
}
|
|
@@ -961,9 +894,6 @@ function createImaController(video, options) {
|
|
|
961
894
|
},
|
|
962
895
|
updateOriginalMutedState(muted, volume) {
|
|
963
896
|
const nextVolume = typeof volume === "number" && !Number.isNaN(volume) ? Math.max(0, Math.min(1, volume)) : originalVolume;
|
|
964
|
-
console.log(
|
|
965
|
-
`[DEBUG-AUDIO] \u{1F4BE} Saved original state | muted: ${originalMutedState}->${muted}, volume: ${originalVolume}->${nextVolume}`
|
|
966
|
-
);
|
|
967
897
|
originalMutedState = muted;
|
|
968
898
|
originalVolume = nextVolume;
|
|
969
899
|
},
|
|
@@ -978,15 +908,11 @@ function createImaController(video, options) {
|
|
|
978
908
|
if (adVideoElement && adPlaying) {
|
|
979
909
|
adVideoElement.volume = clampedVolume;
|
|
980
910
|
adVideoElement.muted = clampedVolume === 0;
|
|
981
|
-
console.log(
|
|
982
|
-
`[DEBUG-AUDIO] \u{1F50A} Ad volume changed | volume=${clampedVolume}, muted=${clampedVolume === 0}`
|
|
983
|
-
);
|
|
984
911
|
}
|
|
985
912
|
if (adsManager && adPlaying) {
|
|
986
913
|
try {
|
|
987
914
|
adsManager.setVolume(clampedVolume);
|
|
988
|
-
} catch
|
|
989
|
-
console.warn("[DEBUG-ERROR] Failed to set IMA manager volume:", error);
|
|
915
|
+
} catch {
|
|
990
916
|
}
|
|
991
917
|
}
|
|
992
918
|
},
|
|
@@ -2476,51 +2402,37 @@ var StormcloudVideoPlayer = class {
|
|
|
2476
2402
|
});
|
|
2477
2403
|
this.ima.on("ad_error", (errorPayload) => {
|
|
2478
2404
|
const remaining = this.getRemainingAdMs();
|
|
2479
|
-
console.error(
|
|
2480
|
-
`[DEBUG-POD] \u274C ad_error event | inBreak=${this.inAdBreak}, queue=${this.adPodQueue.length}, remaining=${remaining}ms`,
|
|
2481
|
-
errorPayload ? `
|
|
2482
|
-
Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
2483
|
-
);
|
|
2405
|
+
console.error("[AD-ERROR] Ad playback failed", errorPayload || "");
|
|
2484
2406
|
if (this.inAdBreak) {
|
|
2485
2407
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
2486
2408
|
const nextPreloaded = this.findNextPreloadedAd();
|
|
2487
2409
|
if (nextPreloaded) {
|
|
2488
2410
|
this.currentAdIndex++;
|
|
2489
|
-
console.log(
|
|
2490
|
-
`[DEBUG-POD] \u27A1\uFE0F Trying next ad after error (${this.currentAdIndex}/${this.totalAdsInBreak})`
|
|
2491
|
-
);
|
|
2492
2411
|
this.playSingleAd(nextPreloaded).catch(() => {
|
|
2493
2412
|
this.handleAdFailure();
|
|
2494
2413
|
});
|
|
2495
2414
|
} else {
|
|
2496
|
-
console.log("[DEBUG-POD] \u26A0\uFE0F No more preloaded ads - calling handleAdFailure");
|
|
2497
2415
|
this.handleAdFailure();
|
|
2498
2416
|
}
|
|
2499
2417
|
} else {
|
|
2500
|
-
console.log("[DEBUG-POD] \u26A0\uFE0F No more ads or time - calling handleAdFailure");
|
|
2501
2418
|
this.handleAdFailure();
|
|
2502
2419
|
}
|
|
2503
2420
|
} else {
|
|
2504
|
-
console.log("[DEBUG-POD] \u26A0\uFE0F Error before ad break established");
|
|
2505
2421
|
this.handleAdFailure();
|
|
2506
2422
|
}
|
|
2507
2423
|
});
|
|
2508
2424
|
this.ima.on("content_pause", () => {
|
|
2509
|
-
console.log(`[DEBUG-POD] \u{1F3AF} content_pause (AD STARTING!) | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}`);
|
|
2510
2425
|
this.clearAdFailsafeTimer();
|
|
2511
2426
|
this.clearAdRequestWatchdog();
|
|
2512
2427
|
this.activeAdRequestToken = null;
|
|
2513
2428
|
this.showAds = true;
|
|
2514
|
-
console.log("[DEBUG-LAYER] \u{1F3AC} Layers: Main=hidden, Ad=visible, Placeholder=no");
|
|
2515
2429
|
});
|
|
2516
2430
|
this.ima.on("content_resume", () => {
|
|
2517
|
-
console.log(`[DEBUG-POD] \u23F8\uFE0F content_resume | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}, remaining=${this.getRemainingAdMs()}ms`);
|
|
2518
2431
|
this.clearAdFailsafeTimer();
|
|
2519
2432
|
this.clearAdRequestWatchdog();
|
|
2520
2433
|
this.activeAdRequestToken = null;
|
|
2521
2434
|
this.showAds = false;
|
|
2522
2435
|
if (!this.inAdBreak) {
|
|
2523
|
-
console.warn("[DEBUG-POD] \u26A0\uFE0F Not in ad break - shouldn't happen");
|
|
2524
2436
|
return;
|
|
2525
2437
|
}
|
|
2526
2438
|
const remaining = this.getRemainingAdMs();
|
|
@@ -2528,17 +2440,13 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
2528
2440
|
const nextPreloaded = this.findNextPreloadedAd();
|
|
2529
2441
|
if (nextPreloaded) {
|
|
2530
2442
|
this.currentAdIndex++;
|
|
2531
|
-
console.log(`[DEBUG-POD] \u27A1\uFE0F Playing next ad ${this.currentAdIndex}/${this.totalAdsInBreak} (preloaded)`);
|
|
2532
2443
|
this.playSingleAd(nextPreloaded).catch(() => {
|
|
2533
|
-
console.error("[DEBUG-POD] \u274C Failed to play next ad");
|
|
2534
2444
|
this.handleAdPodComplete();
|
|
2535
2445
|
});
|
|
2536
2446
|
} else {
|
|
2537
|
-
console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads - ending pod");
|
|
2538
2447
|
this.handleAdPodComplete();
|
|
2539
2448
|
}
|
|
2540
2449
|
} else {
|
|
2541
|
-
console.log("[DEBUG-POD] \u2705 Pod complete (no more ads or time expired)");
|
|
2542
2450
|
this.handleAdPodComplete();
|
|
2543
2451
|
}
|
|
2544
2452
|
});
|
|
@@ -2692,9 +2600,6 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
2692
2600
|
}
|
|
2693
2601
|
if (marker.type === "start") {
|
|
2694
2602
|
if (this.inAdBreak) {
|
|
2695
|
-
console.log(
|
|
2696
|
-
`[DEBUG-POD] \u26A0\uFE0F SCTE-35 start marker ignored - already in ad break (currentTime: ${this.video.currentTime})`
|
|
2697
|
-
);
|
|
2698
2603
|
return;
|
|
2699
2604
|
}
|
|
2700
2605
|
this.inAdBreak = true;
|
|
@@ -2763,9 +2668,6 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
2763
2668
|
return;
|
|
2764
2669
|
}
|
|
2765
2670
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
2766
|
-
console.log(
|
|
2767
|
-
`[DEBUG-POD] \u{1F4CA} SCTE-35 progress marker (currentTime: ${this.video.currentTime})`
|
|
2768
|
-
);
|
|
2769
2671
|
if (marker.durationSeconds != null) {
|
|
2770
2672
|
this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
|
|
2771
2673
|
}
|
|
@@ -2778,7 +2680,6 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
2778
2680
|
this.scheduleAdStopCountdown(remainingMs);
|
|
2779
2681
|
}
|
|
2780
2682
|
if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null) {
|
|
2781
|
-
console.log("[DEBUG-POD] \u{1F4CA} Progress marker: no ad playing, attempting to start");
|
|
2782
2683
|
const scheduled = this.findCurrentOrNextBreak(
|
|
2783
2684
|
this.video.currentTime * 1e3
|
|
2784
2685
|
);
|
|
@@ -2790,24 +2691,16 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
2790
2691
|
this.playSingleAd(first).catch(() => {
|
|
2791
2692
|
});
|
|
2792
2693
|
}
|
|
2793
|
-
} else {
|
|
2794
|
-
console.log(
|
|
2795
|
-
`[DEBUG-POD] \u{1F4CA} Progress marker: ad playing or request active (playing=${this.ima.isAdPlaying()}, token=${this.activeAdRequestToken})`
|
|
2796
|
-
);
|
|
2797
2694
|
}
|
|
2798
2695
|
return;
|
|
2799
2696
|
}
|
|
2800
2697
|
if (marker.type === "end") {
|
|
2801
|
-
console.log(
|
|
2802
|
-
`[DEBUG-POD] \u{1F3C1} SCTE-35 end marker received (currentTime: ${this.video.currentTime})`
|
|
2803
|
-
);
|
|
2804
2698
|
this.inAdBreak = false;
|
|
2805
2699
|
this.expectedAdBreakDurationMs = void 0;
|
|
2806
2700
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
2807
2701
|
this.clearAdStartTimer();
|
|
2808
2702
|
this.clearAdStopTimer();
|
|
2809
2703
|
if (this.ima.isAdPlaying()) {
|
|
2810
|
-
console.log("[DEBUG-POD] \u{1F6D1} Stopping ad due to SCTE-35 end marker");
|
|
2811
2704
|
this.ima.stop().catch(() => {
|
|
2812
2705
|
});
|
|
2813
2706
|
}
|
|
@@ -3208,11 +3101,9 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3208
3101
|
} else if (tags && tags.length > 0) {
|
|
3209
3102
|
vastTagUrls = tags;
|
|
3210
3103
|
} else {
|
|
3211
|
-
console.log("[DEBUG-POD] \u26A0\uFE0F No VAST tag available");
|
|
3212
3104
|
return;
|
|
3213
3105
|
}
|
|
3214
3106
|
if (vastTagUrls.length > 0) {
|
|
3215
|
-
console.log(`[DEBUG-POD] \u{1F3AF} Starting ad break with ${vastTagUrls.length} ads`);
|
|
3216
3107
|
this.adPodAllUrls = [...vastTagUrls];
|
|
3217
3108
|
this.preloadingAdUrls.clear();
|
|
3218
3109
|
this.vastToMediaUrlMap.clear();
|
|
@@ -3220,9 +3111,6 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3220
3111
|
this.preloadingMediaUrls.clear();
|
|
3221
3112
|
const currentMuted = this.video.muted;
|
|
3222
3113
|
const currentVolume = this.video.volume;
|
|
3223
|
-
console.log(
|
|
3224
|
-
`[DEBUG-AUDIO] \u{1F4BE} Capturing ORIGINAL state (once) | muted=${currentMuted}, volume=${currentVolume}`
|
|
3225
|
-
);
|
|
3226
3114
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
3227
3115
|
this.inAdBreak = true;
|
|
3228
3116
|
this.currentAdIndex = 0;
|
|
@@ -3230,21 +3118,38 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3230
3118
|
this.adPodQueue = [...vastTagUrls];
|
|
3231
3119
|
if (this.isAdaptiveMode) {
|
|
3232
3120
|
if (this.config.debugAdTiming) {
|
|
3233
|
-
console.log("[ADAPTIVE-POD]
|
|
3121
|
+
console.log("[ADAPTIVE-POD] \u{1F680} Preloading first 2 ads before starting playback...");
|
|
3234
3122
|
}
|
|
3235
3123
|
try {
|
|
3236
|
-
|
|
3124
|
+
const adsToPreloadBeforeStart = Math.min(2, this.adPodAllUrls.length);
|
|
3125
|
+
for (let i = 0; i < adsToPreloadBeforeStart; i++) {
|
|
3126
|
+
const url = this.adPodAllUrls[i];
|
|
3127
|
+
if (url) {
|
|
3128
|
+
await this.preloadSingleAd(url);
|
|
3129
|
+
if (this.config.debugAdTiming) {
|
|
3130
|
+
console.log(`[ADAPTIVE-POD] \u2705 Preloaded ad ${i + 1}/${adsToPreloadBeforeStart}`);
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3237
3134
|
if (this.config.debugAdTiming) {
|
|
3238
|
-
console.log("[ADAPTIVE-POD]
|
|
3135
|
+
console.log("[ADAPTIVE-POD] \u{1F3AC} First ads preloaded, starting playback immediately");
|
|
3239
3136
|
}
|
|
3240
3137
|
} catch (error) {
|
|
3241
3138
|
if (this.config.debugAdTiming) {
|
|
3242
3139
|
console.warn(
|
|
3243
|
-
"[ADAPTIVE-POD] Error
|
|
3140
|
+
"[ADAPTIVE-POD] \u26A0\uFE0F Error preloading initial ads:",
|
|
3244
3141
|
error
|
|
3245
3142
|
);
|
|
3246
3143
|
}
|
|
3247
3144
|
}
|
|
3145
|
+
this.preloadAllAdsInBackground().catch((error) => {
|
|
3146
|
+
if (this.config.debugAdTiming) {
|
|
3147
|
+
console.warn(
|
|
3148
|
+
"[ADAPTIVE-POD] Error in background preloading:",
|
|
3149
|
+
error
|
|
3150
|
+
);
|
|
3151
|
+
}
|
|
3152
|
+
});
|
|
3248
3153
|
await this.playAdPod();
|
|
3249
3154
|
} else {
|
|
3250
3155
|
this.preloadAllAdsInBackground().catch((error) => {
|
|
@@ -3266,40 +3171,27 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3266
3171
|
}
|
|
3267
3172
|
async playAdPod() {
|
|
3268
3173
|
if (this.adPodQueue.length === 0) {
|
|
3269
|
-
console.log("[DEBUG-POD] \u26A0\uFE0F No ads in pod");
|
|
3270
3174
|
return;
|
|
3271
3175
|
}
|
|
3272
|
-
const waitTime = this.isAdaptiveMode ?
|
|
3176
|
+
const waitTime = this.isAdaptiveMode ? 50 : 500;
|
|
3273
3177
|
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
3274
|
-
if (this.config.debugAdTiming) {
|
|
3275
|
-
console.log(
|
|
3276
|
-
`[DEBUG-POD] \u{1F50D} Looking for preloaded ad in queue of ${this.adPodQueue.length} URLs`
|
|
3277
|
-
);
|
|
3278
|
-
}
|
|
3279
3178
|
const firstPreloaded = this.findNextPreloadedAd();
|
|
3280
3179
|
if (!firstPreloaded) {
|
|
3281
|
-
console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads found, trying first ad from queue");
|
|
3282
3180
|
const firstAd = this.adPodQueue.shift();
|
|
3283
3181
|
if (firstAd) {
|
|
3284
3182
|
this.currentAdIndex++;
|
|
3285
|
-
console.log(`[DEBUG-POD] \u{1F3AC} Attempting to play first ad (not preloaded): ${firstAd.substring(0, 60)}...`);
|
|
3286
3183
|
try {
|
|
3287
3184
|
await this.playSingleAd(firstAd);
|
|
3288
3185
|
} catch (error) {
|
|
3289
|
-
console.log("[DEBUG-POD] \u26A0\uFE0F First ad failed, error handler will retry");
|
|
3290
3186
|
return;
|
|
3291
3187
|
}
|
|
3292
|
-
} else {
|
|
3293
|
-
console.log("[DEBUG-POD] \u274C No ads available in queue");
|
|
3294
3188
|
}
|
|
3295
3189
|
return;
|
|
3296
3190
|
}
|
|
3297
3191
|
this.currentAdIndex++;
|
|
3298
|
-
console.log(`[DEBUG-POD] \u{1F680} Starting pod with ad ${this.currentAdIndex}/${this.totalAdsInBreak}`);
|
|
3299
3192
|
try {
|
|
3300
3193
|
await this.playSingleAd(firstPreloaded);
|
|
3301
3194
|
} catch (error) {
|
|
3302
|
-
console.log("[DEBUG-POD] \u26A0\uFE0F First ad failed, error handler will retry");
|
|
3303
3195
|
}
|
|
3304
3196
|
}
|
|
3305
3197
|
findCurrentOrNextBreak(nowMs) {
|
|
@@ -3379,15 +3271,9 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3379
3271
|
const overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
3380
3272
|
const shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
3381
3273
|
if (shouldExtendAdBreak) {
|
|
3382
|
-
console.log(
|
|
3383
|
-
`[DEBUG-POD] \u23F3 Extending ad break | elapsed=${elapsedSinceStartMs}ms, expected=${expectedDurationMs}ms, overrun=${overrunMs}ms`
|
|
3384
|
-
);
|
|
3385
3274
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
3386
3275
|
return;
|
|
3387
3276
|
}
|
|
3388
|
-
console.log(
|
|
3389
|
-
`[DEBUG-POD] \u23F1\uFE0F Ad break duration expired | elapsed=${elapsedSinceStartMs}ms, expected=${expectedDurationMs}ms`
|
|
3390
|
-
);
|
|
3391
3277
|
if (adPlaying) {
|
|
3392
3278
|
this.ima.stop().catch(() => {
|
|
3393
3279
|
});
|
|
@@ -3420,42 +3306,23 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3420
3306
|
this.ptsDriftEmaMs = this.ptsDriftEmaMs * (1 - alpha) + sampleMs * alpha;
|
|
3421
3307
|
}
|
|
3422
3308
|
async playSingleAd(vastTagUrl) {
|
|
3423
|
-
console.log(`[DEBUG-POD] \u{1F3AC} playSingleAd | url=${vastTagUrl.substring(0, 60)}...`);
|
|
3424
3309
|
if (this.ima.isAdPlaying()) {
|
|
3425
|
-
console.warn("[DEBUG-POD] \u26A0\uFE0F Ad already playing - skipping request");
|
|
3426
3310
|
return;
|
|
3427
3311
|
}
|
|
3428
3312
|
const requestToken = ++this.adRequestTokenCounter;
|
|
3429
|
-
const wasPreloaded = this.ima.hasPreloadedAd(vastTagUrl);
|
|
3430
3313
|
this.activeAdRequestToken = requestToken;
|
|
3431
|
-
console.log(`[DEBUG-POD] \u{1F4DD} Request token=${requestToken}, preloaded=${wasPreloaded}`);
|
|
3432
3314
|
this.startAdRequestWatchdog(requestToken);
|
|
3433
3315
|
try {
|
|
3434
|
-
console.log(`[DEBUG-POD] \u{1F4E1} Calling ima.requestAds() for token=${requestToken}...`);
|
|
3435
3316
|
await this.ima.requestAds(vastTagUrl);
|
|
3436
|
-
console.log(`[DEBUG-POD] \u2705 ima.requestAds() completed successfully`);
|
|
3437
3317
|
this.clearAdRequestWatchdog();
|
|
3438
3318
|
if (this.activeAdRequestToken !== requestToken) {
|
|
3439
|
-
console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after requestAds (stale request)`);
|
|
3440
3319
|
return;
|
|
3441
3320
|
}
|
|
3442
|
-
console.log(`[DEBUG-POD] \u{1F4FA} Calling ima.play() to start ad playback...`);
|
|
3443
|
-
console.log(`[DEBUG-POD] \u{1F4CA} Video element state: paused=${this.video.paused}, muted=${this.video.muted}, readyState=${this.video.readyState}`);
|
|
3444
3321
|
try {
|
|
3445
3322
|
this.startAdFailsafeTimer(requestToken);
|
|
3446
3323
|
await this.ima.play();
|
|
3447
|
-
if (this.activeAdRequestToken === requestToken) {
|
|
3448
|
-
console.log(`[DEBUG-POD] \u2705 Ad play initiated successfully (token=${requestToken})`);
|
|
3449
|
-
} else {
|
|
3450
|
-
console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after play (stale request)`);
|
|
3451
|
-
}
|
|
3452
3324
|
} catch (playError) {
|
|
3453
|
-
console.error(
|
|
3454
|
-
"[DEBUG-POD] \u274C Failed to play ad:",
|
|
3455
|
-
playError instanceof Error ? playError.message : playError,
|
|
3456
|
-
"\nFull error:",
|
|
3457
|
-
playError
|
|
3458
|
-
);
|
|
3325
|
+
console.error("[AD-ERROR] Failed to play ad:", playError);
|
|
3459
3326
|
this.clearAdFailsafeTimer();
|
|
3460
3327
|
if (this.activeAdRequestToken === requestToken) {
|
|
3461
3328
|
this.activeAdRequestToken = null;
|
|
@@ -3464,7 +3331,7 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3464
3331
|
return;
|
|
3465
3332
|
}
|
|
3466
3333
|
} catch (error) {
|
|
3467
|
-
console.error("[
|
|
3334
|
+
console.error("[AD-ERROR] Ad request failed:", error == null ? void 0 : error.message);
|
|
3468
3335
|
this.clearAdRequestWatchdog();
|
|
3469
3336
|
this.clearAdFailsafeTimer();
|
|
3470
3337
|
if (this.activeAdRequestToken === requestToken) {
|
|
@@ -3475,7 +3342,6 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3475
3342
|
}
|
|
3476
3343
|
handleAdPodComplete() {
|
|
3477
3344
|
var _a;
|
|
3478
|
-
console.log("[DEBUG-POD] \u{1F3C1} handleAdPodComplete - Ending ad break, restoring content");
|
|
3479
3345
|
this.clearAdRequestWatchdog();
|
|
3480
3346
|
this.clearAdFailsafeTimer();
|
|
3481
3347
|
this.activeAdRequestToken = null;
|
|
@@ -3497,10 +3363,6 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3497
3363
|
});
|
|
3498
3364
|
const restoredMuted = this.ima.getOriginalMutedState();
|
|
3499
3365
|
const restoredVolume = this.ima.getOriginalVolume();
|
|
3500
|
-
console.log(
|
|
3501
|
-
`[DEBUG-AUDIO] \u{1F50A} Audio restored by IMA | muted=${restoredMuted}, volume=${restoredVolume}`
|
|
3502
|
-
);
|
|
3503
|
-
console.log("[DEBUG-LAYER] \u{1F3AC} Layers: Main=visible, Ad=hidden, Placeholder=no");
|
|
3504
3366
|
if (this.video.muted !== restoredMuted) {
|
|
3505
3367
|
this.video.muted = restoredMuted;
|
|
3506
3368
|
}
|
|
@@ -3508,14 +3370,11 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3508
3370
|
this.video.volume = restoredVolume;
|
|
3509
3371
|
}
|
|
3510
3372
|
if (!this.shouldContinueLiveStreamDuringAds() && this.video.paused) {
|
|
3511
|
-
|
|
3512
|
-
(_a = this.video.play()) == null ? void 0 : _a.catch((error) => {
|
|
3513
|
-
console.error("[DEBUG-ERROR] Failed to resume video:", error);
|
|
3373
|
+
(_a = this.video.play()) == null ? void 0 : _a.catch(() => {
|
|
3514
3374
|
});
|
|
3515
3375
|
}
|
|
3516
3376
|
}
|
|
3517
3377
|
handleAdFailure() {
|
|
3518
|
-
console.log("[DEBUG-POD] \u274C handleAdFailure - skipping to next ad or ending break");
|
|
3519
3378
|
const remaining = this.getRemainingAdMs();
|
|
3520
3379
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
3521
3380
|
if (this.isAdaptiveMode && this.currentAdIndex <= 1) {
|
|
@@ -3528,14 +3387,12 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3528
3387
|
const nextPreloaded = this.findNextPreloadedAd();
|
|
3529
3388
|
if (nextPreloaded) {
|
|
3530
3389
|
this.currentAdIndex++;
|
|
3531
|
-
console.log(`[DEBUG-POD] \u27A1\uFE0F Trying next ad after failure (${this.currentAdIndex}/${this.totalAdsInBreak})`);
|
|
3532
3390
|
this.playSingleAd(nextPreloaded).catch(() => {
|
|
3533
3391
|
this.handleAdPodComplete();
|
|
3534
3392
|
});
|
|
3535
3393
|
return;
|
|
3536
3394
|
}
|
|
3537
3395
|
}
|
|
3538
|
-
console.log("[DEBUG-POD] \u23F9\uFE0F Ending ad break after failure");
|
|
3539
3396
|
this.handleAdPodComplete();
|
|
3540
3397
|
}
|
|
3541
3398
|
tryNextAdWithRetry(retryCount) {
|
|
@@ -3835,16 +3692,27 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3835
3692
|
}
|
|
3836
3693
|
}
|
|
3837
3694
|
async preloadAllAdsInBackground() {
|
|
3695
|
+
var _a, _b;
|
|
3838
3696
|
if (this.adPodAllUrls.length === 0) {
|
|
3839
3697
|
return;
|
|
3840
3698
|
}
|
|
3841
3699
|
if (this.isAdaptiveMode) {
|
|
3842
3700
|
if (this.config.debugAdTiming) {
|
|
3843
3701
|
console.log(
|
|
3844
|
-
`[ADAPTIVE-POD] \u{1F504} Starting sequential preload of
|
|
3702
|
+
`[ADAPTIVE-POD] \u{1F504} Starting sequential preload of remaining ads`
|
|
3845
3703
|
);
|
|
3846
3704
|
}
|
|
3847
3705
|
const processedUrls = /* @__PURE__ */ new Set();
|
|
3706
|
+
for (const url of this.adPodAllUrls) {
|
|
3707
|
+
if (((_b = (_a = this.ima).hasPreloadedAd) == null ? void 0 : _b.call(_a, url)) || this.fetchedAdDurations.has(url)) {
|
|
3708
|
+
processedUrls.add(url);
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
if (this.config.debugAdTiming && processedUrls.size > 0) {
|
|
3712
|
+
console.log(
|
|
3713
|
+
`[ADAPTIVE-POD] \u{1F4E6} Skipping ${processedUrls.size} already-preloaded ads`
|
|
3714
|
+
);
|
|
3715
|
+
}
|
|
3848
3716
|
while (true) {
|
|
3849
3717
|
const nextUrl = this.adPodAllUrls.find((url) => !processedUrls.has(url));
|
|
3850
3718
|
if (!nextUrl) {
|
|
@@ -3977,37 +3845,17 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
|
|
|
3977
3845
|
}
|
|
3978
3846
|
findNextPreloadedAd() {
|
|
3979
3847
|
var _a, _b, _c;
|
|
3980
|
-
if (this.config.debugAdTiming) {
|
|
3981
|
-
console.log(
|
|
3982
|
-
`[DEBUG-POD] \u{1F50E} Searching for preloaded ad in queue (${this.adPodQueue.length} URLs, ${this.preloadedMediaUrls.size} media preloaded, ${this.vastToMediaUrlMap.size} VAST mappings)`
|
|
3983
|
-
);
|
|
3984
|
-
}
|
|
3985
3848
|
for (let i = 0; i < this.adPodQueue.length; i++) {
|
|
3986
3849
|
const vastTagUrl = this.adPodQueue[i];
|
|
3987
3850
|
if (!vastTagUrl) continue;
|
|
3988
3851
|
const hasImaPreload = (_c = (_b = (_a = this.ima).hasPreloadedAd) == null ? void 0 : _b.call(_a, vastTagUrl)) != null ? _c : false;
|
|
3989
3852
|
const mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
3990
3853
|
const hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
|
|
3991
|
-
if (this.config.debugAdTiming) {
|
|
3992
|
-
console.log(
|
|
3993
|
-
`[DEBUG-POD] Ad ${i}: IMA=${hasImaPreload}, Media=${hasMediaPreload}, MediaURLs=${(mediaUrls == null ? void 0 : mediaUrls.length) || 0}, URL=${vastTagUrl.substring(0, 60)}...`
|
|
3994
|
-
);
|
|
3995
|
-
}
|
|
3996
3854
|
if (hasImaPreload || hasMediaPreload) {
|
|
3997
|
-
if (this.config.debugAdTiming) {
|
|
3998
|
-
console.log(
|
|
3999
|
-
`[DEBUG-POD] \u2705 Found preloaded ad at index ${i}`
|
|
4000
|
-
);
|
|
4001
|
-
}
|
|
4002
3855
|
this.adPodQueue.splice(0, i + 1);
|
|
4003
3856
|
return vastTagUrl;
|
|
4004
3857
|
}
|
|
4005
3858
|
}
|
|
4006
|
-
if (this.config.debugAdTiming) {
|
|
4007
|
-
console.log(
|
|
4008
|
-
`[DEBUG-POD] \u274C No preloaded ads found in queue`
|
|
4009
|
-
);
|
|
4010
|
-
}
|
|
4011
3859
|
return void 0;
|
|
4012
3860
|
}
|
|
4013
3861
|
getRemainingAdMs() {
|