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.
@@ -2688,6 +2688,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2688
2688
  this.preloadPoolActive = false;
2689
2689
  this.preloadPoolLoopRunning = false;
2690
2690
  this.adDetectSentForCurrentBreak = false;
2691
+ this.adBreakEpoch = 0;
2691
2692
  this.palPlaybackStarted = false;
2692
2693
  this.streamCorrelator = generateCorrelator();
2693
2694
  this.consentSignals = {};
@@ -5235,7 +5236,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5235
5236
  key: "preloadAdIntoPool",
5236
5237
  value: function preloadAdIntoPool(vastUrl) {
5237
5238
  return _async_to_generator(function() {
5238
- var _this, loadPromise;
5239
+ var _this, epoch, loadPromise;
5239
5240
  return _ts_generator(this, function(_state) {
5240
5241
  _this = this;
5241
5242
  if (this.isGamInCooldown()) {
@@ -5261,6 +5262,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5261
5262
  if (this.config.debugAdTiming) {
5262
5263
  console.log("[PRELOAD-POOL] \uD83D\uDCE5 Preloading ad into pool: ".concat(vastUrl));
5263
5264
  }
5265
+ epoch = this.adBreakEpoch;
5264
5266
  loadPromise = function() {
5265
5267
  return _async_to_generator(function() {
5266
5268
  var _this, hasAdError, adErrorPayload, errorListenerCleanup, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, lateErrorListener, error;
@@ -5338,6 +5340,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5338
5340
  2
5339
5341
  ];
5340
5342
  }
5343
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch) {
5344
+ if (this.config.debugAdTiming) {
5345
+ console.log("[PRELOAD-POOL] \uD83D\uDEAB Discarding preloaded ad - break ended during fetch");
5346
+ }
5347
+ if (errorListenerCleanup) {
5348
+ errorListenerCleanup();
5349
+ }
5350
+ try {
5351
+ preloadAd.destroy();
5352
+ } catch (unused) {}
5353
+ return [
5354
+ 2
5355
+ ];
5356
+ }
5341
5357
  poolEntry = {
5342
5358
  vastUrl: vastUrl,
5343
5359
  adController: preloadAd,
@@ -5409,7 +5425,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5409
5425
  key: "preloadPoolLoop",
5410
5426
  value: function preloadPoolLoop(baseVastUrl) {
5411
5427
  return _async_to_generator(function() {
5412
- var remaining, newUrls, newUrl;
5428
+ var epoch, remaining, newUrls, newUrl;
5413
5429
  return _ts_generator(this, function(_state) {
5414
5430
  switch(_state.label){
5415
5431
  case 0:
@@ -5419,12 +5435,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5419
5435
  ];
5420
5436
  }
5421
5437
  this.preloadPoolLoopRunning = true;
5438
+ epoch = this.adBreakEpoch;
5422
5439
  if (this.config.debugAdTiming) {
5423
5440
  console.log("[PRELOAD-POOL] \uD83D\uDD04 Starting continuous preload loop");
5424
5441
  }
5425
5442
  _state.label = 1;
5426
5443
  case 1:
5427
- if (!this.preloadPoolActive) return [
5444
+ if (!(this.preloadPoolActive && epoch === this.adBreakEpoch)) return [
5428
5445
  3,
5429
5446
  10
5430
5447
  ];
@@ -5469,7 +5486,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5469
5486
  3,
5470
5487
  8
5471
5488
  ];
5472
- if (!this.preloadPoolActive || this.isGamInCooldown()) {
5489
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch || this.isGamInCooldown()) {
5473
5490
  return [
5474
5491
  3,
5475
5492
  8
@@ -5902,7 +5919,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5902
5919
  key: "continuousFetchLoop",
5903
5920
  value: function continuousFetchLoop(baseVastUrl) {
5904
5921
  return _async_to_generator(function() {
5905
- var _this, _loop, _ret;
5922
+ var _this, _loop, epoch, _ret;
5906
5923
  return _ts_generator(this, function(_state) {
5907
5924
  switch(_state.label){
5908
5925
  case 0:
@@ -6012,9 +6029,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6012
6029
  }
6013
6030
  });
6014
6031
  };
6032
+ epoch = this.adBreakEpoch;
6015
6033
  _state.label = 1;
6016
6034
  case 1:
6017
- if (!(this.continuousFetchingActive && this.inAdBreak)) return [
6035
+ if (!(this.continuousFetchingActive && this.inAdBreak && epoch === this.adBreakEpoch)) return [
6018
6036
  3,
6019
6037
  3
6020
6038
  ];
@@ -6063,10 +6081,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6063
6081
  key: "tryNextAvailableAdWithRateLimit",
6064
6082
  value: function tryNextAvailableAdWithRateLimit() {
6065
6083
  return _async_to_generator(function() {
6066
- var backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6084
+ var epoch, backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6067
6085
  return _ts_generator(this, function(_state) {
6068
6086
  switch(_state.label){
6069
6087
  case 0:
6088
+ if (!this.inAdBreak) {
6089
+ return [
6090
+ 2
6091
+ ];
6092
+ }
6093
+ epoch = this.adBreakEpoch;
6070
6094
  if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
6071
6095
  if (this.config.debugAdTiming) {
6072
6096
  console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive failures (".concat(this.consecutiveFailures, "), ending ad break gracefully"));
@@ -6098,6 +6122,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6098
6122
  _state.sent();
6099
6123
  _state.label = 2;
6100
6124
  case 2:
6125
+ if (!this.inAdBreak || epoch !== this.adBreakEpoch) {
6126
+ return [
6127
+ 2
6128
+ ];
6129
+ }
6101
6130
  return [
6102
6131
  2,
6103
6132
  this.tryNextAvailableAd(0)
@@ -6116,6 +6145,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6116
6145
  return _ts_generator(this, function(_state) {
6117
6146
  switch(_state.label){
6118
6147
  case 0:
6148
+ if (!this.inAdBreak) {
6149
+ return [
6150
+ 2
6151
+ ];
6152
+ }
6119
6153
  remaining = this.getRemainingAdMs();
6120
6154
  if (remaining <= 500) {
6121
6155
  if (this.config.debugAdTiming) {
@@ -7128,6 +7162,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7128
7162
  if (this.config.debugAdTiming) {
7129
7163
  console.log("[StormcloudVideoPlayer] \uD83C\uDFC1 Ad pod complete - cleaning up");
7130
7164
  }
7165
+ this.adBreakEpoch++;
7131
7166
  this.clearAdRequestWatchdog();
7132
7167
  this.clearAdFailsafeTimer();
7133
7168
  this.activeAdRequestToken = null;