stormcloud-video-player 0.8.9 → 0.8.10
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 +54 -20
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +4 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +54 -20
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +54 -20
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +4 -1
- package/lib/players/HlsPlayer.cjs +54 -20
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +54 -20
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/{types-CUKMIqHL.d.cts → types-DQM-Tu6a.d.cts} +1 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +54 -20
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/package.json +1 -1
|
@@ -2636,6 +2636,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2636
2636
|
this.maxConsecutiveFailures = 5;
|
|
2637
2637
|
this.lastAdRequestTime = 0;
|
|
2638
2638
|
this.minAdRequestIntervalMs = 3e3;
|
|
2639
|
+
this.defaultMinRemainingMsToStartAd = 4e3;
|
|
2639
2640
|
this.backoffBaseMs = 1e3;
|
|
2640
2641
|
this.maxBackoffMs = 15e3;
|
|
2641
2642
|
this.globalConsecutiveNoFills = 0;
|
|
@@ -3155,7 +3156,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3155
3156
|
} : {});
|
|
3156
3157
|
}
|
|
3157
3158
|
if (_this.inAdBreak) {
|
|
3158
|
-
if (
|
|
3159
|
+
if (_this.hasTimeToStartAnotherAd()) {
|
|
3159
3160
|
_this.tryNextAvailableAdWithRateLimit();
|
|
3160
3161
|
} else {
|
|
3161
3162
|
_this.handleAdPodComplete();
|
|
@@ -3228,7 +3229,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3228
3229
|
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
3229
3230
|
} : {});
|
|
3230
3231
|
}
|
|
3231
|
-
if (
|
|
3232
|
+
if (_this.hasTimeToStartAnotherAd()) {
|
|
3232
3233
|
_this.tryNextAvailableAdWithRateLimit();
|
|
3233
3234
|
} else {
|
|
3234
3235
|
_this.handleAdPodComplete();
|
|
@@ -3928,7 +3929,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3928
3929
|
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
3929
3930
|
this.scheduleAdStopCountdown(remainingMs1);
|
|
3930
3931
|
}
|
|
3931
|
-
if (!this.adPlayer.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
|
|
3932
|
+
if (!this.adPlayer.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0 && this.hasTimeToStartAnotherAd()) {
|
|
3932
3933
|
this.tryNextAvailableAdWithRateLimit();
|
|
3933
3934
|
}
|
|
3934
3935
|
return;
|
|
@@ -5387,7 +5388,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5387
5388
|
key: "preloadPoolLoop",
|
|
5388
5389
|
value: function preloadPoolLoop(baseVastUrl) {
|
|
5389
5390
|
return _async_to_generator(function() {
|
|
5390
|
-
var epoch,
|
|
5391
|
+
var epoch, newUrls, newUrl;
|
|
5391
5392
|
return _ts_generator(this, function(_state) {
|
|
5392
5393
|
switch(_state.label){
|
|
5393
5394
|
case 0:
|
|
@@ -5454,14 +5455,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5454
5455
|
8
|
|
5455
5456
|
];
|
|
5456
5457
|
}
|
|
5457
|
-
if (this.inAdBreak) {
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
return [
|
|
5461
|
-
3,
|
|
5462
|
-
8
|
|
5463
|
-
];
|
|
5458
|
+
if (this.inAdBreak && !this.hasTimeToStartAnotherAd()) {
|
|
5459
|
+
if (this.config.debugAdTiming) {
|
|
5460
|
+
console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
|
|
5464
5461
|
}
|
|
5462
|
+
return [
|
|
5463
|
+
3,
|
|
5464
|
+
8
|
|
5465
|
+
];
|
|
5465
5466
|
}
|
|
5466
5467
|
newUrls = this.generateVastUrlsWithCorrelators(baseVastUrl, 1);
|
|
5467
5468
|
newUrl = newUrls[0];
|
|
@@ -5891,9 +5892,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5891
5892
|
switch(_state.label){
|
|
5892
5893
|
case 0:
|
|
5893
5894
|
remaining = _this.getRemainingAdMs();
|
|
5894
|
-
if (remaining <=
|
|
5895
|
+
if (remaining <= _this.getMinRemainingMsToStartAd()) {
|
|
5895
5896
|
if (_this.config.debugAdTiming) {
|
|
5896
|
-
console.log("[CONTINUOUS-FETCH]
|
|
5897
|
+
console.log("[CONTINUOUS-FETCH] ⏹️ Not enough ad break time left (".concat(remaining, "ms), stopping URL generation"));
|
|
5897
5898
|
}
|
|
5898
5899
|
return [
|
|
5899
5900
|
2,
|
|
@@ -6113,9 +6114,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6113
6114
|
];
|
|
6114
6115
|
}
|
|
6115
6116
|
remaining = this.getRemainingAdMs();
|
|
6116
|
-
if (
|
|
6117
|
+
if (!this.hasTimeToStartAnotherAd()) {
|
|
6117
6118
|
if (this.config.debugAdTiming) {
|
|
6118
|
-
console.log("[CONTINUOUS-FETCH]
|
|
6119
|
+
console.log("[CONTINUOUS-FETCH] ⏹️ Not enough time remaining (".concat(remaining, "ms) to start another ad, ending ad break"));
|
|
6119
6120
|
}
|
|
6120
6121
|
this.handleAdPodComplete();
|
|
6121
6122
|
return [
|
|
@@ -6387,12 +6388,27 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6387
6388
|
10
|
|
6388
6389
|
];
|
|
6389
6390
|
}
|
|
6391
|
+
if (!this.hasTimeToStartAnotherAd()) {
|
|
6392
|
+
if (this.config.debugAdTiming) {
|
|
6393
|
+
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Not enough time remaining during placeholder wait, ending ad break");
|
|
6394
|
+
}
|
|
6395
|
+
return [
|
|
6396
|
+
3,
|
|
6397
|
+
10
|
|
6398
|
+
];
|
|
6399
|
+
}
|
|
6390
6400
|
_state.label = 3;
|
|
6391
6401
|
case 3:
|
|
6392
6402
|
if (!(this.adRequestQueue.length > 0)) return [
|
|
6393
6403
|
3,
|
|
6394
6404
|
9
|
|
6395
6405
|
];
|
|
6406
|
+
if (!this.hasTimeToStartAnotherAd()) {
|
|
6407
|
+
return [
|
|
6408
|
+
3,
|
|
6409
|
+
9
|
|
6410
|
+
];
|
|
6411
|
+
}
|
|
6396
6412
|
nextAdUrl = this.adRequestQueue.shift();
|
|
6397
6413
|
if (!nextAdUrl) {
|
|
6398
6414
|
return [
|
|
@@ -6675,21 +6691,23 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6675
6691
|
if (!this.inAdBreak) return;
|
|
6676
6692
|
this.adStopTimerId = void 0;
|
|
6677
6693
|
var adPlaying = this.adPlayer.isAdPlaying();
|
|
6678
|
-
var pendingAds = this.adPodQueue.length > 0;
|
|
6679
6694
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
6680
6695
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
6681
|
-
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig :
|
|
6696
|
+
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
6682
6697
|
var elapsedSinceStartMs = 0;
|
|
6683
6698
|
if (this.currentAdBreakStartWallClockMs != null) {
|
|
6684
6699
|
elapsedSinceStartMs = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
6685
6700
|
}
|
|
6686
6701
|
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
6687
6702
|
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
6688
|
-
var shouldExtendAdBreak =
|
|
6703
|
+
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
6689
6704
|
if (shouldExtendAdBreak) {
|
|
6690
6705
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
6691
6706
|
return;
|
|
6692
6707
|
}
|
|
6708
|
+
if (this.config.debugAdTiming) {
|
|
6709
|
+
console.log("[StormcloudVideoPlayer] ⏱️ Ad break boundary reached (overrun=".concat(overrunMs, "ms) - hard-stopping ads and resuming stream"));
|
|
6710
|
+
}
|
|
6693
6711
|
if (adPlaying) {
|
|
6694
6712
|
this.adPlayer.stop().catch(function() {});
|
|
6695
6713
|
}
|
|
@@ -7195,11 +7213,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7195
7213
|
this.handleAdPodComplete();
|
|
7196
7214
|
return;
|
|
7197
7215
|
}
|
|
7198
|
-
if (
|
|
7216
|
+
if (this.hasTimeToStartAnotherAd()) {
|
|
7199
7217
|
this.tryNextAvailableAdWithRateLimit();
|
|
7200
7218
|
} else {
|
|
7201
7219
|
if (this.config.debugAdTiming) {
|
|
7202
|
-
console.log("[AD-ERROR] Ad failed and
|
|
7220
|
+
console.log("[AD-ERROR] Ad failed and not enough time remaining for another ad. Failed URLs:", this.failedVastUrls.size);
|
|
7203
7221
|
}
|
|
7204
7222
|
this.handleAdPodComplete();
|
|
7205
7223
|
}
|
|
@@ -7334,6 +7352,22 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7334
7352
|
return Math.max(0, this.expectedAdBreakDurationMs - elapsed);
|
|
7335
7353
|
}
|
|
7336
7354
|
},
|
|
7355
|
+
{
|
|
7356
|
+
key: "getMinRemainingMsToStartAd",
|
|
7357
|
+
value: function getMinRemainingMsToStartAd() {
|
|
7358
|
+
var configured = this.config.minRemainingMsToStartAd;
|
|
7359
|
+
if (typeof configured === "number" && configured >= 0) {
|
|
7360
|
+
return configured;
|
|
7361
|
+
}
|
|
7362
|
+
return this.defaultMinRemainingMsToStartAd;
|
|
7363
|
+
}
|
|
7364
|
+
},
|
|
7365
|
+
{
|
|
7366
|
+
key: "hasTimeToStartAnotherAd",
|
|
7367
|
+
value: function hasTimeToStartAnotherAd() {
|
|
7368
|
+
return this.getRemainingAdMs() > this.getMinRemainingMsToStartAd();
|
|
7369
|
+
}
|
|
7370
|
+
},
|
|
7337
7371
|
{
|
|
7338
7372
|
key: "findBreakForTime",
|
|
7339
7373
|
value: function findBreakForTime(nowMs) {
|