stormcloud-video-player 0.8.54 → 0.8.56

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 (56) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/index.cjs +243 -80
  3. package/lib/index.cjs.map +1 -1
  4. package/lib/index.js +243 -80
  5. package/lib/index.js.map +1 -1
  6. package/lib/player/AdBreakOrchestrator.cjs +41 -40
  7. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  8. package/lib/player/AdConfigManager.cjs +24 -30
  9. package/lib/player/AdConfigManager.cjs.map +1 -1
  10. package/lib/player/AdTimingService.cjs +18 -25
  11. package/lib/player/AdTimingService.cjs.map +1 -1
  12. package/lib/player/HlsEngine.cjs +12 -21
  13. package/lib/player/HlsEngine.cjs.map +1 -1
  14. package/lib/player/PlaceholderLayer.cjs +1 -3
  15. package/lib/player/PlaceholderLayer.cjs.map +1 -1
  16. package/lib/player/PlayerControls.cjs.map +1 -1
  17. package/lib/player/Scte35CueManager.cjs +2 -4
  18. package/lib/player/Scte35CueManager.cjs.map +1 -1
  19. package/lib/player/Scte35Parser.cjs +6 -12
  20. package/lib/player/Scte35Parser.cjs.map +1 -1
  21. package/lib/player/StormcloudVideoPlayer.cjs +233 -66
  22. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  23. package/lib/player/playerTypes.cjs.map +1 -1
  24. package/lib/players/FilePlayer.cjs +17 -26
  25. package/lib/players/FilePlayer.cjs.map +1 -1
  26. package/lib/players/HlsPlayer.cjs +243 -80
  27. package/lib/players/HlsPlayer.cjs.map +1 -1
  28. package/lib/players/index.cjs +243 -80
  29. package/lib/players/index.cjs.map +1 -1
  30. package/lib/sdk/hlsAdPlayer.cjs +190 -25
  31. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  32. package/lib/sdk/pal.cjs +6 -9
  33. package/lib/sdk/pal.cjs.map +1 -1
  34. package/lib/ui/StormcloudVideoPlayer.cjs +233 -66
  35. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  36. package/lib/utils/browserCompat.cjs +3 -6
  37. package/lib/utils/browserCompat.cjs.map +1 -1
  38. package/lib/utils/ctvVastSignals.cjs +3 -6
  39. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  40. package/lib/utils/devUrl.cjs.map +1 -1
  41. package/lib/utils/mqttClient.cjs +1 -3
  42. package/lib/utils/mqttClient.cjs.map +1 -1
  43. package/lib/utils/mqttConfig.cjs +1 -3
  44. package/lib/utils/mqttConfig.cjs.map +1 -1
  45. package/lib/utils/polyfills.cjs +4 -7
  46. package/lib/utils/polyfills.cjs.map +1 -1
  47. package/lib/utils/tracking.cjs +8 -13
  48. package/lib/utils/tracking.cjs.map +1 -1
  49. package/lib/utils/vastEnvironmentSignals.cjs +3 -6
  50. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -1
  51. package/lib/utils/vastMacros.cjs +4 -2
  52. package/lib/utils/vastMacros.cjs.map +1 -1
  53. package/lib/utils/vastTrackingMacros.cjs +185 -0
  54. package/lib/utils/vastTrackingMacros.cjs.map +1 -0
  55. package/lib/utils/vastTrackingMacros.d.cts +19 -0
  56. package/package.json +1 -1
package/lib/index.cjs CHANGED
@@ -11,9 +11,7 @@ function _array_without_holes(arr) {
11
11
  if (Array.isArray(arr)) return _array_like_to_array(arr);
12
12
  }
13
13
  function _assert_this_initialized(self) {
14
- if (self === void 0) {
15
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
16
- }
14
+ if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
17
15
  return self;
18
16
  }
19
17
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -24,11 +22,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
24
22
  reject(error);
25
23
  return;
26
24
  }
27
- if (info.done) {
28
- resolve(value);
29
- } else {
30
- Promise.resolve(value).then(_next, _throw);
31
- }
25
+ if (info.done) resolve(value);
26
+ else Promise.resolve(value).then(_next, _throw);
32
27
  }
