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
|
@@ -628,19 +628,10 @@ function createImaController(video, options) {
|
|
|
628
628
|
adsManager.addEventListener(
|
|
629
629
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
630
630
|
() => {
|
|
631
|
-
console.log("[DEBUG-FLOW] \u{1F3AF} CONTENT_PAUSE_REQUESTED - Ad
|
|
631
|
+
console.log("[DEBUG-FLOW] \u{1F3AF} CONTENT_PAUSE_REQUESTED - Ad request accepted");
|
|
632
632
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
633
633
|
video.pause();
|
|
634
634
|
}
|
|
635
|
-
hideContentVideo();
|
|
636
|
-
if (adContainerEl) {
|
|
637
|
-
adContainerEl.style.pointerEvents = "auto";
|
|
638
|
-
adContainerEl.style.display = "flex";
|
|
639
|
-
adContainerEl.style.backgroundColor = "#000";
|
|
640
|
-
adContainerEl.offsetHeight;
|
|
641
|
-
adContainerEl.style.opacity = "1";
|
|
642
|
-
console.log("[DEBUG-LAYER] \u{1F7E1} Ad container VISIBLE");
|
|
643
|
-
}
|
|
644
635
|
adPlaying = true;
|
|
645
636
|
setAdPlayingFlag(true);
|
|
646
637
|
emit("content_pause");
|
|
@@ -671,7 +662,7 @@ function createImaController(video, options) {
|
|
|
671
662
|
console.log("[DEBUG-FLOW] \u23F8\uFE0F CONTENT_RESUME - Single ad done");
|
|
672
663
|
adPlaying = false;
|
|
673
664
|
setAdPlayingFlag(false);
|
|
674
|
-
console.log("[DEBUG-LAYER] \u26A0\uFE0F Waiting for pod manager
|
|
665
|
+
console.log("[DEBUG-LAYER] \u26A0\uFE0F Waiting for pod manager (more ads, placeholder, or done)");
|
|
675
666
|
emit("content_resume");
|
|
676
667
|
}
|
|
677
668
|
);
|
|
@@ -2439,44 +2430,31 @@ var StormcloudVideoPlayer = class {
|
|
|
2439
2430
|
}
|
|
2440
2431
|
});
|
|
2441
2432
|
this.ima.on("ad_error", () => {
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
remainingAds: this.adPodQueue.length
|
|
2447
|
-
});
|
|
2448
|
-
}
|
|
2433
|
+
const remaining = this.getRemainingAdMs();
|
|
2434
|
+
console.log(
|
|
2435
|
+
`[DEBUG-POD] \u274C ad_error event | inBreak=${this.inAdBreak}, queue=${this.adPodQueue.length}, remaining=${remaining}ms`
|
|
2436
|
+
);
|
|
2449
2437
|
if (this.inAdBreak) {
|
|
2450
|
-
const remaining = this.getRemainingAdMs();
|
|
2451
2438
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
2452
2439
|
const nextPreloaded = this.findNextPreloadedAd();
|
|
2453
2440
|
if (nextPreloaded) {
|
|
2454
2441
|
this.currentAdIndex++;
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
);
|
|
2459
|
-
}
|
|
2442
|
+
console.log(
|
|
2443
|
+
`[DEBUG-POD] \u27A1\uFE0F Trying next ad after error (${this.currentAdIndex}/${this.totalAdsInBreak})`
|
|
2444
|
+
);
|
|
2460
2445
|
this.playSingleAd(nextPreloaded).catch(() => {
|
|
2461
2446
|
this.handleAdFailure();
|
|
2462
2447
|
});
|
|
2463
2448
|
} else {
|
|
2464
|
-
|
|
2465
|
-
console.log(
|
|
2466
|
-
"[StormcloudVideoPlayer] No preloaded ads available, ending ad break"
|
|
2467
|
-
);
|
|
2468
|
-
}
|
|
2449
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F No more preloaded ads - calling handleAdFailure");
|
|
2469
2450
|
this.handleAdFailure();
|
|
2470
2451
|
}
|
|
2471
2452
|
} else {
|
|
2453
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F No more ads or time - calling handleAdFailure");
|
|
2472
2454
|
this.handleAdFailure();
|
|
2473
2455
|
}
|
|
2474
2456
|
} else {
|
|
2475
|
-
|
|
2476
|
-
console.log(
|
|
2477
|
-
"[StormcloudVideoPlayer] Ad error before ad break established - cleaning up"
|
|
2478
|
-
);
|
|
2479
|
-
}
|
|
2457
|
+
console.log("[DEBUG-POD] \u26A0\uFE0F Error before ad break established");
|
|
2480
2458
|
this.handleAdFailure();
|
|
2481
2459
|
}
|
|
2482
2460
|
});
|
|
@@ -2486,7 +2464,7 @@ var StormcloudVideoPlayer = class {
|
|
|
2486
2464
|
this.clearAdRequestWatchdog();
|
|
2487
2465
|
this.activeAdRequestToken = null;
|
|
2488
2466
|
this.showAds = true;
|
|
2489
|
-
|
|
2467
|
+
console.log("[DEBUG-LAYER] \u{1F3AC} Layers: Main=hidden, Ad=visible, Placeholder=no");
|
|
2490
2468
|
});
|
|
2491
2469
|
this.ima.on("content_resume", () => {
|
|
2492
2470
|
console.log(`[DEBUG-POD] \u23F8\uFE0F content_resume | ad ${this.currentAdIndex}/${this.totalAdsInBreak}, queue=${this.adPodQueue.length}, remaining=${this.getRemainingAdMs()}ms`);
|
|
@@ -2666,6 +2644,12 @@ var StormcloudVideoPlayer = class {
|
|
|
2666
2644
|
});
|
|
2667
2645
|
}
|
|
2668
2646
|
if (marker.type === "start") {
|
|
2647
|
+
if (this.inAdBreak) {
|
|
2648
|
+
console.log(
|
|
2649
|
+
`[DEBUG-POD] \u26A0\uFE0F SCTE-35 start marker ignored - already in ad break (currentTime: ${this.video.currentTime})`
|
|
2650
|
+
);
|
|
2651
|
+
return;
|
|
2652
|
+
}
|
|
2669
2653
|
this.inAdBreak = true;
|
|
2670
2654
|
const durationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
|
|
2671
2655
|
this.expectedAdBreakDurationMs = durationMs;
|
|
@@ -2732,6 +2716,9 @@ var StormcloudVideoPlayer = class {
|
|
|
2732
2716
|
return;
|
|
2733
2717
|
}
|
|
2734
2718
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
2719
|
+
console.log(
|
|
2720
|
+
`[DEBUG-POD] \u{1F4CA} SCTE-35 progress marker (currentTime: ${this.video.currentTime})`
|
|
2721
|
+
);
|
|
2735
2722
|
if (marker.durationSeconds != null) {
|
|
2736
2723
|
this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
|
|
2737
2724
|
}
|
|
@@ -2743,7 +2730,8 @@ var StormcloudVideoPlayer = class {
|
|
|
2743
2730
|
);
|
|
2744
2731
|
this.scheduleAdStopCountdown(remainingMs);
|
|
2745
2732
|
}
|
|
2746
|
-
if (!this.ima.isAdPlaying()) {
|
|
2733
|
+
if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null) {
|
|
2734
|
+
console.log("[DEBUG-POD] \u{1F4CA} Progress marker: no ad playing, attempting to start");
|
|
2747
2735
|
const scheduled = this.findCurrentOrNextBreak(
|
|
2748
2736
|
this.video.currentTime * 1e3
|
|
2749
2737
|
);
|
|
@@ -2752,25 +2740,31 @@ var StormcloudVideoPlayer = class {
|
|
|
2752
2740
|
const first = tags[0];
|
|
2753
2741
|
const rest = tags.slice(1);
|
|
2754
2742
|
this.adPodQueue = rest;
|
|
2755
|
-
if (!this.showAds) {
|
|
2756
|
-
this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
2757
|
-
}
|
|
2758
2743
|
this.playSingleAd(first).catch(() => {
|
|
2759
2744
|
});
|
|
2760
2745
|
}
|
|
2746
|
+
} else {
|
|
2747
|
+
console.log(
|
|
2748
|
+
`[DEBUG-POD] \u{1F4CA} Progress marker: ad playing or request active (playing=${this.ima.isAdPlaying()}, token=${this.activeAdRequestToken})`
|
|
2749
|
+
);
|
|
2761
2750
|
}
|
|
2762
2751
|
return;
|
|
2763
2752
|
}
|
|
2764
2753
|
if (marker.type === "end") {
|
|
2754
|
+
console.log(
|
|
2755
|
+
`[DEBUG-POD] \u{1F3C1} SCTE-35 end marker received (currentTime: ${this.video.currentTime})`
|
|
2756
|
+
);
|
|
2765
2757
|
this.inAdBreak = false;
|
|
2766
2758
|
this.expectedAdBreakDurationMs = void 0;
|
|
2767
2759
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
2768
2760
|
this.clearAdStartTimer();
|
|
2769
2761
|
this.clearAdStopTimer();
|
|
2770
2762
|
if (this.ima.isAdPlaying()) {
|
|
2763
|
+
console.log("[DEBUG-POD] \u{1F6D1} Stopping ad due to SCTE-35 end marker");
|
|
2771
2764
|
this.ima.stop().catch(() => {
|
|
2772
2765
|
});
|
|
2773
2766
|
}
|
|
2767
|
+
this.handleAdPodComplete();
|
|
2774
2768
|
return;
|
|
2775
2769
|
}
|
|
2776
2770
|
}
|
|
@@ -3101,10 +3095,12 @@ var StormcloudVideoPlayer = class {
|
|
|
3101
3095
|
this.vastToMediaUrlMap.clear();
|
|
3102
3096
|
this.preloadedMediaUrls.clear();
|
|
3103
3097
|
this.preloadingMediaUrls.clear();
|
|
3098
|
+
const currentMuted = this.video.muted;
|
|
3099
|
+
const currentVolume = this.video.volume;
|
|
3104
3100
|
console.log(
|
|
3105
|
-
`[DEBUG-AUDIO] \u{1F4BE} Capturing
|
|
3101
|
+
`[DEBUG-AUDIO] \u{1F4BE} Capturing ORIGINAL state (once) | muted=${currentMuted}, volume=${currentVolume}`
|
|
3106
3102
|
);
|
|
3107
|
-
this.ima.updateOriginalMutedState(
|
|
3103
|
+
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
3108
3104
|
this.inAdBreak = true;
|
|
3109
3105
|
this.currentAdIndex = 0;
|
|
3110
3106
|
this.totalAdsInBreak = vastTagUrls.length;
|
|
@@ -3227,31 +3223,15 @@ var StormcloudVideoPlayer = class {
|
|
|
3227
3223
|
const overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
3228
3224
|
const shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
3229
3225
|
if (shouldExtendAdBreak) {
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
{
|
|
3234
|
-
adPlaying,
|
|
3235
|
-
pendingAds,
|
|
3236
|
-
showAds: this.showAds,
|
|
3237
|
-
overrunMs,
|
|
3238
|
-
checkIntervalMs,
|
|
3239
|
-
maxExtensionMs
|
|
3240
|
-
}
|
|
3241
|
-
);
|
|
3242
|
-
}
|
|
3226
|
+
console.log(
|
|
3227
|
+
`[DEBUG-POD] \u23F3 Extending ad break | elapsed=${elapsedSinceStartMs}ms, expected=${expectedDurationMs}ms, overrun=${overrunMs}ms`
|
|
3228
|
+
);
|
|
3243
3229
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
3244
3230
|
return;
|
|
3245
3231
|
}
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
pendingAds,
|
|
3250
|
-
showAds: this.showAds,
|
|
3251
|
-
overrunMs,
|
|
3252
|
-
maxExtensionMs
|
|
3253
|
-
});
|
|
3254
|
-
}
|
|
3232
|
+
console.log(
|
|
3233
|
+
`[DEBUG-POD] \u23F1\uFE0F Ad break duration expired | elapsed=${elapsedSinceStartMs}ms, expected=${expectedDurationMs}ms`
|
|
3234
|
+
);
|
|
3255
3235
|
if (adPlaying) {
|
|
3256
3236
|
this.ima.stop().catch(() => {
|
|
3257
3237
|
});
|
|
@@ -3334,7 +3314,6 @@ var StormcloudVideoPlayer = class {
|
|
|
3334
3314
|
this.clearAdRequestWatchdog();
|
|
3335
3315
|
this.clearAdFailsafeTimer();
|
|
3336
3316
|
this.activeAdRequestToken = null;
|
|
3337
|
-
this.releaseAdHoldState();
|
|
3338
3317
|
this.preloadingAdUrls.clear();
|
|
3339
3318
|
this.vastToMediaUrlMap.clear();
|
|
3340
3319
|
this.preloadedMediaUrls.clear();
|
|
@@ -3351,13 +3330,18 @@ var StormcloudVideoPlayer = class {
|
|
|
3351
3330
|
this.totalAdsInBreak = 0;
|
|
3352
3331
|
this.ima.stop().catch(() => {
|
|
3353
3332
|
});
|
|
3354
|
-
const
|
|
3355
|
-
const
|
|
3356
|
-
this.video.muted = originalMutedState;
|
|
3357
|
-
this.video.volume = originalVolume;
|
|
3333
|
+
const restoredMuted = this.ima.getOriginalMutedState();
|
|
3334
|
+
const restoredVolume = this.ima.getOriginalVolume();
|
|
3358
3335
|
console.log(
|
|
3359
|
-
`[DEBUG-AUDIO] \u{1F50A}
|
|
3336
|
+
`[DEBUG-AUDIO] \u{1F50A} Audio restored by IMA | muted=${restoredMuted}, volume=${restoredVolume}`
|
|
3360
3337
|
);
|
|
3338
|
+
console.log("[DEBUG-LAYER] \u{1F3AC} Layers: Main=visible, Ad=hidden, Placeholder=no");
|
|
3339
|
+
if (this.video.muted !== restoredMuted) {
|
|
3340
|
+
this.video.muted = restoredMuted;
|
|
3341
|
+
}
|
|
3342
|
+
if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
|
|
3343
|
+
this.video.volume = restoredVolume;
|
|
3344
|
+
}
|
|
3361
3345
|
if (!this.shouldContinueLiveStreamDuringAds() && this.video.paused) {
|
|
3362
3346
|
console.log("[DEBUG-FLOW] \u25B6\uFE0F Resuming main video playback");
|
|
3363
3347
|
(_a = this.video.play()) == null ? void 0 : _a.catch((error) => {
|
|
@@ -3366,9 +3350,20 @@ var StormcloudVideoPlayer = class {
|
|
|
3366
3350
|
}
|
|
3367
3351
|
}
|
|
3368
3352
|
handleAdFailure() {
|
|
3369
|
-
console.log(
|
|
3370
|
-
|
|
3371
|
-
)
|
|
3353
|
+
console.log("[DEBUG-POD] \u274C handleAdFailure - skipping to next ad or ending break");
|
|
3354
|
+
const remaining = this.getRemainingAdMs();
|
|
3355
|
+
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
3356
|
+
const nextPreloaded = this.findNextPreloadedAd();
|
|
3357
|
+
if (nextPreloaded) {
|
|
3358
|
+
this.currentAdIndex++;
|
|
3359
|
+
console.log(`[DEBUG-POD] \u27A1\uFE0F Trying next ad after failure (${this.currentAdIndex}/${this.totalAdsInBreak})`);
|
|
3360
|
+
this.playSingleAd(nextPreloaded).catch(() => {
|
|
3361
|
+
this.handleAdPodComplete();
|
|
3362
|
+
});
|
|
3363
|
+
return;
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
console.log("[DEBUG-POD] \u23F9\uFE0F Ending ad break after failure");
|
|
3372
3367
|
this.handleAdPodComplete();
|
|
3373
3368
|
}
|
|
3374
3369
|
startAdRequestWatchdog(token) {
|
|
@@ -3441,12 +3436,6 @@ var StormcloudVideoPlayer = class {
|
|
|
3441
3436
|
}
|
|
3442
3437
|
return [b.vastTagUrl];
|
|
3443
3438
|
}
|
|
3444
|
-
logQueuedAdUrls(urls) {
|
|
3445
|
-
if (!this.config.debugAdTiming) {
|
|
3446
|
-
return;
|
|
3447
|
-
}
|
|
3448
|
-
console.log("[StormcloudVideoPlayer] ALL ad URLs queued:", urls);
|
|
3449
|
-
}
|
|
3450
3439
|
logAdState(event, extra = {}) {
|
|
3451
3440
|
if (!this.config.debugAdTiming) {
|
|
3452
3441
|
return;
|
|
@@ -3461,22 +3450,6 @@ var StormcloudVideoPlayer = class {
|
|
|
3461
3450
|
...extra
|
|
3462
3451
|
});
|
|
3463
3452
|
}
|
|
3464
|
-
enforceAdHoldState() {
|
|
3465
|
-
this.video.dataset.stormcloudAdPlaying = "true";
|
|
3466
|
-
this.video.muted = true;
|
|
3467
|
-
this.video.volume = 0;
|
|
3468
|
-
console.log("[DEBUG-LAYER] \u{1F512} Enforced ad hold state (main video muted)");
|
|
3469
|
-
if (typeof this.ima.showPlaceholder === "function") {
|
|
3470
|
-
this.ima.showPlaceholder();
|
|
3471
|
-
}
|
|
3472
|
-
}
|
|
3473
|
-
releaseAdHoldState() {
|
|
3474
|
-
delete this.video.dataset.stormcloudAdPlaying;
|
|
3475
|
-
console.log("[DEBUG-LAYER] \u{1F513} Released ad hold state");
|
|
3476
|
-
if (typeof this.ima.hidePlaceholder === "function") {
|
|
3477
|
-
this.ima.hidePlaceholder();
|
|
3478
|
-
}
|
|
3479
|
-
}
|
|
3480
3453
|
async fetchAndParseVastXml(vastTagUrl) {
|
|
3481
3454
|
try {
|
|
3482
3455
|
const response = await fetch(vastTagUrl, { mode: "cors" });
|
|
@@ -3841,7 +3814,6 @@ var StormcloudVideoPlayer = class {
|
|
|
3841
3814
|
}
|
|
3842
3815
|
(_a = this.hls) == null ? void 0 : _a.destroy();
|
|
3843
3816
|
(_b = this.ima) == null ? void 0 : _b.destroy();
|
|
3844
|
-
this.releaseAdHoldState();
|
|
3845
3817
|
this.preloadingAdUrls.clear();
|
|
3846
3818
|
this.vastToMediaUrlMap.clear();
|
|
3847
3819
|
this.preloadedMediaUrls.clear();
|