stormcloud-video-player 0.5.12 → 0.5.13

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.
@@ -2513,18 +2513,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2513
2513
  this.bufferedSegmentsCount = 0;
2514
2514
  this.shouldAutoplayAfterBuffering = false;
2515
2515
  this.hasInitialBufferCompleted = false;
2516
- this.adRequestTokenCounter = 0;
2517
2516
  this.activeAdRequestToken = null;
2518
2517
  this.adRequestWatchdogToken = null;
2519
2518
  this.adFailsafeToken = null;
2520
2519
  this.continuousFetchingActive = false;
2521
- this.adRequestQueue = [];
2522
2520
  this.maxPlaceholderDurationMs = 5e3;
2523
2521
  this.isShowingPlaceholder = false;
2524
2522
  this.totalAdRequestsInBreak = 0;
2525
2523
  this.maxTotalAdRequestsPerBreak = 20;
2526
2524
  this.pendingAdBreak = null;
2527
- this.prefetchAdPromise = null;
2528
2525
  this.savedMutedStateBeforeScte = null;
2529
2526
  this.consecutiveFailures = 0;
2530
2527
  this.maxConsecutiveFailures = 5;
@@ -2532,6 +2529,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2532
2529
  this.minAdRequestIntervalMs = 2500;
2533
2530
  this.backoffBaseMs = 1e3;
2534
2531
  this.maxBackoffMs = 15e3;
2532
+ this.adTransitionGapMs = 1500;
2535
2533
  initializePolyfills();
2536
2534
  var browserOverrides = getBrowserConfigOverrides();
2537
2535
  this.config = _object_spread({}, browserOverrides, config);
@@ -3058,7 +3056,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3058
3056
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
3059
3057
  _this.handleAdFailure();
3060
3058
  });
3061
- }, 500);
3059
+ }, _this.adTransitionGapMs);
3062
3060
  return;
3063
3061
  }
3064
3062
  if (remaining <= 500 && _this.expectedAdBreakDurationMs != null) {
@@ -3838,7 +3836,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3838
3836
  isFetching: false,
3839
3837
  fetchStartTime: Date.now()
3840
3838
  });
3841
- this.prefetchAdPromise = this.adRequest().then(function() {}).catch(function() {
3839
+ void this.adRequest().then(function() {}).catch(function() {
3842
3840
  if (_this.config.debugAdTiming) {
3843
3841
  console.log("[PREFETCH] Prebid auction prefetch failed, will request at playback time");
3844
3842
  }
@@ -3855,7 +3853,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3855
3853
  clearTimeout(this.prefetchTimerId);
3856
3854
  this.prefetchTimerId = void 0;
3857
3855
  }
3858
- this.prefetchAdPromise = null;
3859
3856
  this.pendingAdBreak = null;
3860
3857
  }
3861
3858
  },
@@ -3883,6 +3880,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3883
3880
  2,
3884
3881
  "break"
3885
3882
  ];
3883
+ if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) return [
3884
+ 2,
3885
+ "break"
3886
+ ];
3886
3887
  delay = _this.lastAdRequestTime ? _this.minAdRequestIntervalMs + (_this.consecutiveFailures > 0 ? backoffMs() : 0) : 0;
3887
3888
  elapsed = Date.now() - _this.lastAdRequestTime;
3888
3889
  if (!(elapsed < delay && _this.lastAdRequestTime > 0)) return [
@@ -4076,14 +4077,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4076
4077
  this.expectedAdBreakDurationMs = adBreakDurationMs;
4077
4078
  }
4078
4079
  this.clearPendingAdBreak();
4079
- this.startContinuousFetchLoop();
4080
4080
  _state.label = 1;
4081
4081
  case 1:
4082
4082
  _state.trys.push([
4083
4083
  1,
4084
- 6,
4084
+ 7,
4085
4085
  ,
4086
- 7
4086
+ 9
4087
4087
  ]);
4088
4088
  this.lastAdRequestTime = Date.now();