33
28
  function _async_to_generator(fn) {
34
29
  return function() {
@@ -50,9 +45,7 @@ function _call_super(_this, derived, args) {
50
45
  return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
51
46
  }
52
47
  function _class_call_check(instance, Constructor) {
53
- if (!(instance instanceof Constructor)) {
54
- throw new TypeError("Cannot call a class as a function");
55
- }
48
+ if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
56
49
  }
57
50
  function _defineProperties(target, props) {
58
51
  for(var i = 0; i < props.length; i++){
@@ -76,9 +69,7 @@ function _define_property(obj, key, value) {
76
69
  configurable: true,
77
70
  writable: true
78
71
  });
79
- } else {
80
- obj[key] = value;
81
- }
72
+ } else obj[key] = value;
82
73
  return obj;
83
74
  }
84
75
  function _get_prototype_of(o) {
@@ -101,14 +92,23 @@ function _inherits(subClass, superClass) {
101
92
  if (superClass) _set_prototype_of(subClass, superClass);
102
93
  }
103
94
  function _instanceof(left, right) {
95
+ "@swc/helpers - instanceof";
104
96
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
105
97
  return !!right[Symbol.hasInstance](left);
106
- } else {
107
- return left instanceof right;
108
- }
98
+ } else return left instanceof right;
99
+ }
100
+ function _is_native_reflect_construct() {
101
+ try {
102
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
103
+ } catch (_) {}
104
+ return (_is_native_reflect_construct = function() {
105
+ return !!result;
106
+ })();
109
107
  }
110
108
  function _iterable_to_array(iter) {
111
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
109
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
110
+ return Array.from(iter);
111
+ }
112
112
  }
