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.cjs CHANGED
@@ -2720,18 +2720,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2720
2720
  this.bufferedSegmentsCount = 0;
2721
2721
  this.shouldAutoplayAfterBuffering = false;
2722
2722
  this.hasInitialBufferCompleted = false;
2723
- this.adRequestTokenCounter = 0;
2724
2723
  this.activeAdRequestToken = null;
2725
2724
  this.adRequestWatchdogToken = null;
2726
2725
  this.adFailsafeToken = null;
2727
2726
  this.continuousFetchingActive = false;
2728
- this.adRequestQueue = [];
2729
2727
  this.maxPlaceholderDurationMs = 5e3;
2730
2728
  this.isShowingPlaceholder = false;
2731
2729
  this.totalAdRequestsInBreak = 0;
2732
2730
  this.maxTotalAdRequestsPerBreak = 20;
2733
2731
  this.pendingAdBreak = null;
2734
- this.prefetchAdPromise = null;
2735
2732
  this.savedMutedStateBeforeScte = null;
2736
2733
  this.consecutiveFailures = 0;
2737
2734
  this.maxConsecutiveFailures = 5;
@@ -2739,6 +2736,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2739
2736
  this.minAdRequestIntervalMs = 2500;
2740
2737
  this.backoffBaseMs = 1e3;
2741
2738
  this.maxBackoffMs = 15e3;
2739
+ this.adTransitionGapMs = 1500;
2742
2740
  initializePolyfills();
2743
2741
  var browserOverrides = getBrowserConfigOverrides();
2744
2742
  this.config = _object_spread({}, browserOverrides, config);
@@ -3265,7 +3263,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3265
3263
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
3266
3264
  _this.handleAdFailure();
3267
3265
  });
3268
- }, 500);
3266
+ }, _this.adTransitionGapMs);
3269
3267
  return;
3270
3268
  }
3271
3269
  if (remaining <= 500 && _this.expectedAdBreakDurationMs != null) {
@@ -4045,7 +4043,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4045
4043
  isFetching: false,
4046
4044
  fetchStartTime: Date.now()
4047
4045
  });
4048
- this.prefetchAdPromise = this.adRequest().then(function() {}).catch(function() {
4046
+ void this.adRequest().then(function() {}).catch(function() {
4049
4047
  if (_this.config.debugAdTiming) {
4050
4048
  console.log("[PREFETCH] Prebid auction prefetch failed, will request at playback time");
4051
4049
  }
@@ -4062,7 +4060,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4062
4060
  clearTimeout(this.prefetchTimerId);
4063
4061
  this.prefetchTimerId = void 0;
4064
4062
  }
4065
- this.prefetchAdPromise = null;
4066
4063
  this.pendingAdBreak = null;
4067
4064
  }
4068
4065
  },
@@ -4090,6 +4087,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4090
4087
  2,
4091
4088
  "break"
4092
4089
  ];
4090
+ if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) return [
4091
+ 2,
4092
+ "break"
4093
+ ];
4093
4094
  delay = _this.lastAdRequestTime ? _this.minAdRequestIntervalMs + (_this.consecutiveFailures > 0 ? backoffMs() : 0) : 0;
4094
4095
  elapsed = Date.now() - _this.lastAdRequestTime;
4095
4096
  if (!(elapsed < delay && _this.lastAdRequestTime > 0)) return [
@@ -4283,14 +4284,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4283
4284
  this.expectedAdBreakDurationMs = adBreakDurationMs;
4284
4285
  }
4285
4286
  this.clearPendingAdBreak();
4286
- this.startContinuousFetchLoop();
4287
4287
  _state.label = 1;
4288
4288
  case 1:
4289
4289
  _state.trys.push([
4290
4290
  1,
4291
- 6,
4291
+ 7,
4292
4292
  ,
4293
- 7
4293
+ 9
4294
4294
  ]);
4295
4295
  this.lastAdRequestTime = Date.now();
