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.cjs CHANGED
@@ -336,20 +336,6 @@ function _ts_generator(thisArg, body) {
336
336
  };
337
337
  }
338
338
  }
339
- function _ts_values(o) {
340
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
341
- if (m) return m.call(o);
342
- if (o && typeof o.length === "number") return {
343
- next: function() {
344
- if (o && i >= o.length) o = void 0;
345
- return {
346
- value: o && o[i++],
347
- done: !o
348
- };
349
- }
350
- };
351
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
352
- }
353
339
  var __create = Object.create;
354
340
  var __defProp = Object.defineProperty;
355
341
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -715,8 +701,6 @@ function createImaController(video, options) {
715
701
  var originalMutedState = false;
716
702
  var originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
717
703
  var listeners = /* @__PURE__ */ new Map();
718
- var preloadedVast = /* @__PURE__ */ new Map();
719
- var preloadingVast = /* @__PURE__ */ new Map();
720
704
  var adVideoElement;
721
705
  function setAdPlayingFlag(isPlaying) {
722
706
  if (isPlaying) {
@@ -866,15 +850,8 @@ function createImaController(video, options) {
866
850
  var adsLoadedReject;
867
851
  function makeAdsRequest(google, vastTagUrl) {
868
852
  var adsRequest = new google.ima.AdsRequest();
869
- var preloadedXml = preloadedVast.get(vastTagUrl);
870
- if (preloadedXml) {
871
- console.log("[IMA] \uD83D\uDCE6 Using preloaded VAST response");
872
- adsRequest.adsResponse = preloadedXml;
873
- preloadedVast.delete(vastTagUrl);
874
- } else {
875
- console.log("[IMA] \uD83D\uDCE1 Requesting VAST from URL (letting IMA fetch fresh)");
876
- adsRequest.adTagUrl = vastTagUrl;
877
- }
853
+ console.log("[IMA] \uD83D\uDCE1 Requesting VAST via IMA SDK:", vastTagUrl.substring(0, 80) + "...");
854
+ adsRequest.adTagUrl = vastTagUrl;
878
855
  var videoWidth = video.offsetWidth || video.clientWidth || 640;
879
856
  var videoHeight = video.offsetHeight || video.clientHeight || 480;
880
857
  adsRequest.linearAdSlotWidth = videoWidth;
@@ -922,36 +899,6 @@ function createImaController(video, options) {
922
899
  (_video_parentElement = video.parentElement) === null || _video_parentElement === void 0 ? void 0 : _video_parentElement.appendChild(container);
923
900
  adContainerEl = container;
924
901
  }
925
- function fetchVastDocument(vastTagUrl) {
926
- return _async_to_generator(function() {
927
- var response;
928
- return _ts_generator(this, function(_state) {
929
- switch(_state.label){
930
- case 0:
931
- return [
932
- 4,
933
- fetch(vastTagUrl, {
934
- mode: "cors",
935
- credentials: "include",
936
- headers: {
937
- "Accept": "application/xml, text/xml, */*"
938
- },
939
- referrerPolicy: "no-referrer-when-downgrade"
940
- })
941
- ];
942
- case 1:
943
- response = _state.sent();
944
- if (!response.ok) {
945
- throw new Error("Failed to preload VAST: ".concat(response.status));
946
- }
947
- return [
948
- 2,
949
- response.text()
950
- ];
951
- }
952
- });
953
- })();
954
- }
955
902
  function destroyAdsManager() {
956
903
  if (adsManager) {
957
904
  try {
@@ -1266,47 +1213,6 @@ function createImaController(video, options) {
1266
1213
  });
1267
1214
  })();
1268
1215
  },
1269
- preloadAds: function preloadAds(vastTagUrl) {
1270
- return _async_to_generator(function() {
1271
- var inflight, preloadPromise;
1272
- return _ts_generator(this, function(_state) {
1273
- if (!vastTagUrl || vastTagUrl.trim() === "") {
1274
- return [
1275
- 2,
1276
- Promise.resolve()
1277
- ];
1278
- }
1279
- if (preloadedVast.has(vastTagUrl)) {
1280
- return [
1281
- 2,
1282
- Promise.resolve()
1283
- ];
1284
- }
1285
- inflight = preloadingVast.get(vastTagUrl);
1286
- if (inflight) {
1287
- return [
1288
- 2,
1289
- inflight
1290
- ];
1291
- }
1292
- preloadPromise = fetchVastDocument(vastTagUrl).then(function(xml) {
1293
- preloadedVast.set(vastTagUrl, xml);
1294
- }).catch(function() {
1295
- preloadedVast.delete(vastTagUrl);
1296
- }).finally(function() {
1297
- preloadingVast.delete(vastTagUrl);
1298
- });
1299
- preloadingVast.set(vastTagUrl, preloadPromise);
1300
- return [
1301
- 2,
1302
- preloadPromise
1303
- ];
1304
- });
1305
- })();
1306
- },
1307
- hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
1308
- return preloadedVast.has(vastTagUrl);
1309
- },
1310
1216
  play: function play() {
1311
1217
  return _async_to_generator(function() {
1312
1218
  var _window_google, width, height, adVolume, _video_play;
@@ -1415,8 +1321,6 @@ function createImaController(video, options) {
1415
1321
  adDisplayContainer = void 0;
1416
1322
  adsLoader = void 0;
1417
1323
  contentVideoHidden = false;
1418
- preloadedVast.clear();
1419
- preloadingVast.clear();
1420
1324
  },
1421
1325
  isAdPlaying: function isAdPlaying() {
1422
1326
  return adPlaying;
@@ -2017,51 +1921,6 @@ function createHlsAdPlayer(contentVideo, options) {
2017
1921
  });
2018
1922
  })();
2019
1923
  },
2020
- preloadAds: function preloadAds(vastTagUrl) {
2021
- return _async_to_generator(function() {
2022
- var inflight, preloadPromise;
2023
- return _ts_generator(this, function(_state) {
2024
- if (!vastTagUrl || vastTagUrl.trim() === "") {
2025
- return [
2026
- 2,
2027
- Promise.resolve()
2028
- ];
2029
- }
2030
- if (preloadedAds.has(vastTagUrl)) {
2031
- return [
2032
- 2,
2033
- Promise.resolve()
2034
- ];
2035
- }
2036
- inflight = preloadingAds.get(vastTagUrl);
2037
- if (inflight) {
2038
- return [
2039
- 2,
2040
- inflight
2041
- ];
2042
- }
2043
- preloadPromise = fetchAndParseVastAd(vastTagUrl).then(function(ad) {
2044
- if (ad) {
2045
- preloadedAds.set(vastTagUrl, ad);
2046
- console.log("[HlsAdPlayer] Cached VAST response for preloading:", vastTagUrl);
2047
- }
2048
- }).catch(function(error) {
2049
- console.warn("[HlsAdPlayer] Failed to preload VAST response:", error);
2050
- preloadedAds.delete(vastTagUrl);
2051
- }).finally(function() {
2052
- preloadingAds.delete(vastTagUrl);
2053
- });
2054
- preloadingAds.set(vastTagUrl, preloadPromise);
2055
- return [
2056
- 2,
2057
- preloadPromise
2058
- ];
2059
- });
2060
- })();
2061
- },
2062
- hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
2063
- return preloadedAds.has(vastTagUrl);
2064
- },
2065
1924
  play: function play() {
2066
1925
  return _async_to_generator(function() {
2067
1926
  var contentVolume, adVolume, mediaFile;
@@ -2960,17 +2819,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2960
2819
  this.failedVastUrls = /* @__PURE__ */ new Set();
2961
2820
  this.continuousFetchingActive = false;
2962
2821
  this.adRequestQueue = [];
2963
- this.successfulAdRequests = [];
2964
2822
  this.maxPlaceholderDurationMs = 5e3;
2965
- this.placeholderStartTimeMs = null;
2966
2823
  this.isShowingPlaceholder = false;
2967
- this.consecutiveEmptyResponses = 0;
2968
2824
  this.totalAdRequestsInBreak = 0;
2969
- this.lastEmptyResponseTimeMs = 0;
2970
2825
  this.maxTotalAdRequestsPerBreak = 20;
2971
- this.maxConsecutiveEmptyResponses = 5;
2972
- this.baseEmptyResponseDelayMs = 2e3;
2973
- this.maxEmptyResponseDelayMs = 3e4;
2974
2826
  initializePolyfills();
2975
2827
  var browserOverrides = getBrowserConfigOverrides();
2976
2828
  this.config = _object_spread({}, config, browserOverrides);
@@ -4215,13 +4067,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4215
4067
  }
4216
4068
  this.failedVastUrls.clear();
4217
4069
  this.adRequestQueue = [];
4218
- this.successfulAdRequests = [];
4219
4070
  this.continuousFetchingActive = true;
4220
4071
  this.isShowingPlaceholder = false;
4221
- this.placeholderStartTimeMs = null;
4222
- this.consecutiveEmptyResponses = 0;
4223
4072
  this.totalAdRequestsInBreak = 0;
4224
- this.lastEmptyResponseTimeMs = 0;
4225
4073
  currentMuted = this.video.muted;
4226
4074
  currentVolume = this.video.volume;
4227
4075
  this.ima.updateOriginalMutedState(currentMuted, currentVolume);
@@ -4267,7 +4115,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4267
4115
  if (this.config.debugAdTiming) {
4268
4116
  console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
4269
4117
  }
4270
- this.successfulAdRequests.push(firstAdUrl);
4271
4118
  this.currentAdIndex++;
4272
4119
  this.startContinuousFetching(baseVastUrl);
4273
4120
  return [
@@ -4317,200 +4164,92 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4317
4164
  key: "continuousFetchLoop",
4318
4165
  value: function continuousFetchLoop(baseVastUrl) {
4319
4166
  return _async_to_generator(function() {
4320
- var _this, _loop, _ret;
4167
+ var remaining, maxQueueSize, newAdUrl;
4321
4168
  return _ts_generator(this, function(_state) {
4322
4169
  switch(_state.label){
4323
4170
  case 0:
4324
- _loop = function() {
4325
- var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
4326
- return _ts_generator(this, function(_state) {
4327
- switch(_state.label){
4328
- case 0:
4329
- remaining = _this.getRemainingAdMs();
4330
- if (remaining <= 0) {
4331
- if (_this.config.debugAdTiming) {
4332
- console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
4333
- }
4334
- return [
4335
- 2,
4336
- "break"
4337
- ];
4338
- }
4339
- if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
4340
- if (_this.config.debugAdTiming) {
4341
- console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
4342
- }
4343
- return [
4344
- 2,
4345
- "break"
4346
- ];
4347
- }
4348
- if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
4349
- if (_this.config.debugAdTiming) {
4350
- console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
4351
- }
4352
- return [
4353
- 2,
4354
- "break"
4355
- ];
4356
- }
4357
- maxQueueSize = 3;
4358
- if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
4359
- 3,
4360
- 2
4361
- ];
4362
- if (_this.config.debugAdTiming) {
4363
- console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
4364
- }
4365
- return [
4366
- 4,
4367
- new Promise(function(resolve) {
4368
- return setTimeout(resolve, 2e3);
4369
- })
4370
- ];
4371
- case 1:
4372
- _state.sent();
4373
- return [
4374
- 2,
4375
- "continue"
4376
- ];
4377
- case 2:
4378
- newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
4379
- if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
4380
- 3,
4381
- 4
4382
- ];
4383
- return [
4384
- 4,
4385
- new Promise(function(resolve) {
4386
- return setTimeout(resolve, 1e3);
4387
- })
4388
- ];
4389
- case 3:
4390
- _state.sent();
4391
- return [
4392
- 2,
4393
- "continue"
4394
- ];
4395
- case 4:
4396
- _this.totalAdRequestsInBreak++;
4397
- if (_this.config.debugAdTiming) {
4398
- console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
4399
- }
4400
- _state.label = 5;
4401
- case 5:
4402
- _state.trys.push([
4403
- 5,
4404
- 11,
4405
- ,
4406
- 13
4407
- ]);
4408
- if (!_this.ima.preloadAds) return [
4409
- 3,
4410
- 7
4411
- ];
4412
- return [
4413
- 4,
4414
- _this.ima.preloadAds(newAdUrl)
4415
- ];
4416
- case 6:
4417
- _state.sent();
4418
- _state.label = 7;
4419
- case 7:
4420
- 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;
4421
- if (!!hasPreloadedAd) return [
4422
- 3,
4423
- 9
4424
- ];
4425
- _this.consecutiveEmptyResponses++;
4426
- _this.lastEmptyResponseTimeMs = Date.now();
4427
- backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
4428
- if (_this.config.debugAdTiming) {
4429
- console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
4430
- }
4431
- _this.failedVastUrls.add(newAdUrl);
4432
- return [
4433
- 4,
4434
- new Promise(function(resolve) {
4435
- return setTimeout(resolve, backoffDelay);
4436
- })
4437
- ];
4438
- case 8:
4439
- _state.sent();
4440
- return [
4441
- 2,
4442
- "continue"
4443
- ];
4444
- case 9:
4445
- _this.consecutiveEmptyResponses = 0;
4446
- if (_this.config.debugAdTiming) {
4447
- console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
4448
- }
4449
- _this.adRequestQueue.push(newAdUrl);
4450
- _this.totalAdsInBreak++;
4451
- return [
4452
- 4,
4453
- new Promise(function(resolve) {
4454
- return setTimeout(resolve, 500);
4455
- })
4456
- ];
4457
- case 10:
4458
- _state.sent();
4459
- return [
4460
- 3,
4461
- 13
4462
- ];
4463
- case 11:
4464
- error = _state.sent();
4465
- if (_this.config.debugAdTiming) {
4466
- console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
4467
- }
4468
- _this.failedVastUrls.add(newAdUrl);
4469
- _this.consecutiveEmptyResponses++;
4470
- backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
4471
- return [
4472
- 4,
4473
- new Promise(function(resolve) {
4474
- return setTimeout(resolve, backoffDelay1);
4475
- })
4476
- ];
4477
- case 12:
4478
- _state.sent();
4479
- return [
4480
- 3,
4481
- 13
4482
- ];
4483
- case 13:
4484
- return [
4485
- 2
4486
- ];
4487
- }
4488
- });
4489
- };
4490
- _state.label = 1;
4491
- case 1:
4492
4171
  if (!(this.continuousFetchingActive && this.inAdBreak)) return [
4493
4172
  3,
4494
- 3
4173
+ 6
4495
4174
  ];
4496
- _this = this;
4175
+ remaining = this.getRemainingAdMs();
4176
+ if (remaining <= 0) {
4177
+ if (this.config.debugAdTiming) {
4178
+ console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping URL generation");
4179
+ }
4180
+ return [
4181
+ 3,
4182
+ 6
4183
+ ];
4184
+ }
4185
+ if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
4186
+ if (this.config.debugAdTiming) {
4187
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(this.maxTotalAdRequestsPerBreak, "), stopping"));
4188
+ }
4189
+ return [
4190
+ 3,
4191
+ 6
4192
+ ];
4193
+ }
4194
+ maxQueueSize = 5;
4195
+ if (!(this.adRequestQueue.length >= maxQueueSize)) return [
4196
+ 3,
4197
+ 2
4198
+ ];
4199
+ if (this.config.debugAdTiming) {
4200
+ console.log("[CONTINUOUS-FETCH] ⏸️ URL queue full (".concat(this.adRequestQueue.length, "), waiting..."));
4201
+ }
4497
4202
  return [
4498
- 5,
4499
- _ts_values(_loop())
4203
+ 4,
4204
+ new Promise(function(resolve) {
4205
+ return setTimeout(resolve, 1e3);
4206
+ })
4207
+ ];
4208
+ case 1:
4209
+ _state.sent();
4210
+ return [
4211
+ 3,
4212
+ 0
4500
4213
  ];
4501
4214
  case 2:
4502
- _ret = _state.sent();
4503
- if (_ret === "break") return [
4215
+ newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
4216
+ if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
4504
4217
  3,
4505
- 3
4218
+ 4
4506
4219
  ];
4507
4220
  return [
4508
- 3,
4509
- 1
4221
+ 4,
4222
+ new Promise(function(resolve) {
4223
+ return setTimeout(resolve, 500);
4224
+ })
4510
4225
  ];
4511
4226
  case 3:
4227
+ _state.sent();
4228
+ return [
4229
+ 3,
4230
+ 0
4231
+ ];
4232
+ case 4:
4233
+ if (this.config.debugAdTiming) {
4234
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDCDD Queued VAST URL (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
4235
+ }
4236
+ this.adRequestQueue.push(newAdUrl);
4237
+ this.totalAdsInBreak++;
4238
+ return [
4239
+ 4,
4240
+ new Promise(function(resolve) {
4241
+ return setTimeout(resolve, 300);
4242
+ })
4243
+ ];
4244
+ case 5:
4245
+ _state.sent();
4246
+ return [
4247
+ 3,
4248
+ 0
4249
+ ];
4250
+ case 6:
4512
4251
  if (this.config.debugAdTiming) {
4513
- console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Continuous fetch loop ended (total requests: ".concat(this.totalAdRequestsInBreak, ", empty responses: ").concat(this.consecutiveEmptyResponses, ")"));
4252
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"));
4514
4253
  }
4515
4254
  return [
4516
4255
  2
@@ -4559,19 +4298,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4559
4298
  2
4560
4299
  ];
4561
4300
  if (this.config.debugAdTiming) {
4562
- console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC Playing next queued ad (".concat(this.currentAdIndex + 1, "/").concat(this.totalAdsInBreak, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
4301
+ 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)"));
4563
4302
  }
4564
4303
  currentMuted = this.video.muted;
4565
4304
  currentVolume = this.video.volume;
4566
4305
  this.ima.updateOriginalMutedState(currentMuted, currentVolume);
4567
- if (this.config.debugAdTiming) {
4568
- console.log("[CONTINUOUS-FETCH] \uD83D\uDD0A Updated ad audio state: muted=".concat(currentMuted, ", volume=").concat(currentVolume));
4569
- }
4570
4306
  this.currentAdIndex++;
4571
- this.successfulAdRequests.push(nextAdUrl);
4307
+ this.totalAdRequestsInBreak++;
4572
4308
  return [
4573
4309
  4,
4574
- this.playSingleAd(nextAdUrl).catch(function() {
4310
+ this.playSingleAd(nextAdUrl).catch(function(error) {
4311
+ if (_this.config.debugAdTiming) {
4312
+ console.log("[CONTINUOUS-FETCH] \u274C Ad request failed:", error.message);
4313
+ }
4314
+ _this.failedVastUrls.add(nextAdUrl);
4575
4315
  _this.tryNextAvailableAd(0);
4576
4316
  })
4577
4317
  ];
@@ -4581,18 +4321,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4581
4321
  2
4582
4322
  ];
4583
4323
  case 2:
4584
- maxRetries = 5;
4324
+ maxRetries = 3;
4585
4325
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
4586
4326
  3,
4587
4327
  5
4588
4328
  ];
4589
4329
  if (this.config.debugAdTiming) {
4590
- console.log("[CONTINUOUS-FETCH] ⏳ Queue empty but fetching active, waiting... (retry ".concat(retryCount + 1, "/").concat(maxRetries, ")"));
4330
+ console.log("[CONTINUOUS-FETCH] ⏳ Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
4591
4331
  }
4592
4332
  return [
4593
4333
  4,
4594
4334
  new Promise(function(resolve) {
4595
- return setTimeout(resolve, 1e3);
4335
+ return setTimeout(resolve, 500);
4596
4336
  })
4597
4337
  ];
4598
4338
  case 3:
@@ -4641,12 +4381,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4641
4381
  ];
4642
4382
  }
4643
4383
  if (this.config.debugAdTiming) {
4644
- console.log("[CONTINUOUS-FETCH] ⬛ Showing black placeholder for ".concat(waitTime, "ms while waiting for ads"));
4384
+ console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad URLs"));
4645
4385
  }
4646
4386
  this.isShowingPlaceholder = true;
4647
- this.placeholderStartTimeMs = Date.now();
4648
4387
  this.ima.showPlaceholder();
4649
- checkInterval = 500;
4388
+ checkInterval = 300;
4650
4389
  maxChecks = Math.floor(waitTime / checkInterval);
4651
4390
  i = 0;
4652
4391
  _state.label = 1;
@@ -4673,10 +4412,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4673
4412
  5
4674
4413
  ];
4675
4414
  if (this.config.debugAdTiming) {
4676
- console.log("[CONTINUOUS-FETCH] \u2705 New ad became available during placeholder");
4415
+ console.log("[CONTINUOUS-FETCH] \u2705 Ad URL available, requesting via IMA SDK");
4677
4416
  }
4678
4417
  this.isShowingPlaceholder = false;
4679
- this.placeholderStartTimeMs = null;
4680
4418
  this.ima.hidePlaceholder();
4681
4419
  currentMuted = this.video.muted;
4682
4420
  currentVolume = this.video.volume;
@@ -4687,7 +4425,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4687
4425
  4
4688
4426
  ];
4689
4427
  this.currentAdIndex++;
4690
- this.successfulAdRequests.push(nextAdUrl);
4428
+ this.totalAdRequestsInBreak++;
4691
4429
  return [
4692
4430
  4,
4693
4431
  this.playSingleAd(nextAdUrl).catch(function() {
@@ -4709,10 +4447,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4709
4447
  ];
4710
4448
  case 6:
4711
4449
  if (this.config.debugAdTiming) {
4712
- console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout reached, no ads fetched");
4450
+ console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
4713
4451
  }
4714
4452
  this.isShowingPlaceholder = false;
4715
- this.placeholderStartTimeMs = null;
4716
4453
  this.ima.hidePlaceholder();
4717
4454
  this.handleAdPodComplete();
4718
4455
  return [
@@ -5014,10 +4751,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5014
4751
  if (this.isShowingPlaceholder) {
5015
4752
  this.ima.hidePlaceholder();
5016
4753
  this.isShowingPlaceholder = false;
5017
- this.placeholderStartTimeMs = null;
5018
4754
  }
5019
4755
  this.adRequestQueue = [];
5020
- this.successfulAdRequests = [];
5021
4756
  this.inAdBreak = false;
5022
4757
  this.expectedAdBreakDurationMs = void 0;
5023
4758
  this.currentAdBreakStartWallClockMs = void 0;
@@ -5396,7 +5131,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5396
5131
  (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
5397
5132
  (_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
5398
5133
  this.adRequestQueue = [];
5399
- this.successfulAdRequests = [];
5400
5134
  }
5401
5135
  }
5402
5136
  ]);