stormcloud-video-player 0.8.8 → 0.8.9

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.
@@ -2650,6 +2650,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2650
2650
  this.preloadPoolActive = false;
2651
2651
  this.preloadPoolLoopRunning = false;
2652
2652
  this.adDetectSentForCurrentBreak = false;
2653
+ this.adBreakEpoch = 0;
2653
2654
  this.palPlaybackStarted = false;
2654
2655
  this.streamCorrelator = generateCorrelator();
2655
2656
  this.consentSignals = {};
@@ -5197,7 +5198,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5197
5198
  key: "preloadAdIntoPool",
5198
5199
  value: function preloadAdIntoPool(vastUrl) {
5199
5200
  return _async_to_generator(function() {
5200
- var _this, loadPromise;
5201
+ var _this, epoch, loadPromise;
5201
5202
  return _ts_generator(this, function(_state) {
5202
5203
  _this = this;
5203
5204
  if (this.isGamInCooldown()) {
@@ -5223,6 +5224,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5223
5224
  if (this.config.debugAdTiming) {
5224
5225
  console.log("[PRELOAD-POOL] \uD83D\uDCE5 Preloading ad into pool: ".concat(vastUrl));
5225
5226
  }
5227
+ epoch = this.adBreakEpoch;
5226
5228
  loadPromise = function() {
5227
5229
  return _async_to_generator(function() {
5228
5230
  var _this, hasAdError, adErrorPayload, errorListenerCleanup, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, lateErrorListener, error;
@@ -5300,6 +5302,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5300
5302
  2
5301
5303
  ];
5302
5304
  }
5305
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch) {
5306
+ if (this.config.debugAdTiming) {
5307
+ console.log("[PRELOAD-POOL] \uD83D\uDEAB Discarding preloaded ad - break ended during fetch");
5308
+ }
5309
+ if (errorListenerCleanup) {
5310
+ errorListenerCleanup();
5311
+ }
5312
+ try {
5313
+ preloadAd.destroy();
5314
+ } catch (unused) {}
5315
+ return [
5316
+ 2
5317
+ ];
5318
+ }
5303
5319
  poolEntry = {
5304
5320
  vastUrl: vastUrl,
5305
5321
  adController: preloadAd,
@@ -5371,7 +5387,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5371
5387
  key: "preloadPoolLoop",
5372
5388
  value: function preloadPoolLoop(baseVastUrl) {
5373
5389
  return _async_to_generator(function() {
5374
- var remaining, newUrls, newUrl;
5390
+ var epoch, remaining, newUrls, newUrl;
5375
5391
  return _ts_generator(this, function(_state) {
5376
5392
  switch(_state.label){
5377
5393
  case 0:
@@ -5381,12 +5397,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5381
5397
  ];
5382
5398
  }
5383
5399
  this.preloadPoolLoopRunning = true;
5400
+ epoch = this.adBreakEpoch;
5384
5401
  if (this.config.debugAdTiming) {
5385
5402
  console.log("[PRELOAD-POOL] \uD83D\uDD04 Starting continuous preload loop");
5386
5403
  }
5387
5404
  _state.label = 1;
5388
5405
  case 1:
5389
- if (!this.preloadPoolActive) return [
5406
+ if (!(this.preloadPoolActive && epoch === this.adBreakEpoch)) return [
5390
5407
  3,
5391
5408
  10
5392
5409
  ];
@@ -5431,7 +5448,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5431
5448
  3,
5432
5449
  8
5433
5450
  ];
5434
- if (!this.preloadPoolActive || this.isGamInCooldown()) {
5451
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch || this.isGamInCooldown()) {
5435
5452
  return [
5436
5453
  3,
5437
5454
  8
@@ -5864,7 +5881,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5864
5881
  key: "continuousFetchLoop",
5865
5882
  value: function continuousFetchLoop(baseVastUrl) {
5866
5883
  return _async_to_generator(function() {
5867
- var _this, _loop, _ret;
5884
+ var _this, _loop, epoch, _ret;
5868
5885
  return _ts_generator(this, function(_state) {
5869
5886
  switch(_state.label){
5870
5887
  case 0:
@@ -5974,9 +5991,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5974
5991
  }
5975
5992
  });
5976
5993
  };
5994
+ epoch = this.adBreakEpoch;
5977
5995
  _state.label = 1;
5978
5996
  case 1:
5979
- if (!(this.continuousFetchingActive && this.inAdBreak)) return [
5997
+ if (!(this.continuousFetchingActive && this.inAdBreak && epoch === this.adBreakEpoch)) return [
5980
5998
  3,
5981
5999
  3
5982
6000
  ];
@@ -6025,10 +6043,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6025
6043
  key: "tryNextAvailableAdWithRateLimit",
6026
6044
  value: function tryNextAvailableAdWithRateLimit() {
6027
6045
  return _async_to_generator(function() {
6028
- var backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6046
+ var epoch, backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6029
6047
  return _ts_generator(this, function(_state) {
6030
6048
  switch(_state.label){
6031
6049
  case 0:
6050
+ if (!this.inAdBreak) {
6051
+ return [
6052
+ 2
6053
+ ];
6054
+ }
6055
+ epoch = this.adBreakEpoch;
6032
6056
  if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
6033
6057
  if (this.config.debugAdTiming) {
6034
6058
  console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive failures (".concat(this.consecutiveFailures, "), ending ad break gracefully"));
@@ -6060,6 +6084,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6060
6084
  _state.sent();
6061
6085
  _state.label = 2;
6062
6086
  case 2:
6087
+ if (!this.inAdBreak || epoch !== this.adBreakEpoch) {
6088
+ return [
6089
+ 2
6090
+ ];
6091
+ }
6063
6092
  return [
6064
6093
  2,
6065
6094
  this.tryNextAvailableAd(0)
@@ -6078,6 +6107,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6078
6107
  return _ts_generator(this, function(_state) {
6079
6108
  switch(_state.label){
6080
6109
  case 0:
6110
+ if (!this.inAdBreak) {
6111
+ return [
6112
+ 2
6113
+ ];
6114
+ }
6081
6115
  remaining = this.getRemainingAdMs();
6082
6116
  if (remaining <= 500) {
6083
6117
  if (this.config.debugAdTiming) {
@@ -7090,6 +7124,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7090
7124
  if (this.config.debugAdTiming) {
7091
7125
  console.log("[StormcloudVideoPlayer] \uD83C\uDFC1 Ad pod complete - cleaning up");
7092
7126
  }
7127
+ this.adBreakEpoch++;
7093
7128
  this.clearAdRequestWatchdog();
7094
7129
  this.clearAdFailsafeTimer();
7095
7130
  this.activeAdRequestToken = null;