stormcloud-video-player 0.2.19 → 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 +56 -111
- 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 +56 -111
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +56 -111
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -0
- package/lib/players/HlsPlayer.cjs +56 -111
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +56 -111
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +1 -23
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/ima.cjs +7 -49
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +56 -111
- 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
|
}
|
|
@@ -592,53 +594,16 @@ function createImaController(video, options) {
|
|
|
592
594
|
adsManager.addEventListener(
|
|
593
595
|
AdEvent.CONTENT_RESUME_REQUESTED,
|
|
594
596
|
() => {
|
|
595
|
-
var _a;
|
|
596
597
|
console.log("[IMA] Content resume requested");
|
|
597
598
|
adPlaying = false;
|
|
598
|
-
video.muted = originalMutedState;
|
|
599
599
|
setAdPlayingFlag(false);
|
|
600
|
-
if (adContainerEl) {
|
|
601
|
-
adContainerEl.style.pointerEvents = "none";
|
|
602
|
-
adContainerEl.style.display = "none";
|
|
603
|
-
console.log(
|
|
604
|
-
"[IMA] Ad container hidden - pointer events disabled"
|
|
605
|
-
);
|
|
606
|
-
}
|
|
607
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
608
|
-
(_a = video.play()) == null ? void 0 : _a.catch(() => {
|
|
609
|
-
});
|
|
610
|
-
console.log("[IMA] Video resumed (VOD mode)");
|
|
611
|
-
} else {
|
|
612
|
-
console.log(
|
|
613
|
-
"[IMA] Video unmuted (Live mode - was never paused)"
|
|
614
|
-
);
|
|
615
|
-
}
|
|
616
600
|
emit("content_resume");
|
|
617
601
|
}
|
|
618
602
|
);
|
|
619
603
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
620
|
-
console.log("[IMA] All ads completed");
|
|
604
|
+
console.log("[IMA] All ads completed - notifying parent");
|
|
621
605
|
adPlaying = false;
|
|
622
|
-
video.muted = originalMutedState;
|
|
623
606
|
setAdPlayingFlag(false);
|
|
624
|
-
if (adContainerEl) {
|
|
625
|
-
adContainerEl.style.pointerEvents = "none";
|
|
626
|
-
adContainerEl.style.display = "none";
|
|
627
|
-
console.log(
|
|
628
|
-
"[IMA] Ad container hidden after all ads completed"
|
|
629
|
-
);
|
|
630
|
-
}
|
|
631
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
632
|
-
video.play().catch(() => {
|
|
633
|
-
});
|
|
634
|
-
console.log(
|
|
635
|
-
"[IMA] Video resumed after all ads completed (VOD mode)"
|
|
636
|
-
);
|
|
637
|
-
} else {
|
|
638
|
-
console.log(
|
|
639
|
-
"[IMA] Video unmuted after all ads completed (Live mode)"
|
|
640
|
-
);
|
|
641
|
-
}
|
|
642
607
|
emit("all_ads_completed");
|
|
643
608
|
});
|
|
644
609
|
console.log("[IMA] Ads manager event listeners attached");
|
|
@@ -761,8 +726,8 @@ function createImaController(video, options) {
|
|
|
761
726
|
},
|
|
762
727
|
async stop() {
|
|
763
728
|
var _a;
|
|
729
|
+
console.log("[IMA] Stopping ad playback");
|
|
764
730
|
adPlaying = false;
|
|
765
|
-
video.muted = originalMutedState;
|
|
766
731
|
setAdPlayingFlag(false);
|
|
767
732
|
if (adContainerEl) {
|
|
768
733
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -774,13 +739,6 @@ function createImaController(video, options) {
|
|
|
774
739
|
} catch {
|
|
775
740
|
}
|
|
776
741
|
destroyAdsManager();
|
|
777
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
778
|
-
video.play().catch(() => {
|
|
779
|
-
});
|
|
780
|
-
console.log("[IMA] Video resumed after stop (VOD mode)");
|
|
781
|
-
} else {
|
|
782
|
-
console.log("[IMA] Video unmuted after stop (Live mode)");
|
|
783
|
-
}
|
|
784
742
|
},
|
|
785
743
|
destroy() {
|
|
786
744
|
var _a;
|
|
@@ -1188,24 +1146,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1188
1146
|
console.log("[HlsAdPlayer] Handling ad completion");
|
|
1189
1147
|
adPlaying = false;
|
|
1190
1148
|
setAdPlayingFlag(false);
|
|
1191
|
-
const previousMutedState = contentVideo.muted;
|
|
1192
|
-
contentVideo.muted = originalMutedState;
|
|
1193
|
-
console.log(
|
|
1194
|
-
`[HlsAdPlayer] Restored mute state: ${previousMutedState} -> ${originalMutedState}`
|
|
1195
|
-
);
|
|
1196
|
-
if (adContainerEl) {
|
|
1197
|
-
adContainerEl.style.display = "none";
|
|
1198
|
-
adContainerEl.style.pointerEvents = "none";
|
|
1199
|
-
}
|
|
1200
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1201
|
-
contentVideo.play().catch(() => {
|
|
1202
|
-
});
|
|
1203
|
-
console.log("[HlsAdPlayer] Content resumed (VOD mode)");
|
|
1204
|
-
} else {
|
|
1205
|
-
console.log("[HlsAdPlayer] Content unmuted (Live mode)");
|
|
1206
|
-
}
|
|
1207
1149
|
emit("content_resume");
|
|
1208
|
-
emit("all_ads_completed");
|
|
1209
1150
|
}
|
|
1210
1151
|
function handleAdError() {
|
|
1211
1152
|
console.log("[HlsAdPlayer] Handling ad error");
|
|
@@ -1243,7 +1184,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1243
1184
|
container.style.alignItems = "center";
|
|
1244
1185
|
container.style.justifyContent = "center";
|
|
1245
1186
|
container.style.pointerEvents = "none";
|
|
1246
|
-
container.style.zIndex = "
|
|
1187
|
+
container.style.zIndex = "10";
|
|
1247
1188
|
container.style.backgroundColor = "#000";
|
|
1248
1189
|
(_a = contentVideo.parentElement) == null ? void 0 : _a.appendChild(container);
|
|
1249
1190
|
adContainerEl = container;
|
|
@@ -1381,7 +1322,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1381
1322
|
console.log("[HlsAdPlayer] Stopping ad");
|
|
1382
1323
|
adPlaying = false;
|
|
1383
1324
|
setAdPlayingFlag(false);
|
|
1384
|
-
contentVideo.muted = originalMutedState;
|
|
1385
1325
|
if (adContainerEl) {
|
|
1386
1326
|
adContainerEl.style.display = "none";
|
|
1387
1327
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -1394,10 +1334,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1394
1334
|
adVideoElement.pause();
|
|
1395
1335
|
adVideoElement.src = "";
|
|
1396
1336
|
}
|
|
1397
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1398
|
-
contentVideo.play().catch(() => {
|
|
1399
|
-
});
|
|
1400
|
-
}
|
|
1401
1337
|
currentAd = void 0;
|
|
1402
1338
|
},
|
|
1403
1339
|
destroy() {
|
|
@@ -2206,9 +2142,12 @@ var StormcloudVideoPlayer = class {
|
|
|
2206
2142
|
this.ima.on("all_ads_completed", () => {
|
|
2207
2143
|
if (this.config.debugAdTiming) {
|
|
2208
2144
|
console.log(
|
|
2209
|
-
"[StormcloudVideoPlayer] IMA all_ads_completed event received"
|
|
2145
|
+
"[StormcloudVideoPlayer] IMA all_ads_completed event received - ending ad break"
|
|
2210
2146
|
);
|
|
2211
2147
|
}
|
|
2148
|
+
if (this.inAdBreak) {
|
|
2149
|
+
this.handleAdPodComplete();
|
|
2150
|
+
}
|
|
2212
2151
|
});
|
|
2213
2152
|
this.ima.on("ad_error", () => {
|
|
2214
2153
|
if (this.config.debugAdTiming) {
|
|
@@ -2244,29 +2183,46 @@ var StormcloudVideoPlayer = class {
|
|
|
2244
2183
|
this.ima.on("content_resume", () => {
|
|
2245
2184
|
if (this.config.debugAdTiming) {
|
|
2246
2185
|
console.log(
|
|
2247
|
-
"[StormcloudVideoPlayer] IMA content_resume event received"
|
|
2186
|
+
"[StormcloudVideoPlayer] IMA content_resume event received",
|
|
2187
|
+
{
|
|
2188
|
+
inAdBreak: this.inAdBreak,
|
|
2189
|
+
pendingAds: this.adPodQueue.length
|
|
2190
|
+
}
|
|
2248
2191
|
);
|
|
2249
2192
|
}
|
|
2250
2193
|
this.clearAdFailsafeTimer();
|
|
2251
|
-
if (!this.inAdBreak)
|
|
2194
|
+
if (!this.inAdBreak) {
|
|
2195
|
+
if (this.config.debugAdTiming) {
|
|
2196
|
+
console.log(
|
|
2197
|
+
"[StormcloudVideoPlayer] Not in ad break - this shouldn't happen during pod"
|
|
2198
|
+
);
|
|
2199
|
+
}
|
|
2200
|
+
return;
|
|
2201
|
+
}
|
|
2252
2202
|
const remaining = this.getRemainingAdMs();
|
|
2253
2203
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
2254
2204
|
const next = this.adPodQueue.shift();
|
|
2255
2205
|
this.currentAdIndex++;
|
|
2256
2206
|
if (this.config.debugAdTiming) {
|
|
2257
2207
|
console.log(
|
|
2258
|
-
`[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`
|
|
2259
2209
|
);
|
|
2260
2210
|
}
|
|
2261
2211
|
this.playSingleAd(next).catch(() => {
|
|
2212
|
+
if (this.config.debugAdTiming) {
|
|
2213
|
+
console.error(
|
|
2214
|
+
"[StormcloudVideoPlayer] Failed to play next ad in pod"
|
|
2215
|
+
);
|
|
2216
|
+
}
|
|
2217
|
+
this.handleAdPodComplete();
|
|
2262
2218
|
});
|
|
2263
2219
|
} else {
|
|
2264
2220
|
if (this.config.debugAdTiming) {
|
|
2265
|
-
console.log(
|
|
2221
|
+
console.log(
|
|
2222
|
+
"[StormcloudVideoPlayer] No more ads in pod - completing ad break"
|
|
2223
|
+
);
|
|
2266
2224
|
}
|
|
2267
|
-
this.
|
|
2268
|
-
this.totalAdsInBreak = 0;
|
|
2269
|
-
this.showAds = false;
|
|
2225
|
+
this.handleAdPodComplete();
|
|
2270
2226
|
}
|
|
2271
2227
|
});
|
|
2272
2228
|
this.video.addEventListener("timeupdate", () => {
|
|
@@ -2984,23 +2940,11 @@ var StormcloudVideoPlayer = class {
|
|
|
2984
2940
|
maxExtensionMs
|
|
2985
2941
|
});
|
|
2986
2942
|
}
|
|
2987
|
-
this.inAdBreak = false;
|
|
2988
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
2989
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
2990
|
-
this.showAds = false;
|
|
2991
|
-
this.adPodQueue = [];
|
|
2992
|
-
this.currentAdIndex = 0;
|
|
2993
|
-
this.totalAdsInBreak = 0;
|
|
2994
|
-
this.clearAdFailsafeTimer();
|
|
2995
2943
|
if (adPlaying) {
|
|
2996
2944
|
this.ima.stop().catch(() => {
|
|
2997
2945
|
});
|
|
2998
|
-
return;
|
|
2999
|
-
}
|
|
3000
|
-
const originalMutedState = this.ima.getOriginalMutedState();
|
|
3001
|
-
if (this.video.muted !== originalMutedState) {
|
|
3002
|
-
this.video.muted = originalMutedState;
|
|
3003
2946
|
}
|
|
2947
|
+
this.handleAdPodComplete();
|
|
3004
2948
|
}
|
|
3005
2949
|
scheduleAdStartIn(delayMs) {
|
|
3006
2950
|
this.clearAdStartTimer();
|
|
@@ -3087,17 +3031,11 @@ var StormcloudVideoPlayer = class {
|
|
|
3087
3031
|
this.handleAdFailure();
|
|
3088
3032
|
}
|
|
3089
3033
|
}
|
|
3090
|
-
|
|
3034
|
+
handleAdPodComplete() {
|
|
3091
3035
|
var _a;
|
|
3092
3036
|
if (this.config.debugAdTiming) {
|
|
3093
3037
|
console.log(
|
|
3094
|
-
"[StormcloudVideoPlayer] Handling ad
|
|
3095
|
-
{
|
|
3096
|
-
inAdBreak: this.inAdBreak,
|
|
3097
|
-
showAds: this.showAds,
|
|
3098
|
-
videoPaused: this.video.paused,
|
|
3099
|
-
adPlaying: this.ima.isAdPlaying()
|
|
3100
|
-
}
|
|
3038
|
+
"[StormcloudVideoPlayer] Handling ad pod completion - resuming content"
|
|
3101
3039
|
);
|
|
3102
3040
|
}
|
|
3103
3041
|
this.inAdBreak = false;
|
|
@@ -3110,34 +3048,41 @@ var StormcloudVideoPlayer = class {
|
|
|
3110
3048
|
this.showAds = false;
|
|
3111
3049
|
this.currentAdIndex = 0;
|
|
3112
3050
|
this.totalAdsInBreak = 0;
|
|
3113
|
-
const currentMutedState = this.video.muted;
|
|
3114
3051
|
const originalMutedState = this.ima.getOriginalMutedState();
|
|
3115
3052
|
this.video.muted = originalMutedState;
|
|
3116
3053
|
if (this.config.debugAdTiming) {
|
|
3117
3054
|
console.log(
|
|
3118
|
-
`[StormcloudVideoPlayer] Restored mute state: ${
|
|
3055
|
+
`[StormcloudVideoPlayer] Restored main video mute state to: ${originalMutedState}`
|
|
3119
3056
|
);
|
|
3120
3057
|
}
|
|
3121
|
-
if (this.video.paused) {
|
|
3058
|
+
if (!this.shouldContinueLiveStreamDuringAds() && this.video.paused) {
|
|
3122
3059
|
if (this.config.debugAdTiming) {
|
|
3123
3060
|
console.log("[StormcloudVideoPlayer] Resuming paused video");
|
|
3124
3061
|
}
|
|
3125
3062
|
(_a = this.video.play()) == null ? void 0 : _a.catch((error) => {
|
|
3126
3063
|
if (this.config.debugAdTiming) {
|
|
3127
3064
|
console.error(
|
|
3128
|
-
"[StormcloudVideoPlayer] Failed to resume video
|
|
3065
|
+
"[StormcloudVideoPlayer] Failed to resume video:",
|
|
3129
3066
|
error
|
|
3130
3067
|
);
|
|
3131
3068
|
}
|
|
3132
3069
|
});
|
|
3133
|
-
} else {
|
|
3134
|
-
if (this.config.debugAdTiming) {
|
|
3135
|
-
console.log(
|
|
3136
|
-
"[StormcloudVideoPlayer] Video is already playing, no resume needed"
|
|
3137
|
-
);
|
|
3138
|
-
}
|
|
3139
3070
|
}
|
|
3140
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
|
+
}
|
|
3141
3086
|
startAdFailsafeTimer() {
|
|
3142
3087
|
var _a;
|
|
3143
3088
|
this.clearAdFailsafeTimer();
|