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
@@ -762,24 +762,65 @@ function createHlsAdPlayer(contentVideo, options) {
762
762
  }
763
763
  }
764
764
  function fetchVastXml(vastTagUrl) {
765
+ var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
765
766
  return _async_to_generator(function() {
766
- var response;
767
+ var requestVast, response, error;
767
768
  return _ts_generator(this, function(_state) {
768
769
  switch(_state.label){
769
770
  case 0:
770
- return [
771
- 4,
772
- fetch(vastTagUrl, {
771
+ requestVast = function requestVast(creds) {
772
+ return fetch(vastTagUrl, {
773
773
  mode: "cors",
774
- credentials: "include",
774
+ credentials: creds,
775
775
  headers: {
776
776
  "Accept": "application/xml, text/xml, */*"
777
777
  },
778
778
  referrerPolicy: "no-referrer-when-downgrade"
779
- })
780
- ];
779
+ });
780
+ };
781
+ _state.label = 1;
781
782
  case 1:
783
+ _state.trys.push([
784
+ 1,
785
+ 3,
786
+ ,
787
+ 7
788
+ ]);
789
+ return [
790
+ 4,
791
+ requestVast(credentials)
792
+ ];
793
+ case 2:
782
794
  response = _state.sent();
795
+ return [
796
+ 3,
797
+ 7
798
+ ];
799
+ case 3:
800
+ error = _state.sent();
801
+ if (!(credentials !== "omit")) return [
802
+ 3,
803
+ 5
804
+ ];
805
+ console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
806
+ return [
807
+ 4,
808
+ requestVast("omit")
809
+ ];
810
+ case 4:
811
+ response = _state.sent();
812
+ return [
813
+ 3,
814
+ 6
815
+ ];
816
+ case 5:
817
+ throw error;
818
+ case 6:
819
+ return [
820
+ 3,
821
+ 7
822
+ ];
823
+ case 7:
783
824
  if (!response.ok) {
784
825
  throw new Error("Failed to fetch VAST: ".concat(response.statusText));
785
826
  }
@@ -801,7 +842,7 @@ function createHlsAdPlayer(contentVideo, options) {
801
842
  depth = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : 0, accumulatedTracking = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : createEmptyTrackingUrls();
802
843
  return [
803
844
  4,
804
- fetchVastXml(vastTagUrl)
845
+ fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit")
805
846
  ];
806
847
  case 1:
807
848
  vastXml = _state.sent();
@@ -3453,21 +3494,16 @@ function applyVastMacros(baseUrl, ctx) {
3453
3494
  if (ctx.pod != null) {
3454
3495
  params.set("pod", String(ctx.pod));
3455
3496
  }
3456
- var optimizedPodMode = ctx.podMaxAds != null || ctx.podMinDurationMs != null || ctx.podMaxDurationMs != null;
3457
- if (optimizedPodMode) {
3458
- params.delete("ppos");
3459
- params.delete("lip");
3460
- if (ctx.podMinDurationMs != null) {
3461
- params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3462
- }
3463
- if (ctx.podMaxDurationMs != null) {
3464
- params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3465
- }
3466
- if (ctx.podMaxAds != null) {
3467
- params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3468
- }
3469
- } else if (ctx.adPosition != null) {
3470
- params.set("ppos", String(ctx.adPosition));
3497
+ params.delete("ppos");
3498
+ params.delete("lip");
3499
+ if (ctx.podMinDurationMs != null) {
3500
+ params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3501
+ }
3502
+ if (ctx.podMaxDurationMs != null) {
3503
+ params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3504
+ }
3505
+ if (ctx.podMaxAds != null) {
3506
+ params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3471
3507
  }
3472
3508
  var requestUrl = ctx.contentUrl || ctx.pageUrl;
3473
3509
  if (requestUrl) {
@@ -4807,9 +4843,9 @@ var AdConfigManager = /*#__PURE__*/ function() {
4807
4843
  this.consentSignals = {};
4808
4844
  this.podCounter = 0;
4809
4845
  this.podAssignedByPrefetch = false;
4810
- this.adRequestPositionInBreak = 0;
4811
4846
  this.lastHeartbeatTime = 0;
4812
4847
  this.defaultPodMaxAds = 6;
4848
+ this.defaultPodMaxDurationMs = 12e4;
4813
4849
  this.config = config;
4814
4850
  this.video = video;
4815
4851
  }
@@ -5227,48 +5263,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
5227
5263
  key: "beginNewAdPod",
5228
5264
  value: function beginNewAdPod() {
5229
5265
  this.podCounter++;
5230
- this.adRequestPositionInBreak = 0;
5231
- }
5232
- },
5233
- {
5234
- key: "generateVastUrlsWithCorrelators",
5235
- value: function generateVastUrlsWithCorrelators(baseUrl, count, adPlayer, palNonce, inAdBreak) {
5236
- var urls = [];
5237
- for(var i = 0; i < count; i++){
5238
- this.adRequestPositionInBreak++;
5239
- var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
5240
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
5241
- var urlWithMacros = applyVastMacros(baseUrl, {
5242
- correlator: this.viewCorrelator,
5243
- streamCorrelator: this.streamCorrelator,
5244
- pod: this.podCounter > 0 ? this.podCounter : void 0,
5245
- adPosition: this.adRequestPositionInBreak,
5246
- isCtv: envSignals.isCtv,
5247
- contentUrl: envSignals.contentUrl,
5248
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5249
- adWillPlayMuted: adWillPlayMuted,
5250
- adWillAutoPlay: !!this.config.autoplay,
5251
- appId: envSignals.appId,
5252
- appName: envSignals.appName,
5253
- sessionId: envSignals.sessionId,
5254
- deviceId: envSignals.deviceId,
5255
- deviceIdType: envSignals.deviceIdType,
5256
- limitAdTracking: envSignals.limitAdTracking,
5257
- deviceTypeHint: envSignals.deviceTypeHint,
5258
- adTest: this.config.adTest,
5259
- consent: this.consentSignals
5260
- });
5261
- var finalUrl = palNonce.injectNonce(urlWithMacros);
5262
- console.log("[StormcloudVideoPlayer] Resolved ad request URL (pod=".concat(this.podCounter, ", pos=").concat(this.adRequestPositionInBreak, "):"), finalUrl);
5263
- urls.push(finalUrl);
5264
- }
5265
- return urls;
5266
5266
  }
5267
5267
  },
5268
5268
  {
5269
5269
  key: "resolvePodParams",
5270
5270
  value: function resolvePodParams(breakDurationMs) {
5271
- var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs;
5271
+ var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs != null && this.config.podMaxDurationMs > 0 ? this.config.podMaxDurationMs : this.defaultPodMaxDurationMs;
5272
5272
  var maxAds = this.config.podMaxAds && this.config.podMaxAds > 0 ? this.config.podMaxAds : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultPodMaxAds;
5273
5273
  var minDurationMs = this.config.podExactDuration && maxDurationMs != null ? maxDurationMs : 0;
5274
5274
  return {
@@ -5921,611 +5921,155 @@ var AdTimingService = /*#__PURE__*/ function() {
5921
5921
  ]);
5922
5922
  return AdTimingService;
5923
5923
  }();
5924
- // src/player/AdPreloadPool.ts
5925
- var AdPreloadPool = /*#__PURE__*/ function() {
5926
- function AdPreloadPool(deps) {
5927
- _class_call_check(this, AdPreloadPool);
5928
- this.pool = [];
5929
- this.maxPoolSize = 2;
5930
- this.poolActive = false;
5931
- this.loopRunning = false;
5932
- this.deps = deps;
5933
- }
5934
- _create_class(AdPreloadPool, [
5935
- {
5936
- key: "active",
5937
- get: function get() {
5938
- return this.poolActive;
5939
- },
5940
- set: function set(value) {
5941
- this.poolActive = value;
5942
- }
5943
- },
5924
+ // src/player/PlaceholderLayer.ts
5925
+ var PlaceholderLayer = /*#__PURE__*/ function() {
5926
+ function PlaceholderLayer(video, debug) {
5927
+ _class_call_check(this, PlaceholderLayer);
5928
+ this.video = video;
5929
+ this.debug = debug;
5930
+ }
5931
+ _create_class(PlaceholderLayer, [
5944
5932
  {
5945
- key: "isLoopRunning",
5946
- get: function get() {
5947
- return this.loopRunning;
5933
+ key: "ensureContainer",
5934
+ value: function ensureContainer() {
5935
+ if (this.container) {
5936
+ return;
5937
+ }
5938
+ var el = document.createElement("div");
5939
+ el.style.position = "absolute";
5940
+ el.style.left = "0";
5941
+ el.style.top = "0";
5942
+ el.style.right = "0";
5943
+ el.style.bottom = "0";
5944
+ el.style.display = "none";
5945
+ el.style.alignItems = "center";
5946
+ el.style.justifyContent = "center";
5947
+ el.style.pointerEvents = "none";
5948
+ el.style.zIndex = "5";
5949
+ el.style.backgroundColor = "#000";
5950
+ el.style.transition = "opacity 0.3s ease-in-out";
5951
+ el.style.opacity = "0";
5952
+ if (!this.video.parentElement) {
5953
+ if (this.debug) {
5954
+ console.warn("[StormcloudVideoPlayer] Video element has no parent for placeholder container");
5955
+ }
5956
+ return;
5957
+ }
5958
+ this.video.parentElement.appendChild(el);
5959
+ this.container = el;
5948
5960
  }
5949
5961
  },
5950
5962
  {
5951
- key: "startPreloadPool",
5952
- value: function startPreloadPool(baseVastUrl, initialUrls) {
5953
- var startLoopImmediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
5954
- if (this.poolActive) {
5955
- if (this.deps.debug) {
5956
- console.log("[PRELOAD-POOL] Already active, skipping duplicate start");
5957
- }
5963
+ key: "show",
5964
+ value: function show() {
5965
+ var _this = this;
5966
+ this.ensureContainer();
5967
+ if (!this.container) {
5958
5968
  return;
5959
5969
  }
5960
- this.poolActive = true;
5961
- if (this.deps.debug) {
5962
- console.log("[PRELOAD-POOL] Starting preload pool EARLY (target size: ".concat(this.maxPoolSize, ")"));
5963
- console.log("[PRELOAD-POOL] Ad break hasn't started yet, but preloading ads in advance");
5964
- }
5965
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5966
- try {
5967
- for(var _iterator = initialUrls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5968
- var url = _step.value;
5969
- if (this.pool.length < this.maxPoolSize) {
5970
- this.preloadAdIntoPool(url);
5971
- }
5970
+ if (!this.video.muted) {
5971
+ this.video.muted = true;
5972
+ if (this.debug) {
5973
+ console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
5972
5974
  }
5973
- } catch (err) {
5974
- _didIteratorError = true;
5975
- _iteratorError = err;
5976
- } finally{
5977
- try {
5978
- if (!_iteratorNormalCompletion && _iterator.return != null) {
5979
- _iterator.return();
5980
- }
5981
- } finally{
5982
- if (_didIteratorError) {
5983
- throw _iteratorError;
5975
+ }
5976
+ var wasHidden = this.container.style.display === "none" || this.container.style.opacity === "0";
5977
+ if (wasHidden) {
5978
+ this.container.style.transition = "none";
5979
+ } else {
5980
+ this.container.style.transition = "opacity 0.3s ease-in-out";
5981
+ }
5982
+ this.container.style.backgroundColor = "#000";
5983
+ this.container.style.display = "flex";
5984
+ this.container.offsetHeight;
5985
+ this.container.style.opacity = "1";
5986
+ this.container.style.pointerEvents = "auto";
5987
+ if (wasHidden) {
5988
+ requestAnimationFrame(function() {
5989
+ if (_this.container) {
5990
+ _this.container.style.transition = "opacity 0.3s ease-in-out";
5984
5991
  }
5992
+ });
5993
+ }
5994
+ if (this.debug) {
5995
+ console.log("[StormcloudVideoPlayer] Showing placeholder layer (between content and ad layer)");
5996
+ }
5997
+ }
5998
+ },
5999
+ {
6000
+ key: "hide",
6001
+ value: function hide() {
6002
+ var _this = this;
6003
+ if (!this.container) {
6004
+ return;
6005
+ }
6006
+ this.container.style.opacity = "0";
6007
+ setTimeout(function() {
6008
+ if (_this.container) {
6009
+ _this.container.style.display = "none";
6010
+ _this.container.style.pointerEvents = "none";
6011
+ _this.container.style.backgroundColor = "#000";
5985
6012
  }
6013
+ }, 300);
6014
+ if (this.debug) {
6015
+ console.log("[StormcloudVideoPlayer] Hiding placeholder layer");
5986
6016
  }
5987
- if (startLoopImmediately) {
5988
- this.preloadPoolLoop(baseVastUrl);
5989
- } else if (this.deps.debug) {
5990
- console.log("[PRELOAD-POOL] Pre-break mode: preloaded once, waiting for SCTE start to continue fetching");
6017
+ }
6018
+ },
6019
+ {
6020
+ key: "destroy",
6021
+ value: function destroy() {
6022
+ if (this.container) {
6023
+ if (this.container.parentElement) {
6024
+ this.container.parentElement.removeChild(this.container);
6025
+ }
6026
+ this.container = void 0;
5991
6027
  }
5992
6028
  }
6029
+ }
6030
+ ]);
6031
+ return PlaceholderLayer;
6032
+ }();
6033
+ // src/player/HlsEngine.ts
6034
+ var import_hls2 = __toESM(require("hls.js"), 1);
6035
+ var HlsEngine = /*#__PURE__*/ function() {
6036
+ function HlsEngine(config, video, cueManager, timing, callbacks) {
6037
+ _class_call_check(this, HlsEngine);
6038
+ this.isLiveStream = false;
6039
+ this.nativeHlsMode = false;
6040
+ this.videoSrcProtection = null;
6041
+ this.bufferedSegmentsCount = 0;
6042
+ this.shouldAutoplayAfterBuffering = false;
6043
+ this.hasInitialBufferCompleted = false;
6044
+ this.config = config;
6045
+ this.video = video;
6046
+ this.cueManager = cueManager;
6047
+ this.timing = timing;
6048
+ this.callbacks = callbacks;
6049
+ }
6050
+ _create_class(HlsEngine, [
6051
+ {
6052
+ key: "debug",
6053
+ get: function get() {
6054
+ return !!this.config.debugAdTiming;
6055
+ }
5993
6056
  },
5994
6057
  {
5995
- key: "preloadAdIntoPool",
5996
- value: function preloadAdIntoPool(vastUrl) {
5997
- return _async_to_generator(function() {
5998
- var _this, timing, epoch, loadPromise;
5999
- return _ts_generator(this, function(_state) {
6000
- _this = this;
6001
- timing = this.deps.timing;
6002
- if (timing.isGamInCooldown()) {
6003
- if (this.deps.debug) {
6004
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
6005
- }
6006
- return [
6007
- 2
6008
- ];
6009
- }
6010
- if (this.pool.some(function(entry) {
6011
- return entry.vastUrl === vastUrl;
6012
- }) || timing.failedVastUrls.has(vastUrl) || timing.isUrlInCooldown(vastUrl)) {
6013
- return [
6014
- 2
6015
- ];
6016
- }
6017
- if (this.pool.length >= this.maxPoolSize) {
6018
- return [
6019
- 2
6020
- ];
6021
- }
6022
- if (this.deps.debug) {
6023
- console.log("[PRELOAD-POOL] Preloading ad into pool: ".concat(vastUrl));
6024
- }
6025
- epoch = timing.adBreakEpoch;
6026
- loadPromise = function() {
6027
- return _async_to_generator(function() {
6028
- var _this, hasAdError, adErrorPayload, errorListenerCleanup, _preloadAd_getLoadedAdDuration, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, loadedDuration, lateErrorListener, _poolEntry_durationSeconds, error;
6029
- return _ts_generator(this, function(_state) {
6030
- switch(_state.label){
6031
- case 0:
6032
- _this = this;
6033
- hasAdError = false;
6034
- adErrorPayload = null;
6035
- errorListenerCleanup = null;
6036
- _state.label = 1;
6037
- case 1:
6038
- _state.trys.push([
6039
- 1,
6040
- 5,
6041
- ,
6042
- 6
6043
- ]);
6044
- continueLiveStreamDuringAds = this.deps.shouldContinueLiveStreamDuringAds();
6045
- preloadAd = this.deps.createAdPlayer(continueLiveStreamDuringAds);
6046
- preloadAd.initialize();
6047
- errorListener = function errorListener(payload) {
6048
- hasAdError = true;
6049
- adErrorPayload = payload;
6050
- };
6051
- preloadAd.on("ad_error", errorListener);
6052
- errorListenerCleanup = function errorListenerCleanup() {
6053
- return preloadAd.off("ad_error", errorListener);
6054
- };
6055
- return [
6056
- 4,
6057
- timing.enforceGlobalRateLimit()
6058
- ];
6059
- case 2:
6060
- _state.sent();
6061
- return [
6062
- 4,
6063
- preloadAd.requestAds(vastUrl)
6064
- ];
6065
- case 3:
6066
- _state.sent();
6067
- preloadAd.pause();
6068
- return [
6069
- 4,
6070
- new Promise(function(resolve) {
6071
- return setTimeout(resolve, 1500);
6072
- })
6073
- ];
6074
- case 4:
6075
- _state.sent();
6076
- preloadAd.pause();
6077
- if (hasAdError) {
6078
- 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;
6079
- if (errorListenerCleanup) {
6080
- errorListenerCleanup();
6081
- }
6082
- preloadAd.destroy();
6083
- timing.recordGamNoFill();
6084
- if (isNoFill) {
6085
- if (this.deps.debug) {
6086
- console.log("[PRELOAD-POOL] Ad preload returned no-fill: ".concat(vastUrl));
6087
- }
6088
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6089
- } else {
6090
- if (this.deps.debug) {
6091
- console.log("[PRELOAD-POOL] Ad preload failed with error: ".concat(vastUrl), adErrorPayload);
6092
- }
6093
- if (adErrorPayload && !timing.isTemporaryAdError(adErrorPayload)) {
6094
- timing.failedVastUrls.add(vastUrl);
6095
- } else {
6096
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6097
- }
6098
- }
6099
- return [
6100
- 2
6101
- ];
6102
- }
6103
- if (!this.poolActive || epoch !== timing.adBreakEpoch) {
6104
- if (this.deps.debug) {
6105
- console.log("[PRELOAD-POOL] Discarding preloaded ad - break ended during fetch");
6106
- }
6107
- if (errorListenerCleanup) {
6108
- errorListenerCleanup();
6109
- }
6110
- try {
6111
- preloadAd.destroy();
6112
- } catch (unused) {}
6113
- return [
6114
- 2
6115
- ];
6116
- }
6117
- poolEntry = {
6118
- vastUrl: vastUrl,
6119
- adController: preloadAd,
6120
- loadedAt: Date.now(),
6121
- isReady: true,
6122
- loadPromise: Promise.resolve()
6123
- };
6124
- loadedDuration = (_preloadAd_getLoadedAdDuration = preloadAd.getLoadedAdDuration) === null || _preloadAd_getLoadedAdDuration === void 0 ? void 0 : _preloadAd_getLoadedAdDuration.call(preloadAd);
6125
- if (loadedDuration != null && loadedDuration > 0) {
6126
- poolEntry.durationSeconds = loadedDuration;
6127
- }
6128
- lateErrorListener = function lateErrorListener(payload) {
6129
- var index = _this.pool.findIndex(function(entry) {
6130
- return entry.vastUrl === vastUrl;
6131
- });
6132
- if (index >= 0) {
6133
- _this.pool.splice(index, 1);
6134
- if (_this.deps.debug) {
6135
- console.log("[PRELOAD-POOL] Late error detected, removed from pool: ".concat(vastUrl), payload);
6136
- }
6137
- try {
6138
- preloadAd.destroy();
6139
- } catch (unused) {}
6140
- }
6141
- };
6142
- preloadAd.on("ad_error", lateErrorListener);
6143
- this.pool.push(poolEntry);
6144
- if (this.deps.debug) {
6145
- ;
6146
- 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)"));
6147
- }
6148
- if (errorListenerCleanup) {
6149
- errorListenerCleanup();
6150
- }
6151
- return [
6152
- 3,
6153
- 6
6154
- ];
6155
- case 5:
6156
- error = _state.sent();
6157
- if (errorListenerCleanup) {
6158
- errorListenerCleanup();
6159
- }
6160
- timing.recordGamNoFill();
6161
- if (this.deps.debug) {
6162
- console.warn("[PRELOAD-POOL] Failed to preload ad: ".concat(vastUrl), error);
6163
- }
6164
- if (_instanceof(error, Error) && !timing.isTemporaryAdError(error)) {
6165
- timing.failedVastUrls.add(vastUrl);
6166
- } else if (_instanceof(error, Error) && timing.isTemporaryAdError(error)) {
6167
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6168
- }
6169
- return [
6170
- 3,
6171
- 6
6172
- ];
6173
- case 6:
6174
- return [
6175
- 2
6176
- ];
6177
- }
6178
- });
6179
- }).call(_this);
6180
- }();
6181
- loadPromise.catch(function() {});
6182
- return [
6183
- 2
6184
- ];
6185
- });
6186
- }).call(this);
6058
+ key: "shouldUseNativeHls",
6059
+ value: function shouldUseNativeHls(getStreamType) {
6060
+ var streamType = getStreamType();
6061
+ if (streamType === "other") {
6062
+ return true;
6063
+ }
6064
+ var canNative = this.video.canPlayType("application/vnd.apple.mpegurl");
6065
+ return !!(this.config.allowNativeHls && canNative);
6187
6066
  }
6188
6067
  },
6189
6068
  {
6190
- key: "preloadPoolLoop",
6191
- value: function preloadPoolLoop(baseVastUrl) {
6069
+ key: "setupNativeHls",
6070
+ value: function setupNativeHls() {
6192
6071
  return _async_to_generator(function() {
6193
- var epoch, newUrls, newUrl;
6194
- return _ts_generator(this, function(_state) {
6195
- switch(_state.label){
6196
- case 0:
6197
- if (this.loopRunning) {
6198
- return [
6199
- 2
6200
- ];
6201
- }
6202
- this.loopRunning = true;
6203
- epoch = this.deps.timing.adBreakEpoch;
6204
- if (this.deps.debug) {
6205
- console.log("[PRELOAD-POOL] Starting continuous preload loop");
6206
- }
6207
- _state.label = 1;
6208
- case 1:
6209
- if (!(this.poolActive && epoch === this.deps.timing.adBreakEpoch)) return [
6210
- 3,
6211
- 10
6212
- ];
6213
- if (this.deps.timing.isGamInCooldown()) {
6214
- if (this.deps.debug) {
6215
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
6216
- }
6217
- return [
6218
- 3,
6219
- 10
6220
- ];
6221
- }
6222
- if (!(!this.deps.isInAdBreak() && this.pool.length >= this.maxPoolSize)) return [
6223
- 3,
6224
- 3
6225
- ];
6226
- return [
6227
- 4,
6228
- new Promise(function(resolve) {
6229
- return setTimeout(resolve, 2e3);
6230
- })
6231
- ];
6232
- case 2:
6233
- _state.sent();
6234
- return [
6235
- 3,
6236
- 1
6237
- ];
6238
- case 3:
6239
- if (!this.deps.isInAdBreak() && this.deps.getPendingAdBreak() === null) {
6240
- if (this.deps.debug) {
6241
- console.log("[PRELOAD-POOL] Ad break cancelled, stopping preload pool");
6242
- }
6243
- return [
6244
- 3,
6245
- 10
6246
- ];
6247
- }
6248
- _state.label = 4;
6249
- case 4:
6250
- if (!(this.pool.length < this.maxPoolSize)) return [
6251
- 3,
6252
- 8
6253
- ];
6254
- if (!this.poolActive || epoch !== this.deps.timing.adBreakEpoch || this.deps.timing.isGamInCooldown()) {
6255
- return [
6256
- 3,
6257
- 8
6258
- ];
6259
- }
6260
- if (this.deps.isInAdBreak() && !this.deps.timing.hasTimeToStartAnotherAd()) {
6261
- if (this.deps.debug) {
6262
- console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
6263
- }
6264
- return [
6265
- 3,
6266
- 8
6267
- ];
6268
- }
6269
- newUrls = this.deps.generateVastUrlsWithCorrelators(baseVastUrl, 1);
6270
- newUrl = newUrls[0];
6271
- if (!(newUrl && !this.deps.timing.failedVastUrls.has(newUrl) && !this.deps.timing.isUrlInCooldown(newUrl))) return [
6272
- 3,
6273
- 6
6274
- ];
6275
- return [
6276
- 4,
6277
- this.preloadAdIntoPool(newUrl)
6278
- ];
6279
- case 5:
6280
- _state.sent();
6281
- _state.label = 6;
6282
- case 6:
6283
- return [
6284
- 4,
6285
- new Promise(function(resolve) {
6286
- return setTimeout(resolve, 1e3);
6287
- })
6288
- ];
6289
- case 7:
6290
- _state.sent();
6291
- return [
6292
- 3,
6293
- 4
6294
- ];
6295
- case 8:
6296
- return [
6297
- 4,
6298
- new Promise(function(resolve) {
6299
- return setTimeout(resolve, 2e3);
6300
- })
6301
- ];
6302
- case 9:
6303
- _state.sent();
6304
- return [
6305
- 3,
6306
- 1
6307
- ];
6308
- case 10:
6309
- this.loopRunning = false;
6310
- if (this.deps.debug) {
6311
- console.log("[PRELOAD-POOL] Preload loop ended");
6312
- }
6313
- return [
6314
- 2
6315
- ];
6316
- }
6317
- });
6318
- }).call(this);
6319
- }
6320
- },
6321
- {
6322
- key: "getPreloadedAd",
6323
- value: function getPreloadedAd() {
6324
- if (this.pool.length === 0) {
6325
- return null;
6326
- }
6327
- var entry = this.pool.shift();
6328
- if (!entry || !entry.isReady) {
6329
- return null;
6330
- }
6331
- if (this.deps.debug) {
6332
- console.log("[PRELOAD-POOL] Using preloaded ad from pool (".concat(this.pool.length, " remaining)"));
6333
- }
6334
- return {
6335
- vastUrl: entry.vastUrl,
6336
- adController: entry.adController
6337
- };
6338
- }
6339
- },
6340
- {
6341
- key: "stop",
6342
- value: function stop() {
6343
- this.poolActive = false;
6344
- this.loopRunning = false;
6345
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6346
- try {
6347
- for(var _iterator = this.pool[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6348
- var entry = _step.value;
6349
- try {
6350
- entry.adController.destroy();
6351
- } catch (error) {
6352
- if (this.deps.debug) {
6353
- console.warn("[PRELOAD-POOL] Error destroying preloaded controller:", error);
6354
- }
6355
- }
6356
- }
6357
- } catch (err) {
6358
- _didIteratorError = true;
6359
- _iteratorError = err;
6360
- } finally{
6361
- try {
6362
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6363
- _iterator.return();
6364
- }
6365
- } finally{
6366
- if (_didIteratorError) {
6367
- throw _iteratorError;
6368
- }
6369
- }
6370
- }
6371
- this.pool = [];
6372
- if (this.deps.debug) {
6373
- console.log("[PRELOAD-POOL] Preload pool stopped and cleaned up");
6374
- }
6375
- }
6376
- }
6377
- ]);
6378
- return AdPreloadPool;
6379
- }();
6380
- // src/player/PlaceholderLayer.ts
6381
- var PlaceholderLayer = /*#__PURE__*/ function() {
6382
- function PlaceholderLayer(video, debug) {
6383
- _class_call_check(this, PlaceholderLayer);
6384
- this.video = video;
6385
- this.debug = debug;
6386
- }
6387
- _create_class(PlaceholderLayer, [
6388
- {
6389
- key: "ensureContainer",
6390
- value: function ensureContainer() {
6391
- if (this.container) {
6392
- return;
6393
- }
6394
- var el = document.createElement("div");
6395
- el.style.position = "absolute";
6396
- el.style.left = "0";
6397
- el.style.top = "0";
6398
- el.style.right = "0";
6399
- el.style.bottom = "0";
6400
- el.style.display = "none";
6401
- el.style.alignItems = "center";
6402
- el.style.justifyContent = "center";
6403
- el.style.pointerEvents = "none";
6404
- el.style.zIndex = "5";
6405
- el.style.backgroundColor = "#000";
6406
- el.style.transition = "opacity 0.3s ease-in-out";
6407
- el.style.opacity = "0";
6408
- if (!this.video.parentElement) {
6409
- if (this.debug) {
6410
- console.warn("[StormcloudVideoPlayer] Video element has no parent for placeholder container");
6411
- }
6412
- return;
6413
- }
6414
- this.video.parentElement.appendChild(el);
6415
- this.container = el;
6416
- }
6417
- },
6418
- {
6419
- key: "show",
6420
- value: function show() {
6421
- var _this = this;
6422
- this.ensureContainer();
6423
- if (!this.container) {
6424
- return;
6425
- }
6426
- if (!this.video.muted) {
6427
- this.video.muted = true;
6428
- if (this.debug) {
6429
- console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
6430
- }
6431
- }
6432
- var wasHidden = this.container.style.display === "none" || this.container.style.opacity === "0";
6433
- if (wasHidden) {
6434
- this.container.style.transition = "none";
6435
- } else {
6436
- this.container.style.transition = "opacity 0.3s ease-in-out";
6437
- }
6438
- this.container.style.backgroundColor = "#000";
6439
- this.container.style.display = "flex";
6440
- this.container.offsetHeight;
6441
- this.container.style.opacity = "1";
6442
- this.container.style.pointerEvents = "auto";
6443
- if (wasHidden) {
6444
- requestAnimationFrame(function() {
6445
- if (_this.container) {
6446
- _this.container.style.transition = "opacity 0.3s ease-in-out";
6447
- }
6448
- });
6449
- }
6450
- if (this.debug) {
6451
- console.log("[StormcloudVideoPlayer] Showing placeholder layer (between content and ad layer)");
6452
- }
6453
- }
6454
- },
6455
- {
6456
- key: "hide",
6457
- value: function hide() {
6458
- var _this = this;
6459
- if (!this.container) {
6460
- return;
6461
- }
6462
- this.container.style.opacity = "0";
6463
- setTimeout(function() {
6464
- if (_this.container) {
6465
- _this.container.style.display = "none";
6466
- _this.container.style.pointerEvents = "none";
6467
- _this.container.style.backgroundColor = "#000";
6468
- }
6469
- }, 300);
6470
- if (this.debug) {
6471
- console.log("[StormcloudVideoPlayer] Hiding placeholder layer");
6472
- }
6473
- }
6474
- },
6475
- {
6476
- key: "destroy",
6477
- value: function destroy() {
6478
- if (this.container) {
6479
- if (this.container.parentElement) {
6480
- this.container.parentElement.removeChild(this.container);
6481
- }
6482
- this.container = void 0;
6483
- }
6484
- }
6485
- }
6486
- ]);
6487
- return PlaceholderLayer;
6488
- }();
6489
- // src/player/HlsEngine.ts
6490
- var import_hls2 = __toESM(require("hls.js"), 1);
6491
- var HlsEngine = /*#__PURE__*/ function() {
6492
- function HlsEngine(config, video, cueManager, timing, callbacks) {
6493
- _class_call_check(this, HlsEngine);
6494
- this.isLiveStream = false;
6495
- this.nativeHlsMode = false;
6496
- this.videoSrcProtection = null;
6497
- this.bufferedSegmentsCount = 0;
6498
- this.shouldAutoplayAfterBuffering = false;
6499
- this.hasInitialBufferCompleted = false;
6500
- this.config = config;
6501
- this.video = video;
6502
- this.cueManager = cueManager;
6503
- this.timing = timing;
6504
- this.callbacks = callbacks;
6505
- }
6506
- _create_class(HlsEngine, [
6507
- {
6508
- key: "debug",
6509
- get: function get() {
6510
- return !!this.config.debugAdTiming;
6511
- }
6512
- },
6513
- {
6514
- key: "shouldUseNativeHls",
6515
- value: function shouldUseNativeHls(getStreamType) {
6516
- var streamType = getStreamType();
6517
- if (streamType === "other") {
6518
- return true;
6519
- }
6520
- var canNative = this.video.canPlayType("application/vnd.apple.mpegurl");
6521
- return !!(this.config.allowNativeHls && canNative);
6522
- }
6523
- },
6524
- {
6525
- key: "setupNativeHls",
6526
- value: function setupNativeHls() {
6527
- return _async_to_generator(function() {
6528
- var _this_config_isLiveStream, _this_config_lowLatencyMode, adBehavior, _this_video_play;
6072
+ var _this_config_isLiveStream, _this_config_lowLatencyMode, adBehavior, _this_video_play;
6529
6073
  return _ts_generator(this, function(_state) {
6530
6074
  switch(_state.label){
6531
6075
  case 0:
@@ -7098,7 +6642,7 @@ function resizePlayer(video, adPlayer, debug) {
7098
6642
  }
7099
6643
  // src/player/AdBreakOrchestrator.ts
7100
6644
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
7101
- function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6645
+ function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
7102
6646
  _class_call_check(this, AdBreakOrchestrator);
7103
6647
  this.inAdBreak = false;
7104
6648
  this.showAds = false;
@@ -7112,7 +6656,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7112
6656
  this.pendingAdBreak = null;
7113
6657
  this.host = host;
7114
6658
  this.timing = timing;
7115
- this.preloadPool = preloadPool;
7116
6659
  this.adConfig = adConfig;
7117
6660
  this.cueManager = cueManager;
7118
6661
  this.placeholder = placeholder;
@@ -7131,23 +6674,19 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7131
6674
  }
7132
6675
  },
7133
6676
  {
7134
- key: "optimizedPodsEnabled",
7135
- get: // ───────────────────────────────────────────────────────────────
6677
+ // ───────────────────────────────────────────────────────────────
7136
6678
  // IMA event listeners
7137
6679
  // ───────────────────────────────────────────────────────────────
7138
- function get() {
7139
- return this.host.config.optimizedPods !== false;
7140
- }
7141
- },
7142
- {
7143
- key: "nextAdRequestUrl",
6680
+ /**
6681
+ * Produces the next pod ad-request URL for the current break. Every request
6682
+ * (initial and continuous-fetch top-up) carries pod macros (pmad/pmnd/pmxd,
6683
+ * no ppos); pmxd tracks the remaining break time so top-up pods only ask for
6684
+ * what still fits.
6685
+ */ key: "nextAdRequestUrl",
7144
6686
  value: function nextAdRequestUrl(baseVastUrl) {
7145
- if (this.optimizedPodsEnabled) {
7146
- var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
7147
- var breakDurationMs = remaining > 0 ? remaining : void 0;
7148
- return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7149
- }
7150
- return this.host.generateVastUrls(baseVastUrl, 1)[0];
6687
+ var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
6688
+ var breakDurationMs = remaining > 0 ? remaining : void 0;
6689
+ return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7151
6690
  }
7152
6691
  },
7153
6692
  {
@@ -7319,340 +6858,76 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7319
6858
  // ───────────────────────────────────────────────────────────────
7320
6859
  function handleAdStart(_marker) {
7321
6860
  return _async_to_generator(function() {
7322
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed, firstAdUrl, usePreloadedAd, preloadedController, preloaded, adPlayer, preservedMuted, preservedVolume, adVolume, adPlayer1, adVolume1, error, fallbackPreloaded, ap, adVolume2, fallbackError;
6861
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7323
6862
  return _ts_generator(this, function(_state) {
7324
6863
  switch(_state.label){
7325
6864
  case 0:
7326
6865
  scheduled = this.adConfig.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
7327
6866
  if (scheduled) {
7328
- this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
7329
- }
7330
- tags = this.adConfig.selectVastTagsForBreak(scheduled);
7331
- if (tags && tags.length > 0 && tags[0]) {
7332
- baseVastUrl = tags[0];
7333
- } else if (this.adConfig.apiVastTagUrl) {
7334
- baseVastUrl = this.adConfig.apiVastTagUrl;
7335
- } else {
7336
- this.clearPendingAdBreak();
7337
- return [
7338
- 2
7339
- ];
7340
- }
7341
- adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
7342
- if (this.debug) {
7343
- mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
7344
- console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
7345
- }
7346
- this.timing.failedVastUrls.clear();
7347
- this.timing.temporaryFailureUrls.clear();
7348
- this.timing.consecutiveFailures = 0;
7349
- this.continuousFetchingActive = true;
7350
- this.isShowingPlaceholder = false;
7351
- this.timing.totalAdRequestsInBreak = 0;
7352
- if (this.adConfig.podAssignedByPrefetch) {
7353
- this.adConfig.podAssignedByPrefetch = false;
7354
- } else {
7355
- this.adConfig.beginNewAdPod();
7356
- }
7357
- currentMuted = this.host.video.muted;
7358
- currentVolume = this.host.video.volume;
7359
- this.host.getAdPlayer().updateOriginalMutedState(currentMuted, currentVolume);
7360
- this.inAdBreak = true;
7361
- this.timing.adBreakPlayedDurationMs = 0;
7362
- this.timing.currentAdIndex = 0;
7363
- this.timing.totalAdsInBreak = 0;
7364
- this.adPodQueue = [];
7365
- this.showAds = false;
7366
- if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7367
- this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7368
- }
7369
- if (!this.optimizedPodsEnabled) return [
7370
- 3,
7371
- 2
7372
- ];
7373
- return [
7374
- 4,
7375
- this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7376
- ];
7377
- case 1:
7378
- podPlayed = _state.sent();
7379
- if (podPlayed) {
7380
- return [
7381
- 2
7382
- ];
7383
- }
7384
- if (this.debug) {
7385
- console.log("[POD] Optimized pod unavailable, falling back to sequential single-ad path");
7386
- }
7387
- _state.label = 2;
7388
- case 2:
7389
- usePreloadedAd = false;
7390
- preloaded = this.preloadPool.getPreloadedAd();
7391
- if (preloaded) {
7392
- firstAdUrl = preloaded.vastUrl;
7393
- preloadedController = preloaded.adController;
7394
- usePreloadedAd = true;
7395
- sendAdLoadedTracking(this.host.config.licenseKey, {
7396
- source: "hls",
7397
- vastUrl: firstAdUrl,
7398
- timestamp: /* @__PURE__ */ new Date().toISOString()
7399
- }, this.analyticsContext).catch(function() {});
7400
- if (this.debug) {
7401
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7402
- }
7403
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7404
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7405
- firstAdUrl = this.adRequestQueue.shift();
7406
- if (this.debug) {
7407
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7408
- }
7409
- this.clearPendingAdBreak();
7410
- } else {
7411
- if (this.debug) {
7412
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7413
- }
7414
- firstAdUrl = this.nextAdRequestUrl(baseVastUrl);
7415
- this.adRequestQueue = [];
7416
- }
7417
- if (!firstAdUrl) {
7418
- if (this.debug) {
7419
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7420
- }
7421
- this.handleAdPodComplete();
7422
- return [
7423
- 2
7424
- ];
7425
- }
7426
- if (this.debug) {
7427
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7428
- }
7429
- _state.label = 3;
7430
- case 3:
7431
- _state.trys.push([
7432
- 3,
7433
- 14,
7434
- ,
7435
- 22
7436
- ]);
7437
- if (!(usePreloadedAd && preloadedController)) return [
7438
- 3,
7439
- 7
7440
- ];
7441
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7442
- 3,
7443
- 5
7444
- ];
7445
- this.timing.rejectLoadedAdForDuration(preloadedController);
7446
- this.startContinuousFetching(baseVastUrl);
7447
- return [
7448
- 4,
7449
- this.tryNextAvailableAdWithRateLimit()
7450
- ];
7451
- case 4:
7452
- _state.sent();
7453
- return [
7454
- 2
7455
- ];
7456
- case 5:
7457
- adPlayer = this.host.getAdPlayer();
7458
- preservedMuted = adPlayer.getOriginalMutedState();
7459
- preservedVolume = adPlayer.getOriginalVolume();
7460
- adPlayer.destroy();
7461
- this.host.video.muted = true;
7462
- this.host.setAdPlayer(preloadedController);
7463
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7464
- this.attachImaEventListeners();
7465
- if (this.debug) {
7466
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7467
- }
7468
- preloadedController.resume();
7469
- this.timing.consecutiveFailures = 0;
7470
- this.startContinuousFetching(baseVastUrl);
7471
- if (!this.optimizedPodsEnabled) {
7472
- if (!this.preloadPool.active) {
7473
- this.preloadPool.active = true;
7474
- }
7475
- if (!this.preloadPool.isLoopRunning) {
7476
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7477
- }
7478
- }
7479
- return [
7480
- 4,
7481
- preloadedController.play()
7482
- ];
7483
- case 6:
7484
- _state.sent();
7485
- this.timing.markAdStarted();
7486
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7487
- this.timing.scheduleAdStopAtBreakBoundary();
7488
- }
7489
- adVolume = currentMuted ? 0 : currentVolume;
7490
- preloadedController.setAdVolume(adVolume);
7491
- return [
7492
- 3,
7493
- 13
7494
- ];
7495
- case 7:
7496
- adPlayer1 = this.host.getAdPlayer();
7497
- return [
7498
- 4,
7499
- this.timing.enforceGlobalRateLimit()
7500
- ];
7501
- case 8:
7502
- _state.sent();
7503
- this.timing.lastAdRequestTime = Date.now();
7504
- return [
7505
- 4,
7506
- adPlayer1.requestAds(firstAdUrl)
7507
- ];
7508
- case 9:
7509
- _state.sent();
7510
- sendAdLoadedTracking(this.host.config.licenseKey, {
7511
- source: "hls",
7512
- vastUrl: firstAdUrl,
7513
- timestamp: /* @__PURE__ */ new Date().toISOString()
7514
- }, this.analyticsContext).catch(function() {});
7515
- if (this.debug) {
7516
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7517
- }
7518
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7519
- 3,
7520
- 11
7521
- ];
7522
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7523
- this.recreateAdController();
7524
- this.startContinuousFetching(baseVastUrl);
7525
- return [
7526
- 4,
7527
- this.tryNextAvailableAdWithRateLimit()
7528
- ];
7529
- case 10:
7530
- _state.sent();
7531
- return [
7532
- 2
7533
- ];
7534
- case 11:
7535
- this.timing.consecutiveFailures = 0;
7536
- this.startContinuousFetching(baseVastUrl);
7537
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7538
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7539
- }
7540
- return [
7541
- 4,
7542
- adPlayer1.play()
7543
- ];
7544
- case 12:
7545
- _state.sent();
7546
- this.timing.markAdStarted();
7547
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7548
- this.timing.scheduleAdStopAtBreakBoundary();
7549
- }
7550
- adVolume1 = currentMuted ? 0 : currentVolume;
7551
- adPlayer1.setAdVolume(adVolume1);
7552
- _state.label = 13;
7553
- case 13:
7554
- return [
7555
- 3,
7556
- 22
7557
- ];
7558
- case 14:
7559
- error = _state.sent();
7560
- if (this.debug) {
7561
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
6867
+ this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
7562
6868
  }
7563
- if (!!usePreloadedAd) return [
7564
- 3,
7565
- 20
7566
- ];
7567
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7568
- if (!fallbackPreloaded) return [
7569
- 3,
7570
- 20
7571
- ];
6869
+ tags = this.adConfig.selectVastTagsForBreak(scheduled);
6870
+ if (tags && tags.length > 0 && tags[0]) {
6871
+ baseVastUrl = tags[0];
6872
+ } else if (this.adConfig.apiVastTagUrl) {
6873
+ baseVastUrl = this.adConfig.apiVastTagUrl;
6874
+ } else {
6875
+ this.clearPendingAdBreak();
6876
+ return [
6877
+ 2
6878
+ ];
6879
+ }
6880
+ adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
7572
6881
  if (this.debug) {
7573
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
6882
+ mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
6883
+ console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
7574
6884
  }
7575
- _state.label = 15;
7576
- case 15:
7577
- _state.trys.push([
7578
- 15,
7579
- 19,
7580
- ,
7581
- 20
7582
- ]);
7583
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7584
- 3,
7585
- 17
7586
- ];
7587
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7588
- this.startContinuousFetching(baseVastUrl);
7589
- return [
7590
- 4,
7591
- this.tryNextAvailableAdWithRateLimit()
7592
- ];
7593
- case 16:
7594
- _state.sent();
7595
- return [
7596
- 2
7597
- ];
7598
- case 17:
7599
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
6885
+ this.timing.failedVastUrls.clear();
6886
+ this.timing.temporaryFailureUrls.clear();
7600
6887
  this.timing.consecutiveFailures = 0;
7601
- this.startContinuousFetching(baseVastUrl);
7602
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7603
- this.preloadPool.active = true;
7604
- this.preloadPool.preloadPoolLoop(baseVastUrl);
6888
+ this.continuousFetchingActive = true;
6889
+ this.isShowingPlaceholder = false;
6890
+ this.timing.totalAdRequestsInBreak = 0;
6891
+ if (this.adConfig.podAssignedByPrefetch) {
6892
+ this.adConfig.podAssignedByPrefetch = false;
6893
+ } else {
6894
+ this.adConfig.beginNewAdPod();
7605
6895
  }
7606
- ap = this.host.getAdPlayer();
7607
- return [
7608
- 4,
7609
- ap.play()
7610
- ];
7611
- case 18:
7612
- _state.sent();
7613
- this.timing.markAdStarted();
7614
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7615
- this.timing.scheduleAdStopAtBreakBoundary();
6896
+ currentMuted = this.host.video.muted;
6897
+ currentVolume = this.host.video.volume;
6898
+ this.host.getAdPlayer().updateOriginalMutedState(currentMuted, currentVolume);
6899
+ this.inAdBreak = true;
6900
+ this.timing.adBreakPlayedDurationMs = 0;
6901
+ this.timing.currentAdIndex = 0;
6902
+ this.timing.totalAdsInBreak = 0;
6903
+ this.adPodQueue = [];
6904
+ this.showAds = false;
6905
+ if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
6906
+ this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7616
6907
  }
7617
- adVolume2 = currentMuted ? 0 : currentVolume;
7618
- ap.setAdVolume(adVolume2);
7619
6908
  return [
7620
- 2
6909
+ 4,
6910
+ this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7621
6911
  ];
7622
- case 19:
7623
- fallbackError = _state.sent();
7624
- if (this.debug) {
7625
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7626
- }
7627
- return [
6912
+ case 1:
6913
+ podPlayed = _state.sent();
6914
+ if (!!podPlayed) return [
7628
6915
  3,
7629
- 20
6916
+ 3
7630
6917
  ];
7631
- case 20:
7632
- if (this.timing.isTemporaryAdError(error)) {
7633
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7634
- if (this.debug) {
7635
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7636
- }
7637
- } else {
7638
- this.timing.failedVastUrls.add(firstAdUrl);
7639
- if (this.debug) {
7640
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7641
- }
6918
+ if (this.debug) {
6919
+ console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
7642
6920
  }
7643
- this.timing.consecutiveFailures++;
6921
+ this.continuousFetchingActive = true;
7644
6922
  this.startContinuousFetching(baseVastUrl);
7645
6923
  return [
7646
6924
  4,
7647
6925
  this.tryNextAvailableAdWithRateLimit()
7648
6926
  ];
7649
- case 21:
6927
+ case 2:
7650
6928
  _state.sent();
7651
- return [
7652
- 3,
7653
- 22
7654
- ];
7655
- case 22:
6929
+ _state.label = 3;
6930
+ case 3:
7656
6931
  return [
7657
6932
  2
7658
6933
  ];
@@ -7726,7 +7001,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7726
7001
  ];
7727
7002
  }
7728
7003
  if (this.debug) {
7729
- 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"));
7004
+ 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"));
7730
7005
  }
7731
7006
  sendAdLoadedTracking(this.host.config.licenseKey, {
7732
7007
  source: "hls",
@@ -7746,10 +7021,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7746
7021
  }
7747
7022
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7748
7023
  this.timing.consecutiveFailures = 0;
7749
- if (podCount === 1) {
7750
- this.continuousFetchingActive = true;
7751
- this.startContinuousFetching(baseVastUrl);
7752
- }
7024
+ this.continuousFetchingActive = true;
7025
+ this.startContinuousFetching(baseVastUrl);
7753
7026
  return [
7754
7027
  2,
7755
7028
  true
@@ -7782,20 +7055,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7782
7055
  }).call(this);
7783
7056
  }
7784
7057
  },
7785
- {
7786
- key: "swapToPreloadedAdPlayer",
7787
- value: function swapToPreloadedAdPlayer(preloadedController) {
7788
- var adPlayer = this.host.getAdPlayer();
7789
- var preservedMuted = adPlayer.getOriginalMutedState();
7790
- var preservedVolume = adPlayer.getOriginalVolume();
7791
- adPlayer.destroy();
7792
- this.host.video.muted = true;
7793
- this.host.setAdPlayer(preloadedController);
7794
- this.attachImaEventListeners();
7795
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7796
- preloadedController.resume();
7797
- }
7798
- },
7799
7058
  {
7800
7059
  // ───────────────────────────────────────────────────────────────
7801
7060
  // Continuous fetching
@@ -8046,7 +7305,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8046
7305
  value: function tryNextAvailableAd() {
8047
7306
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8048
7307
  return _async_to_generator(function() {
8049
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7308
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8050
7309
  return _ts_generator(this, function(_state) {
8051
7310
  switch(_state.label){
8052
7311
  case 0:
@@ -8084,132 +7343,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8084
7343
  ];
8085
7344
  }
8086
7345
  this.timing.cleanupTemporaryFailures();
8087
- preloaded = this.preloadPool.getPreloadedAd();
8088
- if (!preloaded) return [
8089
- 3,
8090
- 6
8091
- ];
8092
- if (this.debug) {
8093
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8094
- }
8095
- sendAdLoadedTracking(this.host.config.licenseKey, {
8096
- source: "hls",
8097
- vastUrl: preloaded.vastUrl,
8098
- timestamp: /* @__PURE__ */ new Date().toISOString()
8099
- }, this.analyticsContext).catch(function() {});
8100
7346
  _state.label = 1;
8101
7347
  case 1:
8102
- _state.trys.push([
8103
- 1,
8104
- 5,
8105
- ,
8106
- 6
8107
- ]);
8108
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8109
- 3,
8110
- 3
8111
- ];
8112
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8113
- return [
8114
- 4,
8115
- this.tryNextAvailableAdWithRateLimit()
8116
- ];
8117
- case 2:
8118
- _state.sent();
8119
- return [
8120
- 2
8121
- ];
8122
- case 3:
8123
- this.swapToPreloadedAdPlayer(preloaded.adController);
8124
- ap = this.host.getAdPlayer();
8125
- return [
8126
- 4,
8127
- ap.play()
8128
- ];
8129
- case 4:
8130
- _state.sent();
8131
- this.timing.markAdStarted();
8132
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8133
- this.timing.scheduleAdStopAtBreakBoundary();
8134
- }
8135
- ap.setAdVolume(getAdAudioVolume(ap));
8136
- this.timing.consecutiveFailures = 0;
8137
- return [
8138
- 2
8139
- ];
8140
- case 5:
8141
- error = _state.sent();
8142
- if (this.debug) {
8143
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8144
- }
8145
- return [
8146
- 3,
8147
- 6
8148
- ];
8149
- case 6:
8150
7348
  if (!(this.adRequestQueue.length > 0)) return [
8151
7349
  3,
8152
- 14
7350
+ 9
8153
7351
  ];
8154
7352
  nextAdUrl = this.adRequestQueue.shift();
8155
7353
  if (!nextAdUrl) return [
8156
7354
  3,
8157
- 6
7355
+ 1
8158
7356
  ];
8159
7357
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8160
7358
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8161
7359
  return [
8162
7360
  3,
8163
- 6
7361
+ 1
8164
7362
  ];
8165
7363
  }
8166
7364
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8167
7365
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8168
7366
  return [
8169
7367
  3,
8170
- 6
7368
+ 1
8171
7369
  ];
8172
7370
  }
8173
7371
  if (this.debug) {
8174
7372
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8175
7373
  }
8176
- _state.label = 7;
8177
- case 7:
7374
+ _state.label = 2;
7375
+ case 2:
8178
7376
  _state.trys.push([
8179
- 7,
8180
- 9,
7377
+ 2,
7378
+ 4,
8181
7379
  ,
8182
- 13
7380
+ 8
8183
7381
  ]);
8184
7382
  return [
8185
7383
  4,
8186
7384
  this.playSingleAd(nextAdUrl)
8187
7385
  ];
8188
- case 8:
7386
+ case 3:
8189
7387
  _state.sent();
8190
7388
  this.timing.consecutiveFailures = 0;
8191
7389
  return [
8192
7390
  3,
8193
- 13
7391
+ 8
8194
7392
  ];
8195
- case 9:
8196
- error1 = _state.sent();
8197
- errorMessage = error1.message;
7393
+ case 4:
7394
+ error = _state.sent();
7395
+ errorMessage = error.message;
8198
7396
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8199
7397
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8200
7398
  3,
8201
- 11
7399
+ 6
8202
7400
  ];
8203
7401
  return [
8204
7402
  4,
8205
7403
  this.tryNextAvailableAdWithRateLimit()
8206
7404
  ];
8207
- case 10:
7405
+ case 5:
8208
7406
  _state.sent();
8209
7407
  return [
8210
7408
  2
8211
7409
  ];
8212
- case 11:
7410
+ case 6:
8213
7411
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8214
7412
  this.timing.consecutiveFailures++;
8215
7413
  }
@@ -8217,21 +7415,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8217
7415
  4,
8218
7416
  this.tryNextAvailableAdWithRateLimit()
8219
7417
  ];
8220
- case 12:
7418
+ case 7:
8221
7419
  _state.sent();
8222
7420
  return [
8223
7421
  3,
8224
- 13
7422
+ 8
8225
7423
  ];
8226
- case 13:
7424
+ case 8:
8227
7425
  return [
8228
7426
  2
8229
7427
  ];
8230
- case 14:
7428
+ case 9:
8231
7429
  maxRetries = 3;
8232
7430
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8233
7431
  3,
8234
- 17
7432
+ 12
8235
7433
  ];
8236
7434
  if (this.debug) {
8237
7435
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8242,18 +7440,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8242
7440
  return setTimeout(resolve, 500);
8243
7441
  })
8244
7442
  ];
8245
- case 15:
7443
+ case 10:
8246
7444
  _state.sent();
8247
7445
  return [
8248
7446
  4,
8249
7447
  this.tryNextAvailableAd(retryCount + 1)
8250
7448
  ];
8251
- case 16:
7449
+ case 11:
8252
7450
  _state.sent();
8253
7451
  return [
8254
7452
  2
8255
7453
  ];
8256
- case 17:
7454
+ case 12:
8257
7455
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8258
7456
  this.showPlaceholderAndWaitForAds();
8259
7457
  } else {
@@ -8275,7 +7473,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8275
7473
  // ───────────────────────────────────────────────────────────────
8276
7474
  function playSingleAd(vastTagUrl) {
8277
7475
  return _async_to_generator(function() {
8278
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7476
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8279
7477
  return _ts_generator(this, function(_state) {
8280
7478
  switch(_state.label){
8281
7479
  case 0:
@@ -8307,9 +7505,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8307
7505
  case 1:
8308
7506
  _state.trys.push([
8309
7507
  1,
8310
- 12,
7508
+ 8,
8311
7509
  ,
8312
- 17
7510
+ 9
8313
7511
  ]);
8314
7512
  return [
8315
7513
  4,
@@ -8345,7 +7543,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8345
7543
  4,
8346
7544
  6,
8347
7545
  ,
8348
- 11
7546
+ 7
8349
7547
  ]);
8350
7548
  this.timing.startAdFailsafeTimer(requestToken);
8351
7549
  return [
@@ -8363,55 +7561,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8363
7561
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8364
7562
  return [
8365
7563
  3,
8366
- 11
7564
+ 7
8367
7565
  ];
8368
7566
  case 6:
8369
7567
  playError = _state.sent();
8370
7568
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8371
- preloadedFallback = this.preloadPool.getPreloadedAd();
8372
- if (!preloadedFallback) return [
8373
- 3,
8374
- 10
8375
- ];
8376
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8377
- _state.label = 7;
8378
- case 7:
8379
- _state.trys.push([
8380
- 7,
8381
- 9,
8382
- ,
8383
- 10
8384
- ]);
8385
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8386
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8387
- throw playError;
8388
- }
8389
- this.timing.clearAdFailsafeTimer();
8390
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8391
- this.timing.consecutiveFailures = 0;
8392
- fbAp = this.host.getAdPlayer();
8393
- return [
8394
- 4,
8395
- fbAp.play()
8396
- ];
8397
- case 8:
8398
- _state.sent();
8399
- this.timing.markAdStarted();
8400
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8401
- this.timing.scheduleAdStopAtBreakBoundary();
8402
- }
8403
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8404
- return [
8405
- 2
8406
- ];
8407
- case 9:
8408
- fallbackError = _state.sent();
8409
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8410
- return [
8411
- 3,
8412
- 10
8413
- ];
8414
- case 10:
8415
7569
  if (this.timing.isTemporaryAdError(playError)) {
8416
7570
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8417
7571
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8424,57 +7578,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8424
7578
  this.timing.activeAdRequestToken = null;
8425
7579
  }
8426
7580
  throw playError;
8427
- case 11:
7581
+ case 7:
8428
7582
  return [
8429
7583
  3,
8430
- 17
7584
+ 9
8431
7585
  ];
8432
- case 12:
7586
+ case 8:
8433
7587
  error = _state.sent();
8434
7588
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8435
7589
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8436
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8437
- if (!preloadedFallback1) return [
8438
- 3,
8439
- 16
8440
- ];
8441
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8442
- _state.label = 13;
8443
- case 13:
8444
- _state.trys.push([
8445
- 13,
8446
- 15,
8447
- ,
8448
- 16
8449
- ]);
8450
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8451
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8452
- throw error;
8453
- }
8454
- this.timing.clearAdRequestWatchdog();
8455
- this.timing.clearAdFailsafeTimer();
8456
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8457
- this.timing.consecutiveFailures = 0;
8458
- fbAp1 = this.host.getAdPlayer();
8459
- return [
8460
- 4,
8461
- fbAp1.play()
8462
- ];
8463
- case 14:
8464
- _state.sent();
8465
- this.timing.markAdStarted();
8466
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8467
- return [
8468
- 2
8469
- ];
8470
- case 15:
8471
- fallbackError1 = _state.sent();
8472
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8473
- return [
8474
- 3,
8475
- 16
8476
- ];
8477
- case 16:
8478
7590
  if (this.timing.isTemporaryAdError(error)) {
8479
7591
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8480
7592
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8488,7 +7600,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8488
7600
  this.timing.activeAdRequestToken = null;
8489
7601
  }
8490
7602
  throw error;
8491
- case 17:
7603
+ case 9:
8492
7604
  return [
8493
7605
  2
8494
7606
  ];
@@ -8678,7 +7790,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8678
7790
  }
8679
7791
  this.timing.resetForBreakEnd();
8680
7792
  this.stopContinuousFetching();
8681
- this.preloadPool.stop();
8682
7793
  this.clearPendingAdBreak();
8683
7794
  if (this.isShowingPlaceholder) {
8684
7795
  this.host.getAdPlayer().hidePlaceholder();
@@ -8788,25 +7899,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8788
7899
  return _this.adBreak.handleAdFailure();
8789
7900
  }
8790
7901
  });
8791
- this.preloadPool = new AdPreloadPool({
8792
- debug: !!this.config.debugAdTiming,
8793
- createAdPlayer: function createAdPlayer(c) {
8794
- return _this.createAdPlayer(c);
8795
- },
8796
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
8797
- return _this.shouldContinueLiveStreamDuringAds();
8798
- },
8799
- timing: this.timing,
8800
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
8801
- return _this.generateVastUrls(base, count);
8802
- },
8803
- isInAdBreak: function isInAdBreak() {
8804
- return _this.adBreak.inAdBreak;
8805
- },
8806
- getPendingAdBreak: function getPendingAdBreak() {
8807
- return _this.adBreak.pendingAdBreak;
8808
- }
8809
- });
8810
7902
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
8811
7903
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
8812
7904
  onManifestParsed: function onManifestParsed(isLive) {
@@ -8853,13 +7945,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8853
7945
  getLiveSyncPosition: function getLiveSyncPosition() {
8854
7946
  return _this.hlsEngine.getLiveSyncPosition();
8855
7947
  },
8856
- generateVastUrls: function generateVastUrls(base, count) {
8857
- return _this.generateVastUrls(base, count);
8858
- },
8859
7948
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8860
7949
  return _this.generatePodVastUrl(base, breakDurationMs);
8861
7950
  }
8862
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7951
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
8863
7952
  }
8864
7953
  _create_class(StormcloudVideoPlayer, [
8865
7954
  {
@@ -8884,12 +7973,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8884
7973
  } : {}));
8885
7974
  }
8886
7975
  },
8887
- {
8888
- key: "generateVastUrls",
8889
- value: function generateVastUrls(baseUrl, count) {
8890
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8891
- }
8892
- },
8893
7976
  {
8894
7977
  key: "generatePodVastUrl",
8895
7978
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9285,11 +8368,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9285
8368
  }
9286
8369
  this.adConfig.beginNewAdPod();
9287
8370
  this.adConfig.podAssignedByPrefetch = true;
9288
- var optimizedPods = this.config.optimizedPods !== false;
9289
8371
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9290
- var generatedUrls = optimizedPods ? [
8372
+ var generatedUrls = [
9291
8373
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9292
- ] : this.generateVastUrls(baseVastUrl, 1);
8374
+ ];
9293
8375
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9294
8376
  marker: marker
9295
8377
  }, fragmentSn !== void 0 ? {
@@ -9311,15 +8393,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9311
8393
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9312
8394
  if (this.debug) {
9313
8395
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9314
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9315
- }
9316
- if (optimizedPods) {
9317
- if (this.debug) {
9318
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9319
- }
9320
- return;
8396
+ console.log("[PREFETCH] Pre-generated pod request URL");
9321
8397
  }
9322
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9323
8398
  }
9324
8399
  },
9325
8400
  {
@@ -9558,7 +8633,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9558
8633
  value: function destroy() {
9559
8634
  var _this_adPlayer;
9560
8635
  this.adBreak.stopContinuousFetching();
9561
- this.preloadPool.stop();
9562
8636
  this.timing.destroy();
9563
8637
  this.adBreak.clearPendingAdBreak();
9564
8638
  this.placeholder.destroy();