stormcloud-video-player 0.3.6 → 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.
@@ -225,7 +225,6 @@ function createImaController(video, options) {
225
225
  video.muted = true;
226
226
  video.volume = 0;
227
227
  contentVideoHidden = true;
228
- console.log("[DEBUG-LAYER] \u{1F534} Content video HIDDEN | muted=true, volume=0");
229
228
  }
230
229
  }
231
230
  function showContentVideo() {
@@ -237,9 +236,6 @@ function createImaController(video, options) {
237
236
  video.muted = originalMutedState;
238
237
  video.volume = originalVolume;
239
238
  contentVideoHidden = false;
240
- console.log(
241
- `[DEBUG-LAYER] \u{1F7E2} Content video RESTORED | muted=${originalMutedState}, volume=${originalVolume}`
242
- );
243
239
  }
244
240
  }
245
241
  function createAdVideoElement() {
@@ -260,13 +256,9 @@ function createImaController(video, options) {
260
256
  "canplay",
261
257
  () => {
262
258
  adVideo.style.opacity = "1";
263
- console.log("[DEBUG-LAYER] \u{1F4FA} Ad video element ready (canplay fired)");
264
259
  },
265
260
  { once: true }
266
261
  );
267
- console.log(
268
- `[DEBUG-AUDIO] \u{1F50A} Ad video created | volume=${adVideo.volume}, muted=${adVideo.muted}`
269
- );
270
262
  return adVideo;
271
263
  }
