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.
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'react';
2
- import { S as StormcloudVideoPlayerConfig } from '../types-CUKMIqHL.cjs';
2
+ import { S as StormcloudVideoPlayerConfig } from '../types-DQM-Tu6a.cjs';
3
3
 
4
4
  interface HlsPlayerProps extends StormcloudVideoPlayerConfig {
5
5
  onMount?: (player: any) => void;
@@ -2724,6 +2724,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2724
2724
  this.maxConsecutiveFailures = 5;
2725
2725
  this.lastAdRequestTime = 0;
2726
2726
  this.minAdRequestIntervalMs = 3e3;
2727
+ this.defaultMinRemainingMsToStartAd = 4e3;
2727
2728
  this.backoffBaseMs = 1e3;
2728
2729
  this.maxBackoffMs = 15e3;
2729
2730
  this.globalConsecutiveNoFills = 0;
@@ -3243,7 +3244,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3243
3244
  } : {});
3244
3245
  }
3245
3246
  if (_this.inAdBreak) {
3246
- if (remaining > 500) {
3247
+ if (_this.hasTimeToStartAnotherAd()) {
3247
3248
  _this.tryNextAvailableAdWithRateLimit();
3248
3249
  } else {
3249
3250
  _this.handleAdPodComplete();
@@ -3316,7 +3317,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3316
3317
  queuedUrls: _to_consumable_array(_this.adRequestQueue)
3317
3318
  } : {});
3318
3319
  }
