stormcloud-video-player 0.5.11 → 0.5.13
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 +61 -38
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +1 -3
- package/lib/index.d.ts +1 -3
- package/lib/index.js +61 -38
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +61 -38
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -3
- package/lib/players/HlsPlayer.cjs +61 -38
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +61 -38
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +61 -38
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -28,13 +28,11 @@ declare class StormcloudVideoPlayer {
|
|
|
28
28
|
private bufferedSegmentsCount;
|
|
29
29
|
private shouldAutoplayAfterBuffering;
|
|
30
30
|
private hasInitialBufferCompleted;
|
|
31
|
-
private adRequestTokenCounter;
|
|
32
31
|
private activeAdRequestToken;
|
|
33
32
|
private adRequestWatchdogId;
|
|
34
33
|
private adRequestWatchdogToken;
|
|
35
34
|
private adFailsafeToken;
|
|
36
35
|
private continuousFetchingActive;
|
|
37
|
-
private adRequestQueue;
|
|
38
36
|
private maxPlaceholderDurationMs;
|
|
39
37
|
private isShowingPlaceholder;
|
|
40
38
|
private timeUpdateHandler?;
|
|
@@ -43,7 +41,6 @@ declare class StormcloudVideoPlayer {
|
|
|
43
41
|
private readonly maxTotalAdRequestsPerBreak;
|
|
44
42
|
private pendingAdBreak;
|
|
45
43
|
private prefetchTimerId;
|
|
46
|
-
private prefetchAdPromise;
|
|
47
44
|
private savedMutedStateBeforeScte;
|
|
48
45
|
private consecutiveFailures;
|
|
49
46
|
private readonly maxConsecutiveFailures;
|
|
@@ -51,6 +48,7 @@ declare class StormcloudVideoPlayer {
|
|
|
51
48
|
private readonly minAdRequestIntervalMs;
|
|
52
49
|
private readonly backoffBaseMs;
|
|
53
50
|
private readonly maxBackoffMs;
|
|
51
|
+
private readonly adTransitionGapMs;
|
|
54
52
|
private placeholderContainer;
|
|
55
53
|
constructor(config: StormcloudVideoPlayerConfig);
|
|
56
54
|
private adRequest;
|
|
@@ -2565,18 +2565,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2565
2565
|
this.bufferedSegmentsCount = 0;
|
|
2566
2566
|
this.shouldAutoplayAfterBuffering = false;
|
|
2567
2567
|
this.hasInitialBufferCompleted = false;
|
|
2568
|
-
this.adRequestTokenCounter = 0;
|
|
2569
2568
|
this.activeAdRequestToken = null;
|
|
2570
2569
|
this.adRequestWatchdogToken = null;
|
|
2571
2570
|
this.adFailsafeToken = null;
|
|
2572
2571
|
this.continuousFetchingActive = false;
|
|
2573
|
-
this.adRequestQueue = [];
|
|
2574
2572
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2575
2573
|
this.isShowingPlaceholder = false;
|
|
2576
2574
|
this.totalAdRequestsInBreak = 0;
|
|
2577
2575
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2578
2576
|
this.pendingAdBreak = null;
|
|
2579
|
-
this.prefetchAdPromise = null;
|
|
2580
2577
|
this.savedMutedStateBeforeScte = null;
|
|
2581
2578
|
this.consecutiveFailures = 0;
|
|
2582
2579
|
this.maxConsecutiveFailures = 5;
|
|
@@ -2584,6 +2581,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2584
2581
|
this.minAdRequestIntervalMs = 2500;
|
|
2585
2582
|
this.backoffBaseMs = 1e3;
|
|
2586
2583
|
this.maxBackoffMs = 15e3;
|
|
2584
|
+
this.adTransitionGapMs = 1500;
|
|
2587
2585
|
initializePolyfills();
|
|
2588
2586
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2589
2587
|
this.config = _object_spread({}, browserOverrides, config);
|
|
@@ -3067,10 +3065,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3067
3065
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3068
3066
|
}
|
|
3069
3067
|
}
|
|
3070
|
-
|
|
3071
|
-
var currentVolume = _this.video.volume;
|
|
3072
|
-
var adVolume = currentMuted ? 0 : currentVolume;
|
|
3073
|
-
_this.adLayer.setAdVolume(adVolume);
|
|
3068
|
+
_this.adLayer.setAdVolume(_this.adLayer.getOriginalMutedState() ? 0 : _this.adLayer.getOriginalVolume());
|
|
3074
3069
|
if (_this.isShowingPlaceholder) {
|
|
3075
3070
|
if (_this.config.debugAdTiming) {
|
|
3076
3071
|
console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
|
|
@@ -3104,18 +3099,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3104
3099
|
_this.video.muted = true;
|
|
3105
3100
|
_this.video.volume = 0;
|
|
3106
3101
|
}
|
|
3107
|
-
_this.adLayer.updateOriginalMutedState(_this.video.muted, _this.video.volume);
|
|
3108
3102
|
_this.showPlaceholderLayer();
|
|
3109
3103
|
_this.adLayer.showPlaceholder();
|
|
3110
3104
|
setTimeout(function() {
|
|
3111
3105
|
if (!_this.inAdBreak || bids.length === 0) return;
|
|
3112
3106
|
_this.currentAdIndex++;
|
|
3113
|
-
_this.adLayer.updateOriginalMutedState(_this.video.muted, _this.video.volume);
|
|
3114
3107
|
_this.adLayer.playAd(bids).catch(function(err) {
|
|
3115
3108
|
if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
|
|
3116
3109
|
_this.handleAdFailure();
|
|
3117
3110
|
});
|
|
3118
|
-
},
|
|
3111
|
+
}, _this.adTransitionGapMs);
|
|
3119
3112
|
return;
|
|
3120
3113
|
}
|
|
3121
3114
|
if (remaining <= 500 && _this.expectedAdBreakDurationMs != null) {
|
|
@@ -3538,7 +3531,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3538
3531
|
if (!this.adLayer.isAdPlaying() && this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0) {
|
|
3539
3532
|
var bids = this.pendingNextAdBids;
|
|
3540
3533
|
this.pendingNextAdBids = null;
|
|
3541
|
-
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3542
3534
|
this.currentAdIndex++;
|
|
3543
3535
|
this.adLayer.playAd(bids).catch(function() {
|
|
3544
3536
|
return _this.handleAdFailure();
|
|
@@ -3896,7 +3888,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3896
3888
|
isFetching: false,
|
|
3897
3889
|
fetchStartTime: Date.now()
|
|
3898
3890
|
});
|
|
3899
|
-
|
|
3891
|
+
void this.adRequest().then(function() {}).catch(function() {
|
|
3900
3892
|
if (_this.config.debugAdTiming) {
|
|
3901
3893
|
console.log("[PREFETCH] Prebid auction prefetch failed, will request at playback time");
|
|
3902
3894
|
}
|
|
@@ -3913,7 +3905,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3913
3905
|
clearTimeout(this.prefetchTimerId);
|
|
3914
3906
|
this.prefetchTimerId = void 0;
|
|
3915
3907
|
}
|
|
3916
|
-
this.prefetchAdPromise = null;
|
|
3917
3908
|
this.pendingAdBreak = null;
|
|
3918
3909
|
}
|
|
3919
3910
|
},
|
|
@@ -3933,7 +3924,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3933
3924
|
switch(_state.label){
|
|
3934
3925
|
case 0:
|
|
3935
3926
|
_loop = function() {
|
|
3936
|
-
var delay, elapsed, bids,
|
|
3927
|
+
var delay, elapsed, bids, err;
|
|
3937
3928
|
return _ts_generator(this, function(_state) {
|
|
3938
3929
|
switch(_state.label){
|
|
3939
3930
|
case 0:
|
|
@@ -3941,6 +3932,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3941
3932
|
2,
|
|
3942
3933
|
"break"
|
|
3943
3934
|
];
|
|
3935
|
+
if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) return [
|
|
3936
|
+
2,
|
|
3937
|
+
"break"
|
|
3938
|
+
];
|
|
3944
3939
|
delay = _this.lastAdRequestTime ? _this.minAdRequestIntervalMs + (_this.consecutiveFailures > 0 ? backoffMs() : 0) : 0;
|
|
3945
3940
|
elapsed = Date.now() - _this.lastAdRequestTime;
|
|
3946
3941
|
if (!(elapsed < delay && _this.lastAdRequestTime > 0)) return [
|
|
@@ -3998,7 +3993,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3998
3993
|
7
|
|
3999
3994
|
];
|
|
4000
3995
|
case 5:
|
|
4001
|
-
_this.adLayer.updateOriginalMutedState(_this.video.muted, _this.video.volume);
|
|
4002
3996
|
_this.currentAdIndex++;
|
|
4003
3997
|
if (_this.config.licenseKey) {
|
|
4004
3998
|
sendAdLoadedTracking(_this.config.licenseKey, {
|
|
@@ -4015,8 +4009,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4015
4009
|
if (_this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
4016
4010
|
_this.scheduleAdStopCountdown(_this.getRemainingAdMs());
|
|
4017
4011
|
}
|
|
4018
|
-
|
|
4019
|
-
_this.adLayer.setAdVolume(adVolume);
|
|
4012
|
+
_this.adLayer.setAdVolume(_this.adLayer.getOriginalMutedState() ? 0 : _this.adLayer.getOriginalVolume());
|
|
4020
4013
|
_state.label = 7;
|
|
4021
4014
|
case 7:
|
|
4022
4015
|
return [
|
|
@@ -4136,14 +4129,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4136
4129
|
this.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
4137
4130
|
}
|
|
4138
4131
|
this.clearPendingAdBreak();
|
|
4139
|
-
this.startContinuousFetchLoop();
|
|
4140
4132
|
_state.label = 1;
|
|
4141
4133
|
case 1:
|
|
4142
4134
|
_state.trys.push([
|
|
4143
4135
|
1,
|
|
4144
|
-
|
|
4136
|
+
7,
|
|
4145
4137
|
,
|
|
4146
|
-
|
|
4138
|
+
9
|
|
4147
4139
|
]);
|
|
4148
4140
|
this.lastAdRequestTime = Date.now();
|
|
4149
4141
|
return [
|
|
@@ -4183,27 +4175,40 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4183
4175
|
this.adLayer.setAdVolume(adVolume);
|
|
4184
4176
|
return [
|
|
4185
4177
|
3,
|
|
4186
|
-
|
|
4178
|
+
6
|
|
4187
4179
|
];
|
|
4188
4180
|
case 4:
|
|
4189
4181
|
this.consecutiveFailures++;
|
|
4190
|
-
|
|
4182
|
+
return [
|
|
4183
|
+
4,
|
|
4184
|
+
this.showPlaceholderAndWaitForAds()
|
|
4185
|
+
];
|
|
4191
4186
|
case 5:
|
|
4187
|
+
_state.sent();
|
|
4188
|
+
_state.label = 6;
|
|
4189
|
+
case 6:
|
|
4192
4190
|
return [
|
|
4193
4191
|
3,
|
|
4194
|
-
|
|
4192
|
+
9
|
|
4195
4193
|
];
|
|
4196
|
-
case
|
|
4194
|
+
case 7:
|
|
4197
4195
|
error = _state.sent();
|
|
4198
4196
|
if (this.config.debugAdTiming) {
|
|
4199
4197
|
console.warn("[CONTINUOUS-FETCH] \u26A0\uFE0F First ad request failed:", error);
|
|
4200
4198
|
}
|
|
4201
4199
|
this.consecutiveFailures++;
|
|
4200
|
+
return [
|
|
4201
|
+
4,
|
|
4202
|
+
this.showPlaceholderAndWaitForAds()
|
|
4203
|
+
];
|
|
4204
|
+
case 8:
|
|
4205
|
+
_state.sent();
|
|
4202
4206
|
return [
|
|
4203
4207
|
3,
|
|
4204
|
-
|
|
4208
|
+
9
|
|
4205
4209
|
];
|
|
4206
|
-
case
|
|
4210
|
+
case 9:
|
|
4211
|
+
this.startContinuousFetchLoop();
|
|
4207
4212
|
return [
|
|
4208
4213
|
2
|
|
4209
4214
|
];
|
|
@@ -4279,6 +4284,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4279
4284
|
return _ts_generator(this, function(_state) {
|
|
4280
4285
|
switch(_state.label){
|
|
4281
4286
|
case 0:
|
|
4287
|
+
if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
|
|
4288
|
+
if (this.config.debugAdTiming) {
|
|
4289
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Max ad requests per break (".concat(this.maxTotalAdRequestsPerBreak, ") reached"));
|
|
4290
|
+
}
|
|
4291
|
+
this.handleAdPodComplete();
|
|
4292
|
+
return [
|
|
4293
|
+
2
|
|
4294
|
+
];
|
|
4295
|
+
}
|
|
4282
4296
|
remaining = this.getRemainingAdMs();
|
|
4283
4297
|
if (remaining <= 500 && this.expectedAdBreakDurationMs != null) {
|
|
4284
4298
|
if (this.config.debugAdTiming) {
|
|
@@ -4302,9 +4316,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4302
4316
|
case 1:
|
|
4303
4317
|
_state.trys.push([
|
|
4304
4318
|
1,
|
|
4305
|
-
|
|
4319
|
+
9,
|
|
4306
4320
|
,
|
|
4307
|
-
|
|
4321
|
+
11
|
|
4308
4322
|
]);
|
|
4309
4323
|
this.lastAdRequestTime = Date.now();
|
|
4310
4324
|
return [
|
|
@@ -4321,7 +4335,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4321
4335
|
6
|
|
4322
4336
|
];
|
|
4323
4337
|
this.consecutiveFailures = 0;
|
|
4324
|
-
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
4325
4338
|
this.currentAdIndex++;
|
|
4326
4339
|
this.totalAdRequestsInBreak++;
|
|
4327
4340
|
if (!this.adLayer.isAdPlaying()) return [
|
|
@@ -4349,32 +4362,44 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4349
4362
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
4350
4363
|
this.scheduleAdStopCountdown(this.getRemainingAdMs());
|
|
4351
4364
|
}
|
|
4352
|
-
this.adLayer.setAdVolume(this.
|
|
4365
|
+
this.adLayer.setAdVolume(this.adLayer.getOriginalMutedState() ? 0 : this.adLayer.getOriginalVolume());
|
|
4353
4366
|
_state.label = 5;
|
|
4354
4367
|
case 5:
|
|
4355
4368
|
return [
|
|
4356
4369
|
3,
|
|
4357
|
-
|
|
4370
|
+
8
|
|
4358
4371
|
];
|
|
4359
4372
|
case 6:
|
|
4360
4373
|
this.consecutiveFailures++;
|
|
4361
|
-
|
|
4374
|
+
return [
|
|
4375
|
+
4,
|
|
4376
|
+
this.showPlaceholderAndWaitForAds()
|
|
4377
|
+
];
|
|
4362
4378
|
case 7:
|
|
4379
|
+
_state.sent();
|
|
4380
|
+
_state.label = 8;
|
|
4381
|
+
case 8:
|
|
4363
4382
|
return [
|
|
4364
4383
|
3,
|
|
4365
|
-
|
|
4384
|
+
11
|
|
4366
4385
|
];
|
|
4367
|
-
case
|
|
4386
|
+
case 9:
|
|
4368
4387
|
error = _state.sent();
|
|
4369
4388
|
this.consecutiveFailures++;
|
|
4370
4389
|
if (this.config.debugAdTiming) {
|
|
4371
4390
|
console.warn("[CONTINUOUS-FETCH] tryNextAvailableAd request failed:", error);
|
|
4372
4391
|
}
|
|
4392
|
+
return [
|
|
4393
|
+
4,
|
|
4394
|
+
this.showPlaceholderAndWaitForAds()
|
|
4395
|
+
];
|
|
4396
|
+
case 10:
|
|
4397
|
+
_state.sent();
|
|
4373
4398
|
return [
|
|
4374
4399
|
3,
|
|
4375
|
-
|
|
4400
|
+
11
|
|
4376
4401
|
];
|
|
4377
|
-
case
|
|
4402
|
+
case 11:
|
|
4378
4403
|
return [
|
|
4379
4404
|
2
|
|
4380
4405
|
];
|
|
@@ -4450,7 +4475,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4450
4475
|
this.pendingNextAdBids = null;
|
|
4451
4476
|
this.isShowingPlaceholder = false;
|
|
4452
4477
|
this.adLayer.hidePlaceholder();
|
|
4453
|
-
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
4454
4478
|
this.currentAdIndex++;
|
|
4455
4479
|
_state.label = 3;
|
|
4456
4480
|
case 3:
|
|
@@ -5004,7 +5028,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5004
5028
|
}
|
|
5005
5029
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5006
5030
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
5007
|
-
this.adRequestQueue = [];
|
|
5008
5031
|
this.consecutiveFailures = 0;
|
|
5009
5032
|
}
|
|
5010
5033
|
}
|