stormcloud-video-player 0.5.12 → 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/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);
@@ -3108,7 +3106,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3108
3106
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
3109
3107
  _this.handleAdFailure();
3110
3108
  });
3111
- }, 500);
3109
+ }, _this.adTransitionGapMs);
3112
3110
  return;
3113
3111
  }
3114
3112
  if (remaining <= 500 && _this.expectedAdBreakDurationMs != null) {
@@ -3888,7 +3886,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3888
3886
  isFetching: false,
3889
3887
  fetchStartTime: Date.now()
3890
3888
  });
3891
- this.prefetchAdPromise = this.adRequest().then(function() {}).catch(function() {
3889
+ void this.adRequest().then(function() {}).catch(function() {
3892
3890
  if (_this.config.debugAdTiming) {
3893
3891
  console.log("[PREFETCH] Prebid auction prefetch failed, will request at playback time");
3894
3892
  }
@@ -3905,7 +3903,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3905
3903
  clearTimeout(this.prefetchTimerId);
3906
3904
  this.prefetchTimerId = void 0;
3907
3905
  }
3908
- this.prefetchAdPromise = null;
3909
3906
  this.pendingAdBreak = null;
3910
3907
  }
3911
3908
  },
@@ -3933,6 +3930,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3933
3930
  2,
3934
3931
  "break"
3935
3932
  ];
3933
+ if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) return [
3934
+ 2,
3935
+ "break"
3936
+ ];
3936
3937
  delay = _this.lastAdRequestTime ? _this.minAdRequestIntervalMs + (_this.consecutiveFailures > 0 ? backoffMs() : 0) : 0;
3937
3938
  elapsed = Date.now() - _this.lastAdRequestTime;
3938
3939
  if (!(elapsed < delay && _this.lastAdRequestTime > 0)) return [
@@ -4126,14 +4127,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4126
4127
  this.expectedAdBreakDurationMs = adBreakDurationMs;
4127
4128
  }
4128
4129
  this.clearPendingAdBreak();
4129
- this.startContinuousFetchLoop();
4130
4130
  _state.label = 1;
4131
4131
  case 1:
4132
4132
  _state.trys.push([
4133
4133
  1,
4134
- 6,
4134
+ 7,
4135
4135
  ,
4136
- 7
4136
+ 9
4137
4137
  ]);
4138
4138
  this.lastAdRequestTime = Date.now();
4139
4139
  return [
@@ -4173,27 +4173,40 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4173
4173
  this.adLayer.setAdVolume(adVolume);
4174
4174
  return [
4175
4175
  3,
4176
- 5
4176
+ 6
4177
4177
  ];
4178
4178
  case 4:
4179
4179
  this.consecutiveFailures++;
4180
- _state.label = 5;
4180
+ return [
4181
+ 4,
4182
+ this.showPlaceholderAndWaitForAds()
4183
+ ];
4181
4184
  case 5:
4185
+ _state.sent();
4186
+ _state.label = 6;
4187
+ case 6:
4182
4188
  return [
4183
4189
  3,
4184
- 7
4190
+ 9
4185
4191
  ];
4186
- case 6:
4192
+ case 7:
4187
4193
  error = _state.sent();
4188
4194
  if (this.config.debugAdTiming) {
4189
4195
  console.warn("[CONTINUOUS-FETCH] \u26A0\uFE0F First ad request failed:", error);
4190
4196
  }
4191
4197
  this.consecutiveFailures++;
4198
+ return [
4199
+ 4,
4200
+ this.showPlaceholderAndWaitForAds()
4201
+ ];
4202
+ case 8:
4203
+ _state.sent();
4192
4204
  return [
4193
4205
  3,
4194
- 7
4206
+ 9
4195
4207
  ];
4196
- case 7:
4208
+ case 9:
4209
+ this.startContinuousFetchLoop();
4197
4210
  return [
4198
4211
  2
4199
4212
  ];
@@ -4269,6 +4282,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4269
4282
  return _ts_generator(this, function(_state) {
4270
4283
  switch(_state.label){
4271
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
+ }
4272
4294
  remaining = this.getRemainingAdMs();
4273
4295
  if (remaining <= 500 && this.expectedAdBreakDurationMs != null) {
4274
4296
  if (this.config.debugAdTiming) {
@@ -4292,9 +4314,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4292
4314
  case 1:
4293
4315
  _state.trys.push([
4294
4316
  1,
4295
- 8,
4317
+ 9,
4296
4318
  ,
4297
- 9
4319
+ 11
4298
4320
  ]);
4299
4321
  this.lastAdRequestTime = Date.now();
4300
4322
  return [
@@ -4343,27 +4365,39 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4343
4365
  case 5:
4344
4366
  return [
4345
4367
  3,
4346
- 7
4368
+ 8
4347
4369
  ];
4348
4370
  case 6:
4349
4371
  this.consecutiveFailures++;
4350
- _state.label = 7;
4372
+ return [
4373
+ 4,
4374
+ this.showPlaceholderAndWaitForAds()
4375
+ ];
4351
4376
  case 7:
4377
+ _state.sent();
4378
+ _state.label = 8;
4379
+ case 8:
4352
4380
  return [
4353
4381
  3,
4354
- 9
4382
+ 11
4355
4383
  ];
4356
- case 8:
4384
+ case 9:
4357
4385
  error = _state.sent();
4358
4386
  this.consecutiveFailures++;
4359
4387
  if (this.config.debugAdTiming) {
4360
4388
  console.warn("[CONTINUOUS-FETCH] tryNextAvailableAd request failed:", error);
4361
4389
  }
4390
+ return [
4391
+ 4,
4392
+ this.showPlaceholderAndWaitForAds()
4393
+ ];
4394
+ case 10:
4395
+ _state.sent();
4362
4396
  return [
4363
4397
  3,
4364
- 9
4398
+ 11
4365
4399
  ];
4366
- case 9:
4400
+ case 11:
4367
4401
  return [
4368
4402
  2
4369
4403
  ];
@@ -4439,7 +4473,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4439
4473
  this.pendingNextAdBids = null;
4440
4474
  this.isShowingPlaceholder = false;
4441
4475
  this.adLayer.hidePlaceholder();
4442
- this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
4443
4476
  this.currentAdIndex++;
4444
4477
  _state.label = 3;
4445
4478
  case 3:
@@ -4993,7 +5026,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4993
5026
  }
4994
5027
  (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
4995
5028
  (_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
4996
- this.adRequestQueue = [];
4997
5029
  this.consecutiveFailures = 0;
4998
5030
  }
4999
5031
  }