4089
4089
  return [
@@ -4123,27 +4123,40 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4123
4123
  this.adLayer.setAdVolume(adVolume);
4124
4124
  return [
4125
4125
  3,
4126
- 5
4126
+ 6
4127
4127
  ];
4128
4128
  case 4:
4129
4129
  this.consecutiveFailures++;
4130
- _state.label = 5;
4130
+ return [
4131
+ 4,
4132
+ this.showPlaceholderAndWaitForAds()
4133
+ ];
4131
4134
  case 5:
4135
+ _state.sent();
4136
+ _state.label = 6;
4137
+ case 6:
4132
4138
  return [
4133
4139
  3,
4134
- 7
4140
+ 9
4135
4141
  ];
4136
- case 6:
4142
+ case 7:
4137
4143
  error = _state.sent();
4138
4144
  if (this.config.debugAdTiming) {
4139
4145
  console.warn("[CONTINUOUS-FETCH] \u26A0\uFE0F First ad request failed:", error);
4140
4146
  }
4141
4147
  this.consecutiveFailures++;
4148
+ return [
4149
+ 4,
4150
+ this.showPlaceholderAndWaitForAds()
4151
+ ];
4152
+ case 8:
4153
+ _state.sent();
4142
4154
  return [
4143
4155
  3,
4144
- 7
4156
+ 9
4145
4157
  ];
4146
- case 7:
4158
+ case 9:
4159
+ this.startContinuousFetchLoop();
4147
4160
  return [
4148
4161
  2
4149
4162
  ];
@@ -4219,6 +4232,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4219
4232
  return _ts_generator(this, function(_state) {
4220
4233
  switch(_state.label){
4221
4234
  case 0:
4235
+ if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
4236
+ if (this.config.debugAdTiming) {
4237
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Max ad requests per break (".concat(this.maxTotalAdRequestsPerBreak, ") reached"));
4238
+ }
4239
+ this.handleAdPodComplete();
4240
+ return [
4241
+ 2
4242
+ ];
4243
+ }
4222
4244
  remaining = this.getRemainingAdMs();
4223
4245
  if (remaining <= 500 && this.expectedAdBreakDurationMs != null) {
4224
4246
  if (this.config.debugAdTiming) {
@@ -4242,9 +4264,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4242
4264
  case 1:
4243
4265
  _state.trys.push([
4244
4266
  1,
4245
- 8,
4267
+ 9,
4246
4268
  ,
4247
- 9
4269
+ 11
4248
4270
  ]);
4249
4271
  this.lastAdRequestTime = Date.now();
4250
4272
  return [
@@ -4293,27 +4315,39 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4293
4315
  case 5:
4294
4316
  return [
4295
4317
  3,
4296
- 7
4318
+ 8
4297
4319
  ];
4298
4320
  case 6:
4299
4321
  this.consecutiveFailures++;
4300
- _state.label = 7;
4322
+ return [
4323
+ 4,
4324
+ this.showPlaceholderAndWaitForAds()
4325
+ ];
4301
4326
  case 7:
4327
+ _state.sent();
4328
+ _state.label = 8;
4329
+ case 8:
4302
4330
  return [
4303
4331
  3,
4304
- 9
4332
+ 11
4305
4333
  ];
4306
- case 8:
4334
+ case 9:
4307
4335
  error = _state.sent();
4308
4336
  this.consecutiveFailures++;
4309
4337
  if (this.config.debugAdTiming) {
4310
4338
  console.warn("[CONTINUOUS-FETCH] tryNextAvailableAd request failed:", error);
4311
4339
  }
4340
+ return [
4341
+ 4,
4342
+ this.showPlaceholderAndWaitForAds()
4343
+ ];
4344
+ case 10:
4345
+ _state.sent();
4312
4346
  return [
4313
4347
  3,
4314
- 9
4348
+ 11
4315
4349
  ];
4316
- case 9:
4350
+ case 11:
4317
4351
  return [
4318
4352
  2
4319
4353
  ];
@@ -4389,7 +4423,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4389
4423
  this.pendingNextAdBids = null;
4390
4424
  this.isShowingPlaceholder = false;
4391
4425
  this.adLayer.hidePlaceholder();
4392
- this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
4393
4426
  this.currentAdIndex++;
4394
4427
  _state.label = 3;
4395
4428
  case 3:
@@ -4943,7 +4976,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4943
4976
  }
4944
4977
  (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
4945
4978
  (_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
4946
- this.adRequestQueue = [];
4947
4979
  this.consecutiveFailures = 0;
4948
4980
  }
4949
4981
  }