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.cjs
CHANGED
|
@@ -3282,90 +3282,80 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3282
3282
|
}
|
|
3283
3283
|
},
|
|
3284
3284
|
{
|
|
3285
|
-
key: "
|
|
3286
|
-
value: function
|
|
3287
|
-
if (this.
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
if (this.config.debugAdTiming) {
|
|
3306
|
-
console.warn("[StormcloudVideoPlayer] Video element has no parent for placeholder container");
|
|
3307
|
-
}
|
|
3308
|
-
return;
|
|
3309
|
-
}
|
|
3310
|
-
this.video.parentElement.appendChild(container);
|
|
3311
|
-
this.placeholderContainer = container;
|
|
3285
|
+
key: "ensureFillerVideo",
|
|
3286
|
+
value: function ensureFillerVideo() {
|
|
3287
|
+
if (this.fillerVideo) return;
|
|
3288
|
+
if (!this.video.parentElement) return;
|
|
3289
|
+
var filler = document.createElement("video");
|
|
3290
|
+
filler.src = "https://f000.backblazeb2.com/file/AdStormAds/384/Sonifi_Filler.mp4";
|
|
3291
|
+
filler.loop = true;
|
|
3292
|
+
filler.muted = false;
|
|
3293
|
+
filler.playsInline = true;
|
|
3294
|
+
filler.style.position = "absolute";
|
|
3295
|
+
filler.style.left = "0";
|
|
3296
|
+
filler.style.top = "0";
|
|
3297
|
+
filler.style.width = "100%";
|
|
3298
|
+
filler.style.height = "100%";
|
|
3299
|
+
filler.style.objectFit = "cover";
|
|
3300
|
+
filler.style.zIndex = "20";
|
|
3301
|
+
filler.style.display = "none";
|
|
3302
|
+
filler.preload = "auto";
|
|
3303
|
+
this.video.parentElement.appendChild(filler);
|
|
3304
|
+
this.fillerVideo = filler;
|
|
3312
3305
|
}
|
|
3313
3306
|
},
|
|
3314
3307
|
{
|
|
3315
3308
|
key: "showPlaceholderLayer",
|
|
3316
3309
|
value: function showPlaceholderLayer() {
|
|
3317
3310
|
var _this = this;
|
|
3318
|
-
this.
|
|
3319
|
-
if (!this.
|
|
3320
|
-
return;
|
|
3321
|
-
}
|
|
3311
|
+
this.ensureFillerVideo();
|
|
3312
|
+
if (!this.fillerVideo) return;
|
|
3322
3313
|
if (!this.video.muted) {
|
|
3323
3314
|
this.video.muted = true;
|
|
3324
3315
|
this.video.volume = 0;
|
|
3325
|
-
if (this.config.debugAdTiming) {
|
|
3326
|
-
console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
|
|
3327
|
-
}
|
|
3328
|
-
}
|
|
3329
|
-
var wasHidden = this.placeholderContainer.style.display === "none" || this.placeholderContainer.style.opacity === "0";
|
|
3330
|
-
if (wasHidden) {
|
|
3331
|
-
this.placeholderContainer.style.transition = "none";
|
|
3332
|
-
} else {
|
|
3333
|
-
this.placeholderContainer.style.transition = "opacity 0.3s ease-in-out";
|
|
3334
|
-
}
|
|
3335
|
-
this.placeholderContainer.style.backgroundColor = "#000";
|
|
3336
|
-
this.placeholderContainer.style.display = "flex";
|
|
3337
|
-
this.placeholderContainer.offsetHeight;
|
|
3338
|
-
this.placeholderContainer.style.opacity = "1";
|
|
3339
|
-
this.placeholderContainer.style.pointerEvents = "auto";
|
|
3340
|
-
if (wasHidden) {
|
|
3341
|
-
requestAnimationFrame(function() {
|
|
3342
|
-
if (_this.placeholderContainer) {
|
|
3343
|
-
_this.placeholderContainer.style.transition = "opacity 0.3s ease-in-out";
|
|
3344
|
-
}
|
|
3345
|
-
});
|
|
3346
3316
|
}
|
|
3317
|
+
this.fillerVideo.style.display = "block";
|
|
3318
|
+
this.fillerVideo.play().catch(function() {
|
|
3319
|
+
if (_this.fillerVideo) {
|
|
3320
|
+
_this.fillerVideo.style.display = "none";
|
|
3321
|
+
}
|
|
3322
|
+
});
|
|
3347
3323
|
if (this.config.debugAdTiming) {
|
|
3348
|
-
console.log("[StormcloudVideoPlayer] Showing
|
|
3324
|
+
console.log("[StormcloudVideoPlayer] Showing filler video layer");
|
|
3349
3325
|
}
|
|
3350
3326
|
}
|
|
3351
3327
|
},
|
|
3352
3328
|
{
|
|
3353
3329
|
key: "hidePlaceholderLayer",
|
|
3354
3330
|
value: function hidePlaceholderLayer() {
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
this.placeholderContainer.style.opacity = "0";
|
|
3360
|
-
setTimeout(function() {
|
|
3361
|
-
if (_this.placeholderContainer) {
|
|
3362
|
-
_this.placeholderContainer.style.display = "none";
|
|
3363
|
-
_this.placeholderContainer.style.pointerEvents = "none";
|
|
3364
|
-
_this.placeholderContainer.style.backgroundColor = "#000";
|
|
3365
|
-
}
|
|
3366
|
-
}, 300);
|
|
3331
|
+
if (!this.fillerVideo) return;
|
|
3332
|
+
this.fillerVideo.style.display = "none";
|
|
3333
|
+
this.fillerVideo.pause();
|
|
3334
|
+
this.fillerVideo.currentTime = 0;
|
|
3367
3335
|
if (this.config.debugAdTiming) {
|
|
3368
|
-
console.log("[StormcloudVideoPlayer] Hiding
|
|
3336
|
+
console.log("[StormcloudVideoPlayer] Hiding filler video layer");
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
},
|
|
3340
|
+
{
|
|
3341
|
+
key: "startFillerBreakTimer",
|
|
3342
|
+
value: function startFillerBreakTimer(durationMs) {
|
|
3343
|
+
var _this = this;
|
|
3344
|
+
this.stopFillerBreakTimer();
|
|
3345
|
+
this.showPlaceholderLayer();
|
|
3346
|
+
this.fillerBreakTimerId = setTimeout(function() {
|
|
3347
|
+
_this.fillerBreakTimerId = void 0;
|
|
3348
|
+
_this.hidePlaceholderLayer();
|
|
3349
|
+
if (_this.inAdBreak) _this.handleAdPodComplete();
|
|
3350
|
+
}, durationMs);
|
|
3351
|
+
}
|
|
3352
|
+
},
|
|
3353
|
+
{
|
|
3354
|
+
key: "stopFillerBreakTimer",
|
|
3355
|
+
value: function stopFillerBreakTimer() {
|
|
3356
|
+
if (this.fillerBreakTimerId !== void 0) {
|
|
3357
|
+
clearTimeout(this.fillerBreakTimerId);
|
|
3358
|
+
this.fillerBreakTimerId = void 0;
|
|
3369
3359
|
}
|
|
3370
3360
|
}
|
|
3371
3361
|
},
|
|
@@ -3378,6 +3368,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3378
3368
|
this.video.autoplay = !!this.config.autoplay;
|
|
3379
3369
|
this.video.muted = !!this.config.muted;
|
|
3380
3370
|
this.adLayer.initialize();
|
|
3371
|
+
this.ensureFillerVideo();
|
|
3381
3372
|
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3382
3373
|
this.attachAdLayerEventListeners();
|
|
3383
3374
|
this.timeUpdateHandler = function() {
|
|
@@ -4297,7 +4288,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4297
4288
|
this.totalAdsInBreak = 1;
|
|
4298
4289
|
this.adPodQueue = [];
|
|
4299
4290
|
this.showAds = true;
|
|
4300
|
-
|
|
4291
|
+
if (adBreakDurationMs != null) {
|
|
4292
|
+
this.startFillerBreakTimer(adBreakDurationMs);
|
|
4293
|
+
} else {
|
|
4294
|
+
this.showPlaceholderLayer();
|
|
4295
|
+
}
|
|
4301
4296
|
this.adLayer.showPlaceholder();
|
|
4302
4297
|
if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
4303
4298
|
this.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
@@ -4399,7 +4394,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4399
4394
|
key: "stopContinuousFetching",
|
|
4400
4395
|
value: function stopContinuousFetching() {
|
|
4401
4396
|
this.continuousFetchingActive = false;
|
|
4402
|
-
this.hidePlaceholderLayer();
|
|
4403
4397
|
if (this.config.debugAdTiming) {
|
|
4404
4398
|
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Stopping continuous ad fetching");
|
|
4405
4399
|
}
|
|
@@ -4590,13 +4584,23 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4590
4584
|
key: "showPlaceholderAndWaitForAds",
|
|
4591
4585
|
value: function showPlaceholderAndWaitForAds() {
|
|
4592
4586
|
return _async_to_generator(function() {
|
|
4593
|
-
var remaining, waitTime, checkInterval, maxChecks, i, bids, unused;
|
|
4587
|
+
var remaining, waitTime, stillRemaining2, checkInterval, maxChecks, i, bids, unused, stillRemaining;
|
|
4594
4588
|
return _ts_generator(this, function(_state) {
|
|
4595
4589
|
switch(_state.label){
|
|
4596
4590
|
case 0:
|
|
4597
4591
|
remaining = this.getRemainingAdMs();
|
|
4598
4592
|
waitTime = Math.min(this.maxPlaceholderDurationMs, remaining);
|
|
4599
4593
|
if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
|
|
4594
|
+
stillRemaining2 = this.getRemainingAdMs();
|
|
4595
|
+
if (stillRemaining2 >= 1e3) {
|
|
4596
|
+
if (this.config.debugAdTiming) {
|
|
4597
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Max failures reached but break still active — resetting and continuing filler");
|
|
4598
|
+
}
|
|
4599
|
+
this.consecutiveFailures = 0;
|
|
4600
|
+
return [
|
|
4601
|
+
2
|
|
4602
|
+
];
|
|
4603
|
+
}
|
|
4600
4604
|
if (this.config.debugAdTiming) {
|
|
4601
4605
|
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Skipping placeholder - too many consecutive failures");
|
|
4602
4606
|
}
|
|
@@ -4615,6 +4619,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4615
4619
|
console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad response"));
|
|
4616
4620
|
}
|
|
4617
4621
|
this.isShowingPlaceholder = true;
|
|
4622
|
+
this.showPlaceholderLayer();
|
|
4618
4623
|
this.adLayer.showPlaceholder();
|
|
4619
4624
|
checkInterval = 300;
|
|
4620
4625
|
maxChecks = Math.floor(waitTime / checkInterval);
|
|
@@ -4638,8 +4643,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4638
4643
|
];
|
|
4639
4644
|
if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
|
|
4640
4645
|
if (this.config.debugAdTiming) {
|
|
4641
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many failures during placeholder wait");
|
|
4646
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many failures during placeholder wait — resetting and continuing filler");
|
|
4642
4647
|
}
|
|
4648
|
+
this.consecutiveFailures = 0;
|
|
4643
4649
|
return [
|
|
4644
4650
|
3,
|
|
4645
4651
|
10
|
|
@@ -4706,6 +4712,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4706
4712
|
1
|
|
4707
4713
|
];
|
|
4708
4714
|
case 10:
|
|
4715
|
+
stillRemaining = this.getRemainingAdMs();
|
|
4716
|
+
if (stillRemaining >= 1e3) {
|
|
4717
|
+
if (this.config.debugAdTiming) {
|
|
4718
|
+
console.log("[CONTINUOUS-FETCH] ⏰ Placeholder slot expired, ".concat(stillRemaining, "ms still remaining — continuing filler"));
|
|
4719
|
+
}
|
|
4720
|
+
this.isShowingPlaceholder = false;
|
|
4721
|
+
this.adLayer.hidePlaceholder();
|
|
4722
|
+
this.consecutiveFailures = 0;
|
|
4723
|
+
return [
|
|
4724
|
+
2
|
|
4725
|
+
];
|
|
4726
|
+
}
|
|
4709
4727
|
if (this.config.debugAdTiming) {
|
|
4710
4728
|
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
|
|
4711
4729
|
}
|
|
@@ -4829,6 +4847,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4829
4847
|
this.activeAdRequestToken = null;
|
|
4830
4848
|
this.isInAdTransition = false;
|
|
4831
4849
|
this.stopContinuousFetching();
|
|
4850
|
+
this.stopFillerBreakTimer();
|
|
4851
|
+
this.hidePlaceholderLayer();
|
|
4832
4852
|
this.clearPendingAdBreak();
|
|
4833
4853
|
this.pendingNextAdBids = null;
|
|
4834
4854
|
if (this.isShowingPlaceholder) {
|
|
@@ -5237,16 +5257,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5237
5257
|
value: function destroy() {
|
|
5238
5258
|
var _this_hls, _this_adLayer;
|
|
5239
5259
|
this.stopContinuousFetching();
|
|
5260
|
+
this.stopFillerBreakTimer();
|
|
5240
5261
|
this.clearAdStartTimer();
|
|
5241
5262
|
this.clearAdStopTimer();
|
|
5242
5263
|
this.clearAdFailsafeTimer();
|
|
5243
5264
|
this.clearAdRequestWatchdog();
|
|
5244
5265
|
this.clearPendingAdBreak();
|
|
5245
|
-
if (this.
|
|
5246
|
-
|
|
5247
|
-
|
|
5266
|
+
if (this.fillerVideo) {
|
|
5267
|
+
this.fillerVideo.pause();
|
|
5268
|
+
if (this.fillerVideo.parentElement) {
|
|
5269
|
+
this.fillerVideo.parentElement.removeChild(this.fillerVideo);
|
|
5248
5270
|
}
|
|
5249
|
-
this.
|
|
5271
|
+
this.fillerVideo = void 0;
|
|
5250
5272
|
}
|
|
5251
5273
|
if (this.timeUpdateHandler) {
|
|
5252
5274
|
this.video.removeEventListener("timeupdate", this.timeUpdateHandler);
|