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.
@@ -2738,6 +2738,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2738
2738
  this.preloadPoolActive = false;
2739
2739
  this.preloadPoolLoopRunning = false;
2740
2740
  this.adDetectSentForCurrentBreak = false;
2741
+ this.adBreakEpoch = 0;
2741
2742
  this.palPlaybackStarted = false;
2742
2743
  this.streamCorrelator = generateCorrelator();
2743
2744
  this.consentSignals = {};
@@ -5285,7 +5286,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5285
5286
  key: "preloadAdIntoPool",
5286
5287
  value: function preloadAdIntoPool(vastUrl) {
5287
5288
  return _async_to_generator(function() {
5288
- var _this, loadPromise;
5289
+ var _this, epoch, loadPromise;
5289
5290
  return _ts_generator(this, function(_state) {
5290
5291
  _this = this;
5291
5292
  if (this.isGamInCooldown()) {
@@ -5311,6 +5312,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5311
5312
  if (this.config.debugAdTiming) {
5312
5313
  console.log("[PRELOAD-POOL] \uD83D\uDCE5 Preloading ad into pool: ".concat(vastUrl));
5313
5314
  }
5315
+ epoch = this.adBreakEpoch;
5314
5316
  loadPromise = function() {
5315
5317
  return _async_to_generator(function() {
5316
5318
  var _this, hasAdError, adErrorPayload, errorListenerCleanup, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, lateErrorListener, error;
@@ -5388,6 +5390,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5388
5390
  2
5389
5391
  ];
5390
5392
  }
5393
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch) {
5394
+ if (this.config.debugAdTiming) {
5395
+ console.log("[PRELOAD-POOL] \uD83D\uDEAB Discarding preloaded ad - break ended during fetch");
5396
+ }
5397
+ if (errorListenerCleanup) {
5398
+ errorListenerCleanup();
5399
+ }
5400
+ try {
5401
+ preloadAd.destroy();
5402
+ } catch (unused) {}
5403
+ return [
5404
+ 2
5405
+ ];
5406
+ }
5391
5407
  poolEntry = {
5392
5408
  vastUrl: vastUrl,
5393
5409
  adController: preloadAd,
@@ -5459,7 +5475,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5459
5475
  key: "preloadPoolLoop",
5460
5476
  value: function preloadPoolLoop(baseVastUrl) {
5461
5477
  return _async_to_generator(function() {
5462
- var remaining, newUrls, newUrl;
5478
+ var epoch, remaining, newUrls, newUrl;
5463
5479
  return _ts_generator(this, function(_state) {
5464
5480
  switch(_state.label){
5465
5481
  case 0:
@@ -5469,12 +5485,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5469
5485
  ];
5470
5486
  }
5471
5487
  this.preloadPoolLoopRunning = true;
5488
+ epoch = this.adBreakEpoch;
5472
5489
  if (this.config.debugAdTiming) {
5473
5490
  console.log("[PRELOAD-POOL] \uD83D\uDD04 Starting continuous preload loop");
5474
5491
  }
5475
5492
  _state.label = 1;
5476
5493
  case 1:
5477
- if (!this.preloadPoolActive) return [
5494
+ if (!(this.preloadPoolActive && epoch === this.adBreakEpoch)) return [
5478
5495
  3,
5479
5496
  10
5480
5497
  ];
@@ -5519,7 +5536,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5519
5536
  3,
5520
5537
  8
5521
5538
  ];
5522
- if (!this.preloadPoolActive || this.isGamInCooldown()) {
5539
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch || this.isGamInCooldown()) {
5523
5540
  return [
5524
5541
  3,
5525
5542
  8
@@ -5952,7 +5969,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5952
5969
  key: "continuousFetchLoop",
5953
5970
  value: function continuousFetchLoop(baseVastUrl) {
5954
5971
  return _async_to_generator(function() {
5955
- var _this, _loop, _ret;
5972
+ var _this, _loop, epoch, _ret;
5956
5973
  return _ts_generator(this, function(_state) {
5957
5974
  switch(_state.label){
5958
5975
  case 0:
@@ -6062,9 +6079,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6062
6079
  }
6063
6080
  });
6064
6081
  };
6082
+ epoch = this.adBreakEpoch;
6065
6083
  _state.label = 1;
6066
6084
  case 1:
6067
- if (!(this.continuousFetchingActive && this.inAdBreak)) return [
6085
+ if (!(this.continuousFetchingActive && this.inAdBreak && epoch === this.adBreakEpoch)) return [
6068
6086
  3,
6069
6087
  3
6070
6088
  ];
@@ -6113,10 +6131,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6113
6131
  key: "tryNextAvailableAdWithRateLimit",
6114
6132
  value: function tryNextAvailableAdWithRateLimit() {
6115
6133
  return _async_to_generator(function() {
6116
- var backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6134
+ var epoch, backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6117
6135
  return _ts_generator(this, function(_state) {
6118
6136
  switch(_state.label){
6119
6137
  case 0:
6138
+ if (!this.inAdBreak) {
6139
+ return [
6140
+ 2
6141
+ ];
6142
+ }
6143
+ epoch = this.adBreakEpoch;
6120
6144
  if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
6121
6145
  if (this.config.debugAdTiming) {
6122
6146
  console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive failures (".concat(this.consecutiveFailures, "), ending ad break gracefully"));
@@ -6148,6 +6172,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6148
6172
  _state.sent();
6149
6173
  _state.label = 2;
6150
6174
  case 2:
6175
+ if (!this.inAdBreak || epoch !== this.adBreakEpoch) {
6176
+ return [
6177
+ 2
6178
+ ];
6179
+ }
6151
6180
  return [
6152
6181
  2,
6153
6182
  this.tryNextAvailableAd(0)
@@ -6166,6 +6195,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6166
6195
  return _ts_generator(this, function(_state) {
6167
6196
  switch(_state.label){
6168
6197
  case 0:
6198
+ if (!this.inAdBreak) {
6199
+ return [
6200
+ 2
6201
+ ];
6202
+ }
6169
6203
  remaining = this.getRemainingAdMs();
6170
6204
  if (remaining <= 500) {
6171
6205
  if (this.config.debugAdTiming) {
@@ -7178,6 +7212,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7178
7212
  if (this.config.debugAdTiming) {
7179
7213
  console.log("[StormcloudVideoPlayer] \uD83C\uDFC1 Ad pod complete - cleaning up");
7180
7214
  }
7215
+ this.adBreakEpoch++;
7181
7216
  this.clearAdRequestWatchdog();
7182
7217
  this.clearAdFailsafeTimer();
7183
7218
  this.activeAdRequestToken = null;