stormcloud-video-player 0.2.35 → 0.2.36

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/lib/index.d.cts CHANGED
@@ -181,10 +181,7 @@ declare class StormcloudVideoPlayer {
181
181
  private startAdFailsafeTimer;
182
182
  private clearAdFailsafeTimer;
183
183
  private selectVastTagsForBreak;
184
- private logQueuedAdUrls;
185
184
  private logAdState;
186
- private enforceAdHoldState;
187
- private releaseAdHoldState;
188
185
  private fetchAndParseVastXml;
189
186
  private extractMediaUrlsFromVast;
190
187
  private preloadMediaFile;
package/lib/index.d.ts CHANGED
@@ -181,10 +181,7 @@ declare class StormcloudVideoPlayer {
181
181
  private startAdFailsafeTimer;
182
182
  private clearAdFailsafeTimer;
183
183
  private selectVastTagsForBreak;
184
- private logQueuedAdUrls;
185
184
  private logAdState;
186
- private enforceAdHoldState;
187
- private releaseAdHoldState;
188
185
  private fetchAndParseVastXml;
189
186
  private extractMediaUrlsFromVast;
190
187
  private preloadMediaFile;
package/lib/index.js CHANGED
@@ -626,19 +626,10 @@ function createImaController(video, options) {
626
626
  adsManager.addEventListener(
627
627
  AdEvent.CONTENT_PAUSE_REQUESTED,
628
628
  () => {
629
- console.log("[DEBUG-FLOW] \u{1F3AF} CONTENT_PAUSE_REQUESTED - Ad starting");
629
+ console.log("[DEBUG-FLOW] \u{1F3AF} CONTENT_PAUSE_REQUESTED - Ad request accepted");
630
630
  if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
631
631
  video.pause();
632
632
  }
633
- hideContentVideo();
634
- if (adContainerEl) {
635
- adContainerEl.style.pointerEvents = "auto";
636
- adContainerEl.style.display = "flex";
637
- adContainerEl.style.backgroundColor = "#000";
638
- adContainerEl.offsetHeight;
639
- adContainerEl.style.opacity = "1";
640
- console.log("[DEBUG-LAYER] \u{1F7E1} Ad container VISIBLE");
641
- }
642
633
  adPlaying = true;
643
634
  setAdPlayingFlag(true);
644
635
  emit("content_pause");
@@ -2471,7 +2462,7 @@ var StormcloudVideoPlayer = class {
2471
2462
  this.clearAdRequestWatchdog();
2472
2463
  this.activeAdRequestToken = null;
2473
2464
  this.showAds = true;
2474
- this.enforceAdHoldState();
2465
+ console.log("[DEBUG-LAYER] \u{1F3AC} Layers: Main=hidden, Ad=visible, Placeholder=no");
2475
2466
  });
2476
2467
  this.ima.on("content_resume", () => {
2477
2468
  console.log(`[DEBUG-POD] \u23F8\uFE0F content_resume | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}, remaining=${this.getRemainingAdMs()}ms`);
@@ -2651,6 +2642,12 @@ var StormcloudVideoPlayer = class {
2651
2642
  });
2652
2643
  }
2653
2644
  if (marker.type === "start") {
2645
+ if (this.inAdBreak) {
2646
+ console.log(
2647
+ `[DEBUG-POD] \u26A0\uFE0F SCTE-35 start marker ignored - already in ad break (currentTime: ${this.video.currentTime})`
2648
+ );
2649
+ return;
2650
+ }
2654
2651
  this.inAdBreak = true;
2655
2652
  const durationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
2656
2653
  this.expectedAdBreakDurationMs = durationMs;
@@ -2717,6 +2714,9 @@ var StormcloudVideoPlayer = class {
2717
2714
  return;
2718
2715
  }
2719
2716
  if (marker.type === "progress" && this.inAdBreak) {
2717
+ console.log(
2718
+ `[DEBUG-POD] \u{1F4CA} SCTE-35 progress marker (currentTime: ${this.video.currentTime})`
2719
+ );
2720
2720
  if (marker.durationSeconds != null) {
2721
2721
  this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
2722
2722
  }
@@ -2728,7 +2728,8 @@ var StormcloudVideoPlayer = class {
2728
2728
  );
2729
2729
  this.scheduleAdStopCountdown(remainingMs);
2730
2730
  }
2731
- if (!this.ima.isAdPlaying()) {
2731
+ if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null) {
2732
+ console.log("[DEBUG-POD] \u{1F4CA} Progress marker: no ad playing, attempting to start");
2732
2733
  const scheduled = this.findCurrentOrNextBreak(
2733
2734
  this.video.currentTime * 1e3
2734
2735
  );
@@ -2737,25 +2738,31 @@ var StormcloudVideoPlayer = class {
2737
2738
  const first = tags[0];
2738
2739
  const rest = tags.slice(1);
2739
2740
  this.adPodQueue = rest;
2740
- if (!this.showAds) {
2741
- this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
2742
- }
2743
2741
  this.playSingleAd(first).catch(() => {
2744
2742
  });
2745
2743
  }
2744
+ } else {
2745
+ console.log(
2746
+ `[DEBUG-POD] \u{1F4CA} Progress marker: ad playing or request active (playing=${this.ima.isAdPlaying()}, token=${this.activeAdRequestToken})`
2747
+ );
2746
2748
  }
2747
2749
  return;
2748
2750
  }
2749
2751
  if (marker.type === "end") {
2752
+ console.log(
2753
+ `[DEBUG-POD] \u{1F3C1} SCTE-35 end marker received (currentTime: ${this.video.currentTime})`
2754
+ );
2750
2755
  this.inAdBreak = false;
2751
2756
  this.expectedAdBreakDurationMs = void 0;
2752
2757
  this.currentAdBreakStartWallClockMs = void 0;
2753
2758
  this.clearAdStartTimer();
2754
2759
  this.clearAdStopTimer();
2755
2760
  if (this.ima.isAdPlaying()) {
2761
+ console.log("[DEBUG-POD] \u{1F6D1} Stopping ad due to SCTE-35 end marker");
2756
2762
  this.ima.stop().catch(() => {
2757
2763
  });
2758
2764
  }
2765
+ this.handleAdPodComplete();
2759
2766
  return;
2760
2767
  }
2761
2768
  }
@@ -3086,10 +3093,12 @@ var StormcloudVideoPlayer = class {
3086
3093
  this.vastToMediaUrlMap.clear();
3087
3094
  this.preloadedMediaUrls.clear();
3088
3095
  this.preloadingMediaUrls.clear();
3096
+ const currentMuted = this.video.muted;
3097
+ const currentVolume = this.video.volume;
3089
3098
  console.log(
3090
- `[DEBUG-AUDIO] \u{1F4BE} Capturing original state | muted=${this.video.muted}, volume=${this.video.volume}`
3099
+ `[DEBUG-AUDIO] \u{1F4BE} Capturing ORIGINAL state (once) | muted=${currentMuted}, volume=${currentVolume}`
3091
3100
  );
3092
- this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
3101
+ this.ima.updateOriginalMutedState(currentMuted, currentVolume);
3093
3102
  this.inAdBreak = true;
3094
3103
  this.currentAdIndex = 0;
3095
3104
  this.totalAdsInBreak = vastTagUrls.length;
@@ -3303,7 +3312,6 @@ var StormcloudVideoPlayer = class {
3303
3312
  this.clearAdRequestWatchdog();
3304
3313
  this.clearAdFailsafeTimer();
3305
3314
  this.activeAdRequestToken = null;
3306
- this.releaseAdHoldState();
3307
3315
  this.preloadingAdUrls.clear();
3308
3316
  this.vastToMediaUrlMap.clear();
3309
3317
  this.preloadedMediaUrls.clear();
@@ -3320,13 +3328,18 @@ var StormcloudVideoPlayer = class {
3320
3328
  this.totalAdsInBreak = 0;
3321
3329
  this.ima.stop().catch(() => {
3322
3330
  });
3323
- const originalMutedState = this.ima.getOriginalMutedState();
3324
- const originalVolume = typeof this.ima.getOriginalVolume === "function" ? this.ima.getOriginalVolume() : this.video.volume;
3325
- this.video.muted = originalMutedState;
3326
- this.video.volume = originalVolume;
3331
+ const restoredMuted = this.ima.getOriginalMutedState();
3332
+ const restoredVolume = this.ima.getOriginalVolume();
3327
3333
  console.log(
3328
- `[DEBUG-AUDIO] \u{1F50A} Main video restored | muted=${originalMutedState}, volume=${originalVolume}`
3334
+ `[DEBUG-AUDIO] \u{1F50A} Audio restored by IMA | muted=${restoredMuted}, volume=${restoredVolume}`
3329
3335
  );
3336
+ console.log("[DEBUG-LAYER] \u{1F3AC} Layers: Main=visible, Ad=hidden, Placeholder=no");
3337
+ if (this.video.muted !== restoredMuted) {
3338
+ this.video.muted = restoredMuted;
3339
+ }
3340
+ if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
3341
+ this.video.volume = restoredVolume;
3342
+ }
3330
3343
  if (!this.shouldContinueLiveStreamDuringAds() && this.video.paused) {
3331
3344
  console.log("[DEBUG-FLOW] \u25B6\uFE0F Resuming main video playback");
3332
3345
  (_a = this.video.play()) == null ? void 0 : _a.catch((error) => {
@@ -3335,20 +3348,20 @@ var StormcloudVideoPlayer = class {
3335
3348
  }
3336
3349
  }
3337
3350
  handleAdFailure() {
3351
+ console.log("[DEBUG-POD] \u274C handleAdFailure - skipping to next ad or ending break");
3338
3352
  const remaining = this.getRemainingAdMs();
3339
- console.log(
3340
- `[DEBUG-POD] \u274C handleAdFailure | inBreak=${this.inAdBreak}, showAds=${this.showAds}, remaining=${remaining}ms`
3341
- );
3342
- if (remaining > 500 && this.inAdBreak) {
3343
- console.log(
3344
- `[DEBUG-POD] \u23F3 Ad failed but ${remaining}ms remaining - showing placeholder until duration expires`
3345
- );
3346
- this.showAds = true;
3347
- this.ima.showPlaceholder();
3348
- this.enforceAdHoldState();
3349
- return;
3353
+ if (remaining > 500 && this.adPodQueue.length > 0) {
3354
+ const nextPreloaded = this.findNextPreloadedAd();
3355
+ if (nextPreloaded) {
3356
+ this.currentAdIndex++;
3357
+ console.log(`[DEBUG-POD] \u27A1\uFE0F Trying next ad after failure (${this.currentAdIndex}/${this.totalAdsInBreak})`);
3358
+ this.playSingleAd(nextPreloaded).catch(() => {
3359
+ this.handleAdPodComplete();
3360
+ });
3361
+ return;
3362
+ }
3350
3363
  }
3351
- console.log("[DEBUG-POD] \u23F9\uFE0F No remaining time - ending ad break now");
3364
+ console.log("[DEBUG-POD] \u23F9\uFE0F Ending ad break after failure");
3352
3365
  this.handleAdPodComplete();
3353
3366
  }
3354
3367
  startAdRequestWatchdog(token) {
@@ -3421,12 +3434,6 @@ var StormcloudVideoPlayer = class {
3421
3434
  }
3422
3435
  return [b.vastTagUrl];
3423
3436
  }
3424
- logQueuedAdUrls(urls) {
3425
- if (!this.config.debugAdTiming) {
3426
- return;
3427
- }
3428
- console.log("[StormcloudVideoPlayer] ALL ad URLs queued:", urls);
3429
- }
3430
3437
  logAdState(event, extra = {}) {
3431
3438
  if (!this.config.debugAdTiming) {
3432
3439
  return;
@@ -3441,22 +3448,6 @@ var StormcloudVideoPlayer = class {
3441
3448
  ...extra
3442
3449
  });
3443
3450
  }
3444
- enforceAdHoldState() {
3445
- this.video.dataset.stormcloudAdPlaying = "true";
3446
- this.video.muted = true;
3447
- this.video.volume = 0;
3448
- console.log("[DEBUG-LAYER] \u{1F512} Enforced ad hold state (main video muted)");
3449
- if (typeof this.ima.showPlaceholder === "function") {
3450
- this.ima.showPlaceholder();
3451
- }
3452
- }
3453
- releaseAdHoldState() {
3454
- delete this.video.dataset.stormcloudAdPlaying;
3455
- console.log("[DEBUG-LAYER] \u{1F513} Released ad hold state");
3456
- if (typeof this.ima.hidePlaceholder === "function") {
3457
- this.ima.hidePlaceholder();
3458
- }
3459
- }
3460
3451
  async fetchAndParseVastXml(vastTagUrl) {
3461
3452
  try {
3462
3453
  const response = await fetch(vastTagUrl, { mode: "cors" });
@@ -3821,7 +3812,6 @@ var StormcloudVideoPlayer = class {
3821
3812
  }
3822
3813
  (_a = this.hls) == null ? void 0 : _a.destroy();
3823
3814
  (_b = this.ima) == null ? void 0 : _b.destroy();
3824
- this.releaseAdHoldState();
3825
3815
  this.preloadingAdUrls.clear();
3826
3816
  this.vastToMediaUrlMap.clear();
3827
3817
  this.preloadedMediaUrls.clear();