stormcloud-video-player 0.8.29 → 0.8.31

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.
Files changed (42) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/index.cjs +293 -1219
  3. package/lib/index.cjs.map +1 -1
  4. package/lib/index.d.cts +0 -3
  5. package/lib/index.d.ts +0 -3
  6. package/lib/index.js +292 -1219
  7. package/lib/index.js.map +1 -1
  8. package/lib/player/AdBreakOrchestrator.cjs +57 -490
  9. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  10. package/lib/player/AdBreakOrchestrator.d.cts +8 -7
  11. package/lib/player/AdConfigManager.cjs +12 -53
  12. package/lib/player/AdConfigManager.cjs.map +1 -1
  13. package/lib/player/AdConfigManager.d.cts +4 -5
  14. package/lib/player/AdTimingService.d.cts +1 -1
  15. package/lib/player/HlsEngine.d.cts +1 -1
  16. package/lib/player/PlayerControls.d.cts +1 -1
  17. package/lib/player/Scte35CueManager.d.cts +1 -1
  18. package/lib/player/Scte35Parser.d.cts +1 -1
  19. package/lib/player/StormcloudVideoPlayer.cjs +293 -1219
  20. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  21. package/lib/player/StormcloudVideoPlayer.d.cts +1 -3
  22. package/lib/player/playerTypes.d.cts +1 -1
  23. package/lib/players/HlsPlayer.cjs +293 -1219
  24. package/lib/players/HlsPlayer.cjs.map +1 -1
  25. package/lib/players/HlsPlayer.d.cts +1 -1
  26. package/lib/players/index.cjs +293 -1219
  27. package/lib/players/index.cjs.map +1 -1
  28. package/lib/sdk/hlsAdPlayer.cjs +49 -8
  29. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  30. package/lib/sdk/hlsAdPlayer.d.cts +1 -1
  31. package/lib/{types-Xgz2_W1C.d.cts → types-CSHvCbhZ.d.cts} +0 -1
  32. package/lib/ui/StormcloudVideoPlayer.cjs +293 -1219
  33. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  34. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
  35. package/lib/utils/tracking.d.cts +1 -1
  36. package/lib/utils/vastMacros.cjs +10 -15
  37. package/lib/utils/vastMacros.cjs.map +1 -1
  38. package/lib/utils/vastMacros.d.cts +0 -1
  39. package/package.json +1 -1
  40. package/lib/player/AdPreloadPool.cjs +0 -673
  41. package/lib/player/AdPreloadPool.cjs.map +0 -1
  42. package/lib/player/AdPreloadPool.d.cts +0 -37
@@ -725,24 +725,65 @@ function createHlsAdPlayer(contentVideo, options) {
725
725
  }
726
726
  }