3319
- if (remaining > 500) {
3320
+ if (_this.hasTimeToStartAnotherAd()) {
3320
3321
  _this.tryNextAvailableAdWithRateLimit();
3321
3322
  } else {
3322
3323
  _this.handleAdPodComplete();
@@ -4016,7 +4017,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4016
4017
  var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
4017
4018
  this.scheduleAdStopCountdown(remainingMs1);
4018
4019
  }
4019
- if (!this.adPlayer.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
4020
+ if (!this.adPlayer.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0 && this.hasTimeToStartAnotherAd()) {
4020
4021
  this.tryNextAvailableAdWithRateLimit();
4021
4022
  }
4022
4023
  return;
@@ -5475,7 +5476,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5475
5476
  key: "preloadPoolLoop",
5476
5477
  value: function preloadPoolLoop(baseVastUrl) {
5477
5478
  return _async_to_generator(function() {
5478
- var epoch, remaining, newUrls, newUrl;
5479
+ var epoch, newUrls, newUrl;
5479
5480
  return _ts_generator(this, function(_state) {
5480
5481
  switch(_state.label){
5481
5482
  case 0:
@@ -5542,14 +5543,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5542
5543
  8
5543
5544
  ];
5544
5545
  }
5545
- if (this.inAdBreak) {
5546
- remaining = this.getRemainingAdMs();
5547
- if (remaining <= 0) {
5548
- return [
5549
- 3,
5550
- 8
5551
- ];
5546
+ if (this.inAdBreak && !this.hasTimeToStartAnotherAd()) {
5547
+ if (this.config.debugAdTiming) {
5548
+ console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
5552
5549
  }
5550
+ return [
5551
+ 3,
5552
+ 8
5553
+ ];
5553
5554
  }
5554
5555
  newUrls = this.generateVastUrlsWithCorrelators(baseVastUrl, 1);
5555
5556
  newUrl = newUrls[0];
@@ -5979,9 +5980,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5979
5980
  switch(_state.label){
5980
5981
  case 0:
5981
5982
  remaining = _this.getRemainingAdMs();
5982
- if (remaining <= 0) {
5983
+ if (remaining <= _this.getMinRemainingMsToStartAd()) {
5983
5984
  if (_this.config.debugAdTiming) {
5984
- console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping URL generation");
5985
+ console.log("[CONTINUOUS-FETCH] ⏹️ Not enough ad break time left (".concat(remaining, "ms), stopping URL generation"));
5985
5986
  }
5986
5987
  return [
5987
5988
  2,
@@ -6201,9 +6202,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6201
6202
  ];
6202
6203
  }
6203
6204
  remaining = this.getRemainingAdMs();
6204
- if (remaining <= 500) {
6205
+ if (!this.hasTimeToStartAnotherAd()) {
6205
6206
  if (this.config.debugAdTiming) {
6206
- console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F No time remaining, ending ad break");
6207
+ console.log("[CONTINUOUS-FETCH] ⏹️ Not enough time remaining (".concat(remaining, "ms) to start another ad, ending ad break"));
6207
6208
  }
6208
6209
  this.handleAdPodComplete();
6209
6210
  return [
@@ -6475,12 +6476,27 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6475
6476
  10
6476
6477
  ];
6477
6478
  }
6479
+ if (!this.hasTimeToStartAnotherAd()) {
6480
+ if (this.config.debugAdTiming) {
6481
+ console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Not enough time remaining during placeholder wait, ending ad break");
6482
+ }
6483
+ return [
6484
+ 3,
6485
+ 10
6486
+ ];
6487
+ }
6478
6488
  _state.label = 3;
6479
6489
  case 3:
6480
6490
  if (!(this.adRequestQueue.length > 0)) return [
6481
6491
  3,
6482
6492
  9
6483
6493
  ];
6494
+ if (!this.hasTimeToStartAnotherAd()) {
6495
+ return [
6496
+ 3,
6497
+ 9
6498
+ ];
6499
+ }
6484
6500
  nextAdUrl = this.adRequestQueue.shift();
6485
6501
  if (!nextAdUrl) {
6486
6502
  return [
@@ -6763,21 +6779,23 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6763
6779
  if (!this.inAdBreak) return;
6764
6780
  this.adStopTimerId = void 0;
6765
6781
  var adPlaying = this.adPlayer.isAdPlaying();
6766
- var pendingAds = this.adPodQueue.length > 0;
6767
6782
  var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
6768
6783
  var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
6769
- var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 6e4;
6784
+ var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
6770
6785
  var elapsedSinceStartMs = 0;
6771
6786
  if (this.currentAdBreakStartWallClockMs != null) {
6772
6787
  elapsedSinceStartMs = Date.now() - this.currentAdBreakStartWallClockMs;
6773
6788
  }
6774
6789
  var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
6775
6790
  var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
6776
- var shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
6791
+ var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
6777
6792
  if (shouldExtendAdBreak) {
6778
6793
  this.scheduleAdStopCountdown(checkIntervalMs);
6779
6794
  return;
6780
6795
  }
6796
+ if (this.config.debugAdTiming) {
6797
+ console.log("[StormcloudVideoPlayer] ⏱️ Ad break boundary reached (overrun=".concat(overrunMs, "ms) - hard-stopping ads and resuming stream"));
6798
+ }
6781
6799
  if (adPlaying) {
6782
6800
  this.adPlayer.stop().catch(function() {});
6783
6801
  }
@@ -7283,11 +7301,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7283
7301
  this.handleAdPodComplete();
7284
7302
  return;
7285
7303
  }
7286
- if (remaining > 500) {
7304
+ if (this.hasTimeToStartAnotherAd()) {
7287
7305
  this.tryNextAvailableAdWithRateLimit();
7288
7306
  } else {
7289
7307
  if (this.config.debugAdTiming) {
7290
- console.log("[AD-ERROR] Ad failed and no time remaining. Failed URLs:", this.failedVastUrls.size);
7308
+ console.log("[AD-ERROR] Ad failed and not enough time remaining for another ad. Failed URLs:", this.failedVastUrls.size);
7291
7309
  }
7292
7310
  this.handleAdPodComplete();
7293
7311
  }
@@ -7422,6 +7440,22 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7422
7440
  return Math.max(0, this.expectedAdBreakDurationMs - elapsed);
7423
7441
  }
7424
7442
  },
7443
+ {
7444
+ key: "getMinRemainingMsToStartAd",
7445
+ value: function getMinRemainingMsToStartAd() {
7446
+ var configured = this.config.minRemainingMsToStartAd;
7447
+ if (typeof configured === "number" && configured >= 0) {
7448
+ return configured;
7449
+ }
7450
+ return this.defaultMinRemainingMsToStartAd;
7451
+ }
7452
+ },
7453
+ {
7454
+ key: "hasTimeToStartAnotherAd",
7455
+ value: function hasTimeToStartAnotherAd() {
7456
+ return this.getRemainingAdMs() > this.getMinRemainingMsToStartAd();
7457
+ }
7458
+ },
7425
7459
  {
7426
7460
  key: "findBreakForTime",
7427
7461
  value: function findBreakForTime(nowMs) {