stormcloud-video-player 0.3.21 → 0.3.22

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.
package/lib/index.js CHANGED
@@ -335,20 +335,6 @@ function _ts_generator(thisArg, body) {
335
335
  };
336
336
  }
337
337
  }
338
- function _ts_values(o) {
339
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
340
- if (m) return m.call(o);
341
- if (o && typeof o.length === "number") return {
342
- next: function() {
343
- if (o && i >= o.length) o = void 0;
344
- return {
345
- value: o && o[i++],
346
- done: !o
347
- };
348
- }
349
- };
350
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
351
- }
352
338
  // src/ui/StormcloudVideoPlayer.tsx
353
339
  import React, { useEffect, useRef, useMemo } from "react";
354
340
  // src/player/StormcloudVideoPlayer.ts
@@ -549,8 +535,6 @@ function createImaController(video, options) {
549
535
  var originalMutedState = false;
550
536
  var originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
551
537
  var listeners = /* @__PURE__ */ new Map();
552
- var preloadedVast = /* @__PURE__ */ new Map();
553
- var preloadingVast = /* @__PURE__ */ new Map();
554
538
  var adVideoElement;
555
539
  function setAdPlayingFlag(isPlaying) {
556
540
  if (isPlaying) {
@@ -700,15 +684,8 @@ function createImaController(video, options) {
700
684
  var adsLoadedReject;
701
685
  function makeAdsRequest(google, vastTagUrl) {
702
686
  var adsRequest = new google.ima.AdsRequest();
703
- var preloadedXml = preloadedVast.get(vastTagUrl);
704
- if (preloadedXml) {
705
- console.log("[IMA] \uD83D\uDCE6 Using preloaded VAST response");
706
- adsRequest.adsResponse = preloadedXml;
707
- preloadedVast.delete(vastTagUrl);
708
- } else {
709
- console.log("[IMA] \uD83D\uDCE1 Requesting VAST from URL (letting IMA fetch fresh)");
710
- adsRequest.adTagUrl = vastTagUrl;
711
- }
687
+ console.log("[IMA] \uD83D\uDCE1 Requesting VAST via IMA SDK:", vastTagUrl.substring(0, 80) + "...");
688
+ adsRequest.adTagUrl = vastTagUrl;
712
689
  var videoWidth = video.offsetWidth || video.clientWidth || 640;
713
690
  var videoHeight = video.offsetHeight || video.clientHeight || 480;
714
691
  adsRequest.linearAdSlotWidth = videoWidth;
@@ -756,36 +733,6 @@ function createImaController(video, options) {
756
733
  (_video_parentElement = video.parentElement) === null || _video_parentElement === void 0 ? void 0 : _video_parentElement.appendChild(container);
757
734
  adContainerEl = container;
758
735
  }
759
- function fetchVastDocument(vastTagUrl) {
760
- return _async_to_generator(function() {
761
- var response;
762
- return _ts_generator(this, function(_state) {
763
- switch(_state.label){
764
- case 0:
765
- return [
766
- 4,
767
- fetch(vastTagUrl, {
768
- mode: "cors",
769
- credentials: "include",
770
- headers: {
771
- "Accept": "application/xml, text/xml, */*"
772
- },
773
- referrerPolicy: "no-referrer-when-downgrade"
774
- })
775
- ];
776
- case 1:
777
- response = _state.sent();
778
- if (!response.ok) {
779
- throw new Error("Failed to preload VAST: ".concat(response.status));
780
- }
781
- return [
782
- 2,
783
- response.text()
784
- ];
785
- }
786
- });
787
- })();
788
- }
789
736
  function destroyAdsManager() {
790
737
  if (adsManager) {
791
738
  try {
@@ -1100,47 +1047,6 @@ function createImaController(video, options) {
1100
1047
  });
1101
1048
  })();
1102
1049
  },
1103
- preloadAds: function preloadAds(vastTagUrl) {
1104
- return _async_to_generator(function() {
1105
- var inflight, preloadPromise;
1106
- return _ts_generator(this, function(_state) {
1107
- if (!vastTagUrl || vastTagUrl.trim() === "") {
1108
- return [
1109
- 2,
1110
- Promise.resolve()
1111
- ];
1112
- }
1113
- if (preloadedVast.has(vastTagUrl)) {
1114
- return [
1115
- 2,
1116
- Promise.resolve()
1117
- ];
1118
- }
1119
- inflight = preloadingVast.get(vastTagUrl);
1120
- if (inflight) {
1121
- return [
1122
- 2,
1123
- inflight
1124
- ];
1125
- }
1126
- preloadPromise = fetchVastDocument(vastTagUrl).then(function(xml) {
1127
- preloadedVast.set(vastTagUrl, xml);
1128
- }).catch(function() {
1129
- preloadedVast.delete(vastTagUrl);
1130
- }).finally(function() {
1131
- preloadingVast.delete(vastTagUrl);
1132
- });
1133
- preloadingVast.set(vastTagUrl, preloadPromise);
1134
- return [
1135
- 2,
1136
- preloadPromise
1137
- ];
1138
- });
1139
- })();
1140
- },
1141
- hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
1142
- return preloadedVast.has(vastTagUrl);
1143
- },
1144
1050
  play: function play() {
1145
1051
  return _async_to_generator(function() {
1146
1052
  var _window_google, width, height, adVolume, _video_play;
@@ -1249,8 +1155,6 @@ function createImaController(video, options) {
1249
1155
  adDisplayContainer = void 0;
1250
1156
  adsLoader = void 0;
1251
1157
  contentVideoHidden = false;
1252
- preloadedVast.clear();
1253
- preloadingVast.clear();
1254
1158
  },
1255
1159
  isAdPlaying: function isAdPlaying() {
1256
1160
  return adPlaying;
@@ -1851,51 +1755,6 @@ function createHlsAdPlayer(contentVideo, options) {
1851
1755
  });
1852
1756
  })();
1853
1757
  },
1854
- preloadAds: function preloadAds(vastTagUrl) {
1855
- return _async_to_generator(function() {
1856
- var inflight, preloadPromise;
1857
- return _ts_generator(this, function(_state) {
1858
- if (!vastTagUrl || vastTagUrl.trim() === "") {
1859
- return [
1860
- 2,
1861
- Promise.resolve()
1862
- ];
1863
- }
1864
- if (preloadedAds.has(vastTagUrl)) {
1865
- return [
1866
- 2,
1867
- Promise.resolve()
1868
- ];
1869
- }
1870
- inflight = preloadingAds.get(vastTagUrl);
1871
- if (inflight) {
1872
- return [
1873
- 2,
1874
- inflight
1875
- ];
1876
- }
1877
- preloadPromise = fetchAndParseVastAd(vastTagUrl).then(function(ad) {
1878
- if (ad) {
1879
- preloadedAds.set(vastTagUrl, ad);
1880
- console.log("[HlsAdPlayer] Cached VAST response for preloading:", vastTagUrl);
1881
- }
1882
- }).catch(function(error) {
1883
- console.warn("[HlsAdPlayer] Failed to preload VAST response:", error);
1884
- preloadedAds.delete(vastTagUrl);
1885
- }).finally(function() {
1886
- preloadingAds.delete(vastTagUrl);
1887
- });
1888
- preloadingAds.set(vastTagUrl, preloadPromise);
1889
- return [
1890
- 2,
1891
- preloadPromise
1892
- ];
1893
- });
1894
- })();
1895
- },
1896
- hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
1897
- return preloadedAds.has(vastTagUrl);
1898
- },
1899
1758
  play: function play() {
1900
1759
  return _async_to_generator(function() {
1901
1760
  var contentVolume, adVolume, mediaFile;
@@ -2797,17 +2656,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2797
2656
  this.failedVastUrls = /* @__PURE__ */ new Set();
2798
2657
  this.continuousFetchingActive = false;
2799
2658
  this.adRequestQueue = [];
2800
- this.successfulAdRequests = [];
2801
2659
  this.maxPlaceholderDurationMs = 5e3;
2802
- this.placeholderStartTimeMs = null;
2803
2660
  this.isShowingPlaceholder = false;
2804
- this.consecutiveEmptyResponses = 0;
2805
2661
  this.totalAdRequestsInBreak = 0;
2806
- this.lastEmptyResponseTimeMs = 0;
2807
2662
  this.maxTotalAdRequestsPerBreak = 20;
2808
- this.maxConsecutiveEmptyResponses = 5;
2809
- this.baseEmptyResponseDelayMs = 2e3;
2810
- this.maxEmptyResponseDelayMs = 3e4;
2811
2663
  initializePolyfills();
2812
2664
  var browserOverrides = getBrowserConfigOverrides();
2813
2665
  this.config = _object_spread({}, config, browserOverrides);
@@ -4052,13 +3904,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4052
3904
  }
4053
3905
  this.failedVastUrls.clear();
4054
3906
  this.adRequestQueue = [];
4055
- this.successfulAdRequests = [];
4056
3907
  this.continuousFetchingActive = true;
4057
3908
  this.isShowingPlaceholder = false;
4058
- this.placeholderStartTimeMs = null;
4059
- this.consecutiveEmptyResponses = 0;
4060
3909
  this.totalAdRequestsInBreak = 0;
4061
- this.lastEmptyResponseTimeMs = 0;
4062
3910
  currentMuted = this.video.muted;
4063
3911
  currentVolume = this.video.volume;
4064
3912
  this.ima.updateOriginalMutedState(currentMuted, currentVolume);
@@ -4104,7 +3952,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4104
3952
  if (this.config.debugAdTiming) {
4105
3953
  console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
4106
3954
  }
4107
- this.successfulAdRequests.push(firstAdUrl);
4108
3955
  this.currentAdIndex++;
4109
3956
  this.startContinuousFetching(baseVastUrl);
4110
3957
  return [
@@ -4154,200 +4001,92 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4154
4001
  key: "continuousFetchLoop",
4155
4002
  value: function continuousFetchLoop(baseVastUrl) {
4156
4003
  return _async_to_generator(function() {
4157
- var _this, _loop, _ret;
4004
+ var remaining, maxQueueSize, newAdUrl;
4158
4005
  return _ts_generator(this, function(_state) {
4159
4006
  switch(_state.label){
4160
4007
  case 0:
4161
- _loop = function() {
4162
- var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
4163
- return _ts_generator(this, function(_state) {
4164
- switch(_state.label){
4165
- case 0:
4166
- remaining = _this.getRemainingAdMs();
4167
- if (remaining <= 0) {
4168
- if (_this.config.debugAdTiming) {
4169
- console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
4170
- }
4171
- return [
4172
- 2,
4173
- "break"
4174
- ];
4175
- }
4176
- if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
4177
- if (_this.config.debugAdTiming) {
4178
- console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
4179
- }
4180
- return [
4181
- 2,
4182
- "break"
4183
- ];
4184
- }
4185
- if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
4186
- if (_this.config.debugAdTiming) {
4187
- console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
4188
- }
4189
- return [
4190
- 2,
4191
- "break"
4192
- ];
4193
- }
4194
- maxQueueSize = 3;
4195
- if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
4196
- 3,
4197
- 2
4198
- ];
4199
- if (_this.config.debugAdTiming) {
4200
- console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
4201
- }
4202
- return [
4203
- 4,
4204
- new Promise(function(resolve) {
4205
- return setTimeout(resolve, 2e3);
4206
- })
4207
- ];
4208
- case 1:
4209
- _state.sent();
4210
- return [
4211
- 2,
4212
- "continue"
4213
- ];
4214
- case 2:
4215
- newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
4216
- if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
4217
- 3,
4218
- 4
4219
- ];
4220
- return [
4221
- 4,
4222
- new Promise(function(resolve) {
4223
- return setTimeout(resolve, 1e3);
4224
- })
4225
- ];
4226
- case 3:
4227
- _state.sent();
4228
- return [
4229
- 2,
4230
- "continue"
4231
- ];
4232
- case 4:
4233
- _this.totalAdRequestsInBreak++;
4234
- if (_this.config.debugAdTiming) {
4235
- console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
4236
- }
4237
- _state.label = 5;
4238
- case 5:
4239
- _state.trys.push([
4240
- 5,
4241
- 11,
4242
- ,
4243
- 13
4244
- ]);
4245
- if (!_this.ima.preloadAds) return [
4246
- 3,
4247
- 7
4248
- ];
4249
- return [
4250
- 4,
4251
- _this.ima.preloadAds(newAdUrl)
4252
- ];
4253
- case 6:
4254
- _state.sent();
4255
- _state.label = 7;
4256
- case 7:
4257
- hasPreloadedAd = (_this_ima_hasPreloadedAd1 = (_this_ima_hasPreloadedAd = (_this_ima = _this.ima).hasPreloadedAd) === null || _this_ima_hasPreloadedAd === void 0 ? void 0 : _this_ima_hasPreloadedAd.call(_this_ima, newAdUrl)) !== null && _this_ima_hasPreloadedAd1 !== void 0 ? _this_ima_hasPreloadedAd1 : false;
4258
- if (!!hasPreloadedAd) return [
4259
- 3,
4260
- 9
4261
- ];
4262
- _this.consecutiveEmptyResponses++;
4263
- _this.lastEmptyResponseTimeMs = Date.now();
4264
- backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
4265
- if (_this.config.debugAdTiming) {
4266
- console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
4267
- }
4268
- _this.failedVastUrls.add(newAdUrl);
4269
- return [
4270
- 4,
4271
- new Promise(function(resolve) {
4272
- return setTimeout(resolve, backoffDelay);
4273
- })
4274
- ];
4275
- case 8:
4276
- _state.sent();
4277
- return [
4278
- 2,
4279
- "continue"
4280
- ];
4281
- case 9:
4282
- _this.consecutiveEmptyResponses = 0;
4283
- if (_this.config.debugAdTiming) {
4284
- console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
4285
- }
4286
- _this.adRequestQueue.push(newAdUrl);
4287
- _this.totalAdsInBreak++;
4288
- return [
4289
- 4,
4290
- new Promise(function(resolve) {
4291
- return setTimeout(resolve, 500);
4292
- })
4293
- ];
4294
- case 10:
4295
- _state.sent();
4296
- return [
4297
- 3,
4298
- 13
4299
- ];
4300
- case 11:
4301
- error = _state.sent();
4302
- if (_this.config.debugAdTiming) {
4303
- console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
4304
- }
4305
- _this.failedVastUrls.add(newAdUrl);
4306
- _this.consecutiveEmptyResponses++;
4307
- backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
4308
- return [
4309
- 4,
4310
- new Promise(function(resolve) {
4311
- return setTimeout(resolve, backoffDelay1);
4312
- })
4313
- ];
4314
- case 12:
4315
- _state.sent();
4316
- return [
4317
- 3,
4318
- 13
4319
- ];
4320
- case 13:
4321
- return [
4322
- 2
4323
- ];
4324
- }
4325
- });
4326
- };
4327
- _state.label = 1;
4328
- case 1:
4329
4008
  if (!(this.continuousFetchingActive && this.inAdBreak)) return [
4330
4009
  3,
4331
- 3
4010
+ 6
4332
4011
  ];
4333
- _this = this;
4012
+ remaining = this.getRemainingAdMs();
4013
+ if (remaining <= 0) {
4014
+ if (this.config.debugAdTiming) {
4015
+ console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping URL generation");
4016
+ }
4017
+ return [
4018
+ 3,
4019
+ 6
4020
+ ];
4021
+ }
4022
+ if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
4023
+ if (this.config.debugAdTiming) {
4024
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(this.maxTotalAdRequestsPerBreak, "), stopping"));
4025
+ }
4026
+ return [
4027
+ 3,
4028
+ 6
4029
+ ];
4030
+ }
4031
+ maxQueueSize = 5;
4032
+ if (!(this.adRequestQueue.length >= maxQueueSize)) return [
4033
+ 3,
4034
+ 2
4035
+ ];
4036
+ if (this.config.debugAdTiming) {
4037
+ console.log("[CONTINUOUS-FETCH] ⏸️ URL queue full (".concat(this.adRequestQueue.length, "), waiting..."));
4038
+ }
4334
4039
  return [
4335
- 5,
4336
- _ts_values(_loop())
4040
+ 4,
4041
+ new Promise(function(resolve) {
4042
+ return setTimeout(resolve, 1e3);
4043
+ })
4044
+ ];
4045
+ case 1:
4046
+ _state.sent();
4047
+ return [
4048
+ 3,
4049
+ 0
4337
4050
  ];
4338
4051
  case 2:
4339
- _ret = _state.sent();
4340
- if (_ret === "break") return [
4052
+ newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
4053
+ if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
4341
4054
  3,
4342
- 3
4055
+ 4
4343
4056
  ];
4344
4057
  return [
4345
- 3,
4346
- 1
4058
+ 4,
4059
+ new Promise(function(resolve) {
4060
+ return setTimeout(resolve, 500);
4061
+ })
4347
4062
  ];
4348
4063
  case 3:
4064
+ _state.sent();
4065
+ return [
4066
+ 3,
4067
+ 0
4068
+ ];
4069
+ case 4:
4070
+ if (this.config.debugAdTiming) {
4071
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDCDD Queued VAST URL (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
4072
+ }
4073
+ this.adRequestQueue.push(newAdUrl);
4074
+ this.totalAdsInBreak++;
4075
+ return [
4076
+ 4,
4077
+ new Promise(function(resolve) {
4078
+ return setTimeout(resolve, 300);
4079
+ })
4080
+ ];
4081
+ case 5:
4082
+ _state.sent();
4083
+ return [
4084
+ 3,
4085
+ 0
4086
+ ];
4087
+ case 6:
4349
4088
  if (this.config.debugAdTiming) {
4350
- console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Continuous fetch loop ended (total requests: ".concat(this.totalAdRequestsInBreak, ", empty responses: ").concat(this.consecutiveEmptyResponses, ")"));
4089
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"));
4351
4090
  }
4352
4091
  return [
4353
4092
  2
@@ -4396,19 +4135,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4396
4135
  2
4397
4136
  ];
4398
4137
  if (this.config.debugAdTiming) {
4399
- console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC Playing next queued ad (".concat(this.currentAdIndex + 1, "/").concat(this.totalAdsInBreak, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
4138
+ console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC Requesting next ad via IMA SDK (".concat(this.currentAdIndex + 1, "/").concat(this.totalAdsInBreak, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
4400
4139
  }
4401
4140
  currentMuted = this.video.muted;
4402
4141
  currentVolume = this.video.volume;
4403
4142
  this.ima.updateOriginalMutedState(currentMuted, currentVolume);
4404
- if (this.config.debugAdTiming) {
4405
- console.log("[CONTINUOUS-FETCH] \uD83D\uDD0A Updated ad audio state: muted=".concat(currentMuted, ", volume=").concat(currentVolume));
4406
- }
4407
4143
  this.currentAdIndex++;
4408
- this.successfulAdRequests.push(nextAdUrl);
4144
+ this.totalAdRequestsInBreak++;
4409
4145
  return [
4410
4146
  4,
4411
- this.playSingleAd(nextAdUrl).catch(function() {
4147
+ this.playSingleAd(nextAdUrl).catch(function(error) {
4148
+ if (_this.config.debugAdTiming) {
4149
+ console.log("[CONTINUOUS-FETCH] \u274C Ad request failed:", error.message);
4150
+ }
4151
+ _this.failedVastUrls.add(nextAdUrl);
4412
4152
  _this.tryNextAvailableAd(0);
4413
4153
  })
4414
4154
  ];
@@ -4418,18 +4158,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4418
4158
  2
4419
4159
  ];
4420
4160
  case 2:
4421
- maxRetries = 5;
4161
+ maxRetries = 3;
4422
4162
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
4423
4163
  3,
4424
4164
  5
4425
4165
  ];
4426
4166
  if (this.config.debugAdTiming) {
4427
- console.log("[CONTINUOUS-FETCH] ⏳ Queue empty but fetching active, waiting... (retry ".concat(retryCount + 1, "/").concat(maxRetries, ")"));
4167
+ console.log("[CONTINUOUS-FETCH] ⏳ Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
4428
4168
  }
4429
4169
  return [
4430
4170
  4,
4431
4171
  new Promise(function(resolve) {
4432
- return setTimeout(resolve, 1e3);
4172
+ return setTimeout(resolve, 500);
4433
4173
  })
4434
4174
  ];
4435
4175
  case 3:
@@ -4478,12 +4218,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4478
4218
  ];
4479
4219
  }
4480
4220
  if (this.config.debugAdTiming) {
4481
- console.log("[CONTINUOUS-FETCH] ⬛ Showing black placeholder for ".concat(waitTime, "ms while waiting for ads"));
4221
+ console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad URLs"));
4482
4222
  }
4483
4223
  this.isShowingPlaceholder = true;
4484
- this.placeholderStartTimeMs = Date.now();
4485
4224
  this.ima.showPlaceholder();
4486
- checkInterval = 500;
4225
+ checkInterval = 300;
4487
4226
  maxChecks = Math.floor(waitTime / checkInterval);
4488
4227
  i = 0;
4489
4228
  _state.label = 1;
@@ -4510,10 +4249,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4510
4249
  5
4511
4250
  ];
4512
4251
  if (this.config.debugAdTiming) {
4513
- console.log("[CONTINUOUS-FETCH] \u2705 New ad became available during placeholder");
4252
+ console.log("[CONTINUOUS-FETCH] \u2705 Ad URL available, requesting via IMA SDK");
4514
4253
  }
4515
4254
  this.isShowingPlaceholder = false;
4516
- this.placeholderStartTimeMs = null;
4517
4255
  this.ima.hidePlaceholder();
4518
4256
  currentMuted = this.video.muted;
4519
4257
  currentVolume = this.video.volume;
@@ -4524,7 +4262,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4524
4262
  4
4525
4263
  ];
4526
4264
  this.currentAdIndex++;
4527
- this.successfulAdRequests.push(nextAdUrl);
4265
+ this.totalAdRequestsInBreak++;
4528
4266
  return [
4529
4267
  4,
4530
4268
  this.playSingleAd(nextAdUrl).catch(function() {
@@ -4546,10 +4284,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4546
4284
  ];
4547
4285
  case 6:
4548
4286
  if (this.config.debugAdTiming) {
4549
- console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout reached, no ads fetched");
4287
+ console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
4550
4288
  }
4551
4289
  this.isShowingPlaceholder = false;
4552
- this.placeholderStartTimeMs = null;
4553
4290
  this.ima.hidePlaceholder();
4554
4291
  this.handleAdPodComplete();
4555
4292
  return [
@@ -4851,10 +4588,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4851
4588
  if (this.isShowingPlaceholder) {
4852
4589
  this.ima.hidePlaceholder();
4853
4590
  this.isShowingPlaceholder = false;
4854
- this.placeholderStartTimeMs = null;
4855
4591
  }
4856
4592
  this.adRequestQueue = [];
4857
- this.successfulAdRequests = [];
4858
4593
  this.inAdBreak = false;
4859
4594
  this.expectedAdBreakDurationMs = void 0;
4860
4595
  this.currentAdBreakStartWallClockMs = void 0;
@@ -5233,7 +4968,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5233
4968
  (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
5234
4969
  (_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
5235
4970
  this.adRequestQueue = [];
5236
- this.successfulAdRequests = [];
5237
4971
  }
5238
4972
  }
5239
4973
  ]);