727
727
  function fetchVastXml(vastTagUrl) {
728
+ var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
728
729
  return _async_to_generator(function() {
729
- var response;
730
+ var requestVast, response, error;
730
731
  return _ts_generator(this, function(_state) {
731
732
  switch(_state.label){
732
733
  case 0:
733
- return [
734
- 4,
735
- fetch(vastTagUrl, {
734
+ requestVast = function requestVast(creds) {
735
+ return fetch(vastTagUrl, {
736
736
  mode: "cors",
737
- credentials: "include",
737
+ credentials: creds,
738
738
  headers: {
739
739
  "Accept": "application/xml, text/xml, */*"
740
740
  },
741
741
  referrerPolicy: "no-referrer-when-downgrade"
742
- })
743
- ];
742
+ });
743
+ };
744
+ _state.label = 1;
744
745
  case 1:
746
+ _state.trys.push([
747
+ 1,
748
+ 3,
749
+ ,
750
+ 7
751
+ ]);
752
+ return [
753
+ 4,
754
+ requestVast(credentials)
755
+ ];
756
+ case 2:
757
+ response = _state.sent();
758
+ return [
759
+ 3,
760
+ 7
761
+ ];
762
+ case 3:
763
+ error = _state.sent();
764
+ if (!(credentials !== "omit")) return [
765
+ 3,
766
+ 5
767
+ ];
768
+ console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
769
+ return [
770
+ 4,
771
+ requestVast("omit")
772
+ ];
773
+ case 4:
745
774
  response = _state.sent();
775
+ return [
776
+ 3,
777
+ 6
778
+ ];
779
+ case 5:
780
+ throw error;
781
+ case 6:
782
+ return [
783
+ 3,
784
+ 7
785
+ ];
786
+ case 7:
746
787
  if (!response.ok) {
747
788
  throw new Error("Failed to fetch VAST: ".concat(response.statusText));
748
789
  }
@@ -764,7 +805,7 @@ function createHlsAdPlayer(contentVideo, options) {
764
805
  depth = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : 0, accumulatedTracking = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : createEmptyTrackingUrls();
765
806
  return [
766
807
  4,
767
- fetchVastXml(vastTagUrl)
808
+ fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit")
768
809
  ];
769
810
  case 1:
770
811
  vastXml = _state.sent();
@@ -3416,21 +3457,16 @@ function applyVastMacros(baseUrl, ctx) {
3416
3457
  if (ctx.pod != null) {
3417
3458
  params.set("pod", String(ctx.pod));
3418
3459
  }
3419
- var optimizedPodMode = ctx.podMaxAds != null || ctx.podMinDurationMs != null || ctx.podMaxDurationMs != null;
3420
- if (optimizedPodMode) {
3421
- params.delete("ppos");
3422
- params.delete("lip");
3423
- if (ctx.podMinDurationMs != null) {
3424
- params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3425
- }
3426
- if (ctx.podMaxDurationMs != null) {
3427
- params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3428
- }
3429
- if (ctx.podMaxAds != null) {
3430
- params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3431
- }
3432
- } else if (ctx.adPosition != null) {
3433
- params.set("ppos", String(ctx.adPosition));
3460
+ params.delete("ppos");
3461
+ params.delete("lip");
3462
+ if (ctx.podMinDurationMs != null) {
3463
+ params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3464
+ }
3465
+ if (ctx.podMaxDurationMs != null) {
3466
+ params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3467
+ }
3468
+ if (ctx.podMaxAds != null) {
3469
+ params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3434
3470
  }
3435
3471
  var requestUrl = ctx.contentUrl || ctx.pageUrl;
3436
3472
  if (requestUrl) {
@@ -4770,9 +4806,9 @@ var AdConfigManager = /*#__PURE__*/ function() {
4770
4806
  this.consentSignals = {};
4771
4807
  this.podCounter = 0;
4772
4808
  this.podAssignedByPrefetch = false;
4773
- this.adRequestPositionInBreak = 0;
4774
4809
  this.lastHeartbeatTime = 0;
4775
4810
  this.defaultPodMaxAds = 6;
4811
+ this.defaultPodMaxDurationMs = 12e4;
4776
4812
  this.config = config;
4777
4813
  this.video = video;
4778
4814
  }
@@ -5190,48 +5226,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
5190
5226
  key: "beginNewAdPod",
5191
5227
  value: function beginNewAdPod() {
5192
5228
  this.podCounter++;
5193
- this.adRequestPositionInBreak = 0;
5194
- }
5195
- },
5196
- {
5197
- key: "generateVastUrlsWithCorrelators",
5198
- value: function generateVastUrlsWithCorrelators(baseUrl, count, adPlayer, palNonce, inAdBreak) {
5199
- var urls = [];
5200
- for(var i = 0; i < count; i++){
5201
- this.adRequestPositionInBreak++;
5202
- var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
5203
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
5204
- var urlWithMacros = applyVastMacros(baseUrl, {
5205
- correlator: this.viewCorrelator,
5206
- streamCorrelator: this.streamCorrelator,
5207
- pod: this.podCounter > 0 ? this.podCounter : void 0,
5208
- adPosition: this.adRequestPositionInBreak,
5209
- isCtv: envSignals.isCtv,
5210
- contentUrl: envSignals.contentUrl,
5211
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5212
- adWillPlayMuted: adWillPlayMuted,
5213
- adWillAutoPlay: !!this.config.autoplay,
5214
- appId: envSignals.appId,
5215
- appName: envSignals.appName,
5216
- sessionId: envSignals.sessionId,
5217
- deviceId: envSignals.deviceId,
5218
- deviceIdType: envSignals.deviceIdType,
5219
- limitAdTracking: envSignals.limitAdTracking,
5220
- deviceTypeHint: envSignals.deviceTypeHint,
5221
- adTest: this.config.adTest,
5222
- consent: this.consentSignals
5223
- });
5224
- var finalUrl = palNonce.injectNonce(urlWithMacros);
5225
- console.log("[StormcloudVideoPlayer] Resolved ad request URL (pod=".concat(this.podCounter, ", pos=").concat(this.adRequestPositionInBreak, "):"), finalUrl);
5226
- urls.push(finalUrl);
5227
- }
5228
- return urls;
5229
5229
  }
5230
5230
  },
5231
5231
  {
5232
5232
  key: "resolvePodParams",
5233
5233
  value: function resolvePodParams(breakDurationMs) {
5234
- var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs;
5234
+ var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs != null && this.config.podMaxDurationMs > 0 ? this.config.podMaxDurationMs : this.defaultPodMaxDurationMs;
5235
5235
  var maxAds = this.config.podMaxAds && this.config.podMaxAds > 0 ? this.config.podMaxAds : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultPodMaxAds;
5236
5236
  var minDurationMs = this.config.podExactDuration && maxDurationMs != null ? maxDurationMs : 0;
5237
5237
  return {
@@ -5884,611 +5884,155 @@ var AdTimingService = /*#__PURE__*/ function() {
5884
5884
  ]);
5885
5885
  return AdTimingService;
5886
5886
  }();
5887
- // src/player/AdPreloadPool.ts
5888
- var AdPreloadPool = /*#__PURE__*/ function() {
5889
- function AdPreloadPool(deps) {
5890
- _class_call_check(this, AdPreloadPool);
5891
- this.pool = [];
5892
- this.maxPoolSize = 2;
5893
- this.poolActive = false;
5894
- this.loopRunning = false;
5895
- this.deps = deps;
5896
- }
5897
- _create_class(AdPreloadPool, [
5898
- {
5899
- key: "active",
5900
- get: function get() {
5901
- return this.poolActive;
5902
- },
5903
- set: function set(value) {
5904
- this.poolActive = value;
5905
- }
5906
- },
5887
+ // src/player/PlaceholderLayer.ts
5888
+ var PlaceholderLayer = /*#__PURE__*/ function() {
5889
+ function PlaceholderLayer(video, debug) {
5890
+ _class_call_check(this, PlaceholderLayer);
5891
+ this.video = video;
5892
+ this.debug = debug;
5893
+ }
5894
+ _create_class(PlaceholderLayer, [
5907
5895
  {
5908
- key: "isLoopRunning",
5909
- get: function get() {
5910
- return this.loopRunning;
5896
+ key: "ensureContainer",
5897
+ value: function ensureContainer() {
5898
+ if (this.container) {
5899
+ return;
5900
+ }
5901
+ var el = document.createElement("div");
5902
+ el.style.position = "absolute";
5903
+ el.style.left = "0";
5904
+ el.style.top = "0";
5905
+ el.style.right = "0";
5906
+ el.style.bottom = "0";
5907
+ el.style.display = "none";
5908
+ el.style.alignItems = "center";
5909
+ el.style.justifyContent = "center";
5910
+ el.style.pointerEvents = "none";
5911
+ el.style.zIndex = "5";
5912
+ el.style.backgroundColor = "#000";
5913
+ el.style.transition = "opacity 0.3s ease-in-out";
5914
+ el.style.opacity = "0";
5915
+ if (!this.video.parentElement) {
5916
+ if (this.debug) {
5917
+ console.warn("[StormcloudVideoPlayer] Video element has no parent for placeholder container");
5918
+ }
5919
+ return;
5920
+ }
5921
+ this.video.parentElement.appendChild(el);
5922
+ this.container = el;
5911
5923
  }
5912
5924
  },
5913
5925
  {
5914
- key: "startPreloadPool",
5915
- value: function startPreloadPool(baseVastUrl, initialUrls) {
5916
- var startLoopImmediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
5917
- if (this.poolActive) {
5918
- if (this.deps.debug) {
5919
- console.log("[PRELOAD-POOL] Already active, skipping duplicate start");
5920
- }
5926
+ key: "show",
5927
+ value: function show() {
5928
+ var _this = this;
5929
+ this.ensureContainer();
5930
+ if (!this.container) {
5921
5931
  return;
5922
5932
  }
5923
- this.poolActive = true;
5924
- if (this.deps.debug) {
5925
- console.log("[PRELOAD-POOL] Starting preload pool EARLY (target size: ".concat(this.maxPoolSize, ")"));
5926
- console.log("[PRELOAD-POOL] Ad break hasn't started yet, but preloading ads in advance");
5927
- }
5928
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5929
- try {
5930
- for(var _iterator = initialUrls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5931
- var url = _step.value;
5932
- if (this.pool.length < this.maxPoolSize) {
5933
- this.preloadAdIntoPool(url);
5934
- }
5933
+ if (!this.video.muted) {
5934
+ this.video.muted = true;
5935
+ if (this.debug) {
5936
+ console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
5935
5937
  }
5936
- } catch (err) {
5937
- _didIteratorError = true;
5938
- _iteratorError = err;
5939
- } finally{
5940
- try {
5941
- if (!_iteratorNormalCompletion && _iterator.return != null) {
5942
- _iterator.return();
5943
- }
5944
- } finally{
5945
- if (_didIteratorError) {
5946
- throw _iteratorError;
5938
+ }
5939
+ var wasHidden = this.container.style.display === "none" || this.container.style.opacity === "0";
5940
+ if (wasHidden) {
5941
+ this.container.style.transition = "none";
5942
+ } else {
5943
+ this.container.style.transition = "opacity 0.3s ease-in-out";
5944
+ }
5945
+ this.container.style.backgroundColor = "#000";
5946
+ this.container.style.display = "flex";
5947
+ this.container.offsetHeight;
5948
+ this.container.style.opacity = "1";
5949
+ this.container.style.pointerEvents = "auto";
5950
+ if (wasHidden) {
5951
+ requestAnimationFrame(function() {
5952
+ if (_this.container) {
5953
+ _this.container.style.transition = "opacity 0.3s ease-in-out";
5947
5954
  }
5955
+ });
5956
+ }
5957
+ if (this.debug) {
5958
+ console.log("[StormcloudVideoPlayer] Showing placeholder layer (between content and ad layer)");
5959
+ }
5960
+ }
5961
+ },
5962
+ {
5963
+ key: "hide",
5964
+ value: function hide() {
5965
+ var _this = this;
5966
+ if (!this.container) {
5967
+ return;
5968
+ }
5969
+ this.container.style.opacity = "0";
5970
+ setTimeout(function() {
5971
+ if (_this.container) {
5972
+ _this.container.style.display = "none";
5973
+ _this.container.style.pointerEvents = "none";
5974
+ _this.container.style.backgroundColor = "#000";
5948
5975
  }
5976
+ }, 300);
5977
+ if (this.debug) {
5978
+ console.log("[StormcloudVideoPlayer] Hiding placeholder layer");
5949
5979
  }
5950
- if (startLoopImmediately) {
5951
- this.preloadPoolLoop(baseVastUrl);
5952
- } else if (this.deps.debug) {
5953
- console.log("[PRELOAD-POOL] Pre-break mode: preloaded once, waiting for SCTE start to continue fetching");
5980
+ }
5981
+ },
5982
+ {
5983
+ key: "destroy",
5984
+ value: function destroy() {
5985
+ if (this.container) {
5986
+ if (this.container.parentElement) {
5987
+ this.container.parentElement.removeChild(this.container);
5988
+ }
5989
+ this.container = void 0;
5954
5990
  }
5955
5991
  }
5992
+ }
5993
+ ]);
5994
+ return PlaceholderLayer;
5995
+ }();
5996
+ // src/player/HlsEngine.ts
5997
+ var import_hls2 = __toESM(require("hls.js"), 1);
5998
+ var HlsEngine = /*#__PURE__*/ function() {
5999
+ function HlsEngine(config, video, cueManager, timing, callbacks) {
6000
+ _class_call_check(this, HlsEngine);
6001
+ this.isLiveStream = false;
6002
+ this.nativeHlsMode = false;
6003
+ this.videoSrcProtection = null;
6004
+ this.bufferedSegmentsCount = 0;
6005
+ this.shouldAutoplayAfterBuffering = false;
6006
+ this.hasInitialBufferCompleted = false;
6007
+ this.config = config;
6008
+ this.video = video;
6009
+ this.cueManager = cueManager;
6010
+ this.timing = timing;
6011
+ this.callbacks = callbacks;
6012
+ }
6013
+ _create_class(HlsEngine, [
6014
+ {
6015
+ key: "debug",
6016
+ get: function get() {
6017
+ return !!this.config.debugAdTiming;
6018
+ }
5956
6019
  },
5957
6020
  {
5958
- key: "preloadAdIntoPool",
5959
- value: function preloadAdIntoPool(vastUrl) {
5960
- return _async_to_generator(function() {
5961
- var _this, timing, epoch, loadPromise;
5962
- return _ts_generator(this, function(_state) {
5963
- _this = this;
5964
- timing = this.deps.timing;
5965
- if (timing.isGamInCooldown()) {
5966
- if (this.deps.debug) {
5967
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
5968
- }
5969
- return [
5970
- 2
5971
- ];
5972
- }
5973
- if (this.pool.some(function(entry) {
5974
- return entry.vastUrl === vastUrl;
5975
- }) || timing.failedVastUrls.has(vastUrl) || timing.isUrlInCooldown(vastUrl)) {
5976
- return [
5977
- 2
5978
- ];
5979
- }
5980
- if (this.pool.length >= this.maxPoolSize) {
5981
- return [
5982
- 2
5983
- ];
5984
- }
5985
- if (this.deps.debug) {
5986
- console.log("[PRELOAD-POOL] Preloading ad into pool: ".concat(vastUrl));
5987
- }
5988
- epoch = timing.adBreakEpoch;
5989
- loadPromise = function() {
5990
- return _async_to_generator(function() {
5991
- var _this, hasAdError, adErrorPayload, errorListenerCleanup, _preloadAd_getLoadedAdDuration, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, loadedDuration, lateErrorListener, _poolEntry_durationSeconds, error;
5992
- return _ts_generator(this, function(_state) {
5993
- switch(_state.label){
5994
- case 0:
5995
- _this = this;
5996
- hasAdError = false;
5997
- adErrorPayload = null;
5998
- errorListenerCleanup = null;
5999
- _state.label = 1;
6000
- case 1:
6001
- _state.trys.push([
6002
- 1,
6003
- 5,
6004
- ,
6005
- 6
6006
- ]);
6007
- continueLiveStreamDuringAds = this.deps.shouldContinueLiveStreamDuringAds();
6008
- preloadAd = this.deps.createAdPlayer(continueLiveStreamDuringAds);
6009
- preloadAd.initialize();
6010
- errorListener = function errorListener(payload) {
6011
- hasAdError = true;
6012
- adErrorPayload = payload;
6013
- };
6014
- preloadAd.on("ad_error", errorListener);
6015
- errorListenerCleanup = function errorListenerCleanup() {
6016
- return preloadAd.off("ad_error", errorListener);
6017
- };
6018
- return [
6019
- 4,
6020
- timing.enforceGlobalRateLimit()
6021
- ];
6022
- case 2:
6023
- _state.sent();
6024
- return [
6025
- 4,
6026
- preloadAd.requestAds(vastUrl)
6027
- ];
6028
- case 3:
6029
- _state.sent();
6030
- preloadAd.pause();
6031
- return [
6032
- 4,
6033
- new Promise(function(resolve) {
6034
- return setTimeout(resolve, 1500);
6035
- })
6036
- ];
6037
- case 4:
6038
- _state.sent();
6039
- preloadAd.pause();
6040
- if (hasAdError) {
6041
- isNoFill = (adErrorPayload === null || adErrorPayload === void 0 ? void 0 : adErrorPayload.isNoFill) || (adErrorPayload === null || adErrorPayload === void 0 ? void 0 : adErrorPayload.code) === 303 || (adErrorPayload === null || adErrorPayload === void 0 ? void 0 : adErrorPayload.vastErrorCode) === 303;
6042
- if (errorListenerCleanup) {
6043
- errorListenerCleanup();
6044
- }
6045
- preloadAd.destroy();
6046
- timing.recordGamNoFill();
6047
- if (isNoFill) {
6048
- if (this.deps.debug) {
6049
- console.log("[PRELOAD-POOL] Ad preload returned no-fill: ".concat(vastUrl));
6050
- }
6051
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6052
- } else {
6053
- if (this.deps.debug) {
6054
- console.log("[PRELOAD-POOL] Ad preload failed with error: ".concat(vastUrl), adErrorPayload);
6055
- }
6056
- if (adErrorPayload && !timing.isTemporaryAdError(adErrorPayload)) {
6057
- timing.failedVastUrls.add(vastUrl);
6058
- } else {
6059
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6060
- }
6061
- }
6062
- return [
6063
- 2
6064
- ];
6065
- }
6066
- if (!this.poolActive || epoch !== timing.adBreakEpoch) {
6067
- if (this.deps.debug) {
6068
- console.log("[PRELOAD-POOL] Discarding preloaded ad - break ended during fetch");
6069
- }
6070
- if (errorListenerCleanup) {
6071
- errorListenerCleanup();
6072
- }
6073
- try {
6074
- preloadAd.destroy();
6075
- } catch (unused) {}
6076
- return [
6077
- 2
6078
- ];
6079
- }
6080
- poolEntry = {
6081
- vastUrl: vastUrl,
6082
- adController: preloadAd,
6083
- loadedAt: Date.now(),
6084
- isReady: true,
6085
- loadPromise: Promise.resolve()
6086
- };
6087
- loadedDuration = (_preloadAd_getLoadedAdDuration = preloadAd.getLoadedAdDuration) === null || _preloadAd_getLoadedAdDuration === void 0 ? void 0 : _preloadAd_getLoadedAdDuration.call(preloadAd);
6088
- if (loadedDuration != null && loadedDuration > 0) {
6089
- poolEntry.durationSeconds = loadedDuration;
6090
- }
6091
- lateErrorListener = function lateErrorListener(payload) {
6092
- var index = _this.pool.findIndex(function(entry) {
6093
- return entry.vastUrl === vastUrl;
6094
- });
6095
- if (index >= 0) {
6096
- _this.pool.splice(index, 1);
6097
- if (_this.deps.debug) {
6098
- console.log("[PRELOAD-POOL] Late error detected, removed from pool: ".concat(vastUrl), payload);
6099
- }
6100
- try {
6101
- preloadAd.destroy();
6102
- } catch (unused) {}
6103
- }
6104
- };
6105
- preloadAd.on("ad_error", lateErrorListener);
6106
- this.pool.push(poolEntry);
6107
- if (this.deps.debug) {
6108
- ;
6109
- console.log("[PRELOAD-POOL] Ad preloaded (no errors detected within timeout) (pool size: ".concat(this.pool.length, "/").concat(this.maxPoolSize, ", duration=").concat((_poolEntry_durationSeconds = poolEntry.durationSeconds) !== null && _poolEntry_durationSeconds !== void 0 ? _poolEntry_durationSeconds : "?", "s)"));
6110
- }
6111
- if (errorListenerCleanup) {
6112
- errorListenerCleanup();
6113
- }
6114
- return [
6115
- 3,
6116
- 6
6117
- ];
6118
- case 5:
6119
- error = _state.sent();
6120
- if (errorListenerCleanup) {
6121
- errorListenerCleanup();
6122
- }
6123
- timing.recordGamNoFill();
6124
- if (this.deps.debug) {
6125
- console.warn("[PRELOAD-POOL] Failed to preload ad: ".concat(vastUrl), error);
6126
- }
6127
- if (_instanceof(error, Error) && !timing.isTemporaryAdError(error)) {
6128
- timing.failedVastUrls.add(vastUrl);
6129
- } else if (_instanceof(error, Error) && timing.isTemporaryAdError(error)) {
6130
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6131
- }
6132
- return [
6133
- 3,
6134
- 6
6135
- ];
6136
- case 6:
6137
- return [
6138
- 2
6139
- ];
6140
- }
6141
- });
6142
- }).call(_this);
6143
- }();
6144
- loadPromise.catch(function() {});
6145
- return [
6146
- 2
6147
- ];
6148
- });
6149
- }).call(this);
6021
+ key: "shouldUseNativeHls",
6022
+ value: function shouldUseNativeHls(getStreamType) {
6023
+ var streamType = getStreamType();
6024
+ if (streamType === "other") {
6025
+ return true;
6026
+ }
6027
+ var canNative = this.video.canPlayType("application/vnd.apple.mpegurl");
6028
+ return !!(this.config.allowNativeHls && canNative);
6150
6029
  }
6151
6030
  },
6152
6031
  {
6153
- key: "preloadPoolLoop",
6154
- value: function preloadPoolLoop(baseVastUrl) {
6032
+ key: "setupNativeHls",
6033
+ value: function setupNativeHls() {
6155
6034
  return _async_to_generator(function() {
6156
- var epoch, newUrls, newUrl;
6157
- return _ts_generator(this, function(_state) {
6158
- switch(_state.label){
6159
- case 0:
6160
- if (this.loopRunning) {
6161
- return [
6162
- 2
6163
- ];
6164
- }
6165
- this.loopRunning = true;
6166
- epoch = this.deps.timing.adBreakEpoch;
6167
- if (this.deps.debug) {
6168
- console.log("[PRELOAD-POOL] Starting continuous preload loop");
6169
- }
6170
- _state.label = 1;
6171
- case 1:
6172
- if (!(this.poolActive && epoch === this.deps.timing.adBreakEpoch)) return [
6173
- 3,
6174
- 10
6175
- ];
6176
- if (this.deps.timing.isGamInCooldown()) {
6177
- if (this.deps.debug) {
6178
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
6179
- }
6180
- return [
6181
- 3,
6182
- 10
6183
- ];
6184
- }
6185
- if (!(!this.deps.isInAdBreak() && this.pool.length >= this.maxPoolSize)) return [
6186
- 3,
6187
- 3
6188
- ];
6189
- return [
6190
- 4,
6191
- new Promise(function(resolve) {
6192
- return setTimeout(resolve, 2e3);
6193
- })
6194
- ];
6195
- case 2:
6196
- _state.sent();
6197
- return [
6198
- 3,
6199
- 1
6200
- ];
6201
- case 3:
6202
- if (!this.deps.isInAdBreak() && this.deps.getPendingAdBreak() === null) {
6203
- if (this.deps.debug) {
6204
- console.log("[PRELOAD-POOL] Ad break cancelled, stopping preload pool");
6205
- }
6206
- return [
6207
- 3,
6208
- 10
6209
- ];
6210
- }
6211
- _state.label = 4;
6212
- case 4:
6213
- if (!(this.pool.length < this.maxPoolSize)) return [
6214
- 3,
6215
- 8
6216
- ];
6217
- if (!this.poolActive || epoch !== this.deps.timing.adBreakEpoch || this.deps.timing.isGamInCooldown()) {
6218
- return [
6219
- 3,
6220
- 8
6221
- ];
6222
- }
6223
- if (this.deps.isInAdBreak() && !this.deps.timing.hasTimeToStartAnotherAd()) {
6224
- if (this.deps.debug) {
6225
- console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
6226
- }
6227
- return [
6228
- 3,
6229
- 8
6230
- ];
6231
- }
6232
- newUrls = this.deps.generateVastUrlsWithCorrelators(baseVastUrl, 1);
6233
- newUrl = newUrls[0];
6234
- if (!(newUrl && !this.deps.timing.failedVastUrls.has(newUrl) && !this.deps.timing.isUrlInCooldown(newUrl))) return [
6235
- 3,
6236
- 6
6237
- ];
6238
- return [
6239
- 4,
6240
- this.preloadAdIntoPool(newUrl)
6241
- ];
6242
- case 5:
6243
- _state.sent();
6244
- _state.label = 6;
6245
- case 6:
6246
- return [
6247
- 4,
6248
- new Promise(function(resolve) {
6249
- return setTimeout(resolve, 1e3);
6250
- })
6251
- ];
6252
- case 7:
6253
- _state.sent();
6254
- return [
6255
- 3,
6256
- 4
6257
- ];
6258
- case 8:
6259
- return [
6260
- 4,
6261
- new Promise(function(resolve) {
6262
- return setTimeout(resolve, 2e3);
6263
- })
6264
- ];
6265
- case 9:
6266
- _state.sent();
6267
- return [
6268
- 3,
6269
- 1
6270
- ];
6271
- case 10:
6272
- this.loopRunning = false;
6273
- if (this.deps.debug) {
6274
- console.log("[PRELOAD-POOL] Preload loop ended");
6275
- }
6276
- return [
6277
- 2
6278
- ];
6279
- }
6280
- });
6281
- }).call(this);
6282
- }
6283
- },
6284
- {
6285
- key: "getPreloadedAd",
6286
- value: function getPreloadedAd() {
6287
- if (this.pool.length === 0) {
6288
- return null;
6289
- }
6290
- var entry = this.pool.shift();
6291
- if (!entry || !entry.isReady) {
6292
- return null;
6293
- }
6294
- if (this.deps.debug) {
6295
- console.log("[PRELOAD-POOL] Using preloaded ad from pool (".concat(this.pool.length, " remaining)"));
6296
- }
6297
- return {
6298
- vastUrl: entry.vastUrl,
6299
- adController: entry.adController
6300
- };
6301
- }
6302
- },
6303
- {
6304
- key: "stop",
6305
- value: function stop() {
6306
- this.poolActive = false;
6307
- this.loopRunning = false;
6308
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6309
- try {
6310
- for(var _iterator = this.pool[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6311
- var entry = _step.value;
6312
- try {
6313
- entry.adController.destroy();
6314
- } catch (error) {
6315
- if (this.deps.debug) {
6316
- console.warn("[PRELOAD-POOL] Error destroying preloaded controller:", error);
6317
- }
6318
- }
6319
- }
6320
- } catch (err) {
6321
- _didIteratorError = true;
6322
- _iteratorError = err;
6323
- } finally{
6324
- try {
6325
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6326
- _iterator.return();
6327
- }
6328
- } finally{
6329
- if (_didIteratorError) {
6330
- throw _iteratorError;
6331
- }
6332
- }
6333
- }
6334
- this.pool = [];
6335
- if (this.deps.debug) {
6336
- console.log("[PRELOAD-POOL] Preload pool stopped and cleaned up");
6337
- }
6338
- }
6339
- }
6340
- ]);
6341
- return AdPreloadPool;
6342
- }();
6343
- // src/player/PlaceholderLayer.ts
6344
- var PlaceholderLayer = /*#__PURE__*/ function() {
6345
- function PlaceholderLayer(video, debug) {
6346
- _class_call_check(this, PlaceholderLayer);
6347
- this.video = video;
6348
- this.debug = debug;
6349
- }
6350
- _create_class(PlaceholderLayer, [
6351
- {
6352
- key: "ensureContainer",
6353
- value: function ensureContainer() {
6354
- if (this.container) {
6355
- return;
6356
- }
6357
- var el = document.createElement("div");
6358
- el.style.position = "absolute";
6359
- el.style.left = "0";
6360
- el.style.top = "0";
6361
- el.style.right = "0";
6362
- el.style.bottom = "0";
6363
- el.style.display = "none";
6364
- el.style.alignItems = "center";
6365
- el.style.justifyContent = "center";
6366
- el.style.pointerEvents = "none";
6367
- el.style.zIndex = "5";
6368
- el.style.backgroundColor = "#000";
6369
- el.style.transition = "opacity 0.3s ease-in-out";
6370
- el.style.opacity = "0";
6371
- if (!this.video.parentElement) {
6372
- if (this.debug) {
6373
- console.warn("[StormcloudVideoPlayer] Video element has no parent for placeholder container");
6374
- }
6375
- return;
6376
- }
6377
- this.video.parentElement.appendChild(el);
6378
- this.container = el;
6379
- }
6380
- },
6381
- {
6382
- key: "show",
6383
- value: function show() {
6384
- var _this = this;
6385
- this.ensureContainer();
6386
- if (!this.container) {
6387
- return;
6388
- }
6389
- if (!this.video.muted) {
6390
- this.video.muted = true;
6391
- if (this.debug) {
6392
- console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
6393
- }
6394
- }
6395
- var wasHidden = this.container.style.display === "none" || this.container.style.opacity === "0";
6396
- if (wasHidden) {
6397
- this.container.style.transition = "none";
6398
- } else {
6399
- this.container.style.transition = "opacity 0.3s ease-in-out";
6400
- }
6401
- this.container.style.backgroundColor = "#000";
6402
- this.container.style.display = "flex";
6403
- this.container.offsetHeight;
6404
- this.container.style.opacity = "1";
6405
- this.container.style.pointerEvents = "auto";
6406
- if (wasHidden) {
6407
- requestAnimationFrame(function() {
6408
- if (_this.container) {
6409
- _this.container.style.transition = "opacity 0.3s ease-in-out";
6410
- }
6411
- });
6412
- }
6413
- if (this.debug) {
6414
- console.log("[StormcloudVideoPlayer] Showing placeholder layer (between content and ad layer)");
6415
- }
6416
- }
6417
- },
6418
- {
6419
- key: "hide",
6420
- value: function hide() {
6421
- var _this = this;
6422
- if (!this.container) {
6423
- return;
6424
- }
6425
- this.container.style.opacity = "0";
6426
- setTimeout(function() {
6427
- if (_this.container) {
6428
- _this.container.style.display = "none";
6429
- _this.container.style.pointerEvents = "none";
6430
- _this.container.style.backgroundColor = "#000";
6431
- }
6432
- }, 300);
6433
- if (this.debug) {
6434
- console.log("[StormcloudVideoPlayer] Hiding placeholder layer");
6435
- }
6436
- }
6437
- },
6438
- {
6439
- key: "destroy",
6440
- value: function destroy() {
6441
- if (this.container) {
6442
- if (this.container.parentElement) {
6443
- this.container.parentElement.removeChild(this.container);
6444
- }
6445
- this.container = void 0;
6446
- }
6447
- }
6448
- }
6449
- ]);
6450
- return PlaceholderLayer;
6451
- }();
6452
- // src/player/HlsEngine.ts
6453
- var import_hls2 = __toESM(require("hls.js"), 1);
6454
- var HlsEngine = /*#__PURE__*/ function() {
6455
- function HlsEngine(config, video, cueManager, timing, callbacks) {
6456
- _class_call_check(this, HlsEngine);
6457
- this.isLiveStream = false;
6458
- this.nativeHlsMode = false;
6459
- this.videoSrcProtection = null;
6460
- this.bufferedSegmentsCount = 0;
6461
- this.shouldAutoplayAfterBuffering = false;
6462
- this.hasInitialBufferCompleted = false;
6463
- this.config = config;
6464
- this.video = video;
6465
- this.cueManager = cueManager;
6466
- this.timing = timing;
6467
- this.callbacks = callbacks;
6468
- }
6469
- _create_class(HlsEngine, [
6470
- {
6471
- key: "debug",
6472
- get: function get() {
6473
- return !!this.config.debugAdTiming;
6474
- }
6475
- },
6476
- {
6477
- key: "shouldUseNativeHls",
6478
- value: function shouldUseNativeHls(getStreamType) {
6479
- var streamType = getStreamType();
6480
- if (streamType === "other") {
6481
- return true;
6482
- }
6483
- var canNative = this.video.canPlayType("application/vnd.apple.mpegurl");
6484
- return !!(this.config.allowNativeHls && canNative);
6485
- }
6486
- },
6487
- {
6488
- key: "setupNativeHls",
6489
- value: function setupNativeHls() {
6490
- return _async_to_generator(function() {
6491
- var _this_config_isLiveStream, _this_config_lowLatencyMode, adBehavior, _this_video_play;
6035
+ var _this_config_isLiveStream, _this_config_lowLatencyMode, adBehavior, _this_video_play;
6492
6036
  return _ts_generator(this, function(_state) {
6493
6037
  switch(_state.label){
6494
6038
  case 0:
@@ -7061,7 +6605,7 @@ function resizePlayer(video, adPlayer, debug) {
7061
6605
  }
7062
6606
  // src/player/AdBreakOrchestrator.ts
7063
6607
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
7064
- function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6608
+ function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
7065
6609
  _class_call_check(this, AdBreakOrchestrator);
7066
6610
  this.inAdBreak = false;
7067
6611
  this.showAds = false;
@@ -7075,7 +6619,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7075
6619
  this.pendingAdBreak = null;
7076
6620
  this.host = host;
7077
6621
  this.timing = timing;
7078
- this.preloadPool = preloadPool;
7079
6622
  this.adConfig = adConfig;
7080
6623
  this.cueManager = cueManager;
7081
6624
  this.placeholder = placeholder;
@@ -7094,23 +6637,19 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7094
6637
  }
7095
6638
  },
7096
6639
  {
7097
- key: "optimizedPodsEnabled",
7098
- get: // ───────────────────────────────────────────────────────────────
6640
+ // ───────────────────────────────────────────────────────────────
7099
6641
  // IMA event listeners
7100
6642
  // ───────────────────────────────────────────────────────────────
7101
- function get() {
7102
- return this.host.config.optimizedPods !== false;
7103
- }
7104
- },
7105
- {
7106
- key: "nextAdRequestUrl",
6643
+ /**
6644
+ * Produces the next pod ad-request URL for the current break. Every request
6645
+ * (initial and continuous-fetch top-up) carries pod macros (pmad/pmnd/pmxd,
6646
+ * no ppos); pmxd tracks the remaining break time so top-up pods only ask for
6647
+ * what still fits.
6648
+ */ key: "nextAdRequestUrl",
7107
6649
  value: function nextAdRequestUrl(baseVastUrl) {
7108
- if (this.optimizedPodsEnabled) {
7109
- var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
7110
- var breakDurationMs = remaining > 0 ? remaining : void 0;
7111
- return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7112
- }
7113
- return this.host.generateVastUrls(baseVastUrl, 1)[0];
6650
+ var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
6651
+ var breakDurationMs = remaining > 0 ? remaining : void 0;
6652
+ return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7114
6653
  }
7115
6654
  },
7116
6655
  {
@@ -7282,340 +6821,76 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7282
6821
  // ───────────────────────────────────────────────────────────────
7283
6822
  function handleAdStart(_marker) {
7284
6823
  return _async_to_generator(function() {
7285
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed, firstAdUrl, usePreloadedAd, preloadedController, preloaded, adPlayer, preservedMuted, preservedVolume, adVolume, adPlayer1, adVolume1, error, fallbackPreloaded, ap, adVolume2, fallbackError;
6824
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7286
6825
  return _ts_generator(this, function(_state) {
7287
6826
  switch(_state.label){
7288
6827
  case 0:
7289
6828
  scheduled = this.adConfig.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
7290
6829
  if (scheduled) {
7291
- this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
7292
- }
7293
- tags = this.adConfig.selectVastTagsForBreak(scheduled);
7294
- if (tags && tags.length > 0 && tags[0]) {
7295
- baseVastUrl = tags[0];
7296
- } else if (this.adConfig.apiVastTagUrl) {
7297
- baseVastUrl = this.adConfig.apiVastTagUrl;
7298
- } else {
7299
- this.clearPendingAdBreak();
7300
- return [
7301
- 2
7302
- ];
7303
- }
7304
- adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
7305
- if (this.debug) {
7306
- mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
7307
- console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
7308
- }
7309
- this.timing.failedVastUrls.clear();
7310
- this.timing.temporaryFailureUrls.clear();
7311
- this.timing.consecutiveFailures = 0;
7312
- this.continuousFetchingActive = true;
7313
- this.isShowingPlaceholder = false;
7314
- this.timing.totalAdRequestsInBreak = 0;
7315
- if (this.adConfig.podAssignedByPrefetch) {
7316
- this.adConfig.podAssignedByPrefetch = false;
7317
- } else {
7318
- this.adConfig.beginNewAdPod();
7319
- }
7320
- currentMuted = this.host.video.muted;
7321
- currentVolume = this.host.video.volume;
7322
- this.host.getAdPlayer().updateOriginalMutedState(currentMuted, currentVolume);
7323
- this.inAdBreak = true;
7324
- this.timing.adBreakPlayedDurationMs = 0;
7325
- this.timing.currentAdIndex = 0;
7326
- this.timing.totalAdsInBreak = 0;
7327
- this.adPodQueue = [];
7328
- this.showAds = false;
7329
- if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7330
- this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7331
- }
7332
- if (!this.optimizedPodsEnabled) return [
7333
- 3,
7334
- 2
7335
- ];
7336
- return [
7337
- 4,
7338
- this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7339
- ];
7340
- case 1:
7341
- podPlayed = _state.sent();
7342
- if (podPlayed) {
7343
- return [
7344
- 2
7345
- ];
7346
- }
7347
- if (this.debug) {
7348
- console.log("[POD] Optimized pod unavailable, falling back to sequential single-ad path");
7349
- }
7350
- _state.label = 2;
7351
- case 2:
7352
- usePreloadedAd = false;
7353
- preloaded = this.preloadPool.getPreloadedAd();
7354
- if (preloaded) {
7355
- firstAdUrl = preloaded.vastUrl;
7356
- preloadedController = preloaded.adController;
7357
- usePreloadedAd = true;
7358
- sendAdLoadedTracking(this.host.config.licenseKey, {
7359
- source: "hls",
7360
- vastUrl: firstAdUrl,
7361
- timestamp: /* @__PURE__ */ new Date().toISOString()
7362
- }, this.analyticsContext).catch(function() {});
7363
- if (this.debug) {
7364
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7365
- }
7366
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7367
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7368
- firstAdUrl = this.adRequestQueue.shift();
7369
- if (this.debug) {
7370
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7371
- }
7372
- this.clearPendingAdBreak();
7373
- } else {
7374
- if (this.debug) {
7375
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7376
- }
7377
- firstAdUrl = this.nextAdRequestUrl(baseVastUrl);
7378
- this.adRequestQueue = [];
7379
- }
7380
- if (!firstAdUrl) {
7381
- if (this.debug) {
7382
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7383
- }
7384
- this.handleAdPodComplete();
7385
- return [
7386
- 2
7387
- ];
7388
- }
7389
- if (this.debug) {
7390
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7391
- }
7392
- _state.label = 3;
7393
- case 3:
7394
- _state.trys.push([
7395
- 3,
7396
- 14,
7397
- ,
7398
- 22
7399
- ]);
7400
- if (!(usePreloadedAd && preloadedController)) return [
7401
- 3,
7402
- 7
7403
- ];
7404
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7405
- 3,
7406
- 5
7407
- ];
7408
- this.timing.rejectLoadedAdForDuration(preloadedController);
7409
- this.startContinuousFetching(baseVastUrl);
7410
- return [
7411
- 4,
7412
- this.tryNextAvailableAdWithRateLimit()
7413
- ];
7414
- case 4:
7415
- _state.sent();
7416
- return [
7417
- 2
7418
- ];
7419
- case 5:
7420
- adPlayer = this.host.getAdPlayer();
7421
- preservedMuted = adPlayer.getOriginalMutedState();
7422
- preservedVolume = adPlayer.getOriginalVolume();
7423
- adPlayer.destroy();
7424
- this.host.video.muted = true;
7425
- this.host.setAdPlayer(preloadedController);
7426
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7427
- this.attachImaEventListeners();
7428
- if (this.debug) {
7429
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7430
- }
7431
- preloadedController.resume();
7432
- this.timing.consecutiveFailures = 0;
7433
- this.startContinuousFetching(baseVastUrl);
7434
- if (!this.optimizedPodsEnabled) {
7435
- if (!this.preloadPool.active) {
7436
- this.preloadPool.active = true;
7437
- }
7438
- if (!this.preloadPool.isLoopRunning) {
7439
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7440
- }
7441
- }
7442
- return [
7443
- 4,
7444
- preloadedController.play()
7445
- ];
7446
- case 6:
7447
- _state.sent();
7448
- this.timing.markAdStarted();
7449
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7450
- this.timing.scheduleAdStopAtBreakBoundary();
7451
- }
7452
- adVolume = currentMuted ? 0 : currentVolume;
7453
- preloadedController.setAdVolume(adVolume);
7454
- return [
7455
- 3,
7456
- 13
7457
- ];
7458
- case 7:
7459
- adPlayer1 = this.host.getAdPlayer();
7460
- return [
7461
- 4,
7462
- this.timing.enforceGlobalRateLimit()
7463
- ];
7464
- case 8:
7465
- _state.sent();
7466
- this.timing.lastAdRequestTime = Date.now();
7467
- return [
7468
- 4,
7469
- adPlayer1.requestAds(firstAdUrl)
7470
- ];
7471
- case 9:
7472
- _state.sent();
7473
- sendAdLoadedTracking(this.host.config.licenseKey, {
7474
- source: "hls",
7475
- vastUrl: firstAdUrl,
7476
- timestamp: /* @__PURE__ */ new Date().toISOString()
7477
- }, this.analyticsContext).catch(function() {});
7478
- if (this.debug) {
7479
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7480
- }
7481
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7482
- 3,
7483
- 11
7484
- ];
7485
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7486
- this.recreateAdController();
7487
- this.startContinuousFetching(baseVastUrl);
7488
- return [
7489
- 4,
7490
- this.tryNextAvailableAdWithRateLimit()
7491
- ];
7492
- case 10:
7493
- _state.sent();
7494
- return [
7495
- 2
7496
- ];
7497
- case 11:
7498
- this.timing.consecutiveFailures = 0;
7499
- this.startContinuousFetching(baseVastUrl);
7500
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7501
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7502
- }
7503
- return [
7504
- 4,
7505
- adPlayer1.play()
7506
- ];
7507
- case 12:
7508
- _state.sent();
7509
- this.timing.markAdStarted();
7510
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7511
- this.timing.scheduleAdStopAtBreakBoundary();
7512
- }
7513
- adVolume1 = currentMuted ? 0 : currentVolume;
7514
- adPlayer1.setAdVolume(adVolume1);
7515
- _state.label = 13;
7516
- case 13:
7517
- return [
7518
- 3,
7519
- 22
7520
- ];
7521
- case 14:
7522
- error = _state.sent();
7523
- if (this.debug) {
7524
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
6830
+ this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
7525
6831
  }
7526
- if (!!usePreloadedAd) return [
7527
- 3,
7528
- 20
7529
- ];
7530
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7531
- if (!fallbackPreloaded) return [
7532
- 3,
7533
- 20
7534
- ];
6832
+ tags = this.adConfig.selectVastTagsForBreak(scheduled);
6833
+ if (tags && tags.length > 0 && tags[0]) {
6834
+ baseVastUrl = tags[0];
6835
+ } else if (this.adConfig.apiVastTagUrl) {
6836
+ baseVastUrl = this.adConfig.apiVastTagUrl;
6837
+ } else {
6838
+ this.clearPendingAdBreak();
6839
+ return [
6840
+ 2
6841
+ ];
6842
+ }
6843
+ adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
7535
6844
  if (this.debug) {
7536
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
6845
+ mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
6846
+ console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
7537
6847
  }
7538
- _state.label = 15;
7539
- case 15:
7540
- _state.trys.push([
7541
- 15,
7542
- 19,
7543
- ,
7544
- 20
7545
- ]);
7546
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7547
- 3,
7548
- 17
7549
- ];
7550
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7551
- this.startContinuousFetching(baseVastUrl);
7552
- return [
7553
- 4,
7554
- this.tryNextAvailableAdWithRateLimit()
7555
- ];
7556
- case 16:
7557
- _state.sent();
7558
- return [
7559
- 2
7560
- ];
7561
- case 17:
7562
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
6848
+ this.timing.failedVastUrls.clear();
6849
+ this.timing.temporaryFailureUrls.clear();
7563
6850
  this.timing.consecutiveFailures = 0;
7564
- this.startContinuousFetching(baseVastUrl);
7565
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7566
- this.preloadPool.active = true;
7567
- this.preloadPool.preloadPoolLoop(baseVastUrl);
6851
+ this.continuousFetchingActive = true;
6852
+ this.isShowingPlaceholder = false;
6853
+ this.timing.totalAdRequestsInBreak = 0;
6854
+ if (this.adConfig.podAssignedByPrefetch) {
6855
+ this.adConfig.podAssignedByPrefetch = false;
6856
+ } else {
6857
+ this.adConfig.beginNewAdPod();
7568
6858
  }
7569
- ap = this.host.getAdPlayer();
7570
- return [
7571
- 4,
7572
- ap.play()
7573
- ];
7574
- case 18:
7575
- _state.sent();
7576
- this.timing.markAdStarted();
7577
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7578
- this.timing.scheduleAdStopAtBreakBoundary();
6859
+ currentMuted = this.host.video.muted;
6860
+ currentVolume = this.host.video.volume;
6861
+ this.host.getAdPlayer().updateOriginalMutedState(currentMuted, currentVolume);
6862
+ this.inAdBreak = true;
6863
+ this.timing.adBreakPlayedDurationMs = 0;
6864
+ this.timing.currentAdIndex = 0;
6865
+ this.timing.totalAdsInBreak = 0;
6866
+ this.adPodQueue = [];
6867
+ this.showAds = false;
6868
+ if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
6869
+ this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7579
6870
  }
7580
- adVolume2 = currentMuted ? 0 : currentVolume;
7581
- ap.setAdVolume(adVolume2);
7582
6871
  return [
7583
- 2
6872
+ 4,
6873
+ this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7584
6874
  ];
7585
- case 19:
7586
- fallbackError = _state.sent();
7587
- if (this.debug) {
7588
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7589
- }
7590
- return [
6875
+ case 1:
6876
+ podPlayed = _state.sent();
6877
+ if (!!podPlayed) return [
7591
6878
  3,
7592
- 20
6879
+ 3
7593
6880
  ];
7594
- case 20:
7595
- if (this.timing.isTemporaryAdError(error)) {
7596
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7597
- if (this.debug) {
7598
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7599
- }
7600
- } else {
7601
- this.timing.failedVastUrls.add(firstAdUrl);
7602
- if (this.debug) {
7603
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7604
- }
6881
+ if (this.debug) {
6882
+ console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
7605
6883
  }
7606
- this.timing.consecutiveFailures++;
6884
+ this.continuousFetchingActive = true;
7607
6885
  this.startContinuousFetching(baseVastUrl);
7608
6886
  return [
7609
6887
  4,
7610
6888
  this.tryNextAvailableAdWithRateLimit()
7611
6889
  ];
7612
- case 21:
6890
+ case 2:
7613
6891
  _state.sent();
7614
- return [
7615
- 3,
7616
- 22
7617
- ];
7618
- case 22:
6892
+ _state.label = 3;
6893
+ case 3:
7619
6894
  return [
7620
6895
  2
7621
6896
  ];
@@ -7689,7 +6964,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7689
6964
  ];
7690
6965
  }
7691
6966
  if (this.debug) {
7692
- console.log(podCount === 1 ? "[POD] Response contained a single ad; playing it and enabling sequential top-up" : "[POD] Optimized pod returned ".concat(podCount, " ads; playing pod in one controller"));
6967
+ console.log(podCount === 1 ? "[POD] Response contained a single ad; playing it and enabling pod top-up" : "[POD] Optimized pod returned ".concat(podCount, " ads; playing pod in one controller"));
7693
6968
  }
7694
6969
  sendAdLoadedTracking(this.host.config.licenseKey, {
7695
6970
  source: "hls",
@@ -7709,10 +6984,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7709
6984
  }
7710
6985
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7711
6986
  this.timing.consecutiveFailures = 0;
7712
- if (podCount === 1) {
7713
- this.continuousFetchingActive = true;
7714
- this.startContinuousFetching(baseVastUrl);
7715
- }
6987
+ this.continuousFetchingActive = true;
6988
+ this.startContinuousFetching(baseVastUrl);
7716
6989
  return [
7717
6990
  2,
7718
6991
  true
@@ -7745,20 +7018,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7745
7018
  }).call(this);
7746
7019
  }
7747
7020
  },
7748
- {
7749
- key: "swapToPreloadedAdPlayer",
7750
- value: function swapToPreloadedAdPlayer(preloadedController) {
7751
- var adPlayer = this.host.getAdPlayer();
7752
- var preservedMuted = adPlayer.getOriginalMutedState();
7753
- var preservedVolume = adPlayer.getOriginalVolume();
7754
- adPlayer.destroy();
7755
- this.host.video.muted = true;
7756
- this.host.setAdPlayer(preloadedController);
7757
- this.attachImaEventListeners();
7758
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7759
- preloadedController.resume();
7760
- }
7761
- },
7762
7021
  {
7763
7022
  // ───────────────────────────────────────────────────────────────
7764
7023
  // Continuous fetching
@@ -8009,7 +7268,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8009
7268
  value: function tryNextAvailableAd() {
8010
7269
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8011
7270
  return _async_to_generator(function() {
8012
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7271
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8013
7272
  return _ts_generator(this, function(_state) {
8014
7273
  switch(_state.label){
8015
7274
  case 0:
@@ -8047,132 +7306,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8047
7306
  ];
8048
7307
  }
8049
7308
  this.timing.cleanupTemporaryFailures();
8050
- preloaded = this.preloadPool.getPreloadedAd();
8051
- if (!preloaded) return [
8052
- 3,
8053
- 6
8054
- ];
8055
- if (this.debug) {
8056
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8057
- }
8058
- sendAdLoadedTracking(this.host.config.licenseKey, {
8059
- source: "hls",
8060
- vastUrl: preloaded.vastUrl,
8061
- timestamp: /* @__PURE__ */ new Date().toISOString()
8062
- }, this.analyticsContext).catch(function() {});
8063
7309
  _state.label = 1;
8064
7310
  case 1:
8065
- _state.trys.push([
8066
- 1,
8067
- 5,
8068
- ,
8069
- 6
8070
- ]);
8071
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8072
- 3,
8073
- 3
8074
- ];
8075
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8076
- return [
8077
- 4,
8078
- this.tryNextAvailableAdWithRateLimit()
8079
- ];
8080
- case 2:
8081
- _state.sent();
8082
- return [
8083
- 2
8084
- ];
8085
- case 3:
8086
- this.swapToPreloadedAdPlayer(preloaded.adController);
8087
- ap = this.host.getAdPlayer();
8088
- return [
8089
- 4,
8090
- ap.play()
8091
- ];
8092
- case 4:
8093
- _state.sent();
8094
- this.timing.markAdStarted();
8095
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8096
- this.timing.scheduleAdStopAtBreakBoundary();
8097
- }
8098
- ap.setAdVolume(getAdAudioVolume(ap));
8099
- this.timing.consecutiveFailures = 0;
8100
- return [
8101
- 2
8102
- ];
8103
- case 5:
8104
- error = _state.sent();
8105
- if (this.debug) {
8106
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8107
- }
8108
- return [
8109
- 3,
8110
- 6
8111
- ];
8112
- case 6:
8113
7311
  if (!(this.adRequestQueue.length > 0)) return [
8114
7312
  3,
8115
- 14
7313
+ 9
8116
7314
  ];
8117
7315
  nextAdUrl = this.adRequestQueue.shift();
8118
7316
  if (!nextAdUrl) return [
8119
7317
  3,
8120
- 6
7318
+ 1
8121
7319
  ];
8122
7320
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8123
7321
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8124
7322
  return [
8125
7323
  3,
8126
- 6
7324
+ 1
8127
7325
  ];
8128
7326
  }
8129
7327
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8130
7328
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8131
7329
  return [
8132
7330
  3,
8133
- 6
7331
+ 1
8134
7332
  ];
8135
7333
  }
8136
7334
  if (this.debug) {
8137
7335
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8138
7336
  }
8139
- _state.label = 7;
8140
- case 7:
7337
+ _state.label = 2;
7338
+ case 2:
8141
7339
  _state.trys.push([
8142
- 7,
8143
- 9,
7340
+ 2,
7341
+ 4,
8144
7342
  ,
8145
- 13
7343
+ 8
8146
7344
  ]);
8147
7345
  return [
8148
7346
  4,
8149
7347
  this.playSingleAd(nextAdUrl)
8150
7348
  ];
8151
- case 8:
7349
+ case 3:
8152
7350
  _state.sent();
8153
7351
  this.timing.consecutiveFailures = 0;
8154
7352
  return [
8155
7353
  3,
8156
- 13
7354
+ 8
8157
7355
  ];
8158
- case 9:
8159
- error1 = _state.sent();
8160
- errorMessage = error1.message;
7356
+ case 4:
7357
+ error = _state.sent();
7358
+ errorMessage = error.message;
8161
7359
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8162
7360
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8163
7361
  3,
8164
- 11
7362
+ 6
8165
7363
  ];
8166
7364
  return [
8167
7365
  4,
8168
7366
  this.tryNextAvailableAdWithRateLimit()
8169
7367
  ];
8170
- case 10:
7368
+ case 5:
8171
7369
  _state.sent();
8172
7370
  return [
8173
7371
  2
8174
7372
  ];
8175
- case 11:
7373
+ case 6:
8176
7374
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8177
7375
  this.timing.consecutiveFailures++;
8178
7376
  }
@@ -8180,21 +7378,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8180
7378
  4,
8181
7379
  this.tryNextAvailableAdWithRateLimit()
8182
7380
  ];
8183
- case 12:
7381
+ case 7:
8184
7382
  _state.sent();
8185
7383
  return [
8186
7384
  3,
8187
- 13
7385
+ 8
8188
7386
  ];
8189
- case 13:
7387
+ case 8:
8190
7388
  return [
8191
7389
  2
8192
7390
  ];
8193
- case 14:
7391
+ case 9:
8194
7392
  maxRetries = 3;
8195
7393
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8196
7394
  3,
8197
- 17
7395
+ 12
8198
7396
  ];
8199
7397
  if (this.debug) {
8200
7398
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8205,18 +7403,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8205
7403
  return setTimeout(resolve, 500);
8206
7404
  })
8207
7405
  ];
8208
- case 15:
7406
+ case 10:
8209
7407
  _state.sent();
8210
7408
  return [
8211
7409
  4,
8212
7410
  this.tryNextAvailableAd(retryCount + 1)
8213
7411
  ];
8214
- case 16:
7412
+ case 11:
8215
7413
  _state.sent();
8216
7414
  return [
8217
7415
  2
8218
7416
  ];
8219
- case 17:
7417
+ case 12:
8220
7418
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8221
7419
  this.showPlaceholderAndWaitForAds();
8222
7420
  } else {
@@ -8238,7 +7436,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8238
7436
  // ───────────────────────────────────────────────────────────────
8239
7437
  function playSingleAd(vastTagUrl) {
8240
7438
  return _async_to_generator(function() {
8241
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7439
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8242
7440
  return _ts_generator(this, function(_state) {
8243
7441
  switch(_state.label){
8244
7442
  case 0:
@@ -8270,9 +7468,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8270
7468
  case 1:
8271
7469
  _state.trys.push([
8272
7470
  1,
8273
- 12,
7471
+ 8,
8274
7472
  ,
8275
- 17
7473
+ 9
8276
7474
  ]);
8277
7475
  return [
8278
7476
  4,
@@ -8308,7 +7506,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8308
7506
  4,
8309
7507
  6,
8310
7508
  ,
8311
- 11
7509
+ 7
8312
7510
  ]);
8313
7511
  this.timing.startAdFailsafeTimer(requestToken);
8314
7512
  return [
@@ -8326,55 +7524,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8326
7524
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8327
7525
  return [
8328
7526
  3,
8329
- 11
7527
+ 7
8330
7528
  ];
8331
7529
  case 6:
8332
7530
  playError = _state.sent();
8333
7531
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8334
- preloadedFallback = this.preloadPool.getPreloadedAd();
8335
- if (!preloadedFallback) return [
8336
- 3,
8337
- 10
8338
- ];
8339
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8340
- _state.label = 7;
8341
- case 7:
8342
- _state.trys.push([
8343
- 7,
8344
- 9,
8345
- ,
8346
- 10
8347
- ]);
8348
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8349
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8350
- throw playError;
8351
- }
8352
- this.timing.clearAdFailsafeTimer();
8353
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8354
- this.timing.consecutiveFailures = 0;
8355
- fbAp = this.host.getAdPlayer();
8356
- return [
8357
- 4,
8358
- fbAp.play()
8359
- ];
8360
- case 8:
8361
- _state.sent();
8362
- this.timing.markAdStarted();
8363
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8364
- this.timing.scheduleAdStopAtBreakBoundary();
8365
- }
8366
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8367
- return [
8368
- 2
8369
- ];
8370
- case 9:
8371
- fallbackError = _state.sent();
8372
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8373
- return [
8374
- 3,
8375
- 10
8376
- ];
8377
- case 10:
8378
7532
  if (this.timing.isTemporaryAdError(playError)) {
8379
7533
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8380
7534
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8387,57 +7541,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8387
7541
  this.timing.activeAdRequestToken = null;
8388
7542
  }
8389
7543
  throw playError;
8390
- case 11:
7544
+ case 7:
8391
7545
  return [
8392
7546
  3,
8393
- 17
7547
+ 9
8394
7548
  ];
8395
- case 12:
7549
+ case 8:
8396
7550
  error = _state.sent();
8397
7551
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8398
7552
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8399
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8400
- if (!preloadedFallback1) return [
8401
- 3,
8402
- 16
8403
- ];
8404
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8405
- _state.label = 13;
8406
- case 13:
8407
- _state.trys.push([
8408
- 13,
8409
- 15,
8410
- ,
8411
- 16
8412
- ]);
8413
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8414
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8415
- throw error;
8416
- }
8417
- this.timing.clearAdRequestWatchdog();
8418
- this.timing.clearAdFailsafeTimer();
8419
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8420
- this.timing.consecutiveFailures = 0;
8421
- fbAp1 = this.host.getAdPlayer();
8422
- return [
8423
- 4,
8424
- fbAp1.play()
8425
- ];
8426
- case 14:
8427
- _state.sent();
8428
- this.timing.markAdStarted();
8429
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8430
- return [
8431
- 2
8432
- ];
8433
- case 15:
8434
- fallbackError1 = _state.sent();
8435
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8436
- return [
8437
- 3,
8438
- 16
8439
- ];
8440
- case 16:
8441
7553
  if (this.timing.isTemporaryAdError(error)) {
8442
7554
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8443
7555
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8451,7 +7563,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8451
7563
  this.timing.activeAdRequestToken = null;
8452
7564
  }
8453
7565
  throw error;
8454
- case 17:
7566
+ case 9:
8455
7567
  return [
8456
7568
  2
8457
7569
  ];
@@ -8641,7 +7753,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8641
7753
  }
8642
7754
  this.timing.resetForBreakEnd();
8643
7755
  this.stopContinuousFetching();
8644
- this.preloadPool.stop();
8645
7756
  this.clearPendingAdBreak();
8646
7757
  if (this.isShowingPlaceholder) {
8647
7758
  this.host.getAdPlayer().hidePlaceholder();
@@ -8751,25 +7862,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8751
7862
  return _this.adBreak.handleAdFailure();
8752
7863
  }
8753
7864
  });
8754
- this.preloadPool = new AdPreloadPool({
8755
- debug: !!this.config.debugAdTiming,
8756
- createAdPlayer: function createAdPlayer(c) {
8757
- return _this.createAdPlayer(c);
8758
- },
8759
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
8760
- return _this.shouldContinueLiveStreamDuringAds();
8761
- },
8762
- timing: this.timing,
8763
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
8764
- return _this.generateVastUrls(base, count);
8765
- },
8766
- isInAdBreak: function isInAdBreak() {
8767
- return _this.adBreak.inAdBreak;
8768
- },
8769
- getPendingAdBreak: function getPendingAdBreak() {
8770
- return _this.adBreak.pendingAdBreak;
8771
- }
8772
- });
8773
7865
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
8774
7866
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
8775
7867
  onManifestParsed: function onManifestParsed(isLive) {
@@ -8816,13 +7908,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8816
7908
  getLiveSyncPosition: function getLiveSyncPosition() {
8817
7909
  return _this.hlsEngine.getLiveSyncPosition();
8818
7910
  },
8819
- generateVastUrls: function generateVastUrls(base, count) {
8820
- return _this.generateVastUrls(base, count);
8821
- },
8822
7911
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8823
7912
  return _this.generatePodVastUrl(base, breakDurationMs);
8824
7913
  }
8825
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7914
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
8826
7915
  }
8827
7916
  _create_class(StormcloudVideoPlayer, [
8828
7917
  {
@@ -8847,12 +7936,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8847
7936
  } : {}));
8848
7937
  }
8849
7938
  },
8850
- {
8851
- key: "generateVastUrls",
8852
- value: function generateVastUrls(baseUrl, count) {
8853
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8854
- }
8855
- },
8856
7939
  {
8857
7940
  key: "generatePodVastUrl",
8858
7941
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9248,11 +8331,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9248
8331
  }
9249
8332
  this.adConfig.beginNewAdPod();
9250
8333
  this.adConfig.podAssignedByPrefetch = true;
9251
- var optimizedPods = this.config.optimizedPods !== false;
9252
8334
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9253
- var generatedUrls = optimizedPods ? [
8335
+ var generatedUrls = [
9254
8336
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9255
- ] : this.generateVastUrls(baseVastUrl, 1);
8337
+ ];
9256
8338
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9257
8339
  marker: marker
9258
8340
  }, fragmentSn !== void 0 ? {
@@ -9274,15 +8356,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9274
8356
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9275
8357
  if (this.debug) {
9276
8358
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9277
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9278
- }
9279
- if (optimizedPods) {
9280
- if (this.debug) {
9281
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9282
- }
9283
- return;
8359
+ console.log("[PREFETCH] Pre-generated pod request URL");
9284
8360
  }
9285
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9286
8361
  }
9287
8362
  },
9288
8363
  {
@@ -9521,7 +8596,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9521
8596
  value: function destroy() {
9522
8597
  var _this_adPlayer;
9523
8598
  this.adBreak.stopContinuousFetching();
9524
- this.preloadPool.stop();
9525
8599
  this.timing.destroy();
9526
8600
  this.adBreak.clearPendingAdBreak();
9527
8601
  this.placeholder.destroy();