4296
4296
  return [
@@ -4330,27 +4330,40 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4330
4330
  this.adLayer.setAdVolume(adVolume);
4331
4331
  return [
4332
4332
  3,
4333
- 5
4333
+ 6
4334
4334
  ];
4335
4335
  case 4:
4336
4336
  this.consecutiveFailures++;
4337
- _state.label = 5;
4337
+ return [
4338
+ 4,
4339
+ this.showPlaceholderAndWaitForAds()
4340
+ ];
4338
4341
  case 5:
4342
+ _state.sent();
4343
+ _state.label = 6;
4344
+ case 6:
4339
4345
  return [
4340
4346
  3,
4341
- 7
4347
+ 9
4342
4348
  ];
4343
- case 6:
4349
+ case 7:
4344
4350
  error = _state.sent();
4345
4351
  if (this.config.debugAdTiming) {
4346
4352
  console.warn("[CONTINUOUS-FETCH] \u26A0\uFE0F First ad request failed:", error);
4347
4353
  }
4348
4354
  this.consecutiveFailures++;
4355
+ return [
4356
+ 4,
4357
+ this.showPlaceholderAndWaitForAds()
4358
+ ];
4359
+ case 8:
4360
+ _state.sent();
4349
4361
  return [
4350
4362
  3,
4351
- 7
4363
+ 9
4352
4364
  ];
4353
- case 7:
4365
+ case 9:
4366
+ this.startContinuousFetchLoop();
4354
4367
  return [
4355
4368
  2
4356
4369
  ];
@@ -4426,6 +4439,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4426
4439
  return _ts_generator(this, function(_state) {
4427
4440
  switch(_state.label){
4428
4441
  case 0:
4442
+ if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
4443
+ if (this.config.debugAdTiming) {
4444
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Max ad requests per break (".concat(this.maxTotalAdRequestsPerBreak, ") reached"));
4445
+ }
4446
+ this.handleAdPodComplete();
4447
+ return [
4448
+ 2
4449
+ ];
4450
+ }
4429
4451
  remaining = this.getRemainingAdMs();
4430
4452
  if (remaining <= 500 && this.expectedAdBreakDurationMs != null) {
4431
4453
  if (this.config.debugAdTiming) {
@@ -4449,9 +4471,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4449
4471
  case 1:
4450
4472
  _state.trys.push([
4451
4473
  1,
4452
- 8,
4474
+ 9,
4453
4475
  ,
4454
- 9
4476
+ 11
4455
4477
  ]);
4456
4478
  this.lastAdRequestTime = Date.now();
4457
4479
  return [
@@ -4500,27 +4522,39 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4500
4522
  case 5:
4501
4523
  return [
4502
4524
  3,
4503
- 7
4525
+ 8
4504
4526
  ];
4505
4527
  case 6:
4506
4528
  this.consecutiveFailures++;
4507
- _state.label = 7;
4529
+ return [
4530
+ 4,
4531
+ this.showPlaceholderAndWaitForAds()
4532
+ ];
4508
4533
  case 7:
4534
+ _state.sent();
4535
+ _state.label = 8;
4536
+ case 8:
4509
4537
  return [
4510
4538
  3,
4511
- 9
4539
+ 11
4512
4540
  ];
4513
- case 8:
4541
+ case 9:
4514
4542
  error = _state.sent();
4515
4543
  this.consecutiveFailures++;
4516
4544
  if (this.config.debugAdTiming) {
4517
4545
  console.warn("[CONTINUOUS-FETCH] tryNextAvailableAd request failed:", error);
4518
4546
  }
4547
+ return [
4548
+ 4,
4549
+ this.showPlaceholderAndWaitForAds()
4550
+ ];
4551
+ case 10:
4552
+ _state.sent();
4519
4553
  return [
4520
4554
  3,
4521
- 9
4555
+ 11
4522
4556
  ];
4523
- case 9:
4557
+ case 11:
4524
4558
  return [
4525
4559
  2
4526
4560
  ];
@@ -4596,7 +4630,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4596
4630
  this.pendingNextAdBids = null;
4597
4631
  this.isShowingPlaceholder = false;
4598
4632
  this.adLayer.hidePlaceholder();
4599
- this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
4600
4633
  this.currentAdIndex++;
4601
4634
  _state.label = 3;
4602
4635
  case 3:
@@ -5150,7 +5183,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5150
5183
  }
5151
5184
  (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
5152
5185
  (_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
5153
- this.adRequestQueue = [];
5154
5186
  this.consecutiveFailures = 0;
5155
5187
  }
5156
5188
  }