272
264
  function emit(event, payload) {
@@ -418,10 +410,8 @@ function createImaController(video, options) {
418
410
  function destroyAdsManager() {
419
411
  if (adsManager) {
420
412
  try {
421
- console.log("[IMA] Destroying existing ads manager");
422
413
  adsManager.destroy();
423
- } catch (error) {
424
- console.warn("[IMA] Error destroying ads manager:", error);
414
+ } catch {
425
415
  }
426
416
  adsManager = void 0;
427
417
  }
@@ -439,9 +429,6 @@ function createImaController(video, options) {
439
429
  if (!adVideoElement) {
440
430
  adVideoElement = createAdVideoElement();
441
431
  adContainerEl.appendChild(adVideoElement);
442
- console.log(
443
- "[IMA] Dedicated ad video element added to container"
444
- );
445
432
  }
446
433
  adDisplayContainer = new google.ima.AdDisplayContainer(
447
434
  adContainerEl,
@@ -449,9 +436,6 @@ function createImaController(video, options) {
449
436
  );
450
437
  try {
451
438
  (_a = adDisplayContainer.initialize) == null ? void 0 : _a.call(adDisplayContainer);
452
- console.log(
453
- "[IMA] AdDisplayContainer initialized with dedicated ad video"
454
- );
455
439
  } catch {
456
440
  }
457
441
  }
@@ -459,9 +443,6 @@ function createImaController(video, options) {
459
443
  });
460
444
  },
461
445
  async requestAds(vastTagUrl) {
462
- console.log("[IMA] \u{1F4E1} === requestAds() called ===");
463
- console.log("[IMA] VAST URL:", vastTagUrl);
464
- console.log("[IMA] This will fetch the ad from the server - no visual change yet");
465
446
  if (!vastTagUrl || vastTagUrl.trim() === "") {
466
447
  const error = new Error("VAST tag URL is empty or undefined");
467
448
  console.warn("[IMA] \u274C", error.message);
@@ -504,7 +485,6 @@ function createImaController(video, options) {
504
485
  lastAdTagUrl = vastTagUrl;
505
486
  retryAttempts = 0;
506
487
  if (!adDisplayContainer) {
507
- console.log("[IMA] Creating ad display container");
508
488
  const container = document.createElement("div");
509
489
  container.style.position = "absolute";
510
490
  container.style.left = "0";
@@ -527,25 +507,11 @@ function createImaController(video, options) {
527
507
  if (!adVideoElement) {
528
508
  adVideoElement = createAdVideoElement();
529
509
  adContainerEl.appendChild(adVideoElement);
530
- console.log(
531
- "[IMA] Dedicated ad video element created and added to container"
532
- );
533
510
  }
534
511
  adDisplayContainer = new google.ima.AdDisplayContainer(
535
512
  container,
536
513
  adVideoElement
537
514
  );
538
- try {
539
- adDisplayContainer.initialize();
540
- console.log(
541
- "[IMA] Ad display container initialized with dedicated ad video"
542
- );
543
- } catch (error) {
544
- console.warn(
545
- "[IMA] Failed to initialize ad display container:",
546
- error
547
- );
548
- }
549
515
  }
550
516
  const videoWidth = video.offsetWidth || video.clientWidth;
551
517
  const videoHeight = video.offsetHeight || video.clientHeight;
@@ -560,29 +526,17 @@ function createImaController(video, options) {
560
526
  return Promise.reject(error);
561
527
  }
562
528
  if (!adsLoader) {
563
- console.log("[IMA] Creating ads loader");
564
529
  const adsLoaderCls = new google.ima.AdsLoader(adDisplayContainer);
565
530
  adsLoader = adsLoaderCls;
566
531
  adsLoader.addEventListener(
567
532
  google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
568
533
  (evt) => {
569
- console.log("[DEBUG-FLOW] \u2705 ADS_MANAGER_LOADED - Setting up manager");
570
534
  try {
571
535
  const adsRenderingSettings = new google.ima.AdsRenderingSettings();
572
536
  adsRenderingSettings.enablePreloading = true;
573
537
  adsManager = evt.getAdsManager(video, adsRenderingSettings);
574
538
  const AdEvent = google.ima.AdEvent.Type;
575
539
  const AdErrorEvent = google.ima.AdErrorEvent.Type;
576
- const keyEvents = ["STARTED", "COMPLETE", "CONTENT_PAUSE_REQUESTED", "CONTENT_RESUME_REQUESTED", "ALL_ADS_COMPLETED"];
577
- keyEvents.forEach((eventType) => {
578
- if (AdEvent[eventType]) {
579
- adsManager.addEventListener(AdEvent[eventType], (e) => {
580
- var _a, _b;
581
- const ad = (_a = e.getAd) == null ? void 0 : _a.call(e);
582
- console.log(`[DEBUG-FLOW] \u{1F3AC} ${eventType} | title=${((_b = ad == null ? void 0 : ad.getTitle) == null ? void 0 : _b.call(ad)) || "N/A"}`);
583
- });
584
- }
585
- });
586
540
  adsManager.addEventListener(
587
541
  AdErrorEvent.AD_ERROR,
588
542
  (errorEvent) => {
@@ -599,7 +553,6 @@ function createImaController(video, options) {
599
553
  if (adContainerEl) {
600
554
  adContainerEl.style.pointerEvents = "none";
601
555
  adContainerEl.style.display = "none";
602
- console.log("[DEBUG-LAYER] \u274C Ad container HIDDEN (error)");
603
556
  }
604
557
  }, 300);
605
558
  }
@@ -631,7 +584,6 @@ function createImaController(video, options) {
631
584
  adsManager.addEventListener(
632
585
  AdEvent.CONTENT_PAUSE_REQUESTED,
633
586
  () => {
634
- console.log("[DEBUG-FLOW] \u{1F3AF} CONTENT_PAUSE_REQUESTED - Ad request accepted");
635
587
  if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
636
588
  video.pause();
637
589
  }
@@ -641,15 +593,11 @@ function createImaController(video, options) {
641
593
  }
642
594
  );
643
595
  adsManager.addEventListener(AdEvent.STARTED, () => {
644
- console.log("[DEBUG-FLOW] \u25B6\uFE0F STARTED - Ad playing now");
645
596
  setAdPlayingFlag(true);
646
597
  hideContentVideo();
647
598
  if (adVideoElement) {
648
599
  adVideoElement.volume = originalMutedState ? 0 : originalVolume;
649
600
  adVideoElement.muted = originalMutedState;
650
- console.log(
651
- `[DEBUG-AUDIO] \u{1F50A} Ad audio set | volume=${adVideoElement.volume}, muted=${adVideoElement.muted}`
652
- );
653
601
  }
654
602
  if (adContainerEl) {
655
603
  adContainerEl.style.pointerEvents = "auto";
@@ -662,15 +610,12 @@ function createImaController(video, options) {
662
610
  adsManager.addEventListener(
663
611
  AdEvent.CONTENT_RESUME_REQUESTED,
664
612
  () => {
665
- console.log("[DEBUG-FLOW] \u23F8\uFE0F CONTENT_RESUME - Single ad done");
666
613
  adPlaying = false;
667
614
  setAdPlayingFlag(false);
668
- console.log("[DEBUG-LAYER] \u26A0\uFE0F Waiting for pod manager (more ads, placeholder, or done)");
669
615
  emit("content_resume");
670
616
  }
671
617
  );
672
618
  adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
673
- console.log("[DEBUG-FLOW] \u{1F3C1} ALL_ADS_COMPLETED - Pod finished");
674
619
  adPlaying = false;
675
620
  setAdPlayingFlag(false);
676
621
  if (adContainerEl) {
@@ -680,19 +625,16 @@ function createImaController(video, options) {
680
625
  if (adContainerEl) {
681
626
  adContainerEl.style.pointerEvents = "none";
682
627
  adContainerEl.style.display = "none";
683
- console.log("[DEBUG-LAYER] \u26AB Ad container HIDDEN (pod done)");
684
628
  }
685
629
  }, 300);
686
630
  }
687
631
  showContentVideo();
688
632
  if (!(options == null ? void 0 : options.continueLiveStreamDuringAds) && video.paused) {
689
- video.play().catch((e) => {
690
- console.warn("[DEBUG-ERROR] Failed to resume video:", e);
633
+ video.play().catch(() => {
691
634
  });
692
635
  }
693
636
  emit("all_ads_completed");
694
637
  });
695
- console.log("[IMA] Ads manager event listeners attached");
696
638
  if (adsLoadedResolve) {
697
639
  adsLoadedResolve();
698
640
  adsLoadedResolve = void 0;
@@ -787,9 +729,7 @@ function createImaController(video, options) {
787
729
  }
788
730
  const preloadPromise = fetchVastDocument(vastTagUrl).then((xml) => {
789
731
  preloadedVast.set(vastTagUrl, xml);
790
- console.log("[IMA] Cached VAST response for preloading:", vastTagUrl);
791
- }).catch((error) => {
792
- console.warn("[IMA] Failed to preload VAST response:", error);
732
+ }).catch(() => {
793
733
  preloadedVast.delete(vastTagUrl);
794
734
  }).finally(() => {
795
735
  preloadingVast.delete(vastTagUrl);
@@ -802,7 +742,6 @@ function createImaController(video, options) {
802
742
  },
803
743
  async play() {
804
744
  var _a, _b;
805
- console.log("[DEBUG-FLOW] \u25B6\uFE0F play() - Starting ad playback");
806
745
  if (!((_a = window.google) == null ? void 0 : _a.ima) || !adDisplayContainer) {
807
746
  return Promise.reject(new Error("IMA SDK not available"));
808
747
  }
@@ -818,19 +757,15 @@ function createImaController(video, options) {
818
757
  if (adVideoElement) {
819
758
  adVideoElement.volume = adVolume;
820
759
  adVideoElement.muted = originalMutedState;
821
- console.log(
822
- `[DEBUG-AUDIO] \u{1F50A} Pre-start ad audio | volume=${adVolume}, muted=${originalMutedState}`
823
- );
824
760
  }
825
761
  try {
826
762
  adsManager.setVolume(adVolume);
827
- } catch (error) {
828
- console.warn("[DEBUG-ERROR] Failed to set IMA manager volume:", error);
763
+ } catch {
829
764
  }
830
765
  adsManager.start();
831
766
  return Promise.resolve();
832
767
  } catch (error) {
833
- console.error("[DEBUG-ERROR] \u274C Error starting ad:", error);
768
+ console.error("[IMA] \u274C Error starting ad:", error);
834
769
  adPlaying = false;
835
770
  setAdPlayingFlag(false);
836
771
  if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
@@ -842,7 +777,6 @@ function createImaController(video, options) {
842
777
  },
843
778
  async stop() {
844
779
  var _a;
845
- console.log("[DEBUG-FLOW] \u23F9\uFE0F stop() - Stopping ad playback");
846
780
  adPlaying = false;
847
781
  setAdPlayingFlag(false);
848
782
  if (adContainerEl) {
@@ -852,7 +786,6 @@ function createImaController(video, options) {
852
786
  if (adContainerEl) {
853
787
  adContainerEl.style.pointerEvents = "none";
854
788
  adContainerEl.style.display = "none";
855
- console.log("[DEBUG-LAYER] \u26AB Ad container HIDDEN (stop)");
856
789
  }
857
790
  }, 300);
858
791
  }
@@ -922,9 +855,6 @@ function createImaController(video, options) {
922
855
  },
923
856
  updateOriginalMutedState(muted, volume) {
924
857
  const nextVolume = typeof volume === "number" && !Number.isNaN(volume) ? Math.max(0, Math.min(1, volume)) : originalVolume;
925
- console.log(
926
- `[DEBUG-AUDIO] \u{1F4BE} Saved original state | muted: ${originalMutedState}->${muted}, volume: ${originalVolume}->${nextVolume}`
927
- );
928
858
  originalMutedState = muted;
929
859
  originalVolume = nextVolume;
930
860
  },
@@ -939,15 +869,11 @@ function createImaController(video, options) {
939
869
  if (adVideoElement && adPlaying) {
940
870
  adVideoElement.volume = clampedVolume;
941
871
  adVideoElement.muted = clampedVolume === 0;
942
- console.log(
943
- `[DEBUG-AUDIO] \u{1F50A} Ad volume changed | volume=${clampedVolume}, muted=${clampedVolume === 0}`
944
- );
945
872
  }
946
873
  if (adsManager && adPlaying) {
947
874
  try {
948
875
  adsManager.setVolume(clampedVolume);
949
- } catch (error) {
950
- console.warn("[DEBUG-ERROR] Failed to set IMA manager volume:", error);
876
+ } catch {
951
877
  }
952
878
  }
953
879
  },
@@ -2437,51 +2363,37 @@ var StormcloudVideoPlayer = class {
2437
2363
  });
2438
2364
  this.ima.on("ad_error", (errorPayload) => {
2439
2365
  const remaining = this.getRemainingAdMs();
2440
- console.error(
2441
- `[DEBUG-POD] \u274C ad_error event | inBreak=${this.inAdBreak}, queue=${this.adPodQueue.length}, remaining=${remaining}ms`,
2442
- errorPayload ? `
2443
- Error details: ${JSON.stringify(errorPayload)}` : ""
2444
- );
2366
+ console.error("[AD-ERROR] Ad playback failed", errorPayload || "");
2445
2367
  if (this.inAdBreak) {
2446
2368
  if (remaining > 500 && this.adPodQueue.length > 0) {
2447
2369
  const nextPreloaded = this.findNextPreloadedAd();
2448
2370
  if (nextPreloaded) {
2449
2371
  this.currentAdIndex++;
2450
- console.log(
2451
- `[DEBUG-POD] \u27A1\uFE0F Trying next ad after error (${this.currentAdIndex}/${this.totalAdsInBreak})`
2452
- );
2453
2372
  this.playSingleAd(nextPreloaded).catch(() => {
2454
2373
  this.handleAdFailure();
2455
2374
  });
2456
2375
  } else {
2457
- console.log("[DEBUG-POD] \u26A0\uFE0F No more preloaded ads - calling handleAdFailure");
2458
2376
  this.handleAdFailure();
2459
2377
  }
2460
2378
  } else {
2461
- console.log("[DEBUG-POD] \u26A0\uFE0F No more ads or time - calling handleAdFailure");
2462
2379
  this.handleAdFailure();
2463
2380
  }
2464
2381
  } else {
2465
- console.log("[DEBUG-POD] \u26A0\uFE0F Error before ad break established");
2466
2382
  this.handleAdFailure();
2467
2383
  }
2468
2384
  });
2469
2385
  this.ima.on("content_pause", () => {
2470
- console.log(`[DEBUG-POD] \u{1F3AF} content_pause (AD STARTING!) | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}`);
2471
2386
  this.clearAdFailsafeTimer();
2472
2387
  this.clearAdRequestWatchdog();
2473
2388
  this.activeAdRequestToken = null;
2474
2389
  this.showAds = true;
2475
- console.log("[DEBUG-LAYER] \u{1F3AC} Layers: Main=hidden, Ad=visible, Placeholder=no");
2476
2390
  });
2477
2391
  this.ima.on("content_resume", () => {
2478
- console.log(`[DEBUG-POD] \u23F8\uFE0F content_resume | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}, remaining=${this.getRemainingAdMs()}ms`);
2479
2392
  this.clearAdFailsafeTimer();
2480
2393
  this.clearAdRequestWatchdog();
2481
2394
  this.activeAdRequestToken = null;
2482
2395
  this.showAds = false;
2483
2396
  if (!this.inAdBreak) {
2484
- console.warn("[DEBUG-POD] \u26A0\uFE0F Not in ad break - shouldn't happen");
2485
2397
  return;
2486
2398
  }
2487
2399
  const remaining = this.getRemainingAdMs();
@@ -2489,17 +2401,13 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
2489
2401
  const nextPreloaded = this.findNextPreloadedAd();
2490
2402
  if (nextPreloaded) {
2491
2403
  this.currentAdIndex++;
2492
- console.log(`[DEBUG-POD] \u27A1\uFE0F Playing next ad ${this.currentAdIndex}/${this.totalAdsInBreak} (preloaded)`);
2493
2404
  this.playSingleAd(nextPreloaded).catch(() => {
2494
- console.error("[DEBUG-POD] \u274C Failed to play next ad");
2495
2405
  this.handleAdPodComplete();
2496
2406
  });
2497
2407
  } else {
2498
- console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads - ending pod");
2499
2408
  this.handleAdPodComplete();
2500
2409
  }
2501
2410
  } else {
2502
- console.log("[DEBUG-POD] \u2705 Pod complete (no more ads or time expired)");
2503
2411
  this.handleAdPodComplete();
2504
2412
  }
2505
2413
  });
@@ -2653,9 +2561,6 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
2653
2561
  }
2654
2562
  if (marker.type === "start") {
2655
2563
  if (this.inAdBreak) {
2656
- console.log(
2657
- `[DEBUG-POD] \u26A0\uFE0F SCTE-35 start marker ignored - already in ad break (currentTime: ${this.video.currentTime})`
2658
- );
2659
2564
  return;
2660
2565
  }
2661
2566
  this.inAdBreak = true;
@@ -2724,9 +2629,6 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
2724
2629
  return;
2725
2630
  }
2726
2631
  if (marker.type === "progress" && this.inAdBreak) {
2727
- console.log(
2728
- `[DEBUG-POD] \u{1F4CA} SCTE-35 progress marker (currentTime: ${this.video.currentTime})`
2729
- );
2730
2632
  if (marker.durationSeconds != null) {
2731
2633
  this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
2732
2634
  }
@@ -2739,7 +2641,6 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
2739
2641
  this.scheduleAdStopCountdown(remainingMs);
2740
2642
  }
2741
2643
  if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null) {
2742
- console.log("[DEBUG-POD] \u{1F4CA} Progress marker: no ad playing, attempting to start");
2743
2644
  const scheduled = this.findCurrentOrNextBreak(
2744
2645
  this.video.currentTime * 1e3
2745
2646
  );
@@ -2751,24 +2652,16 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
2751
2652
  this.playSingleAd(first).catch(() => {
2752
2653
  });
2753
2654
  }
2754
- } else {
2755
- console.log(
2756
- `[DEBUG-POD] \u{1F4CA} Progress marker: ad playing or request active (playing=${this.ima.isAdPlaying()}, token=${this.activeAdRequestToken})`
2757
- );
2758
2655
  }
2759
2656
  return;
2760
2657
  }
2761
2658
  if (marker.type === "end") {
2762
- console.log(
2763
- `[DEBUG-POD] \u{1F3C1} SCTE-35 end marker received (currentTime: ${this.video.currentTime})`
2764
- );
2765
2659
  this.inAdBreak = false;
2766
2660
  this.expectedAdBreakDurationMs = void 0;
2767
2661
  this.currentAdBreakStartWallClockMs = void 0;
2768
2662
  this.clearAdStartTimer();
2769
2663
  this.clearAdStopTimer();
2770
2664
  if (this.ima.isAdPlaying()) {
2771
- console.log("[DEBUG-POD] \u{1F6D1} Stopping ad due to SCTE-35 end marker");
2772
2665
  this.ima.stop().catch(() => {
2773
2666
  });
2774
2667
  }
@@ -3169,11 +3062,9 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3169
3062
  } else if (tags && tags.length > 0) {
3170
3063
  vastTagUrls = tags;
3171
3064
  } else {
3172
- console.log("[DEBUG-POD] \u26A0\uFE0F No VAST tag available");
3173
3065
  return;
3174
3066
  }
3175
3067
  if (vastTagUrls.length > 0) {
3176
- console.log(`[DEBUG-POD] \u{1F3AF} Starting ad break with ${vastTagUrls.length} ads`);
3177
3068
  this.adPodAllUrls = [...vastTagUrls];
3178
3069
  this.preloadingAdUrls.clear();
3179
3070
  this.vastToMediaUrlMap.clear();
@@ -3181,9 +3072,6 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3181
3072
  this.preloadingMediaUrls.clear();
3182
3073
  const currentMuted = this.video.muted;
3183
3074
  const currentVolume = this.video.volume;
3184
- console.log(
3185
- `[DEBUG-AUDIO] \u{1F4BE} Capturing ORIGINAL state (once) | muted=${currentMuted}, volume=${currentVolume}`
3186
- );
3187
3075
  this.ima.updateOriginalMutedState(currentMuted, currentVolume);
3188
3076
  this.inAdBreak = true;
3189
3077
  this.currentAdIndex = 0;
@@ -3244,40 +3132,27 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3244
3132
  }
3245
3133
  async playAdPod() {
3246
3134
  if (this.adPodQueue.length === 0) {
3247
- console.log("[DEBUG-POD] \u26A0\uFE0F No ads in pod");
3248
3135
  return;
3249
3136
  }
3250
3137
  const waitTime = this.isAdaptiveMode ? 50 : 500;
3251
3138
  await new Promise((resolve) => setTimeout(resolve, waitTime));
3252
- if (this.config.debugAdTiming) {
3253
- console.log(
3254
- `[DEBUG-POD] \u{1F50D} Looking for preloaded ad in queue of ${this.adPodQueue.length} URLs`
3255
- );
3256
- }
3257
3139
  const firstPreloaded = this.findNextPreloadedAd();
3258
3140
  if (!firstPreloaded) {
3259
- console.log("[DEBUG-POD] \u26A0\uFE0F No preloaded ads found, trying first ad from queue");
3260
3141
  const firstAd = this.adPodQueue.shift();
3261
3142
  if (firstAd) {
3262
3143
  this.currentAdIndex++;
3263
- console.log(`[DEBUG-POD] \u{1F3AC} Attempting to play first ad (not preloaded): ${firstAd.substring(0, 60)}...`);
3264
3144
  try {
3265
3145
  await this.playSingleAd(firstAd);
3266
3146
  } catch (error) {
3267
- console.log("[DEBUG-POD] \u26A0\uFE0F First ad failed, error handler will retry");
3268
3147
  return;
3269
3148
  }
3270
- } else {
3271
- console.log("[DEBUG-POD] \u274C No ads available in queue");
3272
3149
  }
3273
3150
  return;
3274
3151
  }
3275
3152
  this.currentAdIndex++;
3276
- console.log(`[DEBUG-POD] \u{1F680} Starting pod with ad ${this.currentAdIndex}/${this.totalAdsInBreak}`);
3277
3153
  try {
3278
3154
  await this.playSingleAd(firstPreloaded);
3279
3155
  } catch (error) {
3280
- console.log("[DEBUG-POD] \u26A0\uFE0F First ad failed, error handler will retry");
3281
3156
  }
3282
3157
  }
3283
3158
  findCurrentOrNextBreak(nowMs) {
@@ -3357,15 +3232,9 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3357
3232
  const overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
3358
3233
  const shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
3359
3234
  if (shouldExtendAdBreak) {
3360
- console.log(
3361
- `[DEBUG-POD] \u23F3 Extending ad break | elapsed=${elapsedSinceStartMs}ms, expected=${expectedDurationMs}ms, overrun=${overrunMs}ms`
3362
- );
3363
3235
  this.scheduleAdStopCountdown(checkIntervalMs);
3364
3236
  return;
3365
3237
  }
3366
- console.log(
3367
- `[DEBUG-POD] \u23F1\uFE0F Ad break duration expired | elapsed=${elapsedSinceStartMs}ms, expected=${expectedDurationMs}ms`
3368
- );
3369
3238
  if (adPlaying) {
3370
3239
  this.ima.stop().catch(() => {
3371
3240
  });
@@ -3398,42 +3267,23 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3398
3267
  this.ptsDriftEmaMs = this.ptsDriftEmaMs * (1 - alpha) + sampleMs * alpha;
3399
3268
  }
3400
3269
  async playSingleAd(vastTagUrl) {
3401
- console.log(`[DEBUG-POD] \u{1F3AC} playSingleAd | url=${vastTagUrl.substring(0, 60)}...`);
3402
3270
  if (this.ima.isAdPlaying()) {
3403
- console.warn("[DEBUG-POD] \u26A0\uFE0F Ad already playing - skipping request");
3404
3271
  return;
3405
3272
  }
3406
3273
  const requestToken = ++this.adRequestTokenCounter;
3407
- const wasPreloaded = this.ima.hasPreloadedAd(vastTagUrl);
3408
3274
  this.activeAdRequestToken = requestToken;
3409
- console.log(`[DEBUG-POD] \u{1F4DD} Request token=${requestToken}, preloaded=${wasPreloaded}`);
3410
3275
  this.startAdRequestWatchdog(requestToken);
3411
3276
  try {
3412
- console.log(`[DEBUG-POD] \u{1F4E1} Calling ima.requestAds() for token=${requestToken}...`);
3413
3277
  await this.ima.requestAds(vastTagUrl);
3414
- console.log(`[DEBUG-POD] \u2705 ima.requestAds() completed successfully`);
3415
3278
  this.clearAdRequestWatchdog();
3416
3279
  if (this.activeAdRequestToken !== requestToken) {
3417
- console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after requestAds (stale request)`);
3418
3280
  return;
3419
3281
  }
3420
- console.log(`[DEBUG-POD] \u{1F4FA} Calling ima.play() to start ad playback...`);
3421
- console.log(`[DEBUG-POD] \u{1F4CA} Video element state: paused=${this.video.paused}, muted=${this.video.muted}, readyState=${this.video.readyState}`);
3422
3282
  try {
3423
3283
  this.startAdFailsafeTimer(requestToken);
3424
3284
  await this.ima.play();
3425
- if (this.activeAdRequestToken === requestToken) {
3426
- console.log(`[DEBUG-POD] \u2705 Ad play initiated successfully (token=${requestToken})`);
3427
- } else {
3428
- console.warn(`[DEBUG-POD] \u26A0\uFE0F Token mismatch after play (stale request)`);
3429
- }
3430
3285
  } catch (playError) {
3431
- console.error(
3432
- "[DEBUG-POD] \u274C Failed to play ad:",
3433
- playError instanceof Error ? playError.message : playError,
3434
- "\nFull error:",
3435
- playError
3436
- );
3286
+ console.error("[AD-ERROR] Failed to play ad:", playError);
3437
3287
  this.clearAdFailsafeTimer();
3438
3288
  if (this.activeAdRequestToken === requestToken) {
3439
3289
  this.activeAdRequestToken = null;
@@ -3442,7 +3292,7 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3442
3292
  return;
3443
3293
  }
3444
3294
  } catch (error) {
3445
- console.error("[DEBUG-POD] \u274C Ad request failed:", error == null ? void 0 : error.message);
3295
+ console.error("[AD-ERROR] Ad request failed:", error == null ? void 0 : error.message);
3446
3296
  this.clearAdRequestWatchdog();
3447
3297
  this.clearAdFailsafeTimer();
3448
3298
  if (this.activeAdRequestToken === requestToken) {
@@ -3453,7 +3303,6 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3453
3303
  }
3454
3304
  handleAdPodComplete() {
3455
3305
  var _a;
3456
- console.log("[DEBUG-POD] \u{1F3C1} handleAdPodComplete - Ending ad break, restoring content");
3457
3306
  this.clearAdRequestWatchdog();
3458
3307
  this.clearAdFailsafeTimer();
3459
3308
  this.activeAdRequestToken = null;
@@ -3475,10 +3324,6 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3475
3324
  });
3476
3325
  const restoredMuted = this.ima.getOriginalMutedState();
3477
3326
  const restoredVolume = this.ima.getOriginalVolume();
3478
- console.log(
3479
- `[DEBUG-AUDIO] \u{1F50A} Audio restored by IMA | muted=${restoredMuted}, volume=${restoredVolume}`
3480
- );
3481
- console.log("[DEBUG-LAYER] \u{1F3AC} Layers: Main=visible, Ad=hidden, Placeholder=no");
3482
3327
  if (this.video.muted !== restoredMuted) {
3483
3328
  this.video.muted = restoredMuted;
3484
3329
  }
@@ -3486,14 +3331,11 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3486
3331
  this.video.volume = restoredVolume;
3487
3332
  }
3488
3333
  if (!this.shouldContinueLiveStreamDuringAds() && this.video.paused) {
3489
- console.log("[DEBUG-FLOW] \u25B6\uFE0F Resuming main video playback");
3490
- (_a = this.video.play()) == null ? void 0 : _a.catch((error) => {
3491
- console.error("[DEBUG-ERROR] Failed to resume video:", error);
3334
+ (_a = this.video.play()) == null ? void 0 : _a.catch(() => {
3492
3335
  });
3493
3336
  }
3494
3337
  }
3495
3338
  handleAdFailure() {
3496
- console.log("[DEBUG-POD] \u274C handleAdFailure - skipping to next ad or ending break");
3497
3339
  const remaining = this.getRemainingAdMs();
3498
3340
  if (remaining > 500 && this.adPodQueue.length > 0) {
3499
3341
  if (this.isAdaptiveMode && this.currentAdIndex <= 1) {
@@ -3506,14 +3348,12 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3506
3348
  const nextPreloaded = this.findNextPreloadedAd();
3507
3349
  if (nextPreloaded) {
3508
3350
  this.currentAdIndex++;
3509
- console.log(`[DEBUG-POD] \u27A1\uFE0F Trying next ad after failure (${this.currentAdIndex}/${this.totalAdsInBreak})`);
3510
3351
  this.playSingleAd(nextPreloaded).catch(() => {
3511
3352
  this.handleAdPodComplete();
3512
3353
  });
3513
3354
  return;
3514
3355
  }
3515
3356
  }
3516
- console.log("[DEBUG-POD] \u23F9\uFE0F Ending ad break after failure");
3517
3357
  this.handleAdPodComplete();
3518
3358
  }
3519
3359
  tryNextAdWithRetry(retryCount) {
@@ -3966,37 +3806,17 @@ Error details: ${JSON.stringify(errorPayload)}` : ""
3966
3806
  }
3967
3807
  findNextPreloadedAd() {
3968
3808
  var _a, _b, _c;
3969
- if (this.config.debugAdTiming) {
3970
- console.log(
3971
- `[DEBUG-POD] \u{1F50E} Searching for preloaded ad in queue (${this.adPodQueue.length} URLs, ${this.preloadedMediaUrls.size} media preloaded, ${this.vastToMediaUrlMap.size} VAST mappings)`
3972
- );
3973
- }
3974
3809
  for (let i = 0; i < this.adPodQueue.length; i++) {
3975
3810
  const vastTagUrl = this.adPodQueue[i];
3976
3811
  if (!vastTagUrl) continue;
3977
3812
  const hasImaPreload = (_c = (_b = (_a = this.ima).hasPreloadedAd) == null ? void 0 : _b.call(_a, vastTagUrl)) != null ? _c : false;
3978
3813
  const mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
3979
3814
  const hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
3980
- if (this.config.debugAdTiming) {
3981
- console.log(
3982
- `[DEBUG-POD] Ad ${i}: IMA=${hasImaPreload}, Media=${hasMediaPreload}, MediaURLs=${(mediaUrls == null ? void 0 : mediaUrls.length) || 0}, URL=${vastTagUrl.substring(0, 60)}...`
3983
- );
3984
- }
3985
3815
  if (hasImaPreload || hasMediaPreload) {
3986
- if (this.config.debugAdTiming) {
3987
- console.log(
3988
- `[DEBUG-POD] \u2705 Found preloaded ad at index ${i}`
3989
- );
3990
- }
3991
3816
  this.adPodQueue.splice(0, i + 1);
3992
3817
  return vastTagUrl;
3993
3818
  }
3994
3819
  }
3995
- if (this.config.debugAdTiming) {
3996
- console.log(
3997
- `[DEBUG-POD] \u274C No preloaded ads found in queue`
3998
- );
3999
- }
4000
3820
  return void 0;
4001
3821
  }
4002
3822
  getRemainingAdMs() {