stormcloud-video-player 0.5.11 → 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);
@@ -3015,10 +3013,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3015
3013
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3016
3014
  }
3017
3015
  }
3018
- var currentMuted = _this.video.muted;
3019
- var currentVolume = _this.video.volume;
3020
- var adVolume = currentMuted ? 0 : currentVolume;
3021
- _this.adLayer.setAdVolume(adVolume);
3016
+ _this.adLayer.setAdVolume(_this.adLayer.getOriginalMutedState() ? 0 : _this.adLayer.getOriginalVolume());
3022
3017
  if (_this.isShowingPlaceholder) {
3023
3018
  if (_this.config.debugAdTiming) {
3024
3019
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -3052,18 +3047,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3052
3047
  _this.video.muted = true;
3053
3048
  _this.video.volume = 0;
3054
3049
  }
3055
- _this.adLayer.updateOriginalMutedState(_this.video.muted, _this.video.volume);
3056
3050
  _this.showPlaceholderLayer();
3057
3051
  _this.adLayer.showPlaceholder();
3058
3052
  setTimeout(function() {
3059
3053
  if (!_this.inAdBreak || bids.length === 0) return;
3060
3054
  _this.currentAdIndex++;
3061
- _this.adLayer.updateOriginalMutedState(_this.video.muted, _this.video.volume);
3062
3055
  _this.adLayer.playAd(bids).catch(function(err) {
3063
3056
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
3064
3057
  _this.handleAdFailure();
3065
3058
  });
3066
- }, 500);
3059
+ }, _this.adTransitionGapMs);
3067
3060
  return;
3068
3061
  }
