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
package/lib/players/index.cjs
CHANGED
|
@@ -567,28 +567,42 @@ function createImaController(video, options) {
|
|
|
567
567
|
adsManager.addEventListener(
|
|
568
568
|
AdEvent.CONTENT_RESUME_REQUESTED,
|
|
569
569
|
() => {
|
|
570
|
-
var _a;
|
|
571
570
|
console.log("[IMA] Content resume requested");
|
|
572
571
|
adPlaying = false;
|
|
573
|
-
video.muted = originalMutedState;
|
|
574
572
|
setAdPlayingFlag(false);
|
|
575
|
-
if (adContainerEl) {
|
|
576
|
-
adContainerEl.style.pointerEvents = "none";
|
|
577
|
-
adContainerEl.style.display = "none";
|
|
578
|
-
console.log(
|
|
579
|
-
"[IMA] Ad container hidden - pointer events disabled"
|
|
580
|
-
);
|
|
581
|
-
}
|
|
582
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
583
|
-
(_a = video.play()) == null ? void 0 : _a.catch(() => {
|
|
584
|
-
});
|
|
585
|
-
console.log("[IMA] Video resumed (VOD mode)");
|
|
586
|
-
} else {
|
|
587
|
-
console.log(
|
|
588
|
-
"[IMA] Video unmuted (Live mode - was never paused)"
|
|
589
|
-
);
|
|
590
|
-
}
|
|
591
573
|
emit("content_resume");
|
|
574
|
+
setTimeout(() => {
|
|
575
|
+
var _a;
|
|
576
|
+
const stillInAdPod = video.dataset.stormcloudAdPlaying === "true";
|
|
577
|
+
if (stillInAdPod) {
|
|
578
|
+
console.log(
|
|
579
|
+
"[IMA] Next ad started - keeping content muted/paused and ad container visible"
|
|
580
|
+
);
|
|
581
|
+
if (adContainerEl) {
|
|
582
|
+
adContainerEl.style.display = "flex";
|
|
583
|
+
adContainerEl.style.pointerEvents = "auto";
|
|
584
|
+
}
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
console.log("[IMA] No next ad - resuming content");
|
|
588
|
+
video.muted = originalMutedState;
|
|
589
|
+
if (adContainerEl) {
|
|
590
|
+
adContainerEl.style.pointerEvents = "none";
|
|
591
|
+
adContainerEl.style.display = "none";
|
|
592
|
+
console.log(
|
|
593
|
+
"[IMA] Ad container hidden - pointer events disabled"
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
597
|
+
(_a = video.play()) == null ? void 0 : _a.catch(() => {
|
|
598
|
+
});
|
|
599
|
+
console.log("[IMA] Video resumed (VOD mode)");
|
|
600
|
+
} else {
|
|
601
|
+
console.log(
|
|
602
|
+
"[IMA] Video unmuted (Live mode - was never paused)"
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
}, 100);
|
|
592
606
|
}
|
|
593
607
|
);
|
|
594
608
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
@@ -1163,24 +1177,38 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1163
1177
|
console.log("[HlsAdPlayer] Handling ad completion");
|
|
1164
1178
|
adPlaying = false;
|
|
1165
1179
|
setAdPlayingFlag(false);
|
|
1166
|
-
const previousMutedState = contentVideo.muted;
|
|
1167
|
-
contentVideo.muted = originalMutedState;
|
|
1168
|
-
console.log(
|
|
1169
|
-
`[HlsAdPlayer] Restored mute state: ${previousMutedState} -> ${originalMutedState}`
|
|
1170
|
-
);
|
|
1171
|
-
if (adContainerEl) {
|
|
1172
|
-
adContainerEl.style.display = "none";
|
|
1173
|
-
adContainerEl.style.pointerEvents = "none";
|
|
1174
|
-
}
|
|
1175
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1176
|
-
contentVideo.play().catch(() => {
|
|
1177
|
-
});
|
|
1178
|
-
console.log("[HlsAdPlayer] Content resumed (VOD mode)");
|
|
1179
|
-
} else {
|
|
1180
|
-
console.log("[HlsAdPlayer] Content unmuted (Live mode)");
|
|
1181
|
-
}
|
|
1182
1180
|
emit("content_resume");
|
|
1183
1181
|
emit("all_ads_completed");
|
|
1182
|
+
setTimeout(() => {
|
|
1183
|
+
const stillInAdPod = contentVideo.dataset.stormcloudAdPlaying === "true";
|
|
1184
|
+
if (stillInAdPod) {
|
|
1185
|
+
console.log(
|
|
1186
|
+
"[HlsAdPlayer] Next ad started - keeping content muted/paused and ad container visible"
|
|
1187
|
+
);
|
|
1188
|
+
if (adContainerEl) {
|
|
1189
|
+
adContainerEl.style.display = "flex";
|
|
1190
|
+
adContainerEl.style.pointerEvents = "auto";
|
|
1191
|
+
}
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
console.log("[HlsAdPlayer] No next ad - resuming content");
|
|
1195
|
+
const previousMutedState = contentVideo.muted;
|
|
1196
|
+
contentVideo.muted = originalMutedState;
|
|
1197
|
+
console.log(
|
|
1198
|
+
`[HlsAdPlayer] Restored mute state: ${previousMutedState} -> ${originalMutedState}`
|
|
1199
|
+
);
|
|
1200
|
+
if (adContainerEl) {
|
|
1201
|
+
adContainerEl.style.display = "none";
|
|
1202
|
+
adContainerEl.style.pointerEvents = "none";
|
|
1203
|
+
}
|
|
1204
|
+
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1205
|
+
contentVideo.play().catch(() => {
|
|
1206
|
+
});
|
|
1207
|
+
console.log("[HlsAdPlayer] Content resumed (VOD mode)");
|
|
1208
|
+
} else {
|
|
1209
|
+
console.log("[HlsAdPlayer] Content unmuted (Live mode)");
|
|
1210
|
+
}
|
|
1211
|
+
}, 100);
|
|
1184
1212
|
}
|
|
1185
1213
|
function handleAdError() {
|
|
1186
1214
|
console.log("[HlsAdPlayer] Handling ad error");
|
|
@@ -1918,6 +1946,7 @@ var StormcloudVideoPlayer = class {
|
|
|
1918
1946
|
this.bufferedSegmentsCount = 0;
|
|
1919
1947
|
this.shouldAutoplayAfterBuffering = false;
|
|
1920
1948
|
this.hasInitialBufferCompleted = false;
|
|
1949
|
+
this.isTransitioningBetweenAds = false;
|
|
1921
1950
|
initializePolyfills();
|
|
1922
1951
|
const browserOverrides = getBrowserConfigOverrides();
|
|
1923
1952
|
this.config = { ...config, ...browserOverrides };
|
|
@@ -2219,29 +2248,60 @@ var StormcloudVideoPlayer = class {
|
|
|
2219
2248
|
this.ima.on("content_resume", () => {
|
|
2220
2249
|
if (this.config.debugAdTiming) {
|
|
2221
2250
|
console.log(
|
|
2222
|
-
"[StormcloudVideoPlayer] IMA content_resume event received"
|
|
2251
|
+
"[StormcloudVideoPlayer] IMA content_resume event received",
|
|
2252
|
+
{
|
|
2253
|
+
inAdBreak: this.inAdBreak,
|
|
2254
|
+
isTransitioningBetweenAds: this.isTransitioningBetweenAds,
|
|
2255
|
+
pendingAds: this.adPodQueue.length
|
|
2256
|
+
}
|
|
2223
2257
|
);
|
|
2224
2258
|
}
|
|
2225
2259
|
this.clearAdFailsafeTimer();
|
|
2226
|
-
if (
|
|
2260
|
+
if (this.isTransitioningBetweenAds) {
|
|
2261
|
+
if (this.config.debugAdTiming) {
|
|
2262
|
+
console.log(
|
|
2263
|
+
"[StormcloudVideoPlayer] Transitioning between ads - keeping content muted/paused"
|
|
2264
|
+
);
|
|
2265
|
+
}
|
|
2266
|
+
return;
|
|
2267
|
+
}
|
|
2268
|
+
if (!this.inAdBreak) {
|
|
2269
|
+
if (this.config.debugAdTiming) {
|
|
2270
|
+
console.log(
|
|
2271
|
+
"[StormcloudVideoPlayer] Not in ad break, allowing normal content resume"
|
|
2272
|
+
);
|
|
2273
|
+
}
|
|
2274
|
+
return;
|
|
2275
|
+
}
|
|
2227
2276
|
const remaining = this.getRemainingAdMs();
|
|
2228
2277
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
2278
|
+
this.isTransitioningBetweenAds = true;
|
|
2279
|
+
this.video.muted = true;
|
|
2280
|
+
if (!this.shouldContinueLiveStreamDuringAds()) {
|
|
2281
|
+
this.video.pause();
|
|
2282
|
+
}
|
|
2229
2283
|
const next = this.adPodQueue.shift();
|
|
2230
2284
|
this.currentAdIndex++;
|
|
2231
2285
|
if (this.config.debugAdTiming) {
|
|
2232
2286
|
console.log(
|
|
2233
|
-
`[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak})`
|
|
2287
|
+
`[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - keeping content muted/paused`
|
|
2234
2288
|
);
|
|
2235
2289
|
}
|
|
2236
2290
|
this.playSingleAd(next).catch(() => {
|
|
2291
|
+
}).finally(() => {
|
|
2292
|
+
this.isTransitioningBetweenAds = false;
|
|
2237
2293
|
});
|
|
2238
2294
|
} else {
|
|
2239
2295
|
if (this.config.debugAdTiming) {
|
|
2240
2296
|
console.log("[StormcloudVideoPlayer] Ad pod completed");
|
|
2241
2297
|
}
|
|
2298
|
+
this.inAdBreak = false;
|
|
2299
|
+
this.expectedAdBreakDurationMs = void 0;
|
|
2300
|
+
this.currentAdBreakStartWallClockMs = void 0;
|
|
2242
2301
|
this.currentAdIndex = 0;
|
|
2243
2302
|
this.totalAdsInBreak = 0;
|
|
2244
2303
|
this.showAds = false;
|
|
2304
|
+
this.clearAdStopTimer();
|
|
2245
2305
|
}
|
|
2246
2306
|
});
|
|
2247
2307
|
this.video.addEventListener("timeupdate", () => {
|