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
|
@@ -12,6 +12,7 @@ interface StormcloudVideoPlayerConfig {
|
|
|
12
12
|
adFailsafeTimeoutMs?: number;
|
|
13
13
|
adBreakCheckIntervalMs?: number;
|
|
14
14
|
maxAdBreakExtensionMs?: number;
|
|
15
|
+
minRemainingMsToStartAd?: number;
|
|
15
16
|
showCustomControls?: boolean;
|
|
16
17
|
hideLoadingIndicator?: boolean;
|
|
17
18
|
onVolumeToggle?: () => void;
|
|
@@ -2674,6 +2674,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2674
2674
|
this.maxConsecutiveFailures = 5;
|
|
2675
2675
|
this.lastAdRequestTime = 0;
|
|
2676
2676
|
this.minAdRequestIntervalMs = 3e3;
|
|
2677
|
+
this.defaultMinRemainingMsToStartAd = 4e3;
|
|
2677
2678
|
this.backoffBaseMs = 1e3;
|
|
2678
2679
|
this.maxBackoffMs = 15e3;
|
|
2679
2680
|
this.globalConsecutiveNoFills = 0;
|
|
@@ -3193,7 +3194,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3193
3194
|
} : {});
|
|
3194
3195
|
}
|
|
3195
3196
|
if (_this.inAdBreak) {
|
|
3196
|
-
if (
|
|
3197
|
+
if (_this.hasTimeToStartAnotherAd()) {
|
|
3197
3198
|
_this.tryNextAvailableAdWithRateLimit();
|
|
3198
3199
|
} else {
|
|
3199
3200
|
_this.handleAdPodComplete();
|
|
@@ -3266,7 +3267,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3266
3267
|
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
3267
3268
|
} : {});
|
|
3268
3269
|
}
|
|
3269
|
-
if (
|
|
3270
|
+
if (_this.hasTimeToStartAnotherAd()) {
|
|
3270
3271
|
_this.tryNextAvailableAdWithRateLimit();
|
|
3271
3272
|
} else {
|
|
3272
3273
|
_this.handleAdPodComplete();
|
|
@@ -3966,7 +3967,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3966
3967
|
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
3967
3968
|
this.scheduleAdStopCountdown(remainingMs1);
|
|
3968
3969
|
}
|
|
3969
|
-
if (!this.adPlayer.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
|
|
3970
|
+
if (!this.adPlayer.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0 && this.hasTimeToStartAnotherAd()) {
|
|
3970
3971
|
this.tryNextAvailableAdWithRateLimit();
|
|
3971
3972
|
}
|
|
3972
3973
|
return;
|
|
@@ -5425,7 +5426,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5425
5426
|
key: "preloadPoolLoop",
|
|
5426
5427
|
value: function preloadPoolLoop(baseVastUrl) {
|
|
5427
5428
|
return _async_to_generator(function() {
|
|
5428
|
-
var epoch,
|
|
5429
|
+
var epoch, newUrls, newUrl;
|
|
5429
5430
|
return _ts_generator(this, function(_state) {
|
|
5430
5431
|
switch(_state.label){
|
|
5431
5432
|
case 0:
|
|
@@ -5492,14 +5493,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5492
5493
|
8
|
|
5493
5494
|
];
|
|
5494
5495
|
}
|
|
5495
|
-
if (this.inAdBreak) {
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
return [
|
|
5499
|
-
3,
|
|
5500
|
-
8
|
|
5501
|
-
];
|
|
5496
|
+
if (this.inAdBreak && !this.hasTimeToStartAnotherAd()) {
|
|
5497
|
+
if (this.config.debugAdTiming) {
|
|
5498
|
+
console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
|
|
5502
5499
|
}
|
|
5500
|
+
return [
|
|
5501
|
+
3,
|
|
5502
|
+
8
|
|
5503
|
+
];
|
|
5503
5504
|
}
|
|
5504
5505
|
newUrls = this.generateVastUrlsWithCorrelators(baseVastUrl, 1);
|
|
5505
5506
|
newUrl = newUrls[0];
|
|
@@ -5929,9 +5930,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5929
5930
|
switch(_state.label){
|
|
5930
5931
|
case 0:
|
|
5931
5932
|
remaining = _this.getRemainingAdMs();
|
|
5932
|
-
if (remaining <=
|
|
5933
|
+
if (remaining <= _this.getMinRemainingMsToStartAd()) {
|
|
5933
5934
|
if (_this.config.debugAdTiming) {
|
|
5934
|
-
console.log("[CONTINUOUS-FETCH]
|
|
5935
|
+
console.log("[CONTINUOUS-FETCH] ⏹️ Not enough ad break time left (".concat(remaining, "ms), stopping URL generation"));
|
|
5935
5936
|
}
|
|
5936
5937
|
return [
|
|
5937
5938
|
2,
|
|
@@ -6151,9 +6152,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6151
6152
|
];
|
|
6152
6153
|
}
|
|
6153
6154
|
remaining = this.getRemainingAdMs();
|
|
6154
|
-
if (
|
|
6155
|
+
if (!this.hasTimeToStartAnotherAd()) {
|
|
6155
6156
|
if (this.config.debugAdTiming) {
|
|
6156
|
-
console.log("[CONTINUOUS-FETCH]
|
|
6157
|
+
console.log("[CONTINUOUS-FETCH] ⏹️ Not enough time remaining (".concat(remaining, "ms) to start another ad, ending ad break"));
|
|
6157
6158
|
}
|
|
6158
6159
|
this.handleAdPodComplete();
|
|
6159
6160
|
return [
|
|
@@ -6425,12 +6426,27 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6425
6426
|
10
|
|
6426
6427
|
];
|
|
6427
6428
|
}
|
|
6429
|
+
if (!this.hasTimeToStartAnotherAd()) {
|
|
6430
|
+
if (this.config.debugAdTiming) {
|
|
6431
|
+
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Not enough time remaining during placeholder wait, ending ad break");
|
|
6432
|
+
}
|
|
6433
|
+
return [
|
|
6434
|
+
3,
|
|
6435
|
+
10
|
|
6436
|
+
];
|
|
6437
|
+
}
|
|
6428
6438
|
_state.label = 3;
|
|
6429
6439
|
case 3:
|
|
6430
6440
|
if (!(this.adRequestQueue.length > 0)) return [
|
|
6431
6441
|
3,
|
|
6432
6442
|
9
|
|
6433
6443
|
];
|
|
6444
|
+
if (!this.hasTimeToStartAnotherAd()) {
|
|
6445
|
+
return [
|
|
6446
|
+
3,
|
|
6447
|
+
9
|
|
6448
|
+
];
|
|
6449
|
+
}
|
|
6434
6450
|
nextAdUrl = this.adRequestQueue.shift();
|
|
6435
6451
|
if (!nextAdUrl) {
|
|
6436
6452
|
return [
|
|
@@ -6713,21 +6729,23 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6713
6729
|
if (!this.inAdBreak) return;
|
|
6714
6730
|
this.adStopTimerId = void 0;
|
|
6715
6731
|
var adPlaying = this.adPlayer.isAdPlaying();
|
|
6716
|
-
var pendingAds = this.adPodQueue.length > 0;
|
|
6717
6732
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
6718
6733
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
6719
|
-
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig :
|
|
6734
|
+
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
6720
6735
|
var elapsedSinceStartMs = 0;
|
|
6721
6736
|
if (this.currentAdBreakStartWallClockMs != null) {
|
|
6722
6737
|
elapsedSinceStartMs = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
6723
6738
|
}
|
|
6724
6739
|
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
6725
6740
|
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
6726
|
-
var shouldExtendAdBreak =
|
|
6741
|
+
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
6727
6742
|
if (shouldExtendAdBreak) {
|
|
6728
6743
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
6729
6744
|
return;
|
|
6730
6745
|
}
|
|
6746
|
+
if (this.config.debugAdTiming) {
|
|
6747
|
+
console.log("[StormcloudVideoPlayer] ⏱️ Ad break boundary reached (overrun=".concat(overrunMs, "ms) - hard-stopping ads and resuming stream"));
|
|
6748
|
+
}
|
|
6731
6749
|
if (adPlaying) {
|
|
6732
6750
|
this.adPlayer.stop().catch(function() {});
|
|
6733
6751
|
}
|
|
@@ -7233,11 +7251,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7233
7251
|
this.handleAdPodComplete();
|
|
7234
7252
|
return;
|
|
7235
7253
|
}
|
|
7236
|
-
if (
|
|
7254
|
+
if (this.hasTimeToStartAnotherAd()) {
|
|
7237
7255
|
this.tryNextAvailableAdWithRateLimit();
|
|
7238
7256
|
} else {
|
|
7239
7257
|
if (this.config.debugAdTiming) {
|
|
7240
|
-
console.log("[AD-ERROR] Ad failed and
|
|
7258
|
+
console.log("[AD-ERROR] Ad failed and not enough time remaining for another ad. Failed URLs:", this.failedVastUrls.size);
|
|
7241
7259
|
}
|
|
7242
7260
|
this.handleAdPodComplete();
|
|
7243
7261
|
}
|
|
@@ -7372,6 +7390,22 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7372
7390
|
return Math.max(0, this.expectedAdBreakDurationMs - elapsed);
|
|
7373
7391
|
}
|
|
7374
7392
|
},
|
|
7393
|
+
{
|
|
7394
|
+
key: "getMinRemainingMsToStartAd",
|
|
7395
|
+
value: function getMinRemainingMsToStartAd() {
|
|
7396
|
+
var configured = this.config.minRemainingMsToStartAd;
|
|
7397
|
+
if (typeof configured === "number" && configured >= 0) {
|
|
7398
|
+
return configured;
|
|
7399
|
+
}
|
|
7400
|
+
return this.defaultMinRemainingMsToStartAd;
|
|
7401
|
+
}
|
|
7402
|
+
},
|
|
7403
|
+
{
|
|
7404
|
+
key: "hasTimeToStartAnotherAd",
|
|
7405
|
+
value: function hasTimeToStartAnotherAd() {
|
|
7406
|
+
return this.getRemainingAdMs() > this.getMinRemainingMsToStartAd();
|
|
7407
|
+
}
|
|
7408
|
+
},
|
|
7375
7409
|
{
|
|
7376
7410
|
key: "findBreakForTime",
|
|
7377
7411
|
value: function findBreakForTime(nowMs) {
|