3069
3062
  if (remaining <= 500 && _this.expectedAdBreakDurationMs != null) {
@@ -3486,7 +3479,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3486
3479
  if (!this.adLayer.isAdPlaying() && this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0) {
3487
3480
  var bids = this.pendingNextAdBids;
3488
3481
  this.pendingNextAdBids = null;
3489
- this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
3490
3482
  this.currentAdIndex++;
3491
3483
  this.adLayer.playAd(bids).catch(function() {
3492
3484
  return _this.handleAdFailure();
@@ -3844,7 +3836,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3844
3836
  isFetching: false,
3845
3837
  fetchStartTime: Date.now()
3846
3838
  });
3847
- this.prefetchAdPromise = this.adRequest().then(function() {}).catch(function() {
3839
+ void this.adRequest().then(function() {}).catch(function() {
3848
3840
  if (_this.config.debugAdTiming) {
3849
3841
  console.log("[PREFETCH] Prebid auction prefetch failed, will request at playback time");
3850
3842
  }
@@ -3861,7 +3853,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3861
3853
  clearTimeout(this.prefetchTimerId);
3862
3854
  this.prefetchTimerId = void 0;
3863
3855
  }
3864
- this.prefetchAdPromise = null;
3865
3856
  this.pendingAdBreak = null;
3866
3857
  }
3867
3858
  },
@@ -3881,7 +3872,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3881
3872
  switch(_state.label){
3882
3873
  case 0:
3883
3874
  _loop = function() {
3884
- var delay, elapsed, bids, adVolume, err;
3875
+ var delay, elapsed, bids, err;
3885
3876
  return _ts_generator(this, function(_state) {
3886
3877
  switch(_state.label){
3887
3878
  case 0:
@@ -3889,6 +3880,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3889
3880
  2,
3890
3881
  "break"
3891
3882
  ];
3883
+ if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) return [
3884
+ 2,
3885
+ "break"
3886
+ ];
3892
3887
  delay = _this.lastAdRequestTime ? _this.minAdRequestIntervalMs + (_this.consecutiveFailures > 0 ? backoffMs() : 0) : 0;
3893
3888
  elapsed = Date.now() - _this.lastAdRequestTime;
3894
3889
  if (!(elapsed < delay && _this.lastAdRequestTime > 0)) return [
@@ -3946,7 +3941,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3946
3941
  7
3947
3942
  ];
3948
3943
  case 5:
3949
- _this.adLayer.updateOriginalMutedState(_this.video.muted, _this.video.volume);
3950
3944
  _this.currentAdIndex++;
3951
3945
  if (_this.config.licenseKey) {
3952
3946
  sendAdLoadedTracking(_this.config.licenseKey, {
@@ -3963,8 +3957,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3963
3957
  if (_this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
3964
3958
  _this.scheduleAdStopCountdown(_this.getRemainingAdMs());
3965
3959
  }
3966
- adVolume = _this.video.muted ? 0 : _this.video.volume;
3967
- _this.adLayer.setAdVolume(adVolume);
3960
+ _this.adLayer.setAdVolume(_this.adLayer.getOriginalMutedState() ? 0 : _this.adLayer.getOriginalVolume());
3968
3961
  _state.label = 7;
3969
3962
  case 7:
3970
3963
  return [
@@ -4084,14 +4077,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4084
4077
  this.expectedAdBreakDurationMs = adBreakDurationMs;
4085
4078
  }
4086
4079
  this.clearPendingAdBreak();
4087
- this.startContinuousFetchLoop();
4088
4080
  _state.label = 1;
4089
4081
  case 1:
4090
4082
  _state.trys.push([
4091
4083
  1,
4092
- 6,
4084
+ 7,
4093
4085
  ,
4094
- 7
4086
+ 9
4095
4087
  ]);
4096
4088
  this.lastAdRequestTime = Date.now();
4097
4089
  return [
@@ -4131,27 +4123,40 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4131
4123
  this.adLayer.setAdVolume(adVolume);
4132
4124
  return [
4133
4125
  3,
4134
- 5
4126
+ 6
4135
4127
  ];
4136
4128
  case 4:
4137
4129
  this.consecutiveFailures++;
4138
- _state.label = 5;
4130
+ return [
4131
+ 4,
4132
+ this.showPlaceholderAndWaitForAds()
4133
+ ];
4139
4134
  case 5:
4135
+ _state.sent();
4136
+ _state.label = 6;
4137
+ case 6:
4140
4138
  return [
4141
4139
  3,
4142
- 7
4140
+ 9
4143
4141
  ];
4144
- case 6:
4142
+ case 7:
4145
4143
  error = _state.sent();
4146
4144
  if (this.config.debugAdTiming) {
4147
4145
  console.warn("[CONTINUOUS-FETCH] \u26A0\uFE0F First ad request failed:", error);
4148
4146
  }
4149
4147
  this.consecutiveFailures++;
4148
+ return [
4149
+ 4,
4150
+ this.showPlaceholderAndWaitForAds()
4151
+ ];
4152
+ case 8:
4153
+ _state.sent();
4150
4154
  return [
4151
4155
  3,
4152
- 7
4156
+ 9
4153
4157
  ];
4154
- case 7:
4158
+ case 9:
4159
+ this.startContinuousFetchLoop();
4155
4160
  return [
4156
4161
  2
4157
4162
  ];
@@ -4227,6 +4232,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4227
4232
  return _ts_generator(this, function(_state) {
4228
4233
  switch(_state.label){
4229
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
+ }
4230
4244
  remaining = this.getRemainingAdMs();
4231
4245
  if (remaining <= 500 && this.expectedAdBreakDurationMs != null) {
4232
4246
  if (this.config.debugAdTiming) {
@@ -4250,9 +4264,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4250
4264
  case 1:
4251
4265
  _state.trys.push([
4252
4266
  1,
4253
- 8,
4267
+ 9,
4254
4268
  ,
4255
- 9
4269
+ 11
4256
4270
  ]);
4257
4271
  this.lastAdRequestTime = Date.now();
4258
4272
  return [
@@ -4269,7 +4283,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4269
4283
  6
4270
4284
  ];
4271
4285
  this.consecutiveFailures = 0;
4272
- this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
4273
4286
  this.currentAdIndex++;
4274
4287
  this.totalAdRequestsInBreak++;
4275
4288
  if (!this.adLayer.isAdPlaying()) return [
@@ -4297,32 +4310,44 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4297
4310
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
4298
4311
  this.scheduleAdStopCountdown(this.getRemainingAdMs());
4299
4312
  }
4300
- this.adLayer.setAdVolume(this.video.muted ? 0 : this.video.volume);
4313
+ this.adLayer.setAdVolume(this.adLayer.getOriginalMutedState() ? 0 : this.adLayer.getOriginalVolume());
4301
4314
  _state.label = 5;
4302
4315
  case 5:
4303
4316
  return [
4304
4317
  3,
4305
- 7
4318
+ 8
4306
4319
  ];
4307
4320
  case 6:
4308
4321
  this.consecutiveFailures++;
4309
- _state.label = 7;
4322
+ return [
4323
+ 4,
4324
+ this.showPlaceholderAndWaitForAds()
4325
+ ];
4310
4326
  case 7:
4327
+ _state.sent();
4328
+ _state.label = 8;
4329
+ case 8:
4311
4330
  return [
4312
4331
  3,
4313
- 9
4332
+ 11
4314
4333
  ];
4315
- case 8:
4334
+ case 9:
4316
4335
  error = _state.sent();
4317
4336
  this.consecutiveFailures++;
4318
4337
  if (this.config.debugAdTiming) {
4319
4338
  console.warn("[CONTINUOUS-FETCH] tryNextAvailableAd request failed:", error);
4320
4339
  }
4340
+ return [
4341
+ 4,
4342
+ this.showPlaceholderAndWaitForAds()
4343
+ ];
4344
+ case 10:
4345
+ _state.sent();
4321
4346
  return [
4322
4347
  3,
4323
- 9
4348
+ 11
4324
4349
  ];
4325
- case 9:
4350
+ case 11:
4326
4351
  return [
4327
4352
  2
4328
4353
  ];
@@ -4398,7 +4423,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4398
4423
  this.pendingNextAdBids = null;
4399
4424
  this.isShowingPlaceholder = false;
4400
4425
  this.adLayer.hidePlaceholder();
4401
- this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
4402
4426
  this.currentAdIndex++;
4403
4427
  _state.label = 3;
4404
4428
  case 3:
@@ -4952,7 +4976,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4952
4976
  }
4953
4977
  (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
4954
4978
  (_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
4955
- this.adRequestQueue = [];
4956
4979
  this.consecutiveFailures = 0;
4957
4980
  }
4958
4981
  }