stormcloud-video-player 0.5.21 → 0.5.22
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 +1 -1
- package/lib/index.cjs +96 -74
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +5 -2
- package/lib/index.d.ts +5 -2
- package/lib/index.js +96 -74
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +96 -74
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +5 -2
- package/lib/players/HlsPlayer.cjs +96 -74
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +96 -74
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +96 -74
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -144,15 +144,18 @@ declare class StormcloudVideoPlayer {
|
|
|
144
144
|
private readonly backoffBaseMs;
|
|
145
145
|
private readonly maxBackoffMs;
|
|
146
146
|
private readonly adTransitionGapMs;
|
|
147
|
-
private
|
|
147
|
+
private fillerVideo;
|
|
148
|
+
private fillerBreakTimerId;
|
|
148
149
|
constructor(config: StormcloudVideoPlayerConfig);
|
|
149
150
|
private adRequest;
|
|
150
151
|
load(): Promise<void>;
|
|
151
152
|
private getAdSource;
|
|
152
153
|
private attachAdLayerEventListeners;
|
|
153
|
-
private
|
|
154
|
+
private ensureFillerVideo;
|
|
154
155
|
private showPlaceholderLayer;
|
|
155
156
|
private hidePlaceholderLayer;
|
|
157
|
+
private startFillerBreakTimer;
|
|
158
|
+
private stopFillerBreakTimer;
|
|
156
159
|
private attach;
|
|
157
160
|
private shouldUseNativeHls;
|
|
158
161
|
private onId3Tag;
|
package/lib/index.d.ts
CHANGED
|
@@ -144,15 +144,18 @@ declare class StormcloudVideoPlayer {
|
|
|
144
144
|
private readonly backoffBaseMs;
|
|
145
145
|
private readonly maxBackoffMs;
|
|
146
146
|
private readonly adTransitionGapMs;
|
|
147
|
-
private
|
|
147
|
+
private fillerVideo;
|
|
148
|
+
private fillerBreakTimerId;
|
|
148
149
|
constructor(config: StormcloudVideoPlayerConfig);
|
|
149
150
|
private adRequest;
|
|
150
151
|
load(): Promise<void>;
|
|
151
152
|
private getAdSource;
|
|
152
153
|
private attachAdLayerEventListeners;
|
|
153
|
-
private
|
|
154
|
+
private ensureFillerVideo;
|
|
154
155
|
private showPlaceholderLayer;
|
|
155
156
|
private hidePlaceholderLayer;
|
|
157
|
+
private startFillerBreakTimer;
|
|
158
|
+
private stopFillerBreakTimer;
|
|
156
159
|
private attach;
|
|
157
160
|
private shouldUseNativeHls;
|
|
158
161
|
private onId3Tag;
|
package/lib/index.js
CHANGED
|
@@ -3125,90 +3125,80 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3125
3125
|
}
|
|
3126
3126
|
},
|
|
3127
3127
|
{
|
|
3128
|
-
key: "
|
|
3129
|
-
value: function
|
|
3130
|
-
if (this.
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
if (this.config.debugAdTiming) {
|
|
3149
|
-
console.warn("[StormcloudVideoPlayer] Video element has no parent for placeholder container");
|
|
3150
|
-
}
|
|
3151
|
-
return;
|
|
3152
|
-
}
|
|
3153
|
-
this.video.parentElement.appendChild(container);
|
|
3154
|
-
this.placeholderContainer = container;
|
|
3128
|
+
key: "ensureFillerVideo",
|
|
3129
|
+
value: function ensureFillerVideo() {
|
|
3130
|
+
if (this.fillerVideo) return;
|
|
3131
|
+
if (!this.video.parentElement) return;
|
|
3132
|
+
var filler = document.createElement("video");
|
|
3133
|
+
filler.src = "https://f000.backblazeb2.com/file/AdStormAds/384/Sonifi_Filler.mp4";
|
|
3134
|
+
filler.loop = true;
|
|
3135
|
+
filler.muted = false;
|
|
3136
|
+
filler.playsInline = true;
|
|
3137
|
+
filler.style.position = "absolute";
|
|
3138
|
+
filler.style.left = "0";
|
|
3139
|
+
filler.style.top = "0";
|
|
3140
|
+
filler.style.width = "100%";
|
|
3141
|
+
filler.style.height = "100%";
|
|
3142
|
+
filler.style.objectFit = "cover";
|
|
3143
|
+
filler.style.zIndex = "20";
|
|
3144
|
+
filler.style.display = "none";
|
|
3145
|
+
filler.preload = "auto";
|
|
3146
|
+
this.video.parentElement.appendChild(filler);
|
|
3147
|
+
this.fillerVideo = filler;
|
|
3155
3148
|
}
|
|
3156
3149
|
},
|
|
3157
3150
|
{
|
|
3158
3151
|
key: "showPlaceholderLayer",
|
|
3159
3152
|
value: function showPlaceholderLayer() {
|
|
3160
3153
|
var _this = this;
|
|
3161
|
-
this.
|
|
3162
|
-
if (!this.
|
|
3163
|
-
return;
|
|
3164
|
-
}
|
|
3154
|
+
this.ensureFillerVideo();
|
|
3155
|
+
if (!this.fillerVideo) return;
|
|
3165
3156
|
if (!this.video.muted) {
|
|
3166
3157
|
this.video.muted = true;
|
|
3167
3158
|
this.video.volume = 0;
|
|
3168
|
-
if (this.config.debugAdTiming) {
|
|
3169
|
-
console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
|
|
3170
|
-
}
|
|
3171
|
-
}
|
|
3172
|
-
var wasHidden = this.placeholderContainer.style.display === "none" || this.placeholderContainer.style.opacity === "0";
|
|
3173
|
-
if (wasHidden) {
|
|
3174
|
-
this.placeholderContainer.style.transition = "none";
|
|
3175
|
-
} else {
|
|
3176
|
-
this.placeholderContainer.style.transition = "opacity 0.3s ease-in-out";
|
|
3177
|
-
}
|
|
3178
|
-
this.placeholderContainer.style.backgroundColor = "#000";
|
|
3179
|
-
this.placeholderContainer.style.display = "flex";
|
|
3180
|
-
this.placeholderContainer.offsetHeight;
|
|
3181
|
-
this.placeholderContainer.style.opacity = "1";
|
|
3182
|
-
this.placeholderContainer.style.pointerEvents = "auto";
|
|
3183
|
-
if (wasHidden) {
|
|
3184
|
-
requestAnimationFrame(function() {
|
|
3185
|
-
if (_this.placeholderContainer) {
|
|
3186
|
-
_this.placeholderContainer.style.transition = "opacity 0.3s ease-in-out";
|
|
3187
|
-
}
|
|
3188
|
-
});
|
|
3189
3159
|
}
|
|
3160
|
+
this.fillerVideo.style.display = "block";
|
|
3161
|
+
this.fillerVideo.play().catch(function() {
|
|
3162
|
+
if (_this.fillerVideo) {
|
|
3163
|
+
_this.fillerVideo.style.display = "none";
|
|
3164
|
+
}
|
|
3165
|
+
});
|
|
3190
3166
|
if (this.config.debugAdTiming) {
|
|
3191
|
-
console.log("[StormcloudVideoPlayer] Showing
|
|
3167
|
+
console.log("[StormcloudVideoPlayer] Showing filler video layer");
|
|
3192
3168
|
}
|
|
3193
3169
|
}
|
|
3194
3170
|
},
|
|
3195
3171
|
{
|
|
3196
3172
|
key: "hidePlaceholderLayer",
|
|
3197
3173
|
value: function hidePlaceholderLayer() {
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
this.placeholderContainer.style.opacity = "0";
|
|
3203
|
-
setTimeout(function() {
|
|
3204
|
-
if (_this.placeholderContainer) {
|
|
3205
|
-
_this.placeholderContainer.style.display = "none";
|
|
3206
|
-
_this.placeholderContainer.style.pointerEvents = "none";
|
|
3207
|
-
_this.placeholderContainer.style.backgroundColor = "#000";
|
|
3208
|
-
}
|
|
3209
|
-
}, 300);
|
|
3174
|
+
if (!this.fillerVideo) return;
|
|
3175
|
+
this.fillerVideo.style.display = "none";
|
|
3176
|
+
this.fillerVideo.pause();
|
|
3177
|
+
this.fillerVideo.currentTime = 0;
|
|
3210
3178
|
if (this.config.debugAdTiming) {
|
|
3211
|
-
console.log("[StormcloudVideoPlayer] Hiding
|
|
3179
|
+
console.log("[StormcloudVideoPlayer] Hiding filler video layer");
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
},
|
|
3183
|
+
{
|
|
3184
|
+
key: "startFillerBreakTimer",
|
|
3185
|
+
value: function startFillerBreakTimer(durationMs) {
|
|
3186
|
+
var _this = this;
|
|
3187
|
+
this.stopFillerBreakTimer();
|
|
3188
|
+
this.showPlaceholderLayer();
|
|
3189
|
+
this.fillerBreakTimerId = setTimeout(function() {
|
|
3190
|
+
_this.fillerBreakTimerId = void 0;
|
|
3191
|
+
_this.hidePlaceholderLayer();
|
|
3192
|
+
if (_this.inAdBreak) _this.handleAdPodComplete();
|
|
3193
|
+
}, durationMs);
|
|
3194
|
+
}
|
|
3195
|
+
},
|
|
3196
|
+
{
|
|
3197
|
+
key: "stopFillerBreakTimer",
|
|
3198
|
+
value: function stopFillerBreakTimer() {
|
|
3199
|
+
if (this.fillerBreakTimerId !== void 0) {
|
|
3200
|
+
clearTimeout(this.fillerBreakTimerId);
|
|
3201
|
+
this.fillerBreakTimerId = void 0;
|
|
3212
3202
|
}
|
|
3213
3203
|
}
|
|
3214
3204
|
},
|
|
@@ -3221,6 +3211,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3221
3211
|
this.video.autoplay = !!this.config.autoplay;
|
|
3222
3212
|
this.video.muted = !!this.config.muted;
|
|
3223
3213
|
this.adLayer.initialize();
|
|
3214
|
+
this.ensureFillerVideo();
|
|
3224
3215
|
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3225
3216
|
this.attachAdLayerEventListeners();
|
|
3226
3217
|
this.timeUpdateHandler = function() {
|
|
@@ -4140,7 +4131,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4140
4131
|
this.totalAdsInBreak = 1;
|
|
4141
4132
|
this.adPodQueue = [];
|
|
4142
4133
|
this.showAds = true;
|
|
4143
|
-
|
|
4134
|
+
if (adBreakDurationMs != null) {
|
|
4135
|
+
this.startFillerBreakTimer(adBreakDurationMs);
|
|
4136
|
+
} else {
|
|
4137
|
+
this.showPlaceholderLayer();
|
|
4138
|
+
}
|
|
4144
4139
|
this.adLayer.showPlaceholder();
|
|
4145
4140
|
if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
4146
4141
|
this.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
@@ -4242,7 +4237,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4242
4237
|
key: "stopContinuousFetching",
|
|
4243
4238
|
value: function stopContinuousFetching() {
|
|
4244
4239
|
this.continuousFetchingActive = false;
|
|
4245
|
-
this.hidePlaceholderLayer();
|
|
4246
4240
|
if (this.config.debugAdTiming) {
|
|
4247
4241
|
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Stopping continuous ad fetching");
|
|
4248
4242
|
}
|
|
@@ -4433,13 +4427,23 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4433
4427
|
key: "showPlaceholderAndWaitForAds",
|
|
4434
4428
|
value: function showPlaceholderAndWaitForAds() {
|
|
4435
4429
|
return _async_to_generator(function() {
|
|
4436
|
-
var remaining, waitTime, checkInterval, maxChecks, i, bids, unused;
|
|
4430
|
+
var remaining, waitTime, stillRemaining2, checkInterval, maxChecks, i, bids, unused, stillRemaining;
|
|
4437
4431
|
return _ts_generator(this, function(_state) {
|
|
4438
4432
|
switch(_state.label){
|
|
4439
4433
|
case 0:
|
|
4440
4434
|
remaining = this.getRemainingAdMs();
|
|
4441
4435
|
waitTime = Math.min(this.maxPlaceholderDurationMs, remaining);
|
|
4442
4436
|
if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
|
|
4437
|
+
stillRemaining2 = this.getRemainingAdMs();
|
|
4438
|
+
if (stillRemaining2 >= 1e3) {
|
|
4439
|
+
if (this.config.debugAdTiming) {
|
|
4440
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Max failures reached but break still active — resetting and continuing filler");
|
|
4441
|
+
}
|
|
4442
|
+
this.consecutiveFailures = 0;
|
|
4443
|
+
return [
|
|
4444
|
+
2
|
|
4445
|
+
];
|
|
4446
|
+
}
|
|
4443
4447
|
if (this.config.debugAdTiming) {
|
|
4444
4448
|
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Skipping placeholder - too many consecutive failures");
|
|
4445
4449
|
}
|
|
@@ -4458,6 +4462,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4458
4462
|
console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad response"));
|
|
4459
4463
|
}
|
|
4460
4464
|
this.isShowingPlaceholder = true;
|
|
4465
|
+
this.showPlaceholderLayer();
|
|
4461
4466
|
this.adLayer.showPlaceholder();
|
|
4462
4467
|
checkInterval = 300;
|
|
4463
4468
|
maxChecks = Math.floor(waitTime / checkInterval);
|
|
@@ -4481,8 +4486,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4481
4486
|
];
|
|
4482
4487
|
if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
|
|
4483
4488
|
if (this.config.debugAdTiming) {
|
|
4484
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many failures during placeholder wait");
|
|
4489
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many failures during placeholder wait — resetting and continuing filler");
|
|
4485
4490
|
}
|
|
4491
|
+
this.consecutiveFailures = 0;
|
|
4486
4492
|
return [
|
|
4487
4493
|
3,
|
|
4488
4494
|
10
|
|
@@ -4549,6 +4555,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4549
4555
|
1
|
|
4550
4556
|
];
|
|
4551
4557
|
case 10:
|
|
4558
|
+
stillRemaining = this.getRemainingAdMs();
|
|
4559
|
+
if (stillRemaining >= 1e3) {
|
|
4560
|
+
if (this.config.debugAdTiming) {
|
|
4561
|
+
console.log("[CONTINUOUS-FETCH] ⏰ Placeholder slot expired, ".concat(stillRemaining, "ms still remaining — continuing filler"));
|
|
4562
|
+
}
|
|
4563
|
+
this.isShowingPlaceholder = false;
|
|
4564
|
+
this.adLayer.hidePlaceholder();
|
|
4565
|
+
this.consecutiveFailures = 0;
|
|
4566
|
+
return [
|
|
4567
|
+
2
|
|
4568
|
+
];
|
|
4569
|
+
}
|
|
4552
4570
|
if (this.config.debugAdTiming) {
|
|
4553
4571
|
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
|
|
4554
4572
|
}
|
|
@@ -4672,6 +4690,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4672
4690
|
this.activeAdRequestToken = null;
|
|
4673
4691
|
this.isInAdTransition = false;
|
|
4674
4692
|
this.stopContinuousFetching();
|
|
4693
|
+
this.stopFillerBreakTimer();
|
|
4694
|
+
this.hidePlaceholderLayer();
|
|
4675
4695
|
this.clearPendingAdBreak();
|
|
4676
4696
|
this.pendingNextAdBids = null;
|
|
4677
4697
|
if (this.isShowingPlaceholder) {
|
|
@@ -5080,16 +5100,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5080
5100
|
value: function destroy() {
|
|
5081
5101
|
var _this_hls, _this_adLayer;
|
|
5082
5102
|
this.stopContinuousFetching();
|
|
5103
|
+
this.stopFillerBreakTimer();
|
|
5083
5104
|
this.clearAdStartTimer();
|
|
5084
5105
|
this.clearAdStopTimer();
|
|
5085
5106
|
this.clearAdFailsafeTimer();
|
|
5086
5107
|
this.clearAdRequestWatchdog();
|
|
5087
5108
|
this.clearPendingAdBreak();
|
|
5088
|
-
if (this.
|
|
5089
|
-
|
|
5090
|
-
|
|
5109
|
+
if (this.fillerVideo) {
|
|
5110
|
+
this.fillerVideo.pause();
|
|
5111
|
+
if (this.fillerVideo.parentElement) {
|
|
5112
|
+
this.fillerVideo.parentElement.removeChild(this.fillerVideo);
|
|
5091
5113
|
}
|
|
5092
|
-
this.
|
|
5114
|
+
this.fillerVideo = void 0;
|
|
5093
5115
|
}
|
|
5094
5116
|
if (this.timeUpdateHandler) {
|
|
5095
5117
|
this.video.removeEventListener("timeupdate", this.timeUpdateHandler);
|