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
@@ -812,24 +812,65 @@ function createHlsAdPlayer(contentVideo, options) {
812
812
  }
813
813
  }
814
814
  function fetchVastXml(vastTagUrl) {
815
+ var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
815
816
  return _async_to_generator(function() {
816
- var response;
817
+ var requestVast, response, error;
817
818
  return _ts_generator(this, function(_state) {
818
819
  switch(_state.label){
819
820
  case 0:
820
- return [
821
- 4,
822
- fetch(vastTagUrl, {
821
+ requestVast = function requestVast(creds) {
822
+ return fetch(vastTagUrl, {
823
823
  mode: "cors",
824
- credentials: "include",
824
+ credentials: creds,
825
825
  headers: {
826
826
  "Accept": "application/xml, text/xml, */*"
827
827
  },
828
828
  referrerPolicy: "no-referrer-when-downgrade"
829
- })
830
- ];
829
+ });
830
+ };
831
+ _state.label = 1;
831
832
  case 1:
833
+ _state.trys.push([
834
+ 1,
835
+ 3,
836
+ ,
837
+ 7
838
+ ]);
839
+ return [
840
+ 4,
841
+ requestVast(credentials)
842
+ ];
843
+ case 2:
844
+ response = _state.sent();
845
+ return [
846
+ 3,
847
+ 7
848
+ ];
849
+ case 3:
850
+ error = _state.sent();
851
+ if (!(credentials !== "omit")) return [
852
+ 3,
853
+ 5
854
+ ];
855
+ console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
856
+ return [
857
+ 4,
858
+ requestVast("omit")
859
+ ];
860
+ case 4:
832
861
  response = _state.sent();
862
+ return [
863
+ 3,
864
+ 6
865
+ ];
866
+ case 5:
867
+ throw error;
868
+ case 6:
869
+ return [
870
+ 3,
871
+ 7
872
+ ];
873
+ case 7:
833
874
  if (!response.ok) {
834
875
  throw new Error("Failed to fetch VAST: ".concat(response.statusText));
835
876
  }
@@ -851,7 +892,7 @@ function createHlsAdPlayer(contentVideo, options) {
851
892
  depth = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : 0, accumulatedTracking = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : createEmptyTrackingUrls();
852
893
  return [
853
894
  4,
854
- fetchVastXml(vastTagUrl)
895
+ fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit")
855
896
  ];
856
897
  case 1:
857
898
  vastXml = _state.sent();
@@ -3503,21 +3544,16 @@ function applyVastMacros(baseUrl, ctx) {
3503
3544
  if (ctx.pod != null) {
3504
3545
  params.set("pod", String(ctx.pod));
3505
3546
  }
3506
- var optimizedPodMode = ctx.podMaxAds != null || ctx.podMinDurationMs != null || ctx.podMaxDurationMs != null;
3507
- if (optimizedPodMode) {
3508
- params.delete("ppos");
3509
- params.delete("lip");
3510
- if (ctx.podMinDurationMs != null) {
3511
- params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3512
- }
3513
- if (ctx.podMaxDurationMs != null) {
3514
- params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3515
- }
3516
- if (ctx.podMaxAds != null) {
3517
- params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3518
- }
3519
- } else if (ctx.adPosition != null) {
3520
- params.set("ppos", String(ctx.adPosition));
3547
+ params.delete("ppos");
3548
+ params.delete("lip");
3549
+ if (ctx.podMinDurationMs != null) {
3550
+ params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3551
+ }
3552
+ if (ctx.podMaxDurationMs != null) {
3553
+ params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3554
+ }
3555
+ if (ctx.podMaxAds != null) {
3556
+ params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3521
3557
  }
3522
3558
  var requestUrl = ctx.contentUrl || ctx.pageUrl;
3523
3559
  if (requestUrl) {
@@ -4857,9 +4893,9 @@ var AdConfigManager = /*#__PURE__*/ function() {
4857
4893
  this.consentSignals = {};
4858
4894
  this.podCounter = 0;
4859
4895
  this.podAssignedByPrefetch = false;
4860
- this.adRequestPositionInBreak = 0;
4861
4896
  this.lastHeartbeatTime = 0;
4862
4897
  this.defaultPodMaxAds = 6;
4898
+ this.defaultPodMaxDurationMs = 12e4;
4863
4899
  this.config = config;
4864
4900
  this.video = video;
4865
4901
  }
@@ -5277,48 +5313,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
5277
5313
  key: "beginNewAdPod",
5278
5314
  value: function beginNewAdPod() {
5279
5315
  this.podCounter++;
5280
- this.adRequestPositionInBreak = 0;
5281
- }
5282
- },
5283
- {
5284
- key: "generateVastUrlsWithCorrelators",
5285
- value: function generateVastUrlsWithCorrelators(baseUrl, count, adPlayer, palNonce, inAdBreak) {
5286
- var urls = [];
5287
- for(var i = 0; i < count; i++){
5288
- this.adRequestPositionInBreak++;
5289
- var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
5290
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
5291
- var urlWithMacros = applyVastMacros(baseUrl, {
5292
- correlator: this.viewCorrelator,
5293
- streamCorrelator: this.streamCorrelator,
5294
- pod: this.podCounter > 0 ? this.podCounter : void 0,
5295
- adPosition: this.adRequestPositionInBreak,
5296
- isCtv: envSignals.isCtv,
5297
- contentUrl: envSignals.contentUrl,
5298
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5299
- adWillPlayMuted: adWillPlayMuted,
5300
- adWillAutoPlay: !!this.config.autoplay,
5301
- appId: envSignals.appId,
5302
- appName: envSignals.appName,
5303
- sessionId: envSignals.sessionId,
5304
- deviceId: envSignals.deviceId,
5305
- deviceIdType: envSignals.deviceIdType,
5306
- limitAdTracking: envSignals.limitAdTracking,
5307
- deviceTypeHint: envSignals.deviceTypeHint,
5308
- adTest: this.config.adTest,
5309
- consent: this.consentSignals
5310
- });
5311
- var finalUrl = palNonce.injectNonce(urlWithMacros);
5312
- console.log("[StormcloudVideoPlayer] Resolved ad request URL (pod=".concat(this.podCounter, ", pos=").concat(this.adRequestPositionInBreak, "):"), finalUrl);
5313
- urls.push(finalUrl);
5314
- }
5315
- return urls;
5316
5316
  }
5317
5317
  },
5318
5318
  {
5319
5319
  key: "resolvePodParams",
5320
5320
  value: function resolvePodParams(breakDurationMs) {
5321
- var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs;
5321
+ var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs != null && this.config.podMaxDurationMs > 0 ? this.config.podMaxDurationMs : this.defaultPodMaxDurationMs;
5322
5322
  var maxAds = this.config.podMaxAds && this.config.podMaxAds > 0 ? this.config.podMaxAds : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultPodMaxAds;
5323
5323
  var minDurationMs = this.config.podExactDuration && maxDurationMs != null ? maxDurationMs : 0;
5324
5324
  return {
@@ -5971,611 +5971,155 @@ var AdTimingService = /*#__PURE__*/ function() {
5971
5971
  ]);
5972
5972
  return AdTimingService;
5973
5973
  }();
5974
- // src/player/AdPreloadPool.ts
5975
- var AdPreloadPool = /*#__PURE__*/ function() {
5976
- function AdPreloadPool(deps) {
5977
- _class_call_check(this, AdPreloadPool);
5978
- this.pool = [];
5979
- this.maxPoolSize = 2;
5980
- this.poolActive = false;
5981
- this.loopRunning = false;
5982
- this.deps = deps;
5983
- }
5984
- _create_class(AdPreloadPool, [
5985
- {
5986
- key: "active",
5987
- get: function get() {
5988
- return this.poolActive;
5989
- },
5990
- set: function set(value) {
5991
- this.poolActive = value;
5992
- }
5993
- },
5974
+ // src/player/PlaceholderLayer.ts
5975
+ var PlaceholderLayer = /*#__PURE__*/ function() {
5976
+ function PlaceholderLayer(video, debug) {
5977
+ _class_call_check(this, PlaceholderLayer);
5978
+ this.video = video;
5979
+ this.debug = debug;
5980
+ }
5981
+ _create_class(PlaceholderLayer, [
5994
5982
  {
5995
- key: "isLoopRunning",
5996
- get: function get() {
5997
- return this.loopRunning;
5983
+ key: "ensureContainer",
5984
+ value: function ensureContainer() {
5985
+ if (this.container) {
5986
+ return;
5987
+ }
5988
+ var el = document.createElement("div");
5989
+ el.style.position = "absolute";
5990
+ el.style.left = "0";
5991
+ el.style.top = "0";
5992
+ el.style.right = "0";
5993
+ el.style.bottom = "0";
5994
+ el.style.display = "none";
5995
+ el.style.alignItems = "center";
5996
+ el.style.justifyContent = "center";
5997
+ el.style.pointerEvents = "none";
5998
+ el.style.zIndex = "5";
5999
+ el.style.backgroundColor = "#000";
6000
+ el.style.transition = "opacity 0.3s ease-in-out";
6001
+ el.style.opacity = "0";
6002
+ if (!this.video.parentElement) {
6003
+ if (this.debug) {
6004
+ console.warn("[StormcloudVideoPlayer] Video element has no parent for placeholder container");
6005
+ }
6006
+ return;
6007
+ }
6008
+ this.video.parentElement.appendChild(el);
6009
+ this.container = el;
5998
6010
  }
5999
6011
  },
6000
6012
  {
6001
- key: "startPreloadPool",
6002
- value: function startPreloadPool(baseVastUrl, initialUrls) {
6003
- var startLoopImmediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
6004
- if (this.poolActive) {
6005
- if (this.deps.debug) {
6006
- console.log("[PRELOAD-POOL] Already active, skipping duplicate start");
6007
- }
6013
+ key: "show",
6014
+ value: function show() {
6015
+ var _this = this;
6016
+ this.ensureContainer();
6017
+ if (!this.container) {
6008
6018
  return;
6009
6019
  }
6010
- this.poolActive = true;
6011
- if (this.deps.debug) {
6012
- console.log("[PRELOAD-POOL] Starting preload pool EARLY (target size: ".concat(this.maxPoolSize, ")"));
6013
- console.log("[PRELOAD-POOL] Ad break hasn't started yet, but preloading ads in advance");
6014
- }
6015
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6016
- try {
6017
- for(var _iterator = initialUrls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6018
- var url = _step.value;
6019
- if (this.pool.length < this.maxPoolSize) {
6020
- this.preloadAdIntoPool(url);
6021
- }
6020
+ if (!this.video.muted) {
6021
+ this.video.muted = true;
6022
+ if (this.debug) {
6023
+ console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
6022
6024
  }
6023
- } catch (err) {
6024
- _didIteratorError = true;
6025
- _iteratorError = err;
6026
- } finally{
6027
- try {
6028
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6029
- _iterator.return();
6030
- }
6031
- } finally{
6032
- if (_didIteratorError) {
6033
- throw _iteratorError;
6025
+ }
6026
+ var wasHidden = this.container.style.display === "none" || this.container.style.opacity === "0";
6027
+ if (wasHidden) {
6028
+ this.container.style.transition = "none";
6029
+ } else {
6030
+ this.container.style.transition = "opacity 0.3s ease-in-out";
6031
+ }
6032
+ this.container.style.backgroundColor = "#000";
6033
+ this.container.style.display = "flex";
6034
+ this.container.offsetHeight;
6035
+ this.container.style.opacity = "1";
6036
+ this.container.style.pointerEvents = "auto";
6037
+ if (wasHidden) {
6038
+ requestAnimationFrame(function() {
6039
+ if (_this.container) {
6040
+ _this.container.style.transition = "opacity 0.3s ease-in-out";
6034
6041
  }
6042
+ });
6043
+ }
6044
+ if (this.debug) {
6045
+ console.log("[StormcloudVideoPlayer] Showing placeholder layer (between content and ad layer)");
6046
+ }
6047
+ }
6048
+ },
6049
+ {
6050
+ key: "hide",
6051
+ value: function hide() {
6052
+ var _this = this;
6053
+ if (!this.container) {
6054
+ return;
6055
+ }
6056
+ this.container.style.opacity = "0";
6057
+ setTimeout(function() {
6058
+ if (_this.container) {
6059
+ _this.container.style.display = "none";
6060
+ _this.container.style.pointerEvents = "none";
6061
+ _this.container.style.backgroundColor = "#000";
6035
6062
  }
6063
+ }, 300);
6064
+ if (this.debug) {
6065
+ console.log("[StormcloudVideoPlayer] Hiding placeholder layer");
6036
6066
  }
6037
- if (startLoopImmediately) {
6038
- this.preloadPoolLoop(baseVastUrl);
6039
- } else if (this.deps.debug) {
6040
- console.log("[PRELOAD-POOL] Pre-break mode: preloaded once, waiting for SCTE start to continue fetching");
6067
+ }
6068
+ },
6069
+ {
6070
+ key: "destroy",
6071
+ value: function destroy() {
6072
+ if (this.container) {
6073
+ if (this.container.parentElement) {
6074
+ this.container.parentElement.removeChild(this.container);
6075
+ }
6076
+ this.container = void 0;
6041
6077
  }
6042
6078
  }
6079
+ }
6080
+ ]);
6081
+ return PlaceholderLayer;
6082
+ }();
6083
+ // src/player/HlsEngine.ts
6084
+ var import_hls2 = __toESM(require("hls.js"), 1);
6085
+ var HlsEngine = /*#__PURE__*/ function() {
6086
+ function HlsEngine(config, video, cueManager, timing, callbacks) {
6087
+ _class_call_check(this, HlsEngine);
6088
+ this.isLiveStream = false;
6089
+ this.nativeHlsMode = false;
6090
+ this.videoSrcProtection = null;
6091
+ this.bufferedSegmentsCount = 0;
6092
+ this.shouldAutoplayAfterBuffering = false;
6093
+ this.hasInitialBufferCompleted = false;
6094
+ this.config = config;
6095
+ this.video = video;
6096
+ this.cueManager = cueManager;
6097
+ this.timing = timing;
6098
+ this.callbacks = callbacks;
6099
+ }
6100
+ _create_class(HlsEngine, [
6101
+ {
6102
+ key: "debug",
6103
+ get: function get() {
6104
+ return !!this.config.debugAdTiming;
6105
+ }
6043
6106
  },
6044
6107
  {
6045
- key: "preloadAdIntoPool",
6046
- value: function preloadAdIntoPool(vastUrl) {
6047
- return _async_to_generator(function() {
6048
- var _this, timing, epoch, loadPromise;
6049
- return _ts_generator(this, function(_state) {
6050
- _this = this;
6051
- timing = this.deps.timing;
6052
- if (timing.isGamInCooldown()) {
6053
- if (this.deps.debug) {
6054
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
6055
- }
6056
- return [
6057
- 2
6058
- ];
6059
- }
6060
- if (this.pool.some(function(entry) {
6061
- return entry.vastUrl === vastUrl;
6062
- }) || timing.failedVastUrls.has(vastUrl) || timing.isUrlInCooldown(vastUrl)) {
6063
- return [
6064
- 2
6065
- ];
6066
- }
6067
- if (this.pool.length >= this.maxPoolSize) {
6068
- return [
6069
- 2
6070
- ];
6071
- }
6072
- if (this.deps.debug) {
6073
- console.log("[PRELOAD-POOL] Preloading ad into pool: ".concat(vastUrl));
6074
- }
6075
- epoch = timing.adBreakEpoch;
6076
- loadPromise = function() {
6077
- return _async_to_generator(function() {
6078
- var _this, hasAdError, adErrorPayload, errorListenerCleanup, _preloadAd_getLoadedAdDuration, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, loadedDuration, lateErrorListener, _poolEntry_durationSeconds, error;
6079
- return _ts_generator(this, function(_state) {
6080
- switch(_state.label){
6081
- case 0:
6082
- _this = this;
6083
- hasAdError = false;
6084
- adErrorPayload = null;
6085
- errorListenerCleanup = null;
6086
- _state.label = 1;
6087
- case 1:
6088
- _state.trys.push([
6089
- 1,
6090
- 5,
6091
- ,
6092
- 6
6093
- ]);
6094
- continueLiveStreamDuringAds = this.deps.shouldContinueLiveStreamDuringAds();
6095
- preloadAd = this.deps.createAdPlayer(continueLiveStreamDuringAds);
6096
- preloadAd.initialize();
6097
- errorListener = function errorListener(payload) {
6098
- hasAdError = true;
6099
- adErrorPayload = payload;
6100
- };
6101
- preloadAd.on("ad_error", errorListener);
6102
- errorListenerCleanup = function errorListenerCleanup() {
6103
- return preloadAd.off("ad_error", errorListener);
6104
- };
6105
- return [
6106
- 4,
6107
- timing.enforceGlobalRateLimit()
6108
- ];
6109
- case 2:
6110
- _state.sent();
6111
- return [
6112
- 4,
6113
- preloadAd.requestAds(vastUrl)
6114
- ];
6115
- case 3:
6116
- _state.sent();
6117
- preloadAd.pause();
6118
- return [
6119
- 4,
6120
- new Promise(function(resolve) {
6121
- return setTimeout(resolve, 1500);
6122
- })
6123
- ];
6124
- case 4:
6125
- _state.sent();
6126
- preloadAd.pause();
6127
- if (hasAdError) {
6128
- 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;
6129
- if (errorListenerCleanup) {
6130
- errorListenerCleanup();
6131
- }
6132
- preloadAd.destroy();
6133
- timing.recordGamNoFill();
6134
- if (isNoFill) {
6135
- if (this.deps.debug) {
6136
- console.log("[PRELOAD-POOL] Ad preload returned no-fill: ".concat(vastUrl));
6137
- }
6138
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6139
- } else {
6140
- if (this.deps.debug) {
6141
- console.log("[PRELOAD-POOL] Ad preload failed with error: ".concat(vastUrl), adErrorPayload);
6142
- }
6143
- if (adErrorPayload && !timing.isTemporaryAdError(adErrorPayload)) {
6144
- timing.failedVastUrls.add(vastUrl);
6145
- } else {
6146
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6147
- }
6148
- }
6149
- return [
6150
- 2
6151
- ];
6152
- }
6153
- if (!this.poolActive || epoch !== timing.adBreakEpoch) {
6154
- if (this.deps.debug) {
6155
- console.log("[PRELOAD-POOL] Discarding preloaded ad - break ended during fetch");
6156
- }
6157
- if (errorListenerCleanup) {
6158
- errorListenerCleanup();
6159
- }
6160
- try {
6161
- preloadAd.destroy();
6162
- } catch (unused) {}
6163
- return [
6164
- 2
6165
- ];
6166
- }
6167
- poolEntry = {
6168
- vastUrl: vastUrl,
6169
- adController: preloadAd,
6170
- loadedAt: Date.now(),
6171
- isReady: true,
6172
- loadPromise: Promise.resolve()
6173
- };
6174
- loadedDuration = (_preloadAd_getLoadedAdDuration = preloadAd.getLoadedAdDuration) === null || _preloadAd_getLoadedAdDuration === void 0 ? void 0 : _preloadAd_getLoadedAdDuration.call(preloadAd);
6175
- if (loadedDuration != null && loadedDuration > 0) {
6176
- poolEntry.durationSeconds = loadedDuration;
6177
- }
6178
- lateErrorListener = function lateErrorListener(payload) {
6179
- var index = _this.pool.findIndex(function(entry) {
6180
- return entry.vastUrl === vastUrl;
6181
- });
6182
- if (index >= 0) {
6183
- _this.pool.splice(index, 1);
6184
- if (_this.deps.debug) {
6185
- console.log("[PRELOAD-POOL] Late error detected, removed from pool: ".concat(vastUrl), payload);
6186
- }
6187
- try {
6188
- preloadAd.destroy();
6189
- } catch (unused) {}
6190
- }
6191
- };
6192
- preloadAd.on("ad_error", lateErrorListener);
6193
- this.pool.push(poolEntry);
6194
- if (this.deps.debug) {
6195
- ;
6196
- 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)"));
6197
- }
6198
- if (errorListenerCleanup) {
6199
- errorListenerCleanup();
6200
- }
6201
- return [
6202
- 3,
6203
- 6
6204
- ];
6205
- case 5:
6206
- error = _state.sent();
6207
- if (errorListenerCleanup) {
6208
- errorListenerCleanup();
6209
- }
6210
- timing.recordGamNoFill();
6211
- if (this.deps.debug) {
6212
- console.warn("[PRELOAD-POOL] Failed to preload ad: ".concat(vastUrl), error);
6213
- }
6214
- if (_instanceof(error, Error) && !timing.isTemporaryAdError(error)) {
6215
- timing.failedVastUrls.add(vastUrl);
6216
- } else if (_instanceof(error, Error) && timing.isTemporaryAdError(error)) {
6217
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6218
- }
6219
- return [
6220
- 3,
6221
- 6
6222
- ];
6223
- case 6:
6224
- return [
6225
- 2
6226
- ];
6227
- }
6228
- });
6229
- }).call(_this);
6230
- }();
6231
- loadPromise.catch(function() {});
6232
- return [
6233
- 2
6234
- ];
6235
- });
6236
- }).call(this);
6108
+ key: "shouldUseNativeHls",
6109
+ value: function shouldUseNativeHls(getStreamType) {
6110
+ var streamType = getStreamType();
6111
+ if (streamType === "other") {
6112
+ return true;
6113
+ }
6114
+ var canNative = this.video.canPlayType("application/vnd.apple.mpegurl");
6115
+ return !!(this.config.allowNativeHls && canNative);
6237
6116
  }
6238
6117
  },
6239
6118
  {
6240
- key: "preloadPoolLoop",
6241
- value: function preloadPoolLoop(baseVastUrl) {
6119
+ key: "setupNativeHls",
6120
+ value: function setupNativeHls() {
6242
6121
  return _async_to_generator(function() {
6243
- var epoch, newUrls, newUrl;
6244
- return _ts_generator(this, function(_state) {
6245
- switch(_state.label){
6246
- case 0:
6247
- if (this.loopRunning) {
6248
- return [
6249
- 2
6250
- ];
6251
- }
6252
- this.loopRunning = true;
6253
- epoch = this.deps.timing.adBreakEpoch;
6254
- if (this.deps.debug) {
6255
- console.log("[PRELOAD-POOL] Starting continuous preload loop");
6256
- }
6257
- _state.label = 1;
6258
- case 1:
6259
- if (!(this.poolActive && epoch === this.deps.timing.adBreakEpoch)) return [
6260
- 3,
6261
- 10
6262
- ];
6263
- if (this.deps.timing.isGamInCooldown()) {
6264
- if (this.deps.debug) {
6265
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
6266
- }
6267
- return [
6268
- 3,
6269
- 10
6270
- ];
6271
- }
6272
- if (!(!this.deps.isInAdBreak() && this.pool.length >= this.maxPoolSize)) return [
6273
- 3,
6274
- 3
6275
- ];
6276
- return [
6277
- 4,
6278
- new Promise(function(resolve) {
6279
- return setTimeout(resolve, 2e3);
6280
- })
6281
- ];
6282
- case 2:
6283
- _state.sent();
6284
- return [
6285
- 3,
6286
- 1
6287
- ];
6288
- case 3:
6289
- if (!this.deps.isInAdBreak() && this.deps.getPendingAdBreak() === null) {
6290
- if (this.deps.debug) {
6291
- console.log("[PRELOAD-POOL] Ad break cancelled, stopping preload pool");
6292
- }
6293
- return [
6294
- 3,
6295
- 10
6296
- ];
6297
- }
6298
- _state.label = 4;
6299
- case 4:
6300
- if (!(this.pool.length < this.maxPoolSize)) return [
6301
- 3,
6302
- 8
6303
- ];
6304
- if (!this.poolActive || epoch !== this.deps.timing.adBreakEpoch || this.deps.timing.isGamInCooldown()) {
6305
- return [
6306
- 3,
6307
- 8
6308
- ];
6309
- }
6310
- if (this.deps.isInAdBreak() && !this.deps.timing.hasTimeToStartAnotherAd()) {
6311
- if (this.deps.debug) {
6312
- console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
6313
- }
6314
- return [
6315
- 3,
6316
- 8
6317
- ];
6318
- }
6319
- newUrls = this.deps.generateVastUrlsWithCorrelators(baseVastUrl, 1);
6320
- newUrl = newUrls[0];
6321
- if (!(newUrl && !this.deps.timing.failedVastUrls.has(newUrl) && !this.deps.timing.isUrlInCooldown(newUrl))) return [
6322
- 3,
6323
- 6
6324
- ];
6325
- return [
6326
- 4,
6327
- this.preloadAdIntoPool(newUrl)
6328
- ];
6329
- case 5:
6330
- _state.sent();
6331
- _state.label = 6;
6332
- case 6:
6333
- return [
6334
- 4,
6335
- new Promise(function(resolve) {
6336
- return setTimeout(resolve, 1e3);
6337
- })
6338
- ];
6339
- case 7:
6340
- _state.sent();
6341
- return [
6342
- 3,
6343
- 4
6344
- ];
6345
- case 8:
6346
- return [
6347
- 4,
6348
- new Promise(function(resolve) {
6349
- return setTimeout(resolve, 2e3);
6350
- })
6351
- ];
6352
- case 9:
6353
- _state.sent();
6354
- return [
6355
- 3,
6356
- 1
6357
- ];
6358
- case 10:
6359
- this.loopRunning = false;
6360
- if (this.deps.debug) {
6361
- console.log("[PRELOAD-POOL] Preload loop ended");
6362
- }
6363
- return [
6364
- 2
6365
- ];
6366
- }
6367
- });
6368
- }).call(this);
6369
- }
6370
- },
6371
- {
6372
- key: "getPreloadedAd",
6373
- value: function getPreloadedAd() {
6374
- if (this.pool.length === 0) {
6375
- return null;
6376
- }
6377
- var entry = this.pool.shift();
6378
- if (!entry || !entry.isReady) {
6379
- return null;
6380
- }
6381
- if (this.deps.debug) {
6382
- console.log("[PRELOAD-POOL] Using preloaded ad from pool (".concat(this.pool.length, " remaining)"));
6383
- }
6384
- return {
6385
- vastUrl: entry.vastUrl,
6386
- adController: entry.adController
6387
- };
6388
- }
6389
- },
6390
- {
6391
- key: "stop",
6392
- value: function stop() {
6393
- this.poolActive = false;
6394
- this.loopRunning = false;
6395
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6396
- try {
6397
- for(var _iterator = this.pool[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6398
- var entry = _step.value;
6399
- try {
6400
- entry.adController.destroy();
6401
- } catch (error) {
6402
- if (this.deps.debug) {
6403
- console.warn("[PRELOAD-POOL] Error destroying preloaded controller:", error);
6404
- }
6405
- }
6406
- }
6407
- } catch (err) {
6408
- _didIteratorError = true;
6409
- _iteratorError = err;
6410
- } finally{
6411
- try {
6412
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6413
- _iterator.return();
6414
- }
6415
- } finally{
6416
- if (_didIteratorError) {
6417
- throw _iteratorError;
6418
- }
6419
- }
6420
- }
6421
- this.pool = [];
6422
- if (this.deps.debug) {
6423
- console.log("[PRELOAD-POOL] Preload pool stopped and cleaned up");
6424
- }
6425
- }
6426
- }
6427
- ]);
6428
- return AdPreloadPool;
6429
- }();
6430
- // src/player/PlaceholderLayer.ts
6431
- var PlaceholderLayer = /*#__PURE__*/ function() {
6432
- function PlaceholderLayer(video, debug) {
6433
- _class_call_check(this, PlaceholderLayer);
6434
- this.video = video;
6435
- this.debug = debug;
6436
- }
6437
- _create_class(PlaceholderLayer, [
6438
- {
6439
- key: "ensureContainer",
6440
- value: function ensureContainer() {
6441
- if (this.container) {
6442
- return;
6443
- }
6444
- var el = document.createElement("div");
6445
- el.style.position = "absolute";
6446
- el.style.left = "0";
6447
- el.style.top = "0";
6448
- el.style.right = "0";
6449
- el.style.bottom = "0";
6450
- el.style.display = "none";
6451
- el.style.alignItems = "center";
6452
- el.style.justifyContent = "center";
6453
- el.style.pointerEvents = "none";
6454
- el.style.zIndex = "5";
6455
- el.style.backgroundColor = "#000";
6456
- el.style.transition = "opacity 0.3s ease-in-out";
6457
- el.style.opacity = "0";
6458
- if (!this.video.parentElement) {
6459
- if (this.debug) {
6460
- console.warn("[StormcloudVideoPlayer] Video element has no parent for placeholder container");
6461
- }
6462
- return;
6463
- }
6464
- this.video.parentElement.appendChild(el);
6465
- this.container = el;
6466
- }
6467
- },
6468
- {
6469
- key: "show",
6470
- value: function show() {
6471
- var _this = this;
6472
- this.ensureContainer();
6473
- if (!this.container) {
6474
- return;
6475
- }
6476
- if (!this.video.muted) {
6477
- this.video.muted = true;
6478
- if (this.debug) {
6479
- console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
6480
- }
6481
- }
6482
- var wasHidden = this.container.style.display === "none" || this.container.style.opacity === "0";
6483
- if (wasHidden) {
6484
- this.container.style.transition = "none";
6485
- } else {
6486
- this.container.style.transition = "opacity 0.3s ease-in-out";
6487
- }
6488
- this.container.style.backgroundColor = "#000";
6489
- this.container.style.display = "flex";
6490
- this.container.offsetHeight;
6491
- this.container.style.opacity = "1";
6492
- this.container.style.pointerEvents = "auto";
6493
- if (wasHidden) {
6494
- requestAnimationFrame(function() {
6495
- if (_this.container) {
6496
- _this.container.style.transition = "opacity 0.3s ease-in-out";
6497
- }
6498
- });
6499
- }
6500
- if (this.debug) {
6501
- console.log("[StormcloudVideoPlayer] Showing placeholder layer (between content and ad layer)");
6502
- }
6503
- }
6504
- },
6505
- {
6506
- key: "hide",
6507
- value: function hide() {
6508
- var _this = this;
6509
- if (!this.container) {
6510
- return;
6511
- }
6512
- this.container.style.opacity = "0";
6513
- setTimeout(function() {
6514
- if (_this.container) {
6515
- _this.container.style.display = "none";
6516
- _this.container.style.pointerEvents = "none";
6517
- _this.container.style.backgroundColor = "#000";
6518
- }
6519
- }, 300);
6520
- if (this.debug) {
6521
- console.log("[StormcloudVideoPlayer] Hiding placeholder layer");
6522
- }
6523
- }
6524
- },
6525
- {
6526
- key: "destroy",
6527
- value: function destroy() {
6528
- if (this.container) {
6529
- if (this.container.parentElement) {
6530
- this.container.parentElement.removeChild(this.container);
6531
- }
6532
- this.container = void 0;
6533
- }
6534
- }
6535
- }
6536
- ]);
6537
- return PlaceholderLayer;
6538
- }();
6539
- // src/player/HlsEngine.ts
6540
- var import_hls2 = __toESM(require("hls.js"), 1);
6541
- var HlsEngine = /*#__PURE__*/ function() {
6542
- function HlsEngine(config, video, cueManager, timing, callbacks) {
6543
- _class_call_check(this, HlsEngine);
6544
- this.isLiveStream = false;
6545
- this.nativeHlsMode = false;
6546
- this.videoSrcProtection = null;
6547
- this.bufferedSegmentsCount = 0;
6548
- this.shouldAutoplayAfterBuffering = false;
6549
- this.hasInitialBufferCompleted = false;
6550
- this.config = config;
6551
- this.video = video;
6552
- this.cueManager = cueManager;
6553
- this.timing = timing;
6554
- this.callbacks = callbacks;
6555
- }
6556
- _create_class(HlsEngine, [
6557
- {
6558
- key: "debug",
6559
- get: function get() {
6560
- return !!this.config.debugAdTiming;
6561
- }
6562
- },
6563
- {
6564
- key: "shouldUseNativeHls",
6565
- value: function shouldUseNativeHls(getStreamType) {
6566
- var streamType = getStreamType();
6567
- if (streamType === "other") {
6568
- return true;
6569
- }
6570
- var canNative = this.video.canPlayType("application/vnd.apple.mpegurl");
6571
- return !!(this.config.allowNativeHls && canNative);
6572
- }
6573
- },
6574
- {
6575
- key: "setupNativeHls",
6576
- value: function setupNativeHls() {
6577
- return _async_to_generator(function() {
6578
- var _this_config_isLiveStream, _this_config_lowLatencyMode, adBehavior, _this_video_play;
6122
+ var _this_config_isLiveStream, _this_config_lowLatencyMode, adBehavior, _this_video_play;
6579
6123
  return _ts_generator(this, function(_state) {
6580
6124
  switch(_state.label){
6581
6125
  case 0:
@@ -7148,7 +6692,7 @@ function resizePlayer(video, adPlayer, debug) {
7148
6692
  }
7149
6693
  // src/player/AdBreakOrchestrator.ts
7150
6694
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
7151
- function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6695
+ function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
7152
6696
  _class_call_check(this, AdBreakOrchestrator);
7153
6697
  this.inAdBreak = false;
7154
6698
  this.showAds = false;
@@ -7162,7 +6706,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7162
6706
  this.pendingAdBreak = null;
7163
6707
  this.host = host;
7164
6708
  this.timing = timing;
7165
- this.preloadPool = preloadPool;
7166
6709
  this.adConfig = adConfig;
7167
6710
  this.cueManager = cueManager;
7168
6711
  this.placeholder = placeholder;
@@ -7181,23 +6724,19 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7181
6724
  }
7182
6725
  },
7183
6726
  {
7184
- key: "optimizedPodsEnabled",
7185
- get: // ───────────────────────────────────────────────────────────────
6727
+ // ───────────────────────────────────────────────────────────────
7186
6728
  // IMA event listeners
7187
6729
  // ───────────────────────────────────────────────────────────────
7188
- function get() {
7189
- return this.host.config.optimizedPods !== false;
7190
- }
7191
- },
7192
- {
7193
- key: "nextAdRequestUrl",
6730
+ /**
6731
+ * Produces the next pod ad-request URL for the current break. Every request
6732
+ * (initial and continuous-fetch top-up) carries pod macros (pmad/pmnd/pmxd,
6733
+ * no ppos); pmxd tracks the remaining break time so top-up pods only ask for
6734
+ * what still fits.
6735
+ */ key: "nextAdRequestUrl",
7194
6736
  value: function nextAdRequestUrl(baseVastUrl) {
7195
- if (this.optimizedPodsEnabled) {
7196
- var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
7197
- var breakDurationMs = remaining > 0 ? remaining : void 0;
7198
- return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7199
- }
7200
- return this.host.generateVastUrls(baseVastUrl, 1)[0];
6737
+ var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
6738
+ var breakDurationMs = remaining > 0 ? remaining : void 0;
6739
+ return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7201
6740
  }
7202
6741
  },
7203
6742
  {
@@ -7369,340 +6908,76 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7369
6908
  // ───────────────────────────────────────────────────────────────
7370
6909
  function handleAdStart(_marker) {
7371
6910
  return _async_to_generator(function() {
7372
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed, firstAdUrl, usePreloadedAd, preloadedController, preloaded, adPlayer, preservedMuted, preservedVolume, adVolume, adPlayer1, adVolume1, error, fallbackPreloaded, ap, adVolume2, fallbackError;
6911
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7373
6912
  return _ts_generator(this, function(_state) {
7374
6913
  switch(_state.label){
7375
6914
  case 0:
7376
6915
  scheduled = this.adConfig.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
7377
6916
  if (scheduled) {
7378
- this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
7379
- }
7380
- tags = this.adConfig.selectVastTagsForBreak(scheduled);
7381
- if (tags && tags.length > 0 && tags[0]) {
7382
- baseVastUrl = tags[0];
7383
- } else if (this.adConfig.apiVastTagUrl) {
7384
- baseVastUrl = this.adConfig.apiVastTagUrl;
7385
- } else {
7386
- this.clearPendingAdBreak();
7387
- return [
7388
- 2
7389
- ];
7390
- }
7391
- adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
7392
- if (this.debug) {
7393
- mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
7394
- console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
7395
- }
7396
- this.timing.failedVastUrls.clear();
7397
- this.timing.temporaryFailureUrls.clear();
7398
- this.timing.consecutiveFailures = 0;
7399
- this.continuousFetchingActive = true;
7400
- this.isShowingPlaceholder = false;
7401
- this.timing.totalAdRequestsInBreak = 0;
7402
- if (this.adConfig.podAssignedByPrefetch) {
7403
- this.adConfig.podAssignedByPrefetch = false;
7404
- } else {
7405
- this.adConfig.beginNewAdPod();
7406
- }
7407
- currentMuted = this.host.video.muted;
7408
- currentVolume = this.host.video.volume;
7409
- this.host.getAdPlayer().updateOriginalMutedState(currentMuted, currentVolume);
7410
- this.inAdBreak = true;
7411
- this.timing.adBreakPlayedDurationMs = 0;
7412
- this.timing.currentAdIndex = 0;
7413
- this.timing.totalAdsInBreak = 0;
7414
- this.adPodQueue = [];
7415
- this.showAds = false;
7416
- if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7417
- this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7418
- }
7419
- if (!this.optimizedPodsEnabled) return [
7420
- 3,
7421
- 2
7422
- ];
7423
- return [
7424
- 4,
7425
- this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7426
- ];
7427
- case 1:
7428
- podPlayed = _state.sent();
7429
- if (podPlayed) {
7430
- return [
7431
- 2
7432
- ];
7433
- }
7434
- if (this.debug) {
7435
- console.log("[POD] Optimized pod unavailable, falling back to sequential single-ad path");
7436
- }
7437
- _state.label = 2;
7438
- case 2:
7439
- usePreloadedAd = false;
7440
- preloaded = this.preloadPool.getPreloadedAd();
7441
- if (preloaded) {
7442
- firstAdUrl = preloaded.vastUrl;
7443
- preloadedController = preloaded.adController;
7444
- usePreloadedAd = true;
7445
- sendAdLoadedTracking(this.host.config.licenseKey, {
7446
- source: "hls",
7447
- vastUrl: firstAdUrl,
7448
- timestamp: /* @__PURE__ */ new Date().toISOString()
7449
- }, this.analyticsContext).catch(function() {});
7450
- if (this.debug) {
7451
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7452
- }
7453
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7454
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7455
- firstAdUrl = this.adRequestQueue.shift();
7456
- if (this.debug) {
7457
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7458
- }
7459
- this.clearPendingAdBreak();
7460
- } else {
7461
- if (this.debug) {
7462
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7463
- }
7464
- firstAdUrl = this.nextAdRequestUrl(baseVastUrl);
7465
- this.adRequestQueue = [];
7466
- }
7467
- if (!firstAdUrl) {
7468
- if (this.debug) {
7469
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7470
- }
7471
- this.handleAdPodComplete();
7472
- return [
7473
- 2
7474
- ];
7475
- }
7476
- if (this.debug) {
7477
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7478
- }
7479
- _state.label = 3;
7480
- case 3:
7481
- _state.trys.push([
7482
- 3,
7483
- 14,
7484
- ,
7485
- 22
7486
- ]);
7487
- if (!(usePreloadedAd && preloadedController)) return [
7488
- 3,
7489
- 7
7490
- ];
7491
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7492
- 3,
7493
- 5
7494
- ];
7495
- this.timing.rejectLoadedAdForDuration(preloadedController);
7496
- this.startContinuousFetching(baseVastUrl);
7497
- return [
7498
- 4,
7499
- this.tryNextAvailableAdWithRateLimit()
7500
- ];
7501
- case 4:
7502
- _state.sent();
7503
- return [
7504
- 2
7505
- ];
7506
- case 5:
7507
- adPlayer = this.host.getAdPlayer();
7508
- preservedMuted = adPlayer.getOriginalMutedState();
7509
- preservedVolume = adPlayer.getOriginalVolume();
7510
- adPlayer.destroy();
7511
- this.host.video.muted = true;
7512
- this.host.setAdPlayer(preloadedController);
7513
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7514
- this.attachImaEventListeners();
7515
- if (this.debug) {
7516
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7517
- }
7518
- preloadedController.resume();
7519
- this.timing.consecutiveFailures = 0;
7520
- this.startContinuousFetching(baseVastUrl);
7521
- if (!this.optimizedPodsEnabled) {
7522
- if (!this.preloadPool.active) {
7523
- this.preloadPool.active = true;
7524
- }
7525
- if (!this.preloadPool.isLoopRunning) {
7526
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7527
- }
7528
- }
7529
- return [
7530
- 4,
7531
- preloadedController.play()
7532
- ];
7533
- case 6:
7534
- _state.sent();
7535
- this.timing.markAdStarted();
7536
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7537
- this.timing.scheduleAdStopAtBreakBoundary();
7538
- }
7539
- adVolume = currentMuted ? 0 : currentVolume;
7540
- preloadedController.setAdVolume(adVolume);
7541
- return [
7542
- 3,
7543
- 13
7544
- ];
7545
- case 7:
7546
- adPlayer1 = this.host.getAdPlayer();
7547
- return [
7548
- 4,
7549
- this.timing.enforceGlobalRateLimit()
7550
- ];
7551
- case 8:
7552
- _state.sent();
7553
- this.timing.lastAdRequestTime = Date.now();
7554
- return [
7555
- 4,
7556
- adPlayer1.requestAds(firstAdUrl)
7557
- ];
7558
- case 9:
7559
- _state.sent();
7560
- sendAdLoadedTracking(this.host.config.licenseKey, {
7561
- source: "hls",
7562
- vastUrl: firstAdUrl,
7563
- timestamp: /* @__PURE__ */ new Date().toISOString()
7564
- }, this.analyticsContext).catch(function() {});
7565
- if (this.debug) {
7566
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7567
- }
7568
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7569
- 3,
7570
- 11
7571
- ];
7572
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7573
- this.recreateAdController();
7574
- this.startContinuousFetching(baseVastUrl);
7575
- return [
7576
- 4,
7577
- this.tryNextAvailableAdWithRateLimit()
7578
- ];
7579
- case 10:
7580
- _state.sent();
7581
- return [
7582
- 2
7583
- ];
7584
- case 11:
7585
- this.timing.consecutiveFailures = 0;
7586
- this.startContinuousFetching(baseVastUrl);
7587
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7588
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7589
- }
7590
- return [
7591
- 4,
7592
- adPlayer1.play()
7593
- ];
7594
- case 12:
7595
- _state.sent();
7596
- this.timing.markAdStarted();
7597
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7598
- this.timing.scheduleAdStopAtBreakBoundary();
7599
- }
7600
- adVolume1 = currentMuted ? 0 : currentVolume;
7601
- adPlayer1.setAdVolume(adVolume1);
7602
- _state.label = 13;
7603
- case 13:
7604
- return [
7605
- 3,
7606
- 22
7607
- ];
7608
- case 14:
7609
- error = _state.sent();
7610
- if (this.debug) {
7611
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
6917
+ this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
7612
6918
  }
7613
- if (!!usePreloadedAd) return [
7614
- 3,
7615
- 20
7616
- ];
7617
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7618
- if (!fallbackPreloaded) return [
7619
- 3,
7620
- 20
7621
- ];
6919
+ tags = this.adConfig.selectVastTagsForBreak(scheduled);
6920
+ if (tags && tags.length > 0 && tags[0]) {
6921
+ baseVastUrl = tags[0];
6922
+ } else if (this.adConfig.apiVastTagUrl) {
6923
+ baseVastUrl = this.adConfig.apiVastTagUrl;
6924
+ } else {
6925
+ this.clearPendingAdBreak();
6926
+ return [
6927
+ 2
6928
+ ];
6929
+ }
6930
+ adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
7622
6931
  if (this.debug) {
7623
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
6932
+ mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
6933
+ console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
7624
6934
  }
7625
- _state.label = 15;
7626
- case 15:
7627
- _state.trys.push([
7628
- 15,
7629
- 19,
7630
- ,
7631
- 20
7632
- ]);
7633
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7634
- 3,
7635
- 17
7636
- ];
7637
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7638
- this.startContinuousFetching(baseVastUrl);
7639
- return [
7640
- 4,
7641
- this.tryNextAvailableAdWithRateLimit()
7642
- ];
7643
- case 16:
7644
- _state.sent();
7645
- return [
7646
- 2
7647
- ];
7648
- case 17:
7649
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
6935
+ this.timing.failedVastUrls.clear();
6936
+ this.timing.temporaryFailureUrls.clear();
7650
6937
  this.timing.consecutiveFailures = 0;
7651
- this.startContinuousFetching(baseVastUrl);
7652
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7653
- this.preloadPool.active = true;
7654
- this.preloadPool.preloadPoolLoop(baseVastUrl);
6938
+ this.continuousFetchingActive = true;
6939
+ this.isShowingPlaceholder = false;
6940
+ this.timing.totalAdRequestsInBreak = 0;
6941
+ if (this.adConfig.podAssignedByPrefetch) {
6942
+ this.adConfig.podAssignedByPrefetch = false;
6943
+ } else {
6944
+ this.adConfig.beginNewAdPod();
7655
6945
  }
7656
- ap = this.host.getAdPlayer();
7657
- return [
7658
- 4,
7659
- ap.play()
7660
- ];
7661
- case 18:
7662
- _state.sent();
7663
- this.timing.markAdStarted();
7664
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7665
- this.timing.scheduleAdStopAtBreakBoundary();
6946
+ currentMuted = this.host.video.muted;
6947
+ currentVolume = this.host.video.volume;
6948
+ this.host.getAdPlayer().updateOriginalMutedState(currentMuted, currentVolume);
6949
+ this.inAdBreak = true;
6950
+ this.timing.adBreakPlayedDurationMs = 0;
6951
+ this.timing.currentAdIndex = 0;
6952
+ this.timing.totalAdsInBreak = 0;
6953
+ this.adPodQueue = [];
6954
+ this.showAds = false;
6955
+ if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
6956
+ this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7666
6957
  }
7667
- adVolume2 = currentMuted ? 0 : currentVolume;
7668
- ap.setAdVolume(adVolume2);
7669
6958
  return [
7670
- 2
6959
+ 4,
6960
+ this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7671
6961
  ];
7672
- case 19:
7673
- fallbackError = _state.sent();
7674
- if (this.debug) {
7675
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7676
- }
7677
- return [
6962
+ case 1:
6963
+ podPlayed = _state.sent();
6964
+ if (!!podPlayed) return [
7678
6965
  3,
7679
- 20
6966
+ 3
7680
6967
  ];
7681
- case 20:
7682
- if (this.timing.isTemporaryAdError(error)) {
7683
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7684
- if (this.debug) {
7685
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7686
- }
7687
- } else {
7688
- this.timing.failedVastUrls.add(firstAdUrl);
7689
- if (this.debug) {
7690
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7691
- }
6968
+ if (this.debug) {
6969
+ console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
7692
6970
  }
7693
- this.timing.consecutiveFailures++;
6971
+ this.continuousFetchingActive = true;
7694
6972
  this.startContinuousFetching(baseVastUrl);
7695
6973
  return [
7696
6974
  4,
7697
6975
  this.tryNextAvailableAdWithRateLimit()
7698
6976
  ];
7699
- case 21:
6977
+ case 2:
7700
6978
  _state.sent();
7701
- return [
7702
- 3,
7703
- 22
7704
- ];
7705
- case 22:
6979
+ _state.label = 3;
6980
+ case 3:
7706
6981
  return [
7707
6982
  2
7708
6983
  ];
@@ -7776,7 +7051,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7776
7051
  ];
7777
7052
  }
7778
7053
  if (this.debug) {
7779
- 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"));
7054
+ 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"));
7780
7055
  }
7781
7056
  sendAdLoadedTracking(this.host.config.licenseKey, {
7782
7057
  source: "hls",
@@ -7796,10 +7071,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7796
7071
  }
7797
7072
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7798
7073
  this.timing.consecutiveFailures = 0;
7799
- if (podCount === 1) {
7800
- this.continuousFetchingActive = true;
7801
- this.startContinuousFetching(baseVastUrl);
7802
- }
7074
+ this.continuousFetchingActive = true;
7075
+ this.startContinuousFetching(baseVastUrl);
7803
7076
  return [
7804
7077
  2,
7805
7078
  true
@@ -7832,20 +7105,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7832
7105
  }).call(this);
7833
7106
  }
7834
7107
  },
7835
- {
7836
- key: "swapToPreloadedAdPlayer",
7837
- value: function swapToPreloadedAdPlayer(preloadedController) {
7838
- var adPlayer = this.host.getAdPlayer();
7839
- var preservedMuted = adPlayer.getOriginalMutedState();
7840
- var preservedVolume = adPlayer.getOriginalVolume();
7841
- adPlayer.destroy();
7842
- this.host.video.muted = true;
7843
- this.host.setAdPlayer(preloadedController);
7844
- this.attachImaEventListeners();
7845
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7846
- preloadedController.resume();
7847
- }
7848
- },
7849
7108
  {
7850
7109
  // ───────────────────────────────────────────────────────────────
7851
7110
  // Continuous fetching
@@ -8096,7 +7355,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8096
7355
  value: function tryNextAvailableAd() {
8097
7356
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8098
7357
  return _async_to_generator(function() {
8099
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7358
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8100
7359
  return _ts_generator(this, function(_state) {
8101
7360
  switch(_state.label){
8102
7361
  case 0:
@@ -8134,132 +7393,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8134
7393
  ];
8135
7394
  }
8136
7395
  this.timing.cleanupTemporaryFailures();
8137
- preloaded = this.preloadPool.getPreloadedAd();
8138
- if (!preloaded) return [
8139
- 3,
8140
- 6
8141
- ];
8142
- if (this.debug) {
8143
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8144
- }
8145
- sendAdLoadedTracking(this.host.config.licenseKey, {
8146
- source: "hls",
8147
- vastUrl: preloaded.vastUrl,
8148
- timestamp: /* @__PURE__ */ new Date().toISOString()
8149
- }, this.analyticsContext).catch(function() {});
8150
7396
  _state.label = 1;
8151
7397
  case 1:
8152
- _state.trys.push([
8153
- 1,
8154
- 5,
8155
- ,
8156
- 6
8157
- ]);
8158
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8159
- 3,
8160
- 3
8161
- ];
8162
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8163
- return [
8164
- 4,
8165
- this.tryNextAvailableAdWithRateLimit()
8166
- ];
8167
- case 2:
8168
- _state.sent();
8169
- return [
8170
- 2
8171
- ];
8172
- case 3:
8173
- this.swapToPreloadedAdPlayer(preloaded.adController);
8174
- ap = this.host.getAdPlayer();
8175
- return [
8176
- 4,
8177
- ap.play()
8178
- ];
8179
- case 4:
8180
- _state.sent();
8181
- this.timing.markAdStarted();
8182
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8183
- this.timing.scheduleAdStopAtBreakBoundary();
8184
- }
8185
- ap.setAdVolume(getAdAudioVolume(ap));
8186
- this.timing.consecutiveFailures = 0;
8187
- return [
8188
- 2
8189
- ];
8190
- case 5:
8191
- error = _state.sent();
8192
- if (this.debug) {
8193
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8194
- }
8195
- return [
8196
- 3,
8197
- 6
8198
- ];
8199
- case 6:
8200
7398
  if (!(this.adRequestQueue.length > 0)) return [
8201
7399
  3,
8202
- 14
7400
+ 9
8203
7401
  ];
8204
7402
  nextAdUrl = this.adRequestQueue.shift();
8205
7403
  if (!nextAdUrl) return [
8206
7404
  3,
8207
- 6
7405
+ 1
8208
7406
  ];
8209
7407
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8210
7408
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8211
7409
  return [
8212
7410
  3,
8213
- 6
7411
+ 1
8214
7412
  ];
8215
7413
  }
8216
7414
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8217
7415
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8218
7416
  return [
8219
7417
  3,
8220
- 6
7418
+ 1
8221
7419
  ];
8222
7420
  }
8223
7421
  if (this.debug) {
8224
7422
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8225
7423
  }
8226
- _state.label = 7;
8227
- case 7:
7424
+ _state.label = 2;
7425
+ case 2:
8228
7426
  _state.trys.push([
8229
- 7,
8230
- 9,
7427
+ 2,
7428
+ 4,
8231
7429
  ,
8232
- 13
7430
+ 8
8233
7431
  ]);
8234
7432
  return [
8235
7433
  4,
8236
7434
  this.playSingleAd(nextAdUrl)
8237
7435
  ];
8238
- case 8:
7436
+ case 3:
8239
7437
  _state.sent();
8240
7438
  this.timing.consecutiveFailures = 0;
8241
7439
  return [
8242
7440
  3,
8243
- 13
7441
+ 8
8244
7442
  ];
8245
- case 9:
8246
- error1 = _state.sent();
8247
- errorMessage = error1.message;
7443
+ case 4:
7444
+ error = _state.sent();
7445
+ errorMessage = error.message;
8248
7446
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8249
7447
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8250
7448
  3,
8251
- 11
7449
+ 6
8252
7450
  ];
8253
7451
  return [
8254
7452
  4,
8255
7453
  this.tryNextAvailableAdWithRateLimit()
8256
7454
  ];
8257
- case 10:
7455
+ case 5:
8258
7456
  _state.sent();
8259
7457
  return [
8260
7458
  2
8261
7459
  ];
8262
- case 11:
7460
+ case 6:
8263
7461
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8264
7462
  this.timing.consecutiveFailures++;
8265
7463
  }
@@ -8267,21 +7465,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8267
7465
  4,
8268
7466
  this.tryNextAvailableAdWithRateLimit()
8269
7467
  ];
8270
- case 12:
7468
+ case 7:
8271
7469
  _state.sent();
8272
7470
  return [
8273
7471
  3,
8274
- 13
7472
+ 8
8275
7473
  ];
8276
- case 13:
7474
+ case 8:
8277
7475
  return [
8278
7476
  2
8279
7477
  ];
8280
- case 14:
7478
+ case 9:
8281
7479
  maxRetries = 3;
8282
7480
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8283
7481
  3,
8284
- 17
7482
+ 12
8285
7483
  ];
8286
7484
  if (this.debug) {
8287
7485
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8292,18 +7490,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8292
7490
  return setTimeout(resolve, 500);
8293
7491
  })
8294
7492
  ];
8295
- case 15:
7493
+ case 10:
8296
7494
  _state.sent();
8297
7495
  return [
8298
7496
  4,
8299
7497
  this.tryNextAvailableAd(retryCount + 1)
8300
7498
  ];
8301
- case 16:
7499
+ case 11:
8302
7500
  _state.sent();
8303
7501
  return [
8304
7502
  2
8305
7503
  ];
8306
- case 17:
7504
+ case 12:
8307
7505
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8308
7506
  this.showPlaceholderAndWaitForAds();
8309
7507
  } else {
@@ -8325,7 +7523,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8325
7523
  // ───────────────────────────────────────────────────────────────
8326
7524
  function playSingleAd(vastTagUrl) {
8327
7525
  return _async_to_generator(function() {
8328
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7526
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8329
7527
  return _ts_generator(this, function(_state) {
8330
7528
  switch(_state.label){
8331
7529
  case 0:
@@ -8357,9 +7555,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8357
7555
  case 1:
8358
7556
  _state.trys.push([
8359
7557
  1,
8360
- 12,
7558
+ 8,
8361
7559
  ,
8362
- 17
7560
+ 9
8363
7561
  ]);
8364
7562
  return [
8365
7563
  4,
@@ -8395,7 +7593,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8395
7593
  4,
8396
7594
  6,
8397
7595
  ,
8398
- 11
7596
+ 7
8399
7597
  ]);
8400
7598
  this.timing.startAdFailsafeTimer(requestToken);
8401
7599
  return [
@@ -8413,55 +7611,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8413
7611
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8414
7612
  return [
8415
7613
  3,
8416
- 11
7614
+ 7
8417
7615
  ];
8418
7616
  case 6:
8419
7617
  playError = _state.sent();
8420
7618
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8421
- preloadedFallback = this.preloadPool.getPreloadedAd();
8422
- if (!preloadedFallback) return [
8423
- 3,
8424
- 10
8425
- ];
8426
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8427
- _state.label = 7;
8428
- case 7:
8429
- _state.trys.push([
8430
- 7,
8431
- 9,
8432
- ,
8433
- 10
8434
- ]);
8435
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8436
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8437
- throw playError;
8438
- }
8439
- this.timing.clearAdFailsafeTimer();
8440
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8441
- this.timing.consecutiveFailures = 0;
8442
- fbAp = this.host.getAdPlayer();
8443
- return [
8444
- 4,
8445
- fbAp.play()
8446
- ];
8447
- case 8:
8448
- _state.sent();
8449
- this.timing.markAdStarted();
8450
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8451
- this.timing.scheduleAdStopAtBreakBoundary();
8452
- }
8453
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8454
- return [
8455
- 2
8456
- ];
8457
- case 9:
8458
- fallbackError = _state.sent();
8459
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8460
- return [
8461
- 3,
8462
- 10
8463
- ];
8464
- case 10:
8465
7619
  if (this.timing.isTemporaryAdError(playError)) {
8466
7620
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8467
7621
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8474,57 +7628,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8474
7628
  this.timing.activeAdRequestToken = null;
8475
7629
  }
8476
7630
  throw playError;
8477
- case 11:
7631
+ case 7:
8478
7632
  return [
8479
7633
  3,
8480
- 17
7634
+ 9
8481
7635
  ];
8482
- case 12:
7636
+ case 8:
8483
7637
  error = _state.sent();
8484
7638
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8485
7639
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8486
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8487
- if (!preloadedFallback1) return [
8488
- 3,
8489
- 16
8490
- ];
8491
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8492
- _state.label = 13;
8493
- case 13:
8494
- _state.trys.push([
8495
- 13,
8496
- 15,
8497
- ,
8498
- 16
8499
- ]);
8500
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8501
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8502
- throw error;
8503
- }
8504
- this.timing.clearAdRequestWatchdog();
8505
- this.timing.clearAdFailsafeTimer();
8506
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8507
- this.timing.consecutiveFailures = 0;
8508
- fbAp1 = this.host.getAdPlayer();
8509
- return [
8510
- 4,
8511
- fbAp1.play()
8512
- ];
8513
- case 14:
8514
- _state.sent();
8515
- this.timing.markAdStarted();
8516
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8517
- return [
8518
- 2
8519
- ];
8520
- case 15:
8521
- fallbackError1 = _state.sent();
8522
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8523
- return [
8524
- 3,
8525
- 16
8526
- ];
8527
- case 16:
8528
7640
  if (this.timing.isTemporaryAdError(error)) {
8529
7641
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8530
7642
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8538,7 +7650,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8538
7650
  this.timing.activeAdRequestToken = null;
8539
7651
  }
8540
7652
  throw error;
8541
- case 17:
7653
+ case 9:
8542
7654
  return [
8543
7655
  2
8544
7656
  ];
@@ -8728,7 +7840,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8728
7840
  }
8729
7841
  this.timing.resetForBreakEnd();
8730
7842
  this.stopContinuousFetching();
8731
- this.preloadPool.stop();
8732
7843
  this.clearPendingAdBreak();
8733
7844
  if (this.isShowingPlaceholder) {
8734
7845
  this.host.getAdPlayer().hidePlaceholder();
@@ -8838,25 +7949,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8838
7949
  return _this.adBreak.handleAdFailure();
8839
7950
  }
8840
7951
  });
8841
- this.preloadPool = new AdPreloadPool({
8842
- debug: !!this.config.debugAdTiming,
8843
- createAdPlayer: function createAdPlayer(c) {
8844
- return _this.createAdPlayer(c);
8845
- },
8846
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
8847
- return _this.shouldContinueLiveStreamDuringAds();
8848
- },
8849
- timing: this.timing,
8850
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
8851
- return _this.generateVastUrls(base, count);
8852
- },
8853
- isInAdBreak: function isInAdBreak() {
8854
- return _this.adBreak.inAdBreak;
8855
- },
8856
- getPendingAdBreak: function getPendingAdBreak() {
8857
- return _this.adBreak.pendingAdBreak;
8858
- }
8859
- });
8860
7952
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
8861
7953
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
8862
7954
  onManifestParsed: function onManifestParsed(isLive) {
@@ -8903,13 +7995,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8903
7995
  getLiveSyncPosition: function getLiveSyncPosition() {
8904
7996
  return _this.hlsEngine.getLiveSyncPosition();
8905
7997
  },
8906
- generateVastUrls: function generateVastUrls(base, count) {
8907
- return _this.generateVastUrls(base, count);
8908
- },
8909
7998
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8910
7999
  return _this.generatePodVastUrl(base, breakDurationMs);
8911
8000
  }
8912
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
8001
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
8913
8002
  }
8914
8003
  _create_class(StormcloudVideoPlayer, [
8915
8004
  {
@@ -8934,12 +8023,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8934
8023
  } : {}));
8935
8024
  }
8936
8025
  },
8937
- {
8938
- key: "generateVastUrls",
8939
- value: function generateVastUrls(baseUrl, count) {
8940
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8941
- }
8942
- },
8943
8026
  {
8944
8027
  key: "generatePodVastUrl",
8945
8028
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9335,11 +8418,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9335
8418
  }
9336
8419
  this.adConfig.beginNewAdPod();
9337
8420
  this.adConfig.podAssignedByPrefetch = true;
9338
- var optimizedPods = this.config.optimizedPods !== false;
9339
8421
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9340
- var generatedUrls = optimizedPods ? [
8422
+ var generatedUrls = [
9341
8423
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9342
- ] : this.generateVastUrls(baseVastUrl, 1);
8424
+ ];
9343
8425
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9344
8426
  marker: marker
9345
8427
  }, fragmentSn !== void 0 ? {
@@ -9361,15 +8443,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9361
8443
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9362
8444
  if (this.debug) {
9363
8445
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9364
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9365
- }
9366
- if (optimizedPods) {
9367
- if (this.debug) {
9368
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9369
- }
9370
- return;
8446
+ console.log("[PREFETCH] Pre-generated pod request URL");
9371
8447
  }
9372
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9373
8448
  }
9374
8449
  },
9375
8450
  {
@@ -9608,7 +8683,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9608
8683
  value: function destroy() {
9609
8684
  var _this_adPlayer;
9610
8685
  this.adBreak.stopContinuousFetching();
9611
- this.preloadPool.stop();
9612
8686
  this.timing.destroy();
9613
8687
  this.adBreak.clearPendingAdBreak();
9614
8688
  this.placeholder.destroy();