stormcloud-video-player 0.2.34 → 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/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +67 -95
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +0 -3
- package/lib/index.d.ts +0 -3
- package/lib/index.js +67 -95
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +67 -95
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +0 -3
- package/lib/players/HlsPlayer.cjs +67 -95
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +67 -95
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/ima.cjs +2 -11
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +67 -95
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/players/index.cjs
CHANGED
|
@@ -670,19 +670,10 @@ function createImaController(video, options) {
|
|
|
670
670
|
adsManager.addEventListener(
|
|
671
671
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
672
672
|
() => {
|
|
673
|
-
console.log("[DEBUG-FLOW] \u{1F3AF} CONTENT_PAUSE_REQUESTED - Ad
|
|
673
|
+
console.log("[DEBUG-FLOW] \u{1F3AF} CONTENT_PAUSE_REQUESTED - Ad request accepted");
|
|
674
674
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
675
675
|
video.pause();
|
|
676
676
|
}
|
|
677
|
-
hideContentVideo();
|
|
678
|
-
if (adContainerEl) {
|
|
679
|
-
adContainerEl.style.pointerEvents = "auto";
|
|
680
|
-
adContainerEl.style.display = "flex";
|
|
681
|
-
adContainerEl.style.backgroundColor = "#000";
|
|
682
|
-
adContainerEl.offsetHeight;
|
|
683
|
-
adContainerEl.style.opacity = "1";
|
|
684
|
-
console.log("[DEBUG-LAYER] \u{1F7E1} Ad container VISIBLE");
|
|
685
|
-
}
|
|
686
677
|
adPlaying = true;
|
|
687
678
|
setAdPlayingFlag(true);
|
|
688
679
|
emit("content_pause");
|
|
@@ -713,7 +704,7 @@ function createImaController(video, options) {
|
|
|
713
704
|
console.log("[DEBUG-FLOW] \u23F8\uFE0F CONTENT_RESUME - Single ad done");
|
|
714
705
|
adPlaying = false;
|
|
715
706
|
setAdPlayingFlag(false);
|
|
716
|
-
console.log("[DEBUG-LAYER] \u26A0\uFE0F Waiting for pod manager
|
|
707
|
+
console.log("[DEBUG-LAYER] \u26A0\uFE0F Waiting for pod manager (more ads, placeholder, or done)");
|
|
717
708
|
emit("content_resume");
|
|
718
709
|
}
|
|
719
710
|
);
|
|
@@ -2481,44 +2472,31 @@ var StormcloudVideoPlayer = class {
|
|
|
2481
2472
|
}
|
|
2482
2473
|
});
|
|
2483
2474
|
this.ima.on("ad_error", () => {
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
remainingAds: this.adPodQueue.length
|
|
2489
|
-
});
|
|
2490
|
-
}
|
|
2475
|
+
const remaining = this.getRemainingAdMs();
|
|
2476
|
+
console.log(
|
|
2477
|
+
`[DEBUG-POD] \u274C ad_error event | inBreak=${this.inAdBreak}, queue=${this.adPodQueue.length}, remaining=${remaining}ms`
|
|
2478
|
+
);
|
|
2491
2479
|
if (this.inAdBreak) {
|
|
2492
|
-
const remaining = this.getRemainingAdMs();
|
|
2493
2480
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
2494
2481
|
const nextPreloaded = this.findNextPreloadedAd();
|
|
2495
2482
|
if (nextPreloaded) {
|
|
2496
2483
|
this.currentAdIndex++;
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
);
|
|
2501
|
-
}
|
|
2484
|
+
console.log(
|
|
2485
|
+
`[DEBUG-POD] \u27A1\uFE0F Trying next ad after error (${this.currentAdIndex}/${this.totalAdsInBreak})`
|
|
2486
|
+
);
|
|
2502
2487
|
this.playSingleAd(nextPreloaded).catch(() => {
|
|
2503
2488
|
this.handleAdFailure();
|
|
2504
2489
|
});
|
|
2505
2490
|
} else {
|
|
2506
|
-
|
|
2507
|
-
console.log(
|
|
2508
|
-
"[StormcloudVideoPlayer] No preloaded ads available, ending ad break"
|
|
2509
|
-
);
|
|
2510
|
-
}
|
|
2491
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F No more preloaded ads - calling handleAdFailure");
|
|
2511
2492
|
this.handleAdFailure();
|
|
2512
2493
|
}
|
|
2513
2494
|
} else {
|
|
2495
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F No more ads or time - calling handleAdFailure");
|
|
2514
2496
|
this.handleAdFailure();
|
|
2515
2497
|
}
|
|
2516
2498
|
} else {
|
|
2517
|
-
|
|
2518
|
-
console.log(
|
|
2519
|
-
"[StormcloudVideoPlayer] Ad error before ad break established - cleaning up"
|
|
2520
|
-
);
|
|
2521
|
-
}
|
|
2499
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F Error before ad break established");
|
|
2522
2500
|
this.handleAdFailure();
|
|
2523
2501
|
}
|
|
2524
2502
|
});
|
|
@@ -2528,7 +2506,7 @@ var StormcloudVideoPlayer = class {
|
|
|
2528
2506
|
this.clearAdRequestWatchdog();
|
|
2529
2507
|
this.activeAdRequestToken = null;
|
|
2530
2508
|
this.showAds = true;
|
|
2531
|
-
|
|
2509
|
+
console.log("[DEBUG-LAYER] \u{1F3AC} Layers: Main=hidden, Ad=visible, Placeholder=no");
|
|
2532
2510
|
});
|
|
2533
2511
|
this.ima.on("content_resume", () => {
|
|
2534
2512
|
console.log(`[DEBUG-POD] \u23F8\uFE0F content_resume | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}, remaining=${this.getRemainingAdMs()}ms`);
|
|
@@ -2708,6 +2686,12 @@ var StormcloudVideoPlayer = class {
|
|
|
2708
2686
|
});
|
|
2709
2687
|
}
|
|
2710
2688
|
if (marker.type === "start") {
|
|
2689
|
+
if (this.inAdBreak) {
|
|
2690
|
+
console.log(
|
|
2691
|
+
`[DEBUG-POD] \u26A0\uFE0F SCTE-35 start marker ignored - already in ad break (currentTime: ${this.video.currentTime})`
|
|
2692
|
+
);
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2711
2695
|
this.inAdBreak = true;
|
|
2712
2696
|
const durationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
|
|
2713
2697
|
this.expectedAdBreakDurationMs = durationMs;
|
|
@@ -2774,6 +2758,9 @@ var StormcloudVideoPlayer = class {
|
|
|
2774
2758
|
return;
|
|
2775
2759
|
}
|
|
2776
2760
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
2761
|
+
console.log(
|
|
2762
|
+
`[DEBUG-POD] \u{1F4CA} SCTE-35 progress marker (currentTime: ${this.video.currentTime})`
|
|
2763
|
+
);
|
|
2777
2764
|
if (marker.durationSeconds != null) {
|
|
2778
2765
|
this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
|
|
2779
2766
|
}
|
|
@@ -2785,7 +2772,8 @@ var StormcloudVideoPlayer = class {
|
|
|
2785
2772
|
);
|
|
2786
2773
|
this.scheduleAdStopCountdown(remainingMs);
|
|
2787
2774
|
}
|
|
2788
|
-
if (!this.ima.isAdPlaying()) {
|
|
2775
|
+
if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null) {
|
|
2776
|
+
console.log("[DEBUG-POD] \u{1F4CA} Progress marker: no ad playing, attempting to start");
|
|
2789
2777
|
const scheduled = this.findCurrentOrNextBreak(
|
|
2790
2778
|
this.video.currentTime * 1e3
|
|
2791
2779
|
);
|
|
@@ -2794,25 +2782,31 @@ var StormcloudVideoPlayer = class {
|
|
|
2794
2782
|
const first = tags[0];
|
|
2795
2783
|
const rest = tags.slice(1);
|
|
2796
2784
|
this.adPodQueue = rest;
|
|
2797
|
-
if (!this.showAds) {
|
|
2798
|
-
this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
2799
|
-
}
|
|
2800
2785
|
this.playSingleAd(first).catch(() => {
|
|
2801
2786
|
});
|
|
2802
2787
|
}
|
|
2788
|
+
} else {
|
|
2789
|
+
console.log(
|
|
2790
|
+
`[DEBUG-POD] \u{1F4CA} Progress marker: ad playing or request active (playing=${this.ima.isAdPlaying()}, token=${this.activeAdRequestToken})`
|
|
2791
|
+
);
|
|
2803
2792
|
}
|
|
2804
2793
|
return;
|
|
2805
2794
|
}
|
|
2806
2795
|
if (marker.type === "end") {
|
|
2796
|
+
console.log(
|
|
2797
|
+
`[DEBUG-POD] \u{1F3C1} SCTE-35 end marker received (currentTime: ${this.video.currentTime})`
|
|
2798
|
+
);
|
|
2807
2799
|
this.inAdBreak = false;
|
|
2808
2800
|
this.expectedAdBreakDurationMs = void 0;
|
|
2809
2801
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
2810
2802
|
this.clearAdStartTimer();
|
|
2811
2803
|
this.clearAdStopTimer();
|
|
2812
2804
|
if (this.ima.isAdPlaying()) {
|
|
2805
|
+
console.log("[DEBUG-POD] \u{1F6D1} Stopping ad due to SCTE-35 end marker");
|
|
2813
2806
|
this.ima.stop().catch(() => {
|
|
2814
2807
|
});
|
|
2815
2808
|
}
|
|
2809
|
+
this.handleAdPodComplete();
|
|
2816
2810
|
return;
|
|
2817
2811
|
}
|
|
2818
2812
|
}
|
|
@@ -3143,10 +3137,12 @@ var StormcloudVideoPlayer = class {
|
|
|
3143
3137
|
this.vastToMediaUrlMap.clear();
|
|
3144
3138
|
this.preloadedMediaUrls.clear();
|
|
3145
3139
|
this.preloadingMediaUrls.clear();
|
|
3140
|
+
const currentMuted = this.video.muted;
|
|
3141
|
+
const currentVolume = this.video.volume;
|
|
3146
3142
|
console.log(
|
|
3147
|
-
`[DEBUG-AUDIO] \u{1F4BE} Capturing
|
|
3143
|
+
`[DEBUG-AUDIO] \u{1F4BE} Capturing ORIGINAL state (once) | muted=${currentMuted}, volume=${currentVolume}`
|
|
3148
3144
|
);
|
|
3149
|
-
this.ima.updateOriginalMutedState(
|
|
3145
|
+
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
3150
3146
|
this.inAdBreak = true;
|
|
3151
3147
|
this.currentAdIndex = 0;
|
|
3152
3148
|
this.totalAdsInBreak = vastTagUrls.length;
|
|
@@ -3269,31 +3265,15 @@ var StormcloudVideoPlayer = class {
|
|
|
3269
3265
|
const overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
3270
3266
|
const shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
3271
3267
|
if (shouldExtendAdBreak) {
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
{
|
|
3276
|
-
adPlaying,
|
|
3277
|
-
pendingAds,
|
|
3278
|
-
showAds: this.showAds,
|
|
3279
|
-
overrunMs,
|
|
3280
|
-
checkIntervalMs,
|
|
3281
|
-
maxExtensionMs
|
|
3282
|
-
}
|
|
3283
|
-
);
|
|
3284
|
-
}
|
|
3268
|
+
console.log(
|
|
3269
|
+
`[DEBUG-POD] \u23F3 Extending ad break | elapsed=${elapsedSinceStartMs}ms, expected=${expectedDurationMs}ms, overrun=${overrunMs}ms`
|
|
3270
|
+
);
|
|
3285
3271
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
3286
3272
|
return;
|
|
3287
3273
|
}
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
pendingAds,
|
|
3292
|
-
showAds: this.showAds,
|
|
3293
|
-
overrunMs,
|
|
3294
|
-
maxExtensionMs
|
|
3295
|
-
});
|
|
3296
|
-
}
|
|
3274
|
+
console.log(
|
|
3275
|
+
`[DEBUG-POD] \u23F1\uFE0F Ad break duration expired | elapsed=${elapsedSinceStartMs}ms, expected=${expectedDurationMs}ms`
|
|
3276
|
+
);
|
|
3297
3277
|
if (adPlaying) {
|
|
3298
3278
|
this.ima.stop().catch(() => {
|
|
3299
3279
|
});
|
|
@@ -3376,7 +3356,6 @@ var StormcloudVideoPlayer = class {
|
|
|
3376
3356
|
this.clearAdRequestWatchdog();
|
|
3377
3357
|
this.clearAdFailsafeTimer();
|
|
3378
3358
|
this.activeAdRequestToken = null;
|
|
3379
|
-
this.releaseAdHoldState();
|
|
3380
3359
|
this.preloadingAdUrls.clear();
|
|
3381
3360
|
this.vastToMediaUrlMap.clear();
|
|
3382
3361
|
this.preloadedMediaUrls.clear();
|
|
@@ -3393,13 +3372,18 @@ var StormcloudVideoPlayer = class {
|
|
|
3393
3372
|
this.totalAdsInBreak = 0;
|
|
3394
3373
|
this.ima.stop().catch(() => {
|
|
3395
3374
|
});
|
|
3396
|
-
const
|
|
3397
|
-
const
|
|
3398
|
-
this.video.muted = originalMutedState;
|
|
3399
|
-
this.video.volume = originalVolume;
|
|
3375
|
+
const restoredMuted = this.ima.getOriginalMutedState();
|
|
3376
|
+
const restoredVolume = this.ima.getOriginalVolume();
|
|
3400
3377
|
console.log(
|
|
3401
|
-
`[DEBUG-AUDIO] \u{1F50A}
|
|
3378
|
+
`[DEBUG-AUDIO] \u{1F50A} Audio restored by IMA | muted=${restoredMuted}, volume=${restoredVolume}`
|
|
3402
3379
|
);
|
|
3380
|
+
console.log("[DEBUG-LAYER] \u{1F3AC} Layers: Main=visible, Ad=hidden, Placeholder=no");
|
|
3381
|
+
if (this.video.muted !== restoredMuted) {
|
|
3382
|
+
this.video.muted = restoredMuted;
|
|
3383
|
+
}
|
|
3384
|
+
if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
|
|
3385
|
+
this.video.volume = restoredVolume;
|
|
3386
|
+
}
|
|
3403
3387
|
if (!this.shouldContinueLiveStreamDuringAds() && this.video.paused) {
|
|
3404
3388
|
console.log("[DEBUG-FLOW] \u25B6\uFE0F Resuming main video playback");
|
|
3405
3389
|
(_a = this.video.play()) == null ? void 0 : _a.catch((error) => {
|
|
@@ -3408,9 +3392,20 @@ var StormcloudVideoPlayer = class {
|
|
|
3408
3392
|
}
|
|
3409
3393
|
}
|
|
3410
3394
|
handleAdFailure() {
|
|
3411
|
-
console.log(
|
|
3412
|
-
|
|
3413
|
-
)
|
|
3395
|
+
console.log("[DEBUG-POD] \u274C handleAdFailure - skipping to next ad or ending break");
|
|
3396
|
+
const remaining = this.getRemainingAdMs();
|
|
3397
|
+
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
3398
|
+
const nextPreloaded = this.findNextPreloadedAd();
|
|
3399
|
+
if (nextPreloaded) {
|
|
3400
|
+
this.currentAdIndex++;
|
|
3401
|
+
console.log(`[DEBUG-POD] \u27A1\uFE0F Trying next ad after failure (${this.currentAdIndex}/${this.totalAdsInBreak})`);
|
|
3402
|
+
this.playSingleAd(nextPreloaded).catch(() => {
|
|
3403
|
+
this.handleAdPodComplete();
|
|
3404
|
+
});
|
|
3405
|
+
return;
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
console.log("[DEBUG-POD] \u23F9\uFE0F Ending ad break after failure");
|
|
3414
3409
|
this.handleAdPodComplete();
|
|
3415
3410
|
}
|
|
3416
3411
|
startAdRequestWatchdog(token) {
|
|
@@ -3483,12 +3478,6 @@ var StormcloudVideoPlayer = class {
|
|
|
3483
3478
|
}
|
|
3484
3479
|
return [b.vastTagUrl];
|
|
3485
3480
|
}
|
|
3486
|
-
logQueuedAdUrls(urls) {
|
|
3487
|
-
if (!this.config.debugAdTiming) {
|
|
3488
|
-
return;
|
|
3489
|
-
}
|
|
3490
|
-
console.log("[StormcloudVideoPlayer] ALL ad URLs queued:", urls);
|
|
3491
|
-
}
|
|
3492
3481
|
logAdState(event, extra = {}) {
|
|
3493
3482
|
if (!this.config.debugAdTiming) {
|
|
3494
3483
|
return;
|
|
@@ -3503,22 +3492,6 @@ var StormcloudVideoPlayer = class {
|
|
|
3503
3492
|
...extra
|
|
3504
3493
|
});
|
|
3505
3494
|
}
|
|
3506
|
-
enforceAdHoldState() {
|
|
3507
|
-
this.video.dataset.stormcloudAdPlaying = "true";
|
|
3508
|
-
this.video.muted = true;
|
|
3509
|
-
this.video.volume = 0;
|
|
3510
|
-
console.log("[DEBUG-LAYER] \u{1F512} Enforced ad hold state (main video muted)");
|
|
3511
|
-
if (typeof this.ima.showPlaceholder === "function") {
|
|
3512
|
-
this.ima.showPlaceholder();
|
|
3513
|
-
}
|
|
3514
|
-
}
|
|
3515
|
-
releaseAdHoldState() {
|
|
3516
|
-
delete this.video.dataset.stormcloudAdPlaying;
|
|
3517
|
-
console.log("[DEBUG-LAYER] \u{1F513} Released ad hold state");
|
|
3518
|
-
if (typeof this.ima.hidePlaceholder === "function") {
|
|
3519
|
-
this.ima.hidePlaceholder();
|
|
3520
|
-
}
|
|
3521
|
-
}
|
|
3522
3495
|
async fetchAndParseVastXml(vastTagUrl) {
|
|
3523
3496
|
try {
|
|
3524
3497
|
const response = await fetch(vastTagUrl, { mode: "cors" });
|
|
@@ -3883,7 +3856,6 @@ var StormcloudVideoPlayer = class {
|
|
|
3883
3856
|
}
|
|
3884
3857
|
(_a = this.hls) == null ? void 0 : _a.destroy();
|
|
3885
3858
|
(_b = this.ima) == null ? void 0 : _b.destroy();
|
|
3886
|
-
this.releaseAdHoldState();
|
|
3887
3859
|
this.preloadingAdUrls.clear();
|
|
3888
3860
|
this.vastToMediaUrlMap.clear();
|
|
3889
3861
|
this.preloadedMediaUrls.clear();
|