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/players/index.cjs
CHANGED
|
@@ -366,11 +366,12 @@ function createImaController(video, options) {
|
|
|
366
366
|
container.style.top = "0";
|
|
367
367
|
container.style.right = "0";
|
|
368
368
|
container.style.bottom = "0";
|
|
369
|
-
container.style.display = "
|
|
369
|
+
container.style.display = "none";
|
|
370
370
|
container.style.alignItems = "center";
|
|
371
371
|
container.style.justifyContent = "center";
|
|
372
372
|
container.style.pointerEvents = "none";
|
|
373
|
-
container.style.zIndex = "
|
|
373
|
+
container.style.zIndex = "10";
|
|
374
|
+
container.style.backgroundColor = "#000";
|
|
374
375
|
(_a = video.parentElement) == null ? void 0 : _a.appendChild(container);
|
|
375
376
|
adContainerEl = container;
|
|
376
377
|
adDisplayContainer = new google.ima.AdDisplayContainer(
|
|
@@ -440,7 +441,8 @@ function createImaController(video, options) {
|
|
|
440
441
|
container.style.alignItems = "center";
|
|
441
442
|
container.style.justifyContent = "center";
|
|
442
443
|
container.style.pointerEvents = "none";
|
|
443
|
-
container.style.zIndex = "
|
|
444
|
+
container.style.zIndex = "10";
|
|
445
|
+
container.style.backgroundColor = "#000";
|
|
444
446
|
if (!video.parentElement) {
|
|
445
447
|
throw new Error("Video element has no parent for ad container");
|
|
446
448
|
}
|
|
@@ -567,53 +569,16 @@ function createImaController(video, options) {
|
|
|
567
569
|
adsManager.addEventListener(
|
|
568
570
|
AdEvent.CONTENT_RESUME_REQUESTED,
|
|
569
571
|
() => {
|
|
570
|
-
var _a;
|
|
571
572
|
console.log("[IMA] Content resume requested");
|
|
572
573
|
adPlaying = false;
|
|
573
|
-
video.muted = originalMutedState;
|
|
574
574
|
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
575
|
emit("content_resume");
|
|
592
576
|
}
|
|
593
577
|
);
|
|
594
578
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, () => {
|
|
595
|
-
console.log("[IMA] All ads completed");
|
|
579
|
+
console.log("[IMA] All ads completed - notifying parent");
|
|
596
580
|
adPlaying = false;
|
|
597
|
-
video.muted = originalMutedState;
|
|
598
581
|
setAdPlayingFlag(false);
|
|
599
|
-
if (adContainerEl) {
|
|
600
|
-
adContainerEl.style.pointerEvents = "none";
|
|
601
|
-
adContainerEl.style.display = "none";
|
|
602
|
-
console.log(
|
|
603
|
-
"[IMA] Ad container hidden after all ads completed"
|
|
604
|
-
);
|
|
605
|
-
}
|
|
606
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
607
|
-
video.play().catch(() => {
|
|
608
|
-
});
|
|
609
|
-
console.log(
|
|
610
|
-
"[IMA] Video resumed after all ads completed (VOD mode)"
|
|
611
|
-
);
|
|
612
|
-
} else {
|
|
613
|
-
console.log(
|
|
614
|
-
"[IMA] Video unmuted after all ads completed (Live mode)"
|
|
615
|
-
);
|
|
616
|
-
}
|
|
617
582
|
emit("all_ads_completed");
|
|
618
583
|
});
|
|
619
584
|
console.log("[IMA] Ads manager event listeners attached");
|
|
@@ -736,8 +701,8 @@ function createImaController(video, options) {
|
|
|
736
701
|
},
|
|
737
702
|
async stop() {
|
|
738
703
|
var _a;
|
|
704
|
+
console.log("[IMA] Stopping ad playback");
|
|
739
705
|
adPlaying = false;
|
|
740
|
-
video.muted = originalMutedState;
|
|
741
706
|
setAdPlayingFlag(false);
|
|
742
707
|
if (adContainerEl) {
|
|
743
708
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -749,13 +714,6 @@ function createImaController(video, options) {
|
|
|
749
714
|
} catch {
|
|
750
715
|
}
|
|
751
716
|
destroyAdsManager();
|
|
752
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
753
|
-
video.play().catch(() => {
|
|
754
|
-
});
|
|
755
|
-
console.log("[IMA] Video resumed after stop (VOD mode)");
|
|
756
|
-
} else {
|
|
757
|
-
console.log("[IMA] Video unmuted after stop (Live mode)");
|
|
758
|
-
}
|
|
759
717
|
},
|
|
760
718
|
destroy() {
|
|
761
719
|
var _a;
|
|
@@ -1163,24 +1121,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1163
1121
|
console.log("[HlsAdPlayer] Handling ad completion");
|
|
1164
1122
|
adPlaying = false;
|
|
1165
1123
|
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
1124
|
emit("content_resume");
|
|
1183
|
-
emit("all_ads_completed");
|
|
1184
1125
|
}
|
|
1185
1126
|
function handleAdError() {
|
|
1186
1127
|
console.log("[HlsAdPlayer] Handling ad error");
|
|
@@ -1218,7 +1159,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1218
1159
|
container.style.alignItems = "center";
|
|
1219
1160
|
container.style.justifyContent = "center";
|
|
1220
1161
|
container.style.pointerEvents = "none";
|
|
1221
|
-
container.style.zIndex = "
|
|
1162
|
+
container.style.zIndex = "10";
|
|
1222
1163
|
container.style.backgroundColor = "#000";
|
|
1223
1164
|
(_a = contentVideo.parentElement) == null ? void 0 : _a.appendChild(container);
|
|
1224
1165
|
adContainerEl = container;
|
|
@@ -1356,7 +1297,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1356
1297
|
console.log("[HlsAdPlayer] Stopping ad");
|
|
1357
1298
|
adPlaying = false;
|
|
1358
1299
|
setAdPlayingFlag(false);
|
|
1359
|
-
contentVideo.muted = originalMutedState;
|
|
1360
1300
|
if (adContainerEl) {
|
|
1361
1301
|
adContainerEl.style.display = "none";
|
|
1362
1302
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -1369,10 +1309,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1369
1309
|
adVideoElement.pause();
|
|
1370
1310
|
adVideoElement.src = "";
|
|
1371
1311
|
}
|
|
1372
|
-
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1373
|
-
contentVideo.play().catch(() => {
|
|
1374
|
-
});
|
|
1375
|
-
}
|
|
1376
1312
|
currentAd = void 0;
|
|
1377
1313
|
},
|
|
1378
1314
|
destroy() {
|
|
@@ -2181,9 +2117,12 @@ var StormcloudVideoPlayer = class {
|
|
|
2181
2117
|
this.ima.on("all_ads_completed", () => {
|
|
2182
2118
|
if (this.config.debugAdTiming) {
|
|
2183
2119
|
console.log(
|
|
2184
|
-
"[StormcloudVideoPlayer] IMA all_ads_completed event received"
|
|
2120
|
+
"[StormcloudVideoPlayer] IMA all_ads_completed event received - ending ad break"
|
|
2185
2121
|
);
|
|
2186
2122
|
}
|
|
2123
|
+
if (this.inAdBreak) {
|
|
2124
|
+
this.handleAdPodComplete();
|
|
2125
|
+
}
|
|
2187
2126
|
});
|
|
2188
2127
|
this.ima.on("ad_error", () => {
|
|
2189
2128
|
if (this.config.debugAdTiming) {
|
|
@@ -2219,29 +2158,46 @@ var StormcloudVideoPlayer = class {
|
|
|
2219
2158
|
this.ima.on("content_resume", () => {
|
|
2220
2159
|
if (this.config.debugAdTiming) {
|
|
2221
2160
|
console.log(
|
|
2222
|
-
"[StormcloudVideoPlayer] IMA content_resume event received"
|
|
2161
|
+
"[StormcloudVideoPlayer] IMA content_resume event received",
|
|
2162
|
+
{
|
|
2163
|
+
inAdBreak: this.inAdBreak,
|
|
2164
|
+
pendingAds: this.adPodQueue.length
|
|
2165
|
+
}
|
|
2223
2166
|
);
|
|
2224
2167
|
}
|
|
2225
2168
|
this.clearAdFailsafeTimer();
|
|
2226
|
-
if (!this.inAdBreak)
|
|
2169
|
+
if (!this.inAdBreak) {
|
|
2170
|
+
if (this.config.debugAdTiming) {
|
|
2171
|
+
console.log(
|
|
2172
|
+
"[StormcloudVideoPlayer] Not in ad break - this shouldn't happen during pod"
|
|
2173
|
+
);
|
|
2174
|
+
}
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2227
2177
|
const remaining = this.getRemainingAdMs();
|
|
2228
2178
|
if (remaining > 500 && this.adPodQueue.length > 0) {
|
|
2229
2179
|
const next = this.adPodQueue.shift();
|
|
2230
2180
|
this.currentAdIndex++;
|
|
2231
2181
|
if (this.config.debugAdTiming) {
|
|
2232
2182
|
console.log(
|
|
2233
|
-
`[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak})`
|
|
2183
|
+
`[StormcloudVideoPlayer] Playing next ad in pod (${this.currentAdIndex}/${this.totalAdsInBreak}) - main video stays muted, ad layer stays visible`
|
|
2234
2184
|
);
|
|
2235
2185
|
}
|
|
2236
2186
|
this.playSingleAd(next).catch(() => {
|
|
2187
|
+
if (this.config.debugAdTiming) {
|
|
2188
|
+
console.error(
|
|
2189
|
+
"[StormcloudVideoPlayer] Failed to play next ad in pod"
|
|
2190
|
+
);
|
|
2191
|
+
}
|
|
2192
|
+
this.handleAdPodComplete();
|
|
2237
2193
|
});
|
|
2238
2194
|
} else {
|
|
2239
2195
|
if (this.config.debugAdTiming) {
|
|
2240
|
-
console.log(
|
|
2196
|
+
console.log(
|
|
2197
|
+
"[StormcloudVideoPlayer] No more ads in pod - completing ad break"
|
|
2198
|
+
);
|
|
2241
2199
|
}
|
|
2242
|
-
this.
|
|
2243
|
-
this.totalAdsInBreak = 0;
|
|
2244
|
-
this.showAds = false;
|
|
2200
|
+
this.handleAdPodComplete();
|
|
2245
2201
|
}
|
|
2246
2202
|
});
|
|
2247
2203
|
this.video.addEventListener("timeupdate", () => {
|
|
@@ -2959,23 +2915,11 @@ var StormcloudVideoPlayer = class {
|
|
|
2959
2915
|
maxExtensionMs
|
|
2960
2916
|
});
|
|
2961
2917
|
}
|
|
2962
|
-
this.inAdBreak = false;
|
|
2963
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
2964
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
2965
|
-
this.showAds = false;
|
|
2966
|
-
this.adPodQueue = [];
|
|
2967
|
-
this.currentAdIndex = 0;
|
|
2968
|
-
this.totalAdsInBreak = 0;
|
|
2969
|
-
this.clearAdFailsafeTimer();
|
|
2970
2918
|
if (adPlaying) {
|
|
2971
2919
|
this.ima.stop().catch(() => {
|
|
2972
2920
|
});
|
|
2973
|
-
return;
|
|
2974
|
-
}
|
|
2975
|
-
const originalMutedState = this.ima.getOriginalMutedState();
|
|
2976
|
-
if (this.video.muted !== originalMutedState) {
|
|
2977
|
-
this.video.muted = originalMutedState;
|
|
2978
2921
|
}
|
|
2922
|
+
this.handleAdPodComplete();
|
|
2979
2923
|
}
|
|
2980
2924
|
scheduleAdStartIn(delayMs) {
|
|
2981
2925
|
this.clearAdStartTimer();
|
|
@@ -3062,17 +3006,11 @@ var StormcloudVideoPlayer = class {
|
|
|
3062
3006
|
this.handleAdFailure();
|
|
3063
3007
|
}
|
|
3064
3008
|
}
|
|
3065
|
-
|
|
3009
|
+
handleAdPodComplete() {
|
|
3066
3010
|
var _a;
|
|
3067
3011
|
if (this.config.debugAdTiming) {
|
|
3068
3012
|
console.log(
|
|
3069
|
-
"[StormcloudVideoPlayer] Handling ad
|
|
3070
|
-
{
|
|
3071
|
-
inAdBreak: this.inAdBreak,
|
|
3072
|
-
showAds: this.showAds,
|
|
3073
|
-
videoPaused: this.video.paused,
|
|
3074
|
-
adPlaying: this.ima.isAdPlaying()
|
|
3075
|
-
}
|
|
3013
|
+
"[StormcloudVideoPlayer] Handling ad pod completion - resuming content"
|
|
3076
3014
|
);
|
|
3077
3015
|
}
|
|
3078
3016
|
this.inAdBreak = false;
|
|
@@ -3085,34 +3023,41 @@ var StormcloudVideoPlayer = class {
|
|
|
3085
3023
|
this.showAds = false;
|
|
3086
3024
|
this.currentAdIndex = 0;
|
|
3087
3025
|
this.totalAdsInBreak = 0;
|
|
3088
|
-
const currentMutedState = this.video.muted;
|
|
3089
3026
|
const originalMutedState = this.ima.getOriginalMutedState();
|
|
3090
3027
|
this.video.muted = originalMutedState;
|
|
3091
3028
|
if (this.config.debugAdTiming) {
|
|
3092
3029
|
console.log(
|
|
3093
|
-
`[StormcloudVideoPlayer] Restored mute state: ${
|
|
3030
|
+
`[StormcloudVideoPlayer] Restored main video mute state to: ${originalMutedState}`
|
|
3094
3031
|
);
|
|
3095
3032
|
}
|
|
3096
|
-
if (this.video.paused) {
|
|
3033
|
+
if (!this.shouldContinueLiveStreamDuringAds() && this.video.paused) {
|
|
3097
3034
|
if (this.config.debugAdTiming) {
|
|
3098
3035
|
console.log("[StormcloudVideoPlayer] Resuming paused video");
|
|
3099
3036
|
}
|
|
3100
3037
|
(_a = this.video.play()) == null ? void 0 : _a.catch((error) => {
|
|
3101
3038
|
if (this.config.debugAdTiming) {
|
|
3102
3039
|
console.error(
|
|
3103
|
-
"[StormcloudVideoPlayer] Failed to resume video
|
|
3040
|
+
"[StormcloudVideoPlayer] Failed to resume video:",
|
|
3104
3041
|
error
|
|
3105
3042
|
);
|
|
3106
3043
|
}
|
|
3107
3044
|
});
|
|
3108
|
-
} else {
|
|
3109
|
-
if (this.config.debugAdTiming) {
|
|
3110
|
-
console.log(
|
|
3111
|
-
"[StormcloudVideoPlayer] Video is already playing, no resume needed"
|
|
3112
|
-
);
|
|
3113
|
-
}
|
|
3114
3045
|
}
|
|
3115
3046
|
}
|
|
3047
|
+
handleAdFailure() {
|
|
3048
|
+
if (this.config.debugAdTiming) {
|
|
3049
|
+
console.log(
|
|
3050
|
+
"[StormcloudVideoPlayer] Handling ad failure - resuming content",
|
|
3051
|
+
{
|
|
3052
|
+
inAdBreak: this.inAdBreak,
|
|
3053
|
+
showAds: this.showAds,
|
|
3054
|
+
videoPaused: this.video.paused,
|
|
3055
|
+
adPlaying: this.ima.isAdPlaying()
|
|
3056
|
+
}
|
|
3057
|
+
);
|
|
3058
|
+
}
|
|
3059
|
+
this.handleAdPodComplete();
|
|
3060
|
+
}
|
|
3116
3061
|
startAdFailsafeTimer() {
|
|
3117
3062
|
var _a;
|
|
3118
3063
|
this.clearAdFailsafeTimer();
|