stormcloud-video-player 0.2.18 → 0.2.19

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
@@ -24,6 +24,8 @@ interface StormcloudVideoPlayerConfig {
24
24
  immediateManifestAds?: boolean;
25
25
  debugAdTiming?: boolean;
26
26
  adFailsafeTimeoutMs?: number;
27
+ adBreakCheckIntervalMs?: number;
28
+ maxAdBreakExtensionMs?: number;
27
29
  showCustomControls?: boolean;
28
30
  onVolumeToggle?: () => void;
29
31
  onFullscreenToggle?: () => void;
package/lib/index.d.ts CHANGED
@@ -24,6 +24,8 @@ interface StormcloudVideoPlayerConfig {
24
24
  immediateManifestAds?: boolean;
25
25
  debugAdTiming?: boolean;
26
26
  adFailsafeTimeoutMs?: number;
27
+ adBreakCheckIntervalMs?: number;
28
+ maxAdBreakExtensionMs?: number;
27
29
  showCustomControls?: boolean;
28
30
  onVolumeToggle?: () => void;
29
31
  onFullscreenToggle?: () => void;
package/lib/index.js CHANGED
@@ -2871,14 +2871,66 @@ var StormcloudVideoPlayer = class {
2871
2871
  }
2872
2872
  }
2873
2873
  ensureAdStoppedByTimer() {
2874
+ var _a, _b;
2874
2875
  if (!this.inAdBreak) return;
2876
+ this.adStopTimerId = void 0;
2877
+ const adPlaying = this.ima.isAdPlaying();
2878
+ const pendingAds = this.adPodQueue.length > 0;
2879
+ const checkIntervalMs = Math.max(
2880
+ 250,
2881
+ Math.floor((_a = this.config.adBreakCheckIntervalMs) != null ? _a : 1e3)
2882
+ );
2883
+ const maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
2884
+ const maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 6e4;
2885
+ let elapsedSinceStartMs = 0;
2886
+ if (this.currentAdBreakStartWallClockMs != null) {
2887
+ elapsedSinceStartMs = Date.now() - this.currentAdBreakStartWallClockMs;
2888
+ }
2889
+ const expectedDurationMs = (_b = this.expectedAdBreakDurationMs) != null ? _b : 0;
2890
+ const overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
2891
+ const shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
2892
+ if (shouldExtendAdBreak) {
2893
+ if (this.config.debugAdTiming) {
2894
+ console.log(
2895
+ "[StormcloudVideoPlayer] Extending ad break beyond scheduled duration",
2896
+ {
2897
+ adPlaying,
2898
+ pendingAds,
2899
+ showAds: this.showAds,
2900
+ overrunMs,
2901
+ checkIntervalMs,
2902
+ maxExtensionMs
2903
+ }
2904
+ );
2905
+ }
2906
+ this.scheduleAdStopCountdown(checkIntervalMs);
2907
+ return;
2908
+ }
2909
+ if (this.config.debugAdTiming) {
2910
+ console.log("[StormcloudVideoPlayer] Ending ad break via timer", {
2911
+ adPlaying,
2912
+ pendingAds,
2913
+ showAds: this.showAds,
2914
+ overrunMs,
2915
+ maxExtensionMs
2916
+ });
2917
+ }
2875
2918
  this.inAdBreak = false;
2876
2919
  this.expectedAdBreakDurationMs = void 0;
2877
2920
  this.currentAdBreakStartWallClockMs = void 0;
2878
- this.adStopTimerId = void 0;
2879
- if (this.ima.isAdPlaying()) {
2921
+ this.showAds = false;
2922
+ this.adPodQueue = [];
2923
+ this.currentAdIndex = 0;
2924
+ this.totalAdsInBreak = 0;
2925
+ this.clearAdFailsafeTimer();
2926
+ if (adPlaying) {
2880
2927
  this.ima.stop().catch(() => {
2881
2928
  });
2929
+ return;
2930
+ }
2931
+ const originalMutedState = this.ima.getOriginalMutedState();
2932
+ if (this.video.muted !== originalMutedState) {
2933
+ this.video.muted = originalMutedState;
2882
2934
  }
2883
2935
  }
2884
2936
  scheduleAdStartIn(delayMs) {