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
package/lib/index.d.cts
CHANGED
|
@@ -122,13 +122,11 @@ declare class StormcloudVideoPlayer {
|
|
|
122
122
|
private bufferedSegmentsCount;
|
|
123
123
|
private shouldAutoplayAfterBuffering;
|
|
124
124
|
private hasInitialBufferCompleted;
|
|
125
|
-
private adRequestTokenCounter;
|
|
126
125
|
private activeAdRequestToken;
|
|
127
126
|
private adRequestWatchdogId;
|
|
128
127
|
private adRequestWatchdogToken;
|
|
129
128
|
private adFailsafeToken;
|
|
130
129
|
private continuousFetchingActive;
|
|
131
|
-
private adRequestQueue;
|
|
132
130
|
private maxPlaceholderDurationMs;
|
|
133
131
|
private isShowingPlaceholder;
|
|
134
132
|
private timeUpdateHandler?;
|
|
@@ -137,7 +135,6 @@ declare class StormcloudVideoPlayer {
|
|
|
137
135
|
private readonly maxTotalAdRequestsPerBreak;
|
|
138
136
|
private pendingAdBreak;
|
|
139
137
|
private prefetchTimerId;
|
|
140
|
-
private prefetchAdPromise;
|
|
141
138
|
private savedMutedStateBeforeScte;
|
|
142
139
|
private consecutiveFailures;
|
|
143
140
|
private readonly maxConsecutiveFailures;
|
|
@@ -145,6 +142,7 @@ declare class StormcloudVideoPlayer {
|
|
|
145
142
|
private readonly minAdRequestIntervalMs;
|
|
146
143
|
private readonly backoffBaseMs;
|
|
147
144
|
private readonly maxBackoffMs;
|
|
145
|
+
private readonly adTransitionGapMs;
|
|
148
146
|
private placeholderContainer;
|
|
149
147
|
constructor(config: StormcloudVideoPlayerConfig);
|
|
150
148
|
private adRequest;
|
package/lib/index.d.ts
CHANGED
|
@@ -122,13 +122,11 @@ declare class StormcloudVideoPlayer {
|
|
|
122
122
|
private bufferedSegmentsCount;
|
|
123
123
|
private shouldAutoplayAfterBuffering;
|
|
124
124
|
private hasInitialBufferCompleted;
|
|
125
|
-
private adRequestTokenCounter;
|
|
126
125
|
private activeAdRequestToken;
|
|
127
126
|
private adRequestWatchdogId;
|
|
128
127
|
private adRequestWatchdogToken;
|
|
129
128
|
private adFailsafeToken;
|
|
130
129
|
private continuousFetchingActive;
|
|
131
|
-
private adRequestQueue;
|
|
132
130
|
private maxPlaceholderDurationMs;
|
|
133
131
|
private isShowingPlaceholder;
|
|
134
132
|
private timeUpdateHandler?;
|
|
@@ -137,7 +135,6 @@ declare class StormcloudVideoPlayer {
|
|
|
137
135
|
private readonly maxTotalAdRequestsPerBreak;
|
|
138
136
|
private pendingAdBreak;
|
|
139
137
|
private prefetchTimerId;
|
|
140
|
-
private prefetchAdPromise;
|
|
141
138
|
private savedMutedStateBeforeScte;
|
|
142
139
|
private consecutiveFailures;
|
|
143
140
|
private readonly maxConsecutiveFailures;
|
|
@@ -145,6 +142,7 @@ declare class StormcloudVideoPlayer {
|
|
|
145
142
|
private readonly minAdRequestIntervalMs;
|
|
146
143
|
private readonly backoffBaseMs;
|
|
147
144
|
private readonly maxBackoffMs;
|
|
145
|
+
private readonly adTransitionGapMs;
|
|
148
146
|
private placeholderContainer;
|
|
149
147
|
constructor(config: StormcloudVideoPlayerConfig);
|
|
150
148
|
private adRequest;
|
package/lib/index.js
CHANGED
|
@@ -2563,18 +2563,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2563
2563
|
this.bufferedSegmentsCount = 0;
|
|
2564
2564
|
this.shouldAutoplayAfterBuffering = false;
|
|
2565
2565
|
this.hasInitialBufferCompleted = false;
|
|
2566
|
-
this.adRequestTokenCounter = 0;
|
|
2567
2566
|
this.activeAdRequestToken = null;
|
|
2568
2567
|
this.adRequestWatchdogToken = null;
|
|
2569
2568
|
this.adFailsafeToken = null;
|
|
2570
2569
|
this.continuousFetchingActive = false;
|
|
2571
|
-
this.adRequestQueue = [];
|
|
2572
2570
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2573
2571
|
this.isShowingPlaceholder = false;
|
|
2574
2572
|
this.totalAdRequestsInBreak = 0;
|
|
2575
2573
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2576
2574
|
this.pendingAdBreak = null;
|
|
2577
|
-
this.prefetchAdPromise = null;
|
|
2578
2575
|
this.savedMutedStateBeforeScte = null;
|
|
2579
2576
|
this.consecutiveFailures = 0;
|
|
2580
2577
|
this.maxConsecutiveFailures = 5;
|
|
@@ -2582,6 +2579,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2582
2579
|
this.minAdRequestIntervalMs = 2500;
|
|
2583
2580
|
this.backoffBaseMs = 1e3;
|
|
2584
2581
|
this.maxBackoffMs = 15e3;
|
|
2582
|
+
this.adTransitionGapMs = 1500;
|
|
2585
2583
|
initializePolyfills();
|
|
2586
2584
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2587
2585
|
this.config = _object_spread({}, browserOverrides, config);
|
|
@@ -3065,10 +3063,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3065
3063
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3066
3064
|
}
|
|
3067
3065
|
}
|
|
3068
|
-
|
|
3069
|
-
var currentVolume = _this.video.volume;
|
|
3070
|
-
var adVolume = currentMuted ? 0 : currentVolume;
|
|
3071
|
-
_this.adLayer.setAdVolume(adVolume);
|
|
3066
|
+
_this.adLayer.setAdVolume(_this.adLayer.getOriginalMutedState() ? 0 : _this.adLayer.getOriginalVolume());
|
|
3072
3067
|
if (_this.isShowingPlaceholder) {
|
|
3073
3068
|
if (_this.config.debugAdTiming) {
|
|
3074
3069
|
console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
|
|
@@ -3102,18 +3097,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3102
3097
|
_this.video.muted = true;
|
|
3103
3098
|
_this.video.volume = 0;
|
|
3104
3099
|
}
|
|
3105
|
-
_this.adLayer.updateOriginalMutedState(_this.video.muted, _this.video.volume);
|
|
3106
3100
|
_this.showPlaceholderLayer();
|
|
3107
3101
|
_this.adLayer.showPlaceholder();
|
|
3108
3102
|
setTimeout(function() {
|
|
3109
3103
|
if (!_this.inAdBreak || bids.length === 0) return;
|
|
3110
3104
|
_this.currentAdIndex++;
|
|
3111
|
-
_this.adLayer.updateOriginalMutedState(_this.video.muted, _this.video.volume);
|
|
3112
3105
|
_this.adLayer.playAd(bids).catch(function(err) {
|
|
3113
3106
|
if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
|
|
3114
3107
|
_this.handleAdFailure();
|
|
3115
3108
|
});
|
|
3116
|
-
},
|
|
3109
|
+
}, _this.adTransitionGapMs);
|
|
3117
3110
|
return;
|
|
3118
3111
|
}
|
|
3119
3112
|
if (remaining <= 500 && _this.expectedAdBreakDurationMs != null) {
|
|
@@ -3536,7 +3529,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3536
3529
|
if (!this.adLayer.isAdPlaying() && this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0) {
|
|
3537
3530
|
var bids = this.pendingNextAdBids;
|
|
3538
3531
|
this.pendingNextAdBids = null;
|
|
3539
|
-
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3540
3532
|
this.currentAdIndex++;
|
|
3541
3533
|
this.adLayer.playAd(bids).catch(function() {
|
|
3542
3534
|
return _this.handleAdFailure();
|
|
@@ -3894,7 +3886,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3894
3886
|
isFetching: false,
|
|
3895
3887
|
fetchStartTime: Date.now()
|
|
3896
3888
|
});
|
|
3897
|
-
|
|
3889
|
+
void this.adRequest().then(function() {}).catch(function() {
|
|
3898
3890
|
if (_this.config.debugAdTiming) {
|
|
3899
3891
|
console.log("[PREFETCH] Prebid auction prefetch failed, will request at playback time");
|
|
3900
3892
|
}
|
|
@@ -3911,7 +3903,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3911
3903
|
clearTimeout(this.prefetchTimerId);
|
|
3912
3904
|
this.prefetchTimerId = void 0;
|
|
3913
3905
|
}
|
|
3914
|
-
this.prefetchAdPromise = null;
|
|
3915
3906
|
this.pendingAdBreak = null;
|
|
3916
3907
|
}
|
|
3917
3908
|
},
|
|
@@ -3931,7 +3922,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3931
3922
|
switch(_state.label){
|
|
3932
3923
|
case 0:
|
|
3933
3924
|
_loop = function() {
|
|
3934
|
-
var delay, elapsed, bids,
|
|
3925
|
+
var delay, elapsed, bids, err;
|
|
3935
3926
|
return _ts_generator(this, function(_state) {
|
|
3936
3927
|
switch(_state.label){
|
|
3937
3928
|
case 0:
|
|
@@ -3939,6 +3930,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3939
3930
|
2,
|
|
3940
3931
|
"break"
|
|
3941
3932
|
];
|
|
3933
|
+
if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) return [
|
|
3934
|
+
2,
|
|
3935
|
+
"break"
|
|
3936
|
+
];
|
|
3942
3937
|
delay = _this.lastAdRequestTime ? _this.minAdRequestIntervalMs + (_this.consecutiveFailures > 0 ? backoffMs() : 0) : 0;
|
|
3943
3938
|
elapsed = Date.now() - _this.lastAdRequestTime;
|
|
3944
3939
|
if (!(elapsed < delay && _this.lastAdRequestTime > 0)) return [
|
|
@@ -3996,7 +3991,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3996
3991
|
7
|
|
3997
3992
|
];
|
|
3998
3993
|
case 5:
|
|
3999
|
-
_this.adLayer.updateOriginalMutedState(_this.video.muted, _this.video.volume);
|
|
4000
3994
|
_this.currentAdIndex++;
|
|
4001
3995
|
if (_this.config.licenseKey) {
|
|
4002
3996
|
sendAdLoadedTracking(_this.config.licenseKey, {
|
|
@@ -4013,8 +4007,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4013
4007
|
if (_this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
4014
4008
|
_this.scheduleAdStopCountdown(_this.getRemainingAdMs());
|
|
4015
4009
|
}
|
|
4016
|
-
|
|
4017
|
-
_this.adLayer.setAdVolume(adVolume);
|
|
4010
|
+
_this.adLayer.setAdVolume(_this.adLayer.getOriginalMutedState() ? 0 : _this.adLayer.getOriginalVolume());
|
|
4018
4011
|
_state.label = 7;
|
|
4019
4012
|
case 7:
|
|
4020
4013
|
return [
|
|
@@ -4134,14 +4127,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4134
4127
|
this.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
4135
4128
|
}
|
|
4136
4129
|
this.clearPendingAdBreak();
|
|
4137
|
-
this.startContinuousFetchLoop();
|
|
4138
4130
|
_state.label = 1;
|
|
4139
4131
|
case 1:
|
|
4140
4132
|
_state.trys.push([
|
|
4141
4133
|
1,
|
|
4142
|
-
|
|
4134
|
+
7,
|
|
4143
4135
|
,
|
|
4144
|
-
|
|
4136
|
+
9
|
|
4145
4137
|
]);
|
|
4146
4138
|
this.lastAdRequestTime = Date.now();
|
|
4147
4139
|
return [
|
|
@@ -4181,27 +4173,40 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4181
4173
|
this.adLayer.setAdVolume(adVolume);
|
|
4182
4174
|
return [
|
|
4183
4175
|
3,
|
|
4184
|
-
|
|
4176
|
+
6
|
|
4185
4177
|
];
|
|
4186
4178
|
case 4:
|
|
4187
4179
|
this.consecutiveFailures++;
|
|
4188
|
-
|
|
4180
|
+
return [
|
|
4181
|
+
4,
|
|
4182
|
+
this.showPlaceholderAndWaitForAds()
|
|
4183
|
+
];
|
|
4189
4184
|
case 5:
|
|
4185
|
+
_state.sent();
|
|
4186
|
+
_state.label = 6;
|
|
4187
|
+
case 6:
|
|
4190
4188
|
return [
|
|
4191
4189
|
3,
|
|
4192
|
-
|
|
4190
|
+
9
|
|
4193
4191
|
];
|
|
4194
|
-
case
|
|
4192
|
+
case 7:
|
|
4195
4193
|
error = _state.sent();
|
|
4196
4194
|
if (this.config.debugAdTiming) {
|
|
4197
4195
|
console.warn("[CONTINUOUS-FETCH] \u26A0\uFE0F First ad request failed:", error);
|
|
4198
4196
|
}
|
|
4199
4197
|
this.consecutiveFailures++;
|
|
4198
|
+
return [
|
|
4199
|
+
4,
|
|
4200
|
+
this.showPlaceholderAndWaitForAds()
|
|
4201
|
+
];
|
|
4202
|
+
case 8:
|
|
4203
|
+
_state.sent();
|
|
4200
4204
|
return [
|
|
4201
4205
|
3,
|
|
4202
|
-
|
|
4206
|
+
9
|
|
4203
4207
|
];
|
|
4204
|
-
case
|
|
4208
|
+
case 9:
|
|
4209
|
+
this.startContinuousFetchLoop();
|
|
4205
4210
|
return [
|
|
4206
4211
|
2
|
|
4207
4212
|
];
|
|
@@ -4277,6 +4282,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4277
4282
|
return _ts_generator(this, function(_state) {
|
|
4278
4283
|
switch(_state.label){
|
|
4279
4284
|
case 0:
|
|
4285
|
+
if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
|
|
4286
|
+
if (this.config.debugAdTiming) {
|
|
4287
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Max ad requests per break (".concat(this.maxTotalAdRequestsPerBreak, ") reached"));
|
|
4288
|
+
}
|
|
4289
|
+
this.handleAdPodComplete();
|
|
4290
|
+
return [
|
|
4291
|
+
2
|
|
4292
|
+
];
|
|
4293
|
+
}
|
|
4280
4294
|
remaining = this.getRemainingAdMs();
|
|
4281
4295
|
if (remaining <= 500 && this.expectedAdBreakDurationMs != null) {
|
|
4282
4296
|
if (this.config.debugAdTiming) {
|
|
@@ -4300,9 +4314,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4300
4314
|
case 1:
|
|
4301
4315
|
_state.trys.push([
|
|
4302
4316
|
1,
|
|
4303
|
-
|
|
4317
|
+
9,
|
|
4304
4318
|
,
|
|
4305
|
-
|
|
4319
|
+
11
|
|
4306
4320
|
]);
|
|
4307
4321
|
this.lastAdRequestTime = Date.now();
|
|
4308
4322
|
return [
|
|
@@ -4319,7 +4333,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4319
4333
|
6
|
|
4320
4334
|
];
|
|
4321
4335
|
this.consecutiveFailures = 0;
|
|
4322
|
-
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
4323
4336
|
this.currentAdIndex++;
|
|
4324
4337
|
this.totalAdRequestsInBreak++;
|
|
4325
4338
|
if (!this.adLayer.isAdPlaying()) return [
|
|
@@ -4347,32 +4360,44 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4347
4360
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
4348
4361
|
this.scheduleAdStopCountdown(this.getRemainingAdMs());
|
|
4349
4362
|
}
|
|
4350
|
-
this.adLayer.setAdVolume(this.
|
|
4363
|
+
this.adLayer.setAdVolume(this.adLayer.getOriginalMutedState() ? 0 : this.adLayer.getOriginalVolume());
|
|
4351
4364
|
_state.label = 5;
|
|
4352
4365
|
case 5:
|
|
4353
4366
|
return [
|
|
4354
4367
|
3,
|
|
4355
|
-
|
|
4368
|
+
8
|
|
4356
4369
|
];
|
|
4357
4370
|
case 6:
|
|
4358
4371
|
this.consecutiveFailures++;
|
|
4359
|
-
|
|
4372
|
+
return [
|
|
4373
|
+
4,
|
|
4374
|
+
this.showPlaceholderAndWaitForAds()
|
|
4375
|
+
];
|
|
4360
4376
|
case 7:
|
|
4377
|
+
_state.sent();
|
|
4378
|
+
_state.label = 8;
|
|
4379
|
+
case 8:
|
|
4361
4380
|
return [
|
|
4362
4381
|
3,
|
|
4363
|
-
|
|
4382
|
+
11
|
|
4364
4383
|
];
|
|
4365
|
-
case
|
|
4384
|
+
case 9:
|
|
4366
4385
|
error = _state.sent();
|
|
4367
4386
|
this.consecutiveFailures++;
|
|
4368
4387
|
if (this.config.debugAdTiming) {
|
|
4369
4388
|
console.warn("[CONTINUOUS-FETCH] tryNextAvailableAd request failed:", error);
|
|
4370
4389
|
}
|
|
4390
|
+
return [
|
|
4391
|
+
4,
|
|
4392
|
+
this.showPlaceholderAndWaitForAds()
|
|
4393
|
+
];
|
|
4394
|
+
case 10:
|
|
4395
|
+
_state.sent();
|
|
4371
4396
|
return [
|
|
4372
4397
|
3,
|
|
4373
|
-
|
|
4398
|
+
11
|
|
4374
4399
|
];
|
|
4375
|
-
case
|
|
4400
|
+
case 11:
|
|
4376
4401
|
return [
|
|
4377
4402
|
2
|
|
4378
4403
|
];
|
|
@@ -4448,7 +4473,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4448
4473
|
this.pendingNextAdBids = null;
|
|
4449
4474
|
this.isShowingPlaceholder = false;
|
|
4450
4475
|
this.adLayer.hidePlaceholder();
|
|
4451
|
-
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
4452
4476
|
this.currentAdIndex++;
|
|
4453
4477
|
_state.label = 3;
|
|
4454
4478
|
case 3:
|
|
@@ -5002,7 +5026,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5002
5026
|
}
|
|
5003
5027
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5004
5028
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
5005
|
-
this.adRequestQueue = [];
|
|
5006
5029
|
this.consecutiveFailures = 0;
|
|
5007
5030
|
}
|
|
5008
5031
|
}
|