113
113
  function _iterable_to_array_limit(arr, i) {
114
114
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
@@ -135,10 +135,10 @@ function _iterable_to_array_limit(arr, i) {
135
135
  return _arr;
136
136
  }
137
137
  function _non_iterable_rest() {
138
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
138
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
139
139
  }
140
140
  function _non_iterable_spread() {
141
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
141
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
142
142
  }
143
143
  function _object_spread(target) {
144
144
  for(var i = 1; i < arguments.length; i++){
@@ -170,9 +170,8 @@ function ownKeys(object, enumerableOnly) {
170
170
  }
171
171
  function _object_spread_props(target, source) {
172
172
  source = source != null ? source : {};
173
- if (Object.getOwnPropertyDescriptors) {
174
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
175
- } else {
173
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
174
+ else {
176
175
  ownKeys(Object(source)).forEach(function(key) {
177
176
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
178
177
  });
@@ -216,9 +215,7 @@ function _object_without_properties_loose(source, excluded) {
216
215
  return target;
217
216
  }
218
217
  function _possible_constructor_return(self, call) {
219
- if (call && (_type_of(call) === "object" || typeof call === "function")) {
220
- return call;
221
- }
218
+ if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
222
219
  return _assert_this_initialized(self);
223
220
  }
224
221
  function _set_prototype_of(o, p) {
@@ -234,26 +231,6 @@ function _sliced_to_array(arr, i) {
234
231
  function _to_consumable_array(arr) {
235
232
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
236
233
  }
237
- function _type_of(obj) {
238
- "@swc/helpers - typeof";
239
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
240
- }
241
- function _unsupported_iterable_to_array(o, minLen) {
242
- if (!o) return;
243
- if (typeof o === "string") return _array_like_to_array(o, minLen);
244
- var n = Object.prototype.toString.call(o).slice(8, -1);
245
- if (n === "Object" && o.constructor) n = o.constructor.name;
246
- if (n === "Map" || n === "Set") return Array.from(n);
247
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
248
- }
249
- function _is_native_reflect_construct() {
250
- try {
251
- var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
252
- } catch (_) {}
253
- return (_is_native_reflect_construct = function() {
254
- return !!result;
255
- })();
256
- }
257
234
  function _ts_generator(thisArg, body) {
258
235
  var f, y, t, _ = {
259
236
  label: 0,
@@ -355,18 +332,36 @@ function _ts_generator(thisArg, body) {
355
332
  }
356
333
  function _ts_values(o) {
357
334
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
358
- if (m) return m.call(o);
359
- if (o && typeof o.length === "number") return {
360
- next: function() {
361
- if (o && i >= o.length) o = void 0;
362
- return {
363
- value: o && o[i++],
364
- done: !o
365
- };
366
- }
367
- };
335
+ if (m) {
336
+ return m.call(o);
337
+ }
338
+ if (o && typeof o.length === "number") {
339
+ return {
340
+ next: function() {
341
+ if (o && i >= o.length) {
342
+ o = void 0;
343
+ }
344
+ return {
345
+ value: o && o[i++],
346
+ done: !o
347
+ };
348
+ }
349
+ };
350
+ }
368
351
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
369
352
  }
353
+ function _type_of(obj) {
354
+ "@swc/helpers - typeof";
355
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
356
+ }
357
+ function _unsupported_iterable_to_array(o, minLen) {
358
+ if (!o) return;
359
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
360
+ var n = Object.prototype.toString.call(o).slice(8, -1);
361
+ if (n === "Object" && o.constructor) n = o.constructor.name;
362
+ if (n === "Map" || n === "Set") return Array.from(n);
363
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
364
+ }
370
365
  var __create = Object.create;
371
366
  var __defProp = Object.defineProperty;
372
367
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -785,15 +780,147 @@ function supportsFeature(feature) {
785
780
  return false;
786
781
  }
787
782
  }
783
+ // src/utils/vastTrackingMacros.ts
784
+ var VAST_MACRO_PATTERN = /\[([A-Z][A-Z0-9_]*)\]/g;
785
+ var CACHEBUSTING_ALIASES = /\[CACHEBUSTER\]|\[cachebuster\]|\[timestamp\]|\[random\]|\[INSERT_RANDOM_NUMBER\]|%%CACHEBUSTER%%|%%CACHEBUST%%|\$\{CACHEBUSTER\}|\$\{CACHEBUSTING\}|\{cachebuster\}|\{random\}/g;
786
+ var KNOWN_VAST_MACROS = /* @__PURE__ */ new Set([
787
+ "ADCATEGORIES",
788
+ "ADCOUNT",
789
+ "ADPLAYHEAD",
790
+ "ADSERVINGID",
791
+ "ADTYPE",
792
+ "APIFRAMEWORKS",
793
+ "APPBUNDLE",
794
+ "ASSETURI",
795
+ "BLOCKEDADCATEGORIES",
796
+ "BREAKMAXADLENGTH",
797
+ "BREAKMAXADS",
798
+ "BREAKMAXDURATION",
799
+ "BREAKMINADLENGTH",
800
+ "BREAKPOSITION",
801
+ "CACHEBUSTING",
802
+ "CLICKPOS",
803
+ "CLICKTYPE",
804
+ "CLIENTUA",
805
+ "CONTENTID",
806
+ "CONTENTPLAYHEAD",
807
+ "CONTENTURI",
808
+ "DEVICEIP",
809
+ "DEVICEUA",
810
+ "DOMAIN",
811
+ "ERRORCODE",
812
+ "EXTENSIONS",
813
+ "GDPRCONSENT",
814
+ "IFA",
815
+ "IFATYPE",
816
+ "INVENTORYSTATE",
817
+ "LATLONG",
818
+ "LIMITADTRACKING",
819
+ "MEDIAMIME",
820
+ "MEDIAPLAYHEAD",
821
+ "OMIDPARTNER",
822
+ "PAGEURL",
823
+ "PLACEMENTTYPE",
824
+ "PLAYERCAPABILITIES",
825
+ "PLAYERSIZE",
826
+ "PLAYERSTATE",
827
+ "PODSEQUENCE",
828
+ "REGULATIONS",
829
+ "SERVERSIDE",
830
+ "SERVERUA",
831
+ "TIMESTAMP",
832
+ "TRANSACTIONID",
833
+ "UNIVERSALADID",
834
+ "VASTVERSIONS",
835
+ "VERIFICATIONVENDORS"
836
+ ]);
837
+ function generateCachebuster() {
838
+ return String(Math.floor(Math.random() * 9e7) + 1e7);
839
+ }
840
+ function formatPlayhead(seconds) {
841
+ if (seconds == null || !Number.isFinite(seconds) || seconds < 0) {
842
+ return void 0;
843
+ }
844
+ var total = Math.floor(seconds);
845
+ var hh = String(Math.floor(total / 3600)).padStart(2, "0");
846
+ var mm = String(Math.floor(total % 3600 / 60)).padStart(2, "0");
847
+ var ss = String(total % 60).padStart(2, "0");
848
+ var ms = String(Math.floor((seconds - total) * 1e3)).padStart(3, "0");
849
+ return "".concat(hh, ":").concat(mm, ":").concat(ss, ".").concat(ms);
850
+ }
851
+ function resolveMacroValues(ctx) {
852
+ var values = /* @__PURE__ */ new Map();
853
+ var set = function set(key, value) {
854
+ if (value != null && value !== "") values.set(key, value);
855
+ };
856
+ var adPlayhead = formatPlayhead(ctx.adPlayheadSeconds);
857
+ set("ADPLAYHEAD", adPlayhead);
858
+ set("MEDIAPLAYHEAD", adPlayhead);
859
+ set("CONTENTPLAYHEAD", formatPlayhead(ctx.contentPlayheadSeconds));
860
+ set("ASSETURI", ctx.assetUri);
861
+ set("MEDIAMIME", ctx.mediaMime);
862
+ set("TIMESTAMP", (/* @__PURE__ */ new Date()).toISOString());
863
+ set("SERVERSIDE", "0");
864
+ if (ctx.errorCode != null && ctx.errorCode !== "") {
865
+ set("ERRORCODE", String(ctx.errorCode));
866
+ }
867
+ if (ctx.playerWidth != null && ctx.playerHeight != null) {
868
+ set("PLAYERSIZE", "".concat(Math.round(ctx.playerWidth), ",").concat(Math.round(ctx.playerHeight)));
869
+ }
870
+ set("IFA", ctx.deviceId);
871
+ set("IFATYPE", ctx.deviceIdType);
872
+ if (ctx.limitAdTracking != null) {
873
+ set("LIMITADTRACKING", ctx.limitAdTracking ? "1" : "0");
874
+ }
875
+ set("PAGEURL", ctx.pageUrl);
876
+ if (ctx.pageUrl) {
877
+ try {
878
+ set("DOMAIN", new URL(ctx.pageUrl).hostname);
879
+ } catch (unused) {}
880
+ }
881
+ set("CLIENTUA", ctx.clientUa);
882
+ set("DEVICEUA", ctx.clientUa);
883
+ if (ctx.podSequence != null) {
884
+ set("PODSEQUENCE", String(ctx.podSequence));
885
+ }
886
+ return values;
887
+ }
888
+ function substituteVastTrackingMacros(url) {
889
+ var ctx = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
890
+ if (!url) return url;
891
+ var values = resolveMacroValues(ctx);
892
+ return url.replace(CACHEBUSTING_ALIASES, function() {
893
+ return generateCachebuster();
894
+ }).replace(VAST_MACRO_PATTERN, function(match, name) {
895
+ if (name === "CACHEBUSTING") return generateCachebuster();
896
+ var value = values.get(name);
897
+ if (value != null) return encodeURIComponent(value);
898
+ return KNOWN_VAST_MACROS.has(name) ? "" : match;
899
+ });
900
+ }
788
901
  // src/sdk/hlsAdPlayer.ts
789
902
  var MAX_VAST_WRAPPER_DEPTH = 5;
903
+ var BEACON_TIMEOUT_MS = 3e4;
904
+ var inFlightBeacons = /* @__PURE__ */ new Set();
905
+ var VAST_ERROR_MEDIA_DISPLAY = 405;
906
+ function toVastMediaErrorCode(error) {
907
+ switch(error === null || error === void 0 ? void 0 : error.code){
908
+ case 1:
909
+ return 400;
910
+ case 2:
911
+ return 401;
912
+ case 4:
913
+ return 403;
914
+ default:
915
+ return VAST_ERROR_MEDIA_DISPLAY;
916
+ }
917
+ }
790
918
  function createHlsAdPlayer(contentVideo, options) {
791
919
  var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
792
920
  var adPlaying = false;
793
921
  var originalMutedState = false;
794
922
  var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
795
923
  var listeners = /* @__PURE__ */ new Map();
796
- var licenseKey = options === null || options === void 0 ? void 0 : options.licenseKey;
797
924
  var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
798
925
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
799
926
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
@@ -804,9 +931,9 @@ function createHlsAdPlayer(contentVideo, options) {
804
931
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
805
932
  var adEventHandlers = [];
806
933
  var currentAd;
934
+ var currentAdMediaFile;
807
935
  var podAds = [];
808
936
  var podIndex = 0;
809
- var sessionId;
810
937
  var preloadedAds = /* @__PURE__ */ new Map();
811
938
  var preloadingAds = /* @__PURE__ */ new Map();
812
939
  var destroyed = false;
@@ -856,21 +983,47 @@ function createHlsAdPlayer(contentVideo, options) {
856
983
  }
857
984
  }
858
985
  }
859
- function generateSessionId() {
860
- return "session-".concat(Date.now(), "-").concat(Math.random().toString(36).substr(2, 9));
986
+ function buildTrackingMacroContext(errorCode) {
987
+ var context = {
988
+ adPlayheadSeconds: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentTime,
989
+ contentPlayheadSeconds: contentVideo.currentTime,
990
+ assetUri: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url,
991
+ mediaMime: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.type,
992
+ playerWidth: (adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.clientWidth) || (adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientWidth),
993
+ playerHeight: (adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.clientHeight) || (adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientHeight)
994
+ };
995
+ if (errorCode != null) {
996
+ context.errorCode = errorCode;
997
+ }
998
+ if (typeof navigator !== "undefined" && navigator.userAgent) {
999
+ context.clientUa = navigator.userAgent;
1000
+ }
1001
+ if (typeof location !== "undefined" && location.href) {
1002
+ context.pageUrl = location.href;
1003
+ }
1004
+ if (podAds.length > 0) {
1005
+ context.podSequence = podIndex + 1;
1006
+ }
1007
+ return context;
861
1008
  }
862
- function fireTrackingPixels(urls) {
1009
+ function fireTrackingPixels(urls, options2) {
863
1010
  if (!urls || urls.length === 0) return;
1011
+ var macroContext = buildTrackingMacroContext(options2 === null || options2 === void 0 ? void 0 : options2.errorCode);
864
1012
  urls.forEach(function(url) {
865
1013
  try {
866
- var trackingUrl = url;
867
- if (sessionId) {
868
- trackingUrl = "".concat(trackingUrl).concat(trackingUrl.includes("?") ? "&" : "?", "session_id=").concat(sessionId);
869
- }
870
- if (licenseKey) {
871
- trackingUrl = "".concat(trackingUrl).concat(trackingUrl.includes("?") ? "&" : "?", "license_key=").concat(licenseKey);
872
- }
1014
+ var trackingUrl = substituteVastTrackingMacros(url, macroContext);
873
1015
  var img = new Image(1, 1);
1016
+ inFlightBeacons.add(img);
1017
+ var timeoutId;
1018
+ var release = function release() {
1019
+ if (timeoutId !== void 0) clearTimeout(timeoutId);
1020
+ img.onload = null;
1021
+ img.onerror = null;
1022
+ inFlightBeacons.delete(img);
1023
+ };
1024
+ img.onload = release;
1025
+ img.onerror = release;
1026
+ timeoutId = setTimeout(release, BEACON_TIMEOUT_MS);
874
1027
  img.src = trackingUrl;
875
1028
  console.log("[HlsAdPlayer] Fired tracking pixel: ".concat(trackingUrl));
876
1029
  } catch (error) {
@@ -1509,7 +1662,9 @@ function createHlsAdPlayer(contentVideo, options) {
1509
1662
  if (!adPlaying) return;
1510
1663
  console.error("[HlsAdPlayer] Ad video error:", e);
1511
1664
  if (currentAd) {
1512
- fireTrackingPixels(currentAd.trackingUrls.error);
1665
+ fireTrackingPixels(currentAd.trackingUrls.error, {
1666
+ errorCode: toVastMediaErrorCode(adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.error)
1667
+ });
1513
1668
  }
1514
1669
  if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
1515
1670
  return;
@@ -1693,6 +1848,7 @@ function createHlsAdPlayer(contentVideo, options) {
1693
1848
  if (!mediaFile) {
1694
1849
  throw new Error("No media file available for ad");
1695
1850
  }
1851
+ currentAdMediaFile = mediaFile;
1696
1852
  var isHlsAd = isHlsMediaFile(mediaFile);
1697
1853
  console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad (pod ").concat(podIndex + 1, "/").concat(podAds.length || 1, ") from: ").concat(mediaFile.url));
1698
1854
  if (isHlsAd && import_hls.default.isSupported()) {
@@ -1736,6 +1892,7 @@ function createHlsAdPlayer(contentVideo, options) {
1736
1892
  }
1737
1893
  podIndex++;
1738
1894
  currentAd = podAds[podIndex];
1895
+ currentAdMediaFile = void 0;
1739
1896
  resetQuartileTracking(false);
1740
1897
  if (currentAd) {
1741
1898
  fireTrackingPixels(currentAd.trackingUrls.impression);
@@ -1778,7 +1935,9 @@ function createHlsAdPlayer(contentVideo, options) {
1778
1935
  console.warn("[HlsAdPlayer] Ad playback stalled (no progress) - recovering to avoid a blank frame");
1779
1936
  clearStallWatchdog();
1780
1937
  if (currentAd) {
1781
- fireTrackingPixels(currentAd.trackingUrls.error);
1938
+ fireTrackingPixels(currentAd.trackingUrls.error, {
1939
+ errorCode: VAST_ERROR_MEDIA_DISPLAY
1940
+ });
1782
1941
  }
1783
1942
  if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
1784
1943
  return;
@@ -1846,7 +2005,9 @@ function createHlsAdPlayer(contentVideo, options) {
1846
2005
  console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
1847
2006
  clearStallWatchdog();
1848
2007
  if (currentAd) {
1849
- fireTrackingPixels(currentAd.trackingUrls.error);
2008
+ fireTrackingPixels(currentAd.trackingUrls.error, {
2009
+ errorCode: VAST_ERROR_MEDIA_DISPLAY
2010
+ });
1850
2011
  }
1851
2012
  if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
1852
2013
  return;
@@ -1980,7 +2141,6 @@ function createHlsAdPlayer(contentVideo, options) {
1980
2141
  ,
1981
2142
  6
1982
2143
  ]);
1983
- sessionId = generateSessionId();
1984
2144
  ads = [];
1985
2145
  if (!preloadedAds.has(vastTagUrl)) return [
1986
2146
  3,
@@ -2018,6 +2178,7 @@ function createHlsAdPlayer(contentVideo, options) {
2018
2178
  podAds = ads;
2019
2179
  podIndex = 0;
2020
2180
  currentAd = ads[0];
2181
+ currentAdMediaFile = void 0;
2021
2182
  console.log("[HlsAdPlayer] Pod parsed: ".concat(ads.length, ' ad(s), first="').concat(currentAd === null || currentAd === void 0 ? void 0 : currentAd.title, '", duration=').concat(currentAd === null || currentAd === void 0 ? void 0 : currentAd.duration, "s"));
2022
2183
  if (currentAd) {
2023
2184
  fireTrackingPixels(currentAd.trackingUrls.impression);
@@ -2152,6 +2313,7 @@ function createHlsAdPlayer(contentVideo, options) {
2152
2313
  }
2153
2314
  }
2154
2315
  currentAd = void 0;
2316
+ currentAdMediaFile = void 0;
2155
2317
  podAds = [];
2156
2318
  podIndex = 0;
2157
2319
  return [
@@ -2192,6 +2354,7 @@ function createHlsAdPlayer(contentVideo, options) {
2192
2354
  teardownAdEventListeners();
2193
2355
  releaseAdDecoder();
2194
2356
  currentAd = void 0;
2357
+ currentAdMediaFile = void 0;
2195
2358
  podAds = [];
2196
2359
  podIndex = 0;
2197
2360
  listeners.clear();
@@ -3487,7 +3650,7 @@ function buildPlayerMetricEvent() {
3487
3650
  if (debugAdTiming) {
3488
3651
  console.log("[StormcloudVideoPlayer] playerId: ", playerId);
3489
3652
  }
3490
- captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
3653
+ captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : (/* @__PURE__ */ new Date()).toISOString();
3491
3654
  return [
3492
3655
  2,
3493
3656
  _object_spread({
@@ -6564,7 +6727,7 @@ var AdTimingService = /*#__PURE__*/ function() {
6564
6727
  var _this_callbacks_getAdState = this.callbacks.getAdState(), inAdBreak = _this_callbacks_getAdState.inAdBreak, showAds = _this_callbacks_getAdState.showAds, adPlaying = _this_callbacks_getAdState.adPlaying;
6565
6728
  console.log("[StormcloudVideoPlayer][AdState]", _object_spread({
6566
6729
  event: event,
6567
- timestamp: /* @__PURE__ */ new Date().toISOString(),
6730
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
6568
6731
  showAds: showAds,
6569
6732
  adPlaying: adPlaying,
6570
6733
  inAdBreak: inAdBreak,
@@ -7529,7 +7692,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7529
7692
  sendAdImpressionTracking(_this.host.config.licenseKey, {
7530
7693
  source: "hls",
7531
7694
  adIndex: _this.timing.currentAdIndex,
7532
- timestamp: /* @__PURE__ */ new Date().toISOString()
7695
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
7533
7696
  }, _this.analyticsContext).catch(function() {});
7534
7697
  _this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
7535
7698
  var remaining = _this.timing.getRemainingAdMs();
@@ -7591,7 +7754,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7591
7754
  sendAdImpressionTracking(_this.host.config.licenseKey, {
7592
7755
  source: "hls",
7593
7756
  adIndex: _this.timing.currentAdIndex,
7594
- timestamp: /* @__PURE__ */ new Date().toISOString()
7757
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
7595
7758
  }, _this.analyticsContext).catch(function() {});
7596
7759
  if (!_this.host.video.muted) {
7597
7760
  _this.host.video.muted = true;
@@ -7830,7 +7993,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7830
7993
  sendAdLoadedTracking(this.host.config.licenseKey, {
7831
7994
  source: "hls",
7832
7995
  vastUrl: podUrl,
7833
- timestamp: /* @__PURE__ */ new Date().toISOString()
7996
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
7834
7997
  }, this.analyticsContext).catch(function() {});
7835
7998
  this.timing.startAdFailsafeTimer(requestToken);
7836
7999
  return [
@@ -8350,7 +8513,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8350
8513
  sendAdLoadedTracking(this.host.config.licenseKey, {
8351
8514
  source: "hls",
8352
8515
  vastUrl: vastTagUrl,
8353
- timestamp: /* @__PURE__ */ new Date().toISOString()
8516
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
8354
8517
  }, this.analyticsContext).catch(function() {});
8355
8518
  this.timing.clearAdRequestWatchdog();
8356
8519
  if (this.timing.activeAdRequestToken !== requestToken) return [
@@ -9331,7 +9494,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9331
9494
  if (marker.ptsSeconds != null) detectPayload.ptsSeconds = marker.ptsSeconds;
9332
9495
  sendAdDetectTracking(this.config.licenseKey, _object_spread({
9333
9496
  source: "scte35",
9334
- timestamp: /* @__PURE__ */ new Date().toISOString()
9497
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
9335
9498
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9336
9499
  }
9337
9500
  var hasPrefetchedAds = this.adBreak.pendingAdBreak && this.adBreak.pendingAdBreak.vastUrls.length > 0;
@@ -9507,7 +9670,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9507
9670
  if (fragmentSn !== void 0) detectPayload.detectedAtFragmentSn = fragmentSn;
9508
9671
  sendAdDetectTracking(this.config.licenseKey, _object_spread({
9509
9672
  source: "scte35",
9510
- timestamp: /* @__PURE__ */ new Date().toISOString()
9673
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
9511
9674
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9512
9675
  if (this.debug) {
9513
9676
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");