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.
@@ -76,6 +76,7 @@ declare class StormcloudVideoPlayer {
76
76
  private preloadPoolActive;
77
77
  private preloadPoolLoopRunning;
78
78
  private adDetectSentForCurrentBreak;
79
+ private adBreakEpoch;
79
80
  private palNonce;
80
81
  private palPlaybackStarted;
81
82
  private readonly streamCorrelator;
@@ -2702,6 +2702,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2702
2702
  this.preloadPoolActive = false;
2703
2703
  this.preloadPoolLoopRunning = false;
2704
2704
  this.adDetectSentForCurrentBreak = false;
2705
+ this.adBreakEpoch = 0;
2705
2706
  this.palPlaybackStarted = false;
2706
2707
  this.streamCorrelator = generateCorrelator();
2707
2708
  this.consentSignals = {};
@@ -5249,7 +5250,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5249
5250
  key: "preloadAdIntoPool",
5250
5251
  value: function preloadAdIntoPool(vastUrl) {
5251
5252
  return _async_to_generator(function() {
5252
- var _this, loadPromise;
5253
+ var _this, epoch, loadPromise;
5253
5254
  return _ts_generator(this, function(_state) {
5254
5255
  _this = this;
5255
5256
  if (this.isGamInCooldown()) {
@@ -5275,6 +5276,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5275
5276
  if (this.config.debugAdTiming) {
5276
5277
  console.log("[PRELOAD-POOL] \uD83D\uDCE5 Preloading ad into pool: ".concat(vastUrl));
5277
5278
  }
5279
+ epoch = this.adBreakEpoch;
5278
5280
  loadPromise = function() {
5279
5281
  return _async_to_generator(function() {
5280
5282
  var _this, hasAdError, adErrorPayload, errorListenerCleanup, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, lateErrorListener, error;
@@ -5352,6 +5354,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5352
5354
  2
5353
5355
  ];
5354
5356
  }
5357
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch) {
5358
+ if (this.config.debugAdTiming) {
5359
+ console.log("[PRELOAD-POOL] \uD83D\uDEAB Discarding preloaded ad - break ended during fetch");
5360
+ }
5361
+ if (errorListenerCleanup) {
5362
+ errorListenerCleanup();
5363
+ }
5364
+ try {
5365
+ preloadAd.destroy();
5366
+ } catch (unused) {}
5367
+ return [
5368
+ 2
5369
+ ];
5370
+ }
5355
5371
  poolEntry = {
5356
5372
  vastUrl: vastUrl,
5357
5373
  adController: preloadAd,
@@ -5423,7 +5439,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5423
5439
  key: "preloadPoolLoop",
5424
5440
  value: function preloadPoolLoop(baseVastUrl) {
5425
5441
  return _async_to_generator(function() {
5426
- var remaining, newUrls, newUrl;
5442
+ var epoch, remaining, newUrls, newUrl;
5427
5443
  return _ts_generator(this, function(_state) {
5428
5444
  switch(_state.label){
5429
5445
  case 0:
@@ -5433,12 +5449,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5433
5449
  ];
5434
5450
  }
5435
5451
  this.preloadPoolLoopRunning = true;
5452
+ epoch = this.adBreakEpoch;
5436
5453
  if (this.config.debugAdTiming) {
5437
5454
  console.log("[PRELOAD-POOL] \uD83D\uDD04 Starting continuous preload loop");
5438
5455
  }
5439
5456
  _state.label = 1;
5440
5457
  case 1:
5441
- if (!this.preloadPoolActive) return [
5458
+ if (!(this.preloadPoolActive && epoch === this.adBreakEpoch)) return [
5442
5459
  3,
5443
5460
  10
5444
5461
  ];
@@ -5483,7 +5500,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5483
5500
  3,
5484
5501
  8
5485
5502
  ];
5486
- if (!this.preloadPoolActive || this.isGamInCooldown()) {
5503
+ if (!this.preloadPoolActive || epoch !== this.adBreakEpoch || this.isGamInCooldown()) {
5487
5504
  return [
5488
5505
  3,
5489
5506
  8
@@ -5916,7 +5933,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5916
5933
  key: "continuousFetchLoop",
5917
5934
  value: function continuousFetchLoop(baseVastUrl) {
5918
5935
  return _async_to_generator(function() {
5919
- var _this, _loop, _ret;
5936
+ var _this, _loop, epoch, _ret;
5920
5937
  return _ts_generator(this, function(_state) {
5921
5938
  switch(_state.label){
5922
5939
  case 0:
@@ -6026,9 +6043,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6026
6043
  }
6027
6044
  });
6028
6045
  };
6046
+ epoch = this.adBreakEpoch;
6029
6047
  _state.label = 1;
6030
6048
  case 1:
6031
- if (!(this.continuousFetchingActive && this.inAdBreak)) return [
6049
+ if (!(this.continuousFetchingActive && this.inAdBreak && epoch === this.adBreakEpoch)) return [
6032
6050
  3,
6033
6051
  3
6034
6052
  ];
@@ -6077,10 +6095,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6077
6095
  key: "tryNextAvailableAdWithRateLimit",
6078
6096
  value: function tryNextAvailableAdWithRateLimit() {
6079
6097
  return _async_to_generator(function() {
6080
- var backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6098
+ var epoch, backoffMultiplier, backoffDelay, effectiveMinInterval, timeSinceLastRequest, waitTime;
6081
6099
  return _ts_generator(this, function(_state) {
6082
6100
  switch(_state.label){
6083
6101
  case 0:
6102
+ if (!this.inAdBreak) {
6103
+ return [
6104
+ 2
6105
+ ];
6106
+ }
6107
+ epoch = this.adBreakEpoch;
6084
6108
  if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
6085
6109
  if (this.config.debugAdTiming) {
6086
6110
  console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive failures (".concat(this.consecutiveFailures, "), ending ad break gracefully"));
@@ -6112,6 +6136,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6112
6136
  _state.sent();
6113
6137
  _state.label = 2;
6114
6138
  case 2:
6139
+ if (!this.inAdBreak || epoch !== this.adBreakEpoch) {
6140
+ return [
6141
+ 2
6142
+ ];
6143
+ }
6115
6144
  return [
6116
6145
  2,
6117
6146
  this.tryNextAvailableAd(0)
@@ -6130,6 +6159,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6130
6159
  return _ts_generator(this, function(_state) {
6131
6160
  switch(_state.label){
6132
6161
  case 0:
6162
+ if (!this.inAdBreak) {
6163
+ return [
6164
+ 2
6165
+ ];
6166
+ }
6133
6167
  remaining = this.getRemainingAdMs();
6134
6168
  if (remaining <= 500) {
6135
6169
  if (this.config.debugAdTiming) {
@@ -7142,6 +7176,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7142
7176
  if (this.config.debugAdTiming) {
7143
7177
  console.log("[StormcloudVideoPlayer] \uD83C\uDFC1 Ad pod complete - cleaning up");
7144
7178
  }
7179
+ this.adBreakEpoch++;
7145
7180
  this.clearAdRequestWatchdog();
7146
7181
  this.clearAdFailsafeTimer();
7147
7182
  this.activeAdRequestToken = null;