stormcloud-video-player 0.2.19 → 0.2.20
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 +2 -2
- package/lib/index.cjs +97 -37
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +97 -37
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +97 -37
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -0
- package/lib/players/HlsPlayer.cjs +97 -37
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +97 -37
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +30 -16
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/ima.cjs +32 -18
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +97 -37
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -26,6 +26,7 @@ declare class StormcloudVideoPlayer {
|
|
|
26
26
|
private bufferedSegmentsCount;
|
|
27
27
|
private shouldAutoplayAfterBuffering;
|
|
28
28
|
private hasInitialBufferCompleted;
|
|
29
|
+
private isTransitioningBetweenAds;
|
|
29
30
|
constructor(config: StormcloudVideoPlayerConfig);
|
|
30
31
|
private createAdPlayer;
|
|
31
32
|
load(): Promise<void>;
|
|
@@ -528,28 +528,42 @@ function createImaController(video, options) {
|
|
|
528
528
|
adsManager.addEventListener(
|
|
529
529
|
AdEvent.CONTENT_RESUME_REQUESTED,
|
|
530
530
|
() => {
|
|
531
|
-
var _a;
|
|
532
531
|
console.log("[IMA] Content resume requested");
|
|
533
532
|
adPlaying = false;
|
|
534
|
-
video.muted = originalMutedState;
|
|
535
533
|
setAdPlayingFlag(false);
|
|
536
|
-
if (adContainerEl) {
|
|
537
|
-
adContainerEl.style.pointerEvents = "none";
|
|
538
|
-
adContainerEl.style.display = "none";
|
|
539
|
-
console.log(
|
|
540
|
-
"[IMA] Ad container hidden - pointer events disabled"
|
|
541
|
-
);
|
|
542
|
-
}
|
|
543
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
544
|
-
(_a = video.play()) == null ? void 0 : _a.catch(() => {
|
|
545
|
-
});
|
|
546
|
-
console.log("[IMA] Video resumed (VOD mode)");
|
|
547
|
-
} else {
|
|
548
|
-
console.log(
|
|
549
|
-
"[IMA] Video unmuted (Live mode - was never paused)"
|
|
550
|
-
);
|
|
551
|
-
}
|
|
552
534
|
emit("content_resume");
|
|
535
|
+
setTimeout(() => {
|
|
536
|
+
var _a;
|
|
537
|
+
const stillInAdPod = video.dataset.stormcloudAdPlaying === "true";
|
|
538
|
+
if (stillInAdPod) {
|
|
539
|
+
console.log(
|
|
540
|
+
"[IMA] Next ad started - keeping content muted/paused and ad container visible"
|
|
541
|
+
);
|
|
542
|
+
if (adContainerEl) {
|
|
543
|
+
adContainerEl.style.display = "flex";
|
|
544
|
+
adContainerEl.style.pointerEvents = "auto";
|
|
545
|
+
}
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
console.log("[IMA] No next ad - resuming content");
|
|
549
|
+
video.muted = originalMutedState;
|
|
550
|
+
if (adContainerEl) {
|
|
551
|
+
adContainerEl.style.pointerEvents = "none";
|
|
552
|
+
adContainerEl.style.display = "none";
|
|
553
|
+
console.log(
|
|
554
|
+
"[IMA] Ad container hidden - pointer events disabled"
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
558
|
+
(_a = video.play()) == null ? void 0 : _a.catch(() => {
|
|
559
|
+
});
|
|
560
|
+
console.log("[IMA] Video resumed (VOD mode)");
|
|
561
|
+
} else {
|
|
562
|
+
console.log(
|
|
563
|
+
"[IMA] Video unmuted (Live mode - was never paused)"
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
}, 100);
|
|
553
567
|
}
|
|
554
568
|
);
|
|
555
569
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
@@ -1124,24 +1138,38 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1124
1138
|
console.log("[HlsAdPlayer] Handling ad completion");
|
|
1125
1139
|
adPlaying = false;
|
|
1126
1140
|
setAdPlayingFlag(false);
|
|
1127
|
-
const previousMutedState = contentVideo.muted;
|
|
1128
|
-
contentVideo.muted = originalMutedState;
|
|
1129
|
-
console.log(
|
|
1130
|
-
`[HlsAdPlayer] Restored mute state: ${previousMutedState} -> ${originalMutedState}`
|
|
1131
|
-
);
|
|
1132
|
-
if (adContainerEl) {
|
|
1133
|
-
adContainerEl.style.display = "none";
|
|
1134
|
-
adContainerEl.style.pointerEvents = "none";
|
|
1135
|
-
}
|
|
1136
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1137
|
-
contentVideo.play().catch(() => {
|
|
1138
|
-
});
|
|
1139
|
-
console.log("[HlsAdPlayer] Content resumed (VOD mode)");
|
|
1140
|
-
} else {
|
|
1141
|
-
console.log("[HlsAdPlayer] Content unmuted (Live mode)");
|
|
1142
|
-
}
|
|
1143
1141
|
emit("content_resume");
|
|
1144
1142
|
emit("all_ads_completed");
|
|
1143
|
+
setTimeout(() => {
|
|
1144
|
+
const stillInAdPod = contentVideo.dataset.stormcloudAdPlaying === "true";
|
|
1145
|
+
if (stillInAdPod) {
|
|
1146
|
+
console.log(
|
|
1147
|
+
"[HlsAdPlayer] Next ad started - keeping content muted/paused and ad container visible"
|
|
1148
|
+
);
|
|
1149
|
+
if (adContainerEl) {
|
|
1150
|
+
adContainerEl.style.display = "flex";
|
|
1151
|
+
adContainerEl.style.pointerEvents = "auto";
|
|
1152
|
+
}
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
console.log("[HlsAdPlayer] No next ad - resuming content");
|
|
1156
|
+
const previousMutedState = contentVideo.muted;
|
|
1157
|
+
contentVideo.muted = originalMutedState;
|
|
1158
|
+
console.log(
|
|
1159
|
+
`[HlsAdPlayer] Restored mute state: ${previousMutedState} -> ${originalMutedState}`
|
|
1160
|
+
);
|
|
1161
|
+
if (adContainerEl) {
|
|
1162
|
+
adContainerEl.style.display = "none";
|
|
1163
|
+
adContainerEl.style.pointerEvents = "none";
|
|
1164
|
+
}
|
|
1165
|
+
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1166
|
+
contentVideo.play().catch(() => {
|
|
1167
|
+
});
|
|
1168
|
+
console.log("[HlsAdPlayer] Content resumed (VOD mode)");
|
|
1169
|
+
} else {
|
|
1170
|
+
console.log("[HlsAdPlayer] Content unmuted (Live mode)");
|
|
1171
|
+
}
|
|
1172
|
+
}, 100);
|
|
1145
1173
|
}
|
|
1146
1174
|
function handleAdError() {
|
|
1147
1175
|
console.log("[HlsAdPlayer] Handling ad error");
|
|
@@ -1879,6 +1907,7 @@ var StormcloudVideoPlayer = class {
|
|
|
1879
1907
|
this.bufferedSegmentsCount = 0;
|
|
1880
1908
|
this.shouldAutoplayAfterBuffering = false;
|
|
1881
1909
|
this.hasInitialBufferCompleted = false;
|
|
1910
|
+
this.isTransitioningBetweenAds = false;
|
|
1882
1911
|
initializePolyfills();
|
|
1883
1912
|
const browserOverrides = getBrowserConfigOverrides();
|
|
1884
1913
|
this.config = { ...config, ...browserOverrides };
|
|
@@ -2180,29 +2209,60 @@ var StormcloudVideoPlayer = class {
|
|
|
2180
2209
|
this.ima.on("content_resume", () => {
|
|
2181
2210
|
if (this.config.debugAdTiming) {
|
|
2182
2211
|
console.log(
|
|
2183
|
-
"[StormcloudVideoPlayer] IMA content_resume event received"
|
|
2212
|
+
"[StormcloudVideoPlayer] IMA content_resume event received",
|
|
2213
|
+
{
|
|
2214
|
+
inAdBreak: this.inAdBreak,
|
|
2215
|
+
isTransitioningBetweenAds: this.isTransitioningBetweenAds,
|
|
2216
|
+
pendingAds: this.adPodQueue.length
|
|
2217
|
+
}
|
|
2184
2218
|
);
|
|
2185
2219
|
}
|
|
2186
2220
|
this.clearAdFailsafeTimer();
|
|
2187
|
-
if (
|
|
2221
|
+
if (this.isTransitioningBetweenAds) {
|
|
2222
|
+
if (this.config.debugAdTiming) {
|
|
2223
|
+
console.log(
|
|
2224
|
+
"[StormcloudVideoPlayer] Transitioning between ads - keeping content muted/paused"
|
|
2225
|
+
);
|
|
2226
|
+
}
|
|
2227
|
+
return;
|
|
2228
|
+
}
|
|
2229
|
+
if (!this.inAdBreak) {
|
|
2230
|
+
if (this.config.debugAdTiming) {
|
|
2231
|
+
console.log(
|
|
2232
|
+
"[StormcloudVideoPlayer] Not in ad break, allowing normal content resume"
|
|
2233
|
+
);
|
|
2234
|
+
}
|
|
2235
|
+
return;
|
|
2236
|
+
}
|
|
2188
2237
|
const remaining = this.getRemainingAdMs();
|
|
2189
2238
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
2239
|
+
this.isTransitioningBetweenAds = true;
|
|
2240
|
+
this.video.muted = true;
|
|
2241
|
+
if (!this.shouldContinueLiveStreamDuringAds()) {
|
|
2242
|
+
this.video.pause();
|
|
2243
|
+
}
|
|
2190
2244
|
const next = this.adPodQueue.shift();
|
|
2191
2245
|
this.currentAdIndex++;
|
|
2192
2246
|
if (this.config.debugAdTiming) {
|
|
2193
2247
|
console.log(
|
|
2194
|
-
`[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak})`
|
|
2248
|
+
`[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - keeping content muted/paused`
|
|
2195
2249
|
);
|
|
2196
2250
|
}
|
|
2197
2251
|
this.playSingleAd(next).catch(() => {
|
|
2252
|
+
}).finally(() => {
|
|
2253
|
+
this.isTransitioningBetweenAds = false;
|
|
2198
2254
|
});
|
|
2199
2255
|
} else {
|
|
2200
2256
|
if (this.config.debugAdTiming) {
|
|
2201
2257
|
console.log("[StormcloudVideoPlayer] Ad pod completed");
|
|
2202
2258
|
}
|
|
2259
|
+
this.inAdBreak = false;
|
|
2260
|
+
this.expectedAdBreakDurationMs = void 0;
|
|
2261
|
+
this.currentAdBreakStartWallClockMs = void 0;
|
|
2203
2262
|
this.currentAdIndex = 0;
|
|
2204
2263
|
this.totalAdsInBreak = 0;
|
|
2205
2264
|
this.showAds = false;
|
|
2265
|
+
this.clearAdStopTimer();
|
|
2206
2266
|
}
|
|
2207
2267
|
});
|
|
2208
2268
|
this.video.addEventListener("timeupdate", () => {
|