stormcloud-video-player 0.2.20 → 0.2.21
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 +44 -159
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +44 -159
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +44 -159
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/players/HlsPlayer.cjs +44 -159
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +44 -159
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +1 -37
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/ima.cjs +7 -63
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +44 -159
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -391,11 +391,12 @@ function createImaController(video, options) {
|
|
|
391
391
|
container.style.top = "0";
|
|
392
392
|
container.style.right = "0";
|
|
393
393
|
container.style.bottom = "0";
|
|
394
|
-
container.style.display = "
|
|
394
|
+
container.style.display = "none";
|
|
395
395
|
container.style.alignItems = "center";
|
|
396
396
|
container.style.justifyContent = "center";
|
|
397
397
|
container.style.pointerEvents = "none";
|
|
398
|
-
container.style.zIndex = "
|
|
398
|
+
container.style.zIndex = "10";
|
|
399
|
+
container.style.backgroundColor = "#000";
|
|
399
400
|
(_a = video.parentElement) == null ? void 0 : _a.appendChild(container);
|
|
400
401
|
adContainerEl = container;
|
|
401
402
|
adDisplayContainer = new google.ima.AdDisplayContainer(
|
|
@@ -465,7 +466,8 @@ function createImaController(video, options) {
|
|
|
465
466
|
container.style.alignItems = "center";
|
|
466
467
|
container.style.justifyContent = "center";
|
|
467
468
|
container.style.pointerEvents = "none";
|
|
468
|
-
container.style.zIndex = "
|
|
469
|
+
container.style.zIndex = "10";
|
|
470
|
+
container.style.backgroundColor = "#000";
|
|
469
471
|
if (!video.parentElement) {
|
|
470
472
|
throw new Error("Video element has no parent for ad container");
|
|
471
473
|
}
|
|
@@ -596,63 +598,12 @@ function createImaController(video, options) {
|
|
|
596
598
|
adPlaying = false;
|
|
597
599
|
setAdPlayingFlag(false);
|
|
598
600
|
emit("content_resume");
|
|
599
|
-
setTimeout(() => {
|
|
600
|
-
var _a;
|
|
601
|
-
const stillInAdPod = video.dataset.stormcloudAdPlaying === "true";
|
|
602
|
-
if (stillInAdPod) {
|
|
603
|
-
console.log(
|
|
604
|
-
"[IMA] Next ad started - keeping content muted/paused and ad container visible"
|
|
605
|
-
);
|
|
606
|
-
if (adContainerEl) {
|
|
607
|
-
adContainerEl.style.display = "flex";
|
|
608
|
-
adContainerEl.style.pointerEvents = "auto";
|
|
609
|
-
}
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
console.log("[IMA] No next ad - resuming content");
|
|
613
|
-
video.muted = originalMutedState;
|
|
614
|
-
if (adContainerEl) {
|
|
615
|
-
adContainerEl.style.pointerEvents = "none";
|
|
616
|
-
adContainerEl.style.display = "none";
|
|
617
|
-
console.log(
|
|
618
|
-
"[IMA] Ad container hidden - pointer events disabled"
|
|
619
|
-
);
|
|
620
|
-
}
|
|
621
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
622
|
-
(_a = video.play()) == null ? void 0 : _a.catch(() => {
|
|
623
|
-
});
|
|
624
|
-
console.log("[IMA] Video resumed (VOD mode)");
|
|
625
|
-
} else {
|
|
626
|
-
console.log(
|
|
627
|
-
"[IMA] Video unmuted (Live mode - was never paused)"
|
|
628
|
-
);
|
|
629
|
-
}
|
|
630
|
-
}, 100);
|
|
631
601
|
}
|
|
632
602
|
);
|
|
633
603
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
634
|
-
console.log("[IMA] All ads completed");
|
|
604
|
+
console.log("[IMA] All ads completed - notifying parent");
|
|
635
605
|
adPlaying = false;
|
|
636
|
-
video.muted = originalMutedState;
|
|
637
606
|
setAdPlayingFlag(false);
|
|
638
|
-
if (adContainerEl) {
|
|
639
|
-
adContainerEl.style.pointerEvents = "none";
|
|
640
|
-
adContainerEl.style.display = "none";
|
|
641
|
-
console.log(
|
|
642
|
-
"[IMA] Ad container hidden after all ads completed"
|
|
643
|
-
);
|
|
644
|
-
}
|
|
645
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
646
|
-
video.play().catch(() => {
|
|
647
|
-
});
|
|
648
|
-
console.log(
|
|
649
|
-
"[IMA] Video resumed after all ads completed (VOD mode)"
|
|
650
|
-
);
|
|
651
|
-
} else {
|
|
652
|
-
console.log(
|
|
653
|
-
"[IMA] Video unmuted after all ads completed (Live mode)"
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
607
|
emit("all_ads_completed");
|
|
657
608
|
});
|
|
658
609
|
console.log("[IMA] Ads manager event listeners attached");
|
|
@@ -775,8 +726,8 @@ function createImaController(video, options) {
|
|
|
775
726
|
},
|
|
776
727
|
async stop() {
|
|
777
728
|
var _a;
|
|
729
|
+
console.log("[IMA] Stopping ad playback");
|
|
778
730
|
adPlaying = false;
|
|
779
|
-
video.muted = originalMutedState;
|
|
780
731
|
setAdPlayingFlag(false);
|
|
781
732
|
if (adContainerEl) {
|
|
782
733
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -788,13 +739,6 @@ function createImaController(video, options) {
|
|
|
788
739
|
} catch {
|
|
789
740
|
}
|
|
790
741
|
destroyAdsManager();
|
|
791
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
792
|
-
video.play().catch(() => {
|
|
793
|
-
});
|
|
794
|
-
console.log("[IMA] Video resumed after stop (VOD mode)");
|
|
795
|
-
} else {
|
|
796
|
-
console.log("[IMA] Video unmuted after stop (Live mode)");
|
|
797
|
-
}
|
|
798
742
|
},
|
|
799
743
|
destroy() {
|
|
800
744
|
var _a;
|
|
@@ -1203,37 +1147,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1203
1147
|
adPlaying = false;
|
|
1204
1148
|
setAdPlayingFlag(false);
|
|
1205
1149
|
emit("content_resume");
|
|
1206
|
-
emit("all_ads_completed");
|
|
1207
|
-
setTimeout(() => {
|
|
1208
|
-
const stillInAdPod = contentVideo.dataset.stormcloudAdPlaying === "true";
|
|
1209
|
-
if (stillInAdPod) {
|
|
1210
|
-
console.log(
|
|
1211
|
-
"[HlsAdPlayer] Next ad started - keeping content muted/paused and ad container visible"
|
|
1212
|
-
);
|
|
1213
|
-
if (adContainerEl) {
|
|
1214
|
-
adContainerEl.style.display = "flex";
|
|
1215
|
-
adContainerEl.style.pointerEvents = "auto";
|
|
1216
|
-
}
|
|
1217
|
-
return;
|
|
1218
|
-
}
|
|
1219
|
-
console.log("[HlsAdPlayer] No next ad - resuming content");
|
|
1220
|
-
const previousMutedState = contentVideo.muted;
|
|
1221
|
-
contentVideo.muted = originalMutedState;
|
|
1222
|
-
console.log(
|
|
1223
|
-
`[HlsAdPlayer] Restored mute state: ${previousMutedState} -> ${originalMutedState}`
|
|
1224
|
-
);
|
|
1225
|
-
if (adContainerEl) {
|
|
1226
|
-
adContainerEl.style.display = "none";
|
|
1227
|
-
adContainerEl.style.pointerEvents = "none";
|
|
1228
|
-
}
|
|
1229
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1230
|
-
contentVideo.play().catch(() => {
|
|
1231
|
-
});
|
|
1232
|
-
console.log("[HlsAdPlayer] Content resumed (VOD mode)");
|
|
1233
|
-
} else {
|
|
1234
|
-
console.log("[HlsAdPlayer] Content unmuted (Live mode)");
|
|
1235
|
-
}
|
|
1236
|
-
}, 100);
|
|
1237
1150
|
}
|
|
1238
1151
|
function handleAdError() {
|
|
1239
1152
|
console.log("[HlsAdPlayer] Handling ad error");
|
|
@@ -1271,7 +1184,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1271
1184
|
container.style.alignItems = "center";
|
|
1272
1185
|
container.style.justifyContent = "center";
|
|
1273
1186
|
container.style.pointerEvents = "none";
|
|
1274
|
-
container.style.zIndex = "
|
|
1187
|
+
container.style.zIndex = "10";
|
|
1275
1188
|
container.style.backgroundColor = "#000";
|
|
1276
1189
|
(_a = contentVideo.parentElement) == null ? void 0 : _a.appendChild(container);
|
|
1277
1190
|
adContainerEl = container;
|
|
@@ -1409,7 +1322,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1409
1322
|
console.log("[HlsAdPlayer] Stopping ad");
|
|
1410
1323
|
adPlaying = false;
|
|
1411
1324
|
setAdPlayingFlag(false);
|
|
1412
|
-
contentVideo.muted = originalMutedState;
|
|
1413
1325
|
if (adContainerEl) {
|
|
1414
1326
|
adContainerEl.style.display = "none";
|
|
1415
1327
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -1422,10 +1334,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1422
1334
|
adVideoElement.pause();
|
|
1423
1335
|
adVideoElement.src = "";
|
|
1424
1336
|
}
|
|
1425
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1426
|
-
contentVideo.play().catch(() => {
|
|
1427
|
-
});
|
|
1428
|
-
}
|
|
1429
1337
|
currentAd = void 0;
|
|
1430
1338
|
},
|
|
1431
1339
|
destroy() {
|
|
@@ -1971,7 +1879,6 @@ var StormcloudVideoPlayer = class {
|
|
|
1971
1879
|
this.bufferedSegmentsCount = 0;
|
|
1972
1880
|
this.shouldAutoplayAfterBuffering = false;
|
|
1973
1881
|
this.hasInitialBufferCompleted = false;
|
|
1974
|
-
this.isTransitioningBetweenAds = false;
|
|
1975
1882
|
initializePolyfills();
|
|
1976
1883
|
const browserOverrides = getBrowserConfigOverrides();
|
|
1977
1884
|
this.config = { ...config, ...browserOverrides };
|
|
@@ -2235,9 +2142,12 @@ var StormcloudVideoPlayer = class {
|
|
|
2235
2142
|
this.ima.on("all_ads_completed", () => {
|
|
2236
2143
|
if (this.config.debugAdTiming) {
|
|
2237
2144
|
console.log(
|
|
2238
|
-
"[StormcloudVideoPlayer] IMA all_ads_completed event received"
|
|
2145
|
+
"[StormcloudVideoPlayer] IMA all_ads_completed event received - ending ad break"
|
|
2239
2146
|
);
|
|
2240
2147
|
}
|
|
2148
|
+
if (this.inAdBreak) {
|
|
2149
|
+
this.handleAdPodComplete();
|
|
2150
|
+
}
|
|
2241
2151
|
});
|
|
2242
2152
|
this.ima.on("ad_error", () => {
|
|
2243
2153
|
if (this.config.debugAdTiming) {
|
|
@@ -2276,57 +2186,43 @@ var StormcloudVideoPlayer = class {
|
|
|
2276
2186
|
"[StormcloudVideoPlayer] IMA content_resume event received",
|
|
2277
2187
|
{
|
|
2278
2188
|
inAdBreak: this.inAdBreak,
|
|
2279
|
-
isTransitioningBetweenAds: this.isTransitioningBetweenAds,
|
|
2280
2189
|
pendingAds: this.adPodQueue.length
|
|
2281
2190
|
}
|
|
2282
2191
|
);
|
|
2283
2192
|
}
|
|
2284
2193
|
this.clearAdFailsafeTimer();
|
|
2285
|
-
if (this.isTransitioningBetweenAds) {
|
|
2286
|
-
if (this.config.debugAdTiming) {
|
|
2287
|
-
console.log(
|
|
2288
|
-
"[StormcloudVideoPlayer] Transitioning between ads - keeping content muted/paused"
|
|
2289
|
-
);
|
|
2290
|
-
}
|
|
2291
|
-
return;
|
|
2292
|
-
}
|
|
2293
2194
|
if (!this.inAdBreak) {
|
|
2294
2195
|
if (this.config.debugAdTiming) {
|
|
2295
2196
|
console.log(
|
|
2296
|
-
"[StormcloudVideoPlayer] Not in ad break
|
|
2197
|
+
"[StormcloudVideoPlayer] Not in ad break - this shouldn't happen during pod"
|
|
2297
2198
|
);
|
|
2298
2199
|
}
|
|
2299
2200
|
return;
|
|
2300
2201
|
}
|
|
2301
2202
|
const remaining = this.getRemainingAdMs();
|
|
2302
2203
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
2303
|
-
this.isTransitioningBetweenAds = true;
|
|
2304
|
-
this.video.muted = true;
|
|
2305
|
-
if (!this.shouldContinueLiveStreamDuringAds()) {
|
|
2306
|
-
this.video.pause();
|
|
2307
|
-
}
|
|
2308
2204
|
const next = this.adPodQueue.shift();
|
|
2309
2205
|
this.currentAdIndex++;
|
|
2310
2206
|
if (this.config.debugAdTiming) {
|
|
2311
2207
|
console.log(
|
|
2312
|
-
`[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) -
|
|
2208
|
+
`[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - main video stays muted, ad layer stays visible`
|
|
2313
2209
|
);
|
|
2314
2210
|
}
|
|
2315
2211
|
this.playSingleAd(next).catch(() => {
|
|
2316
|
-
|
|
2317
|
-
|
|
2212
|
+
if (this.config.debugAdTiming) {
|
|
2213
|
+
console.error(
|
|
2214
|
+
"[StormcloudVideoPlayer] Failed to play next ad in pod"
|
|
2215
|
+
);
|
|
2216
|
+
}
|
|
2217
|
+
this.handleAdPodComplete();
|
|
2318
2218
|
});
|
|
2319
2219
|
} else {
|
|
2320
2220
|
if (this.config.debugAdTiming) {
|
|
2321
|
-
console.log(
|
|
2221
|
+
console.log(
|
|
2222
|
+
"[StormcloudVideoPlayer] No more ads in pod - completing ad break"
|
|
2223
|
+
);
|
|
2322
2224
|
}
|
|
2323
|
-
this.
|
|
2324
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
2325
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
2326
|
-
this.currentAdIndex = 0;
|
|
2327
|
-
this.totalAdsInBreak = 0;
|
|
2328
|
-
this.showAds = false;
|
|
2329
|
-
this.clearAdStopTimer();
|
|
2225
|
+
this.handleAdPodComplete();
|
|
2330
2226
|
}
|
|
2331
2227
|
});
|
|
2332
2228
|
this.video.addEventListener("timeupdate", () => {
|
|
@@ -3044,23 +2940,11 @@ var StormcloudVideoPlayer = class {
|
|
|
3044
2940
|
maxExtensionMs
|
|
3045
2941
|
});
|
|
3046
2942
|
}
|
|
3047
|
-
this.inAdBreak = false;
|
|
3048
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
3049
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
3050
|
-
this.showAds = false;
|
|
3051
|
-
this.adPodQueue = [];
|
|
3052
|
-
this.currentAdIndex = 0;
|
|
3053
|
-
this.totalAdsInBreak = 0;
|
|
3054
|
-
this.clearAdFailsafeTimer();
|
|
3055
2943
|
if (adPlaying) {
|
|
3056
2944
|
this.ima.stop().catch(() => {
|
|
3057
2945
|
});
|
|
3058
|
-
return;
|
|
3059
|
-
}
|
|
3060
|
-
const originalMutedState = this.ima.getOriginalMutedState();
|
|
3061
|
-
if (this.video.muted !== originalMutedState) {
|
|
3062
|
-
this.video.muted = originalMutedState;
|
|
3063
2946
|
}
|
|
2947
|
+
this.handleAdPodComplete();
|
|
3064
2948
|
}
|
|
3065
2949
|
scheduleAdStartIn(delayMs) {
|
|
3066
2950
|
this.clearAdStartTimer();
|
|
@@ -3147,17 +3031,11 @@ var StormcloudVideoPlayer = class {
|
|
|
3147
3031
|
this.handleAdFailure();
|
|
3148
3032
|
}
|
|
3149
3033
|
}
|
|
3150
|
-
|
|
3034
|
+
handleAdPodComplete() {
|
|
3151
3035
|
var _a;
|
|
3152
3036
|
if (this.config.debugAdTiming) {
|
|
3153
3037
|
console.log(
|
|
3154
|
-
"[StormcloudVideoPlayer] Handling ad
|
|
3155
|
-
{
|
|
3156
|
-
inAdBreak: this.inAdBreak,
|
|
3157
|
-
showAds: this.showAds,
|
|
3158
|
-
videoPaused: this.video.paused,
|
|
3159
|
-
adPlaying: this.ima.isAdPlaying()
|
|
3160
|
-
}
|
|
3038
|
+
"[StormcloudVideoPlayer] Handling ad pod completion - resuming content"
|
|
3161
3039
|
);
|
|
3162
3040
|
}
|
|
3163
3041
|
this.inAdBreak = false;
|
|
@@ -3170,34 +3048,41 @@ var StormcloudVideoPlayer = class {
|
|
|
3170
3048
|
this.showAds = false;
|
|
3171
3049
|
this.currentAdIndex = 0;
|
|
3172
3050
|
this.totalAdsInBreak = 0;
|
|
3173
|
-
const currentMutedState = this.video.muted;
|
|
3174
3051
|
const originalMutedState = this.ima.getOriginalMutedState();
|
|
3175
3052
|
this.video.muted = originalMutedState;
|
|
3176
3053
|
if (this.config.debugAdTiming) {
|
|
3177
3054
|
console.log(
|
|
3178
|
-
`[StormcloudVideoPlayer] Restored mute state: ${
|
|
3055
|
+
`[StormcloudVideoPlayer] Restored main video mute state to: ${originalMutedState}`
|
|
3179
3056
|
);
|
|
3180
3057
|
}
|
|
3181
|
-
if (this.video.paused) {
|
|
3058
|
+
if (!this.shouldContinueLiveStreamDuringAds() && this.video.paused) {
|
|
3182
3059
|
if (this.config.debugAdTiming) {
|
|
3183
3060
|
console.log("[StormcloudVideoPlayer] Resuming paused video");
|
|
3184
3061
|
}
|
|
3185
3062
|
(_a = this.video.play()) == null ? void 0 : _a.catch((error) => {
|
|
3186
3063
|
if (this.config.debugAdTiming) {
|
|
3187
3064
|
console.error(
|
|
3188
|
-
"[StormcloudVideoPlayer] Failed to resume video
|
|
3065
|
+
"[StormcloudVideoPlayer] Failed to resume video:",
|
|
3189
3066
|
error
|
|
3190
3067
|
);
|
|
3191
3068
|
}
|
|
3192
3069
|
});
|
|
3193
|
-
} else {
|
|
3194
|
-
if (this.config.debugAdTiming) {
|
|
3195
|
-
console.log(
|
|
3196
|
-
"[StormcloudVideoPlayer] Video is already playing, no resume needed"
|
|
3197
|
-
);
|
|
3198
|
-
}
|
|
3199
3070
|
}
|
|
3200
3071
|
}
|
|
3072
|
+
handleAdFailure() {
|
|
3073
|
+
if (this.config.debugAdTiming) {
|
|
3074
|
+
console.log(
|
|
3075
|
+
"[StormcloudVideoPlayer] Handling ad failure - resuming content",
|
|
3076
|
+
{
|
|
3077
|
+
inAdBreak: this.inAdBreak,
|
|
3078
|
+
showAds: this.showAds,
|
|
3079
|
+
videoPaused: this.video.paused,
|
|
3080
|
+
adPlaying: this.ima.isAdPlaying()
|
|
3081
|
+
}
|
|
3082
|
+
);
|
|
3083
|
+
}
|
|
3084
|
+
this.handleAdPodComplete();
|
|
3085
|
+
}
|
|
3201
3086
|
startAdFailsafeTimer() {
|
|
3202
3087
|
var _a;
|
|
3203
3088
|
this.clearAdFailsafeTimer();
|