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.
- package/dist/stormcloud-vp.min.js +2 -2
- package/lib/index.cjs +243 -80
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +243 -80
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +41 -40
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdConfigManager.cjs +24 -30
- package/lib/player/AdConfigManager.cjs.map +1 -1
- package/lib/player/AdTimingService.cjs +18 -25
- package/lib/player/AdTimingService.cjs.map +1 -1
- package/lib/player/HlsEngine.cjs +12 -21
- package/lib/player/HlsEngine.cjs.map +1 -1
- package/lib/player/PlaceholderLayer.cjs +1 -3
- package/lib/player/PlaceholderLayer.cjs.map +1 -1
- package/lib/player/PlayerControls.cjs.map +1 -1
- package/lib/player/Scte35CueManager.cjs +2 -4
- package/lib/player/Scte35CueManager.cjs.map +1 -1
- package/lib/player/Scte35Parser.cjs +6 -12
- package/lib/player/Scte35Parser.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +233 -66
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/playerTypes.cjs.map +1 -1
- package/lib/players/FilePlayer.cjs +17 -26
- package/lib/players/FilePlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +243 -80
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +243 -80
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +190 -25
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/pal.cjs +6 -9
- package/lib/sdk/pal.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +233 -66
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/browserCompat.cjs +3 -6
- package/lib/utils/browserCompat.cjs.map +1 -1
- package/lib/utils/ctvVastSignals.cjs +3 -6
- package/lib/utils/ctvVastSignals.cjs.map +1 -1
- package/lib/utils/devUrl.cjs.map +1 -1
- package/lib/utils/mqttClient.cjs +1 -3
- package/lib/utils/mqttClient.cjs.map +1 -1
- package/lib/utils/mqttConfig.cjs +1 -3
- package/lib/utils/mqttConfig.cjs.map +1 -1
- package/lib/utils/polyfills.cjs +4 -7
- package/lib/utils/polyfills.cjs.map +1 -1
- package/lib/utils/tracking.cjs +8 -13
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/vastEnvironmentSignals.cjs +3 -6
- package/lib/utils/vastEnvironmentSignals.cjs.map +1 -1
- package/lib/utils/vastMacros.cjs +4 -2
- package/lib/utils/vastMacros.cjs.map +1 -1
- package/lib/utils/vastTrackingMacros.cjs +185 -0
- package/lib/utils/vastTrackingMacros.cjs.map +1 -0
- package/lib/utils/vastTrackingMacros.d.cts +19 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -10,9 +10,7 @@ function _array_without_holes(arr) {
|
|
|
10
10
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
11
|
}
|
|
12
12
|
function _assert_this_initialized(self) {
|
|
13
|
-
if (self === void 0)
|
|
14
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
15
|
-
}
|
|
13
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
16
14
|
return self;
|
|
17
15
|
}
|
|
18
16
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -23,11 +21,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
23
21
|
reject(error);
|
|
24
22
|
return;
|
|
25
23
|
}
|
|
26
|
-
if (info.done)
|
|
27
|
-
|
|
28
|
-
} else {
|
|
29
|
-
Promise.resolve(value).then(_next, _throw);
|
|
30
|
-
}
|
|
24
|
+
if (info.done) resolve(value);
|
|
25
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
31
26
|
}
|
|
32
27
|
function _async_to_generator(fn) {
|
|
33
28
|
return function() {
|
|
@@ -49,9 +44,7 @@ function _call_super(_this, derived, args) {
|
|
|
49
44
|
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
50
45
|
}
|
|
51
46
|
function _class_call_check(instance, Constructor) {
|
|
52
|
-
if (!(instance instanceof Constructor))
|
|
53
|
-
throw new TypeError("Cannot call a class as a function");
|
|
54
|
-
}
|
|
47
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
55
48
|
}
|
|
56
49
|
function _defineProperties(target, props) {
|
|
57
50
|
for(var i = 0; i < props.length; i++){
|
|
@@ -75,9 +68,7 @@ function _define_property(obj, key, value) {
|
|
|
75
68
|
configurable: true,
|
|
76
69
|
writable: true
|
|
77
70
|
});
|
|
78
|
-
} else
|
|
79
|
-
obj[key] = value;
|
|
80
|
-
}
|
|
71
|
+
} else obj[key] = value;
|
|
81
72
|
return obj;
|
|
82
73
|
}
|
|
83
74
|
function _get_prototype_of(o) {
|
|
@@ -100,14 +91,23 @@ function _inherits(subClass, superClass) {
|
|
|
100
91
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
101
92
|
}
|
|
102
93
|
function _instanceof(left, right) {
|
|
94
|
+
"@swc/helpers - instanceof";
|
|
103
95
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
104
96
|
return !!right[Symbol.hasInstance](left);
|
|
105
|
-
} else
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
} else return left instanceof right;
|
|
98
|
+
}
|
|
99
|
+
function _is_native_reflect_construct() {
|
|
100
|
+
try {
|
|
101
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
102
|
+
} catch (_) {}
|
|
103
|
+
return (_is_native_reflect_construct = function() {
|
|
104
|
+
return !!result;
|
|
105
|
+
})();
|
|
108
106
|
}
|
|
109
107
|
function _iterable_to_array(iter) {
|
|
110
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
108
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
|
|
109
|
+
return Array.from(iter);
|
|
110
|
+
}
|
|
111
111
|
}
|
|
112
112
|
function _iterable_to_array_limit(arr, i) {
|
|
113
113
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
@@ -134,10 +134,10 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
134
134
|
return _arr;
|
|
135
135
|
}
|
|
136
136
|
function _non_iterable_rest() {
|
|
137
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance
|
|
137
|
+
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
138
|
}
|
|
139
139
|
function _non_iterable_spread() {
|
|
140
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance
|
|
140
|
+
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
141
|
}
|
|
142
142
|
function _object_spread(target) {
|
|
143
143
|
for(var i = 1; i < arguments.length; i++){
|
|
@@ -169,9 +169,8 @@ function ownKeys(object, enumerableOnly) {
|
|
|
169
169
|
}
|
|
170
170
|
function _object_spread_props(target, source) {
|
|
171
171
|
source = source != null ? source : {};
|
|
172
|
-
if (Object.getOwnPropertyDescriptors)
|
|
173
|
-
|
|
174
|
-
} else {
|
|
172
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
173
|
+
else {
|
|
175
174
|
ownKeys(Object(source)).forEach(function(key) {
|
|
176
175
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
177
176
|
});
|
|
@@ -215,9 +214,7 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
215
214
|
return target;
|
|
216
215
|
}
|
|
217
216
|
function _possible_constructor_return(self, call) {
|
|
218
|
-
if (call && (_type_of(call) === "object" || typeof call === "function"))
|
|
219
|
-
return call;
|
|
220
|
-
}
|
|
217
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
|
|
221
218
|
return _assert_this_initialized(self);
|
|
222
219
|
}
|
|
223
220
|
function _set_prototype_of(o, p) {
|
|
@@ -233,26 +230,6 @@ function _sliced_to_array(arr, i) {
|
|
|
233
230
|
function _to_consumable_array(arr) {
|
|
234
231
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
235
232
|
}
|
|
236
|
-
function _type_of(obj) {
|
|
237
|
-
"@swc/helpers - typeof";
|
|
238
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
239
|
-
}
|
|
240
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
241
|
-
if (!o) return;
|
|
242
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
243
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
244
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
245
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
246
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
247
|
-
}
|
|
248
|
-
function _is_native_reflect_construct() {
|
|
249
|
-
try {
|
|
250
|
-
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
251
|
-
} catch (_) {}
|
|
252
|
-
return (_is_native_reflect_construct = function() {
|
|
253
|
-
return !!result;
|
|
254
|
-
})();
|
|
255
|
-
}
|
|
256
233
|
function _ts_generator(thisArg, body) {
|
|
257
234
|
var f, y, t, _ = {
|
|
258
235
|
label: 0,
|
|
@@ -354,18 +331,36 @@ function _ts_generator(thisArg, body) {
|
|
|
354
331
|
}
|
|
355
332
|
function _ts_values(o) {
|
|
356
333
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
357
|
-
if (m)
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
334
|
+
if (m) {
|
|
335
|
+
return m.call(o);
|
|
336
|
+
}
|
|
337
|
+
if (o && typeof o.length === "number") {
|
|
338
|
+
return {
|
|
339
|
+
next: function() {
|
|
340
|
+
if (o && i >= o.length) {
|
|
341
|
+
o = void 0;
|
|
342
|
+
}
|
|
343
|
+
return {
|
|
344
|
+
value: o && o[i++],
|
|
345
|
+
done: !o
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
}
|
|
367
350
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
368
351
|
}
|
|
352
|
+
function _type_of(obj) {
|
|
353
|
+
"@swc/helpers - typeof";
|
|
354
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
355
|
+
}
|
|
356
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
357
|
+
if (!o) return;
|
|
358
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
359
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
360
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
361
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
362
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
363
|
+
}
|
|
369
364
|
// src/ui/StormcloudVideoPlayer.tsx
|
|
370
365
|
import React, { useEffect, useRef, useMemo, useCallback } from "react";
|
|
371
366
|
// src/sdk/hlsAdPlayer.ts
|
|
@@ -565,15 +560,147 @@ function supportsFeature(feature) {
|
|
|
565
560
|
return false;
|
|
566
561
|
}
|
|
567
562
|
}
|
|
563
|
+
// src/utils/vastTrackingMacros.ts
|
|
564
|
+
var VAST_MACRO_PATTERN = /\[([A-Z][A-Z0-9_]*)\]/g;
|
|
565
|
+
var CACHEBUSTING_ALIASES = /\[CACHEBUSTER\]|\[cachebuster\]|\[timestamp\]|\[random\]|\[INSERT_RANDOM_NUMBER\]|%%CACHEBUSTER%%|%%CACHEBUST%%|\$\{CACHEBUSTER\}|\$\{CACHEBUSTING\}|\{cachebuster\}|\{random\}/g;
|
|
566
|
+
var KNOWN_VAST_MACROS = /* @__PURE__ */ new Set([
|
|
567
|
+
"ADCATEGORIES",
|
|
568
|
+
"ADCOUNT",
|
|
569
|
+
"ADPLAYHEAD",
|
|
570
|
+
"ADSERVINGID",
|
|
571
|
+
"ADTYPE",
|
|
572
|
+
"APIFRAMEWORKS",
|
|
573
|
+
"APPBUNDLE",
|
|
574
|
+
"ASSETURI",
|
|
575
|
+
"BLOCKEDADCATEGORIES",
|
|
576
|
+
"BREAKMAXADLENGTH",
|
|
577
|
+
"BREAKMAXADS",
|
|
578
|
+
"BREAKMAXDURATION",
|
|
579
|
+
"BREAKMINADLENGTH",
|
|
580
|
+
"BREAKPOSITION",
|
|
581
|
+
"CACHEBUSTING",
|
|
582
|
+
"CLICKPOS",
|
|
583
|
+
"CLICKTYPE",
|
|
584
|
+
"CLIENTUA",
|
|
585
|
+
"CONTENTID",
|
|
586
|
+
"CONTENTPLAYHEAD",
|
|
587
|
+
"CONTENTURI",
|
|
588
|
+
"DEVICEIP",
|
|
589
|
+
"DEVICEUA",
|
|
590
|
+
"DOMAIN",
|
|
591
|
+
"ERRORCODE",
|
|
592
|
+
"EXTENSIONS",
|
|
593
|
+
"GDPRCONSENT",
|
|
594
|
+
"IFA",
|
|
595
|
+
"IFATYPE",
|
|
596
|
+
"INVENTORYSTATE",
|
|
597
|
+
"LATLONG",
|
|
598
|
+
"LIMITADTRACKING",
|
|
599
|
+
"MEDIAMIME",
|
|
600
|
+
"MEDIAPLAYHEAD",
|
|
601
|
+
"OMIDPARTNER",
|
|
602
|
+
"PAGEURL",
|
|
603
|
+
"PLACEMENTTYPE",
|
|
604
|
+
"PLAYERCAPABILITIES",
|
|
605
|
+
"PLAYERSIZE",
|
|
606
|
+
"PLAYERSTATE",
|
|
607
|
+
"PODSEQUENCE",
|
|
608
|
+
"REGULATIONS",
|
|
609
|
+
"SERVERSIDE",
|
|
610
|
+
"SERVERUA",
|
|
611
|
+
"TIMESTAMP",
|
|
612
|
+
"TRANSACTIONID",
|
|
613
|
+
"UNIVERSALADID",
|
|
614
|
+
"VASTVERSIONS",
|
|
615
|
+
"VERIFICATIONVENDORS"
|
|
616
|
+
]);
|
|
617
|
+
function generateCachebuster() {
|
|
618
|
+
return String(Math.floor(Math.random() * 9e7) + 1e7);
|
|
619
|
+
}
|
|
620
|
+
function formatPlayhead(seconds) {
|
|
621
|
+
if (seconds == null || !Number.isFinite(seconds) || seconds < 0) {
|
|
622
|
+
return void 0;
|
|
623
|
+
}
|
|
624
|
+
var total = Math.floor(seconds);
|
|
625
|
+
var hh = String(Math.floor(total / 3600)).padStart(2, "0");
|
|
626
|
+
var mm = String(Math.floor(total % 3600 / 60)).padStart(2, "0");
|
|
627
|
+
var ss = String(total % 60).padStart(2, "0");
|
|
628
|
+
var ms = String(Math.floor((seconds - total) * 1e3)).padStart(3, "0");
|
|
629
|
+
return "".concat(hh, ":").concat(mm, ":").concat(ss, ".").concat(ms);
|
|
630
|
+
}
|
|
631
|
+
function resolveMacroValues(ctx) {
|
|
632
|
+
var values = /* @__PURE__ */ new Map();
|
|
633
|
+
var set = function set(key, value) {
|
|
634
|
+
if (value != null && value !== "") values.set(key, value);
|
|
635
|
+
};
|
|
636
|
+
var adPlayhead = formatPlayhead(ctx.adPlayheadSeconds);
|
|
637
|
+
set("ADPLAYHEAD", adPlayhead);
|
|
638
|
+
set("MEDIAPLAYHEAD", adPlayhead);
|
|
639
|
+
set("CONTENTPLAYHEAD", formatPlayhead(ctx.contentPlayheadSeconds));
|
|
640
|
+
set("ASSETURI", ctx.assetUri);
|
|
641
|
+
set("MEDIAMIME", ctx.mediaMime);
|
|
642
|
+
set("TIMESTAMP", (/* @__PURE__ */ new Date()).toISOString());
|
|
643
|
+
set("SERVERSIDE", "0");
|
|
644
|
+
if (ctx.errorCode != null && ctx.errorCode !== "") {
|
|
645
|
+
set("ERRORCODE", String(ctx.errorCode));
|
|
646
|
+
}
|
|
647
|
+
if (ctx.playerWidth != null && ctx.playerHeight != null) {
|
|
648
|
+
set("PLAYERSIZE", "".concat(Math.round(ctx.playerWidth), ",").concat(Math.round(ctx.playerHeight)));
|
|
649
|
+
}
|
|
650
|
+
set("IFA", ctx.deviceId);
|
|
651
|
+
set("IFATYPE", ctx.deviceIdType);
|
|
652
|
+
if (ctx.limitAdTracking != null) {
|
|
653
|
+
set("LIMITADTRACKING", ctx.limitAdTracking ? "1" : "0");
|
|
654
|
+
}
|
|
655
|
+
set("PAGEURL", ctx.pageUrl);
|
|
656
|
+
if (ctx.pageUrl) {
|
|
657
|
+
try {
|
|
658
|
+
set("DOMAIN", new URL(ctx.pageUrl).hostname);
|
|
659
|
+
} catch (unused) {}
|
|
660
|
+
}
|
|
661
|
+
set("CLIENTUA", ctx.clientUa);
|
|
662
|
+
set("DEVICEUA", ctx.clientUa);
|
|
663
|
+
if (ctx.podSequence != null) {
|
|
664
|
+
set("PODSEQUENCE", String(ctx.podSequence));
|
|
665
|
+
}
|
|
666
|
+
return values;
|
|
667
|
+
}
|
|
668
|
+
function substituteVastTrackingMacros(url) {
|
|
669
|
+
var ctx = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
670
|
+
if (!url) return url;
|
|
671
|
+
var values = resolveMacroValues(ctx);
|
|
672
|
+
return url.replace(CACHEBUSTING_ALIASES, function() {
|
|
673
|
+
return generateCachebuster();
|
|
674
|
+
}).replace(VAST_MACRO_PATTERN, function(match, name) {
|
|
675
|
+
if (name === "CACHEBUSTING") return generateCachebuster();
|
|
676
|
+
var value = values.get(name);
|
|
677
|
+
if (value != null) return encodeURIComponent(value);
|
|
678
|
+
return KNOWN_VAST_MACROS.has(name) ? "" : match;
|
|
679
|
+
});
|
|
680
|
+
}
|
|
568
681
|
// src/sdk/hlsAdPlayer.ts
|
|
569
682
|
var MAX_VAST_WRAPPER_DEPTH = 5;
|
|
683
|
+
var BEACON_TIMEOUT_MS = 3e4;
|
|
684
|
+
var inFlightBeacons = /* @__PURE__ */ new Set();
|
|
685
|
+
var VAST_ERROR_MEDIA_DISPLAY = 405;
|
|
686
|
+
function toVastMediaErrorCode(error) {
|
|
687
|
+
switch(error === null || error === void 0 ? void 0 : error.code){
|
|
688
|
+
case 1:
|
|
689
|
+
return 400;
|
|
690
|
+
case 2:
|
|
691
|
+
return 401;
|
|
692
|
+
case 4:
|
|
693
|
+
return 403;
|
|
694
|
+
default:
|
|
695
|
+
return VAST_ERROR_MEDIA_DISPLAY;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
570
698
|
function createHlsAdPlayer(contentVideo, options) {
|
|
571
699
|
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
|
|
572
700
|
var adPlaying = false;
|
|
573
701
|
var originalMutedState = false;
|
|
574
702
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
575
703
|
var listeners = /* @__PURE__ */ new Map();
|
|
576
|
-
var licenseKey = options === null || options === void 0 ? void 0 : options.licenseKey;
|
|
577
704
|
var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
|
|
578
705
|
var AD_CONTAINER_PROP = "__stormcloudAdContainer";
|
|
579
706
|
var AD_VIDEO_PROP = "__stormcloudAdVideo";
|
|
@@ -584,9 +711,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
584
711
|
var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
|
|
585
712
|
var adEventHandlers = [];
|
|
586
713
|
var currentAd;
|
|
714
|
+
var currentAdMediaFile;
|
|
587
715
|
var podAds = [];
|
|
588
716
|
var podIndex = 0;
|
|
589
|
-
var sessionId;
|
|
590
717
|
var preloadedAds = /* @__PURE__ */ new Map();
|
|
591
718
|
var preloadingAds = /* @__PURE__ */ new Map();
|
|
592
719
|
var destroyed = false;
|
|
@@ -636,21 +763,47 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
636
763
|
}
|
|
637
764
|
}
|
|
638
765
|
}
|
|
639
|
-
function
|
|
640
|
-
|
|
766
|
+
function buildTrackingMacroContext(errorCode) {
|
|
767
|
+
var context = {
|
|
768
|
+
adPlayheadSeconds: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentTime,
|
|
769
|
+
contentPlayheadSeconds: contentVideo.currentTime,
|
|
770
|
+
assetUri: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url,
|
|
771
|
+
mediaMime: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.type,
|
|
772
|
+
playerWidth: (adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.clientWidth) || (adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientWidth),
|
|
773
|
+
playerHeight: (adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.clientHeight) || (adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientHeight)
|
|
774
|
+
};
|
|
775
|
+
if (errorCode != null) {
|
|
776
|
+
context.errorCode = errorCode;
|
|
777
|
+
}
|
|
778
|
+
if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
779
|
+
context.clientUa = navigator.userAgent;
|
|
780
|
+
}
|
|
781
|
+
if (typeof location !== "undefined" && location.href) {
|
|
782
|
+
context.pageUrl = location.href;
|
|
783
|
+
}
|
|
784
|
+
if (podAds.length > 0) {
|
|
785
|
+
context.podSequence = podIndex + 1;
|
|
786
|
+
}
|
|
787
|
+
return context;
|
|
641
788
|
}
|
|
642
|
-
function fireTrackingPixels(urls) {
|
|
789
|
+
function fireTrackingPixels(urls, options2) {
|
|
643
790
|
if (!urls || urls.length === 0) return;
|
|
791
|
+
var macroContext = buildTrackingMacroContext(options2 === null || options2 === void 0 ? void 0 : options2.errorCode);
|
|
644
792
|
urls.forEach(function(url) {
|
|
645
793
|
try {
|
|
646
|
-
var trackingUrl = url;
|
|
647
|
-
if (sessionId) {
|
|
648
|
-
trackingUrl = "".concat(trackingUrl).concat(trackingUrl.includes("?") ? "&" : "?", "session_id=").concat(sessionId);
|
|
649
|
-
}
|
|
650
|
-
if (licenseKey) {
|
|
651
|
-
trackingUrl = "".concat(trackingUrl).concat(trackingUrl.includes("?") ? "&" : "?", "license_key=").concat(licenseKey);
|
|
652
|
-
}
|
|
794
|
+
var trackingUrl = substituteVastTrackingMacros(url, macroContext);
|
|
653
795
|
var img = new Image(1, 1);
|
|
796
|
+
inFlightBeacons.add(img);
|
|
797
|
+
var timeoutId;
|
|
798
|
+
var release = function release() {
|
|
799
|
+
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
800
|
+
img.onload = null;
|
|
801
|
+
img.onerror = null;
|
|
802
|
+
inFlightBeacons.delete(img);
|
|
803
|
+
};
|
|
804
|
+
img.onload = release;
|
|
805
|
+
img.onerror = release;
|
|
806
|
+
timeoutId = setTimeout(release, BEACON_TIMEOUT_MS);
|
|
654
807
|
img.src = trackingUrl;
|
|
655
808
|
console.log("[HlsAdPlayer] Fired tracking pixel: ".concat(trackingUrl));
|
|
656
809
|
} catch (error) {
|
|
@@ -1289,7 +1442,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1289
1442
|
if (!adPlaying) return;
|
|
1290
1443
|
console.error("[HlsAdPlayer] Ad video error:", e);
|
|
1291
1444
|
if (currentAd) {
|
|
1292
|
-
fireTrackingPixels(currentAd.trackingUrls.error
|
|
1445
|
+
fireTrackingPixels(currentAd.trackingUrls.error, {
|
|
1446
|
+
errorCode: toVastMediaErrorCode(adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.error)
|
|
1447
|
+
});
|
|
1293
1448
|
}
|
|
1294
1449
|
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
|
|
1295
1450
|
return;
|
|
@@ -1473,6 +1628,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1473
1628
|
if (!mediaFile) {
|
|
1474
1629
|
throw new Error("No media file available for ad");
|
|
1475
1630
|
}
|
|
1631
|
+
currentAdMediaFile = mediaFile;
|
|
1476
1632
|
var isHlsAd = isHlsMediaFile(mediaFile);
|
|
1477
1633
|
console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad (pod ").concat(podIndex + 1, "/").concat(podAds.length || 1, ") from: ").concat(mediaFile.url));
|
|
1478
1634
|
if (isHlsAd && Hls.isSupported()) {
|
|
@@ -1516,6 +1672,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1516
1672
|
}
|
|
1517
1673
|
podIndex++;
|
|
1518
1674
|
currentAd = podAds[podIndex];
|
|
1675
|
+
currentAdMediaFile = void 0;
|
|
1519
1676
|
resetQuartileTracking(false);
|
|
1520
1677
|
if (currentAd) {
|
|
1521
1678
|
fireTrackingPixels(currentAd.trackingUrls.impression);
|
|
@@ -1558,7 +1715,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1558
1715
|
console.warn("[HlsAdPlayer] Ad playback stalled (no progress) - recovering to avoid a blank frame");
|
|
1559
1716
|
clearStallWatchdog();
|
|
1560
1717
|
if (currentAd) {
|
|
1561
|
-
fireTrackingPixels(currentAd.trackingUrls.error
|
|
1718
|
+
fireTrackingPixels(currentAd.trackingUrls.error, {
|
|
1719
|
+
errorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
1720
|
+
});
|
|
1562
1721
|
}
|
|
1563
1722
|
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
|
|
1564
1723
|
return;
|
|
@@ -1626,7 +1785,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1626
1785
|
console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
|
|
1627
1786
|
clearStallWatchdog();
|
|
1628
1787
|
if (currentAd) {
|
|
1629
|
-
fireTrackingPixels(currentAd.trackingUrls.error
|
|
1788
|
+
fireTrackingPixels(currentAd.trackingUrls.error, {
|
|
1789
|
+
errorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
1790
|
+
});
|
|
1630
1791
|
}
|
|
1631
1792
|
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
|
|
1632
1793
|
return;
|
|
@@ -1760,7 +1921,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1760
1921
|
,
|
|
1761
1922
|
6
|
|
1762
1923
|
]);
|
|
1763
|
-
sessionId = generateSessionId();
|
|
1764
1924
|
ads = [];
|
|
1765
1925
|
if (!preloadedAds.has(vastTagUrl)) return [
|
|
1766
1926
|
3,
|
|
@@ -1798,6 +1958,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1798
1958
|
podAds = ads;
|
|
1799
1959
|
podIndex = 0;
|
|
1800
1960
|
currentAd = ads[0];
|
|
1961
|
+
currentAdMediaFile = void 0;
|
|
1801
1962
|
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"));
|
|
1802
1963
|
if (currentAd) {
|
|
1803
1964
|
fireTrackingPixels(currentAd.trackingUrls.impression);
|
|
@@ -1932,6 +2093,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1932
2093
|
}
|
|
1933
2094
|
}
|
|
1934
2095
|
currentAd = void 0;
|
|
2096
|
+
currentAdMediaFile = void 0;
|
|
1935
2097
|
podAds = [];
|
|
1936
2098
|
podIndex = 0;
|
|
1937
2099
|
return [
|
|
@@ -1972,6 +2134,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1972
2134
|
teardownAdEventListeners();
|
|
1973
2135
|
releaseAdDecoder();
|
|
1974
2136
|
currentAd = void 0;
|
|
2137
|
+
currentAdMediaFile = void 0;
|
|
1975
2138
|
podAds = [];
|
|
1976
2139
|
podIndex = 0;
|
|
1977
2140
|
listeners.clear();
|
|
@@ -3267,7 +3430,7 @@ function buildPlayerMetricEvent() {
|
|
|
3267
3430
|
if (debugAdTiming) {
|
|
3268
3431
|
console.log("[StormcloudVideoPlayer] playerId: ", playerId);
|
|
3269
3432
|
}
|
|
3270
|
-
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
|
|
3433
|
+
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : (/* @__PURE__ */ new Date()).toISOString();
|
|
3271
3434
|
return [
|
|
3272
3435
|
2,
|
|
3273
3436
|
_object_spread({
|
|
@@ -6350,7 +6513,7 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6350
6513
|
var _this_callbacks_getAdState = this.callbacks.getAdState(), inAdBreak = _this_callbacks_getAdState.inAdBreak, showAds = _this_callbacks_getAdState.showAds, adPlaying = _this_callbacks_getAdState.adPlaying;
|
|
6351
6514
|
console.log("[StormcloudVideoPlayer][AdState]", _object_spread({
|
|
6352
6515
|
event: event,
|
|
6353
|
-
timestamp: /* @__PURE__ */ new Date().toISOString(),
|
|
6516
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6354
6517
|
showAds: showAds,
|
|
6355
6518
|
adPlaying: adPlaying,
|
|
6356
6519
|
inAdBreak: inAdBreak,
|
|
@@ -7318,7 +7481,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
7318
7481
|
sendAdImpressionTracking(_this.host.config.licenseKey, {
|
|
7319
7482
|
source: "hls",
|
|
7320
7483
|
adIndex: _this.timing.currentAdIndex,
|
|
7321
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
7484
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
7322
7485
|
}, _this.analyticsContext).catch(function() {});
|
|
7323
7486
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
7324
7487
|
var remaining = _this.timing.getRemainingAdMs();
|
|
@@ -7380,7 +7543,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
7380
7543
|
sendAdImpressionTracking(_this.host.config.licenseKey, {
|
|
7381
7544
|
source: "hls",
|
|
7382
7545
|
adIndex: _this.timing.currentAdIndex,
|
|
7383
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
7546
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
7384
7547
|
}, _this.analyticsContext).catch(function() {});
|
|
7385
7548
|
if (!_this.host.video.muted) {
|
|
7386
7549
|
_this.host.video.muted = true;
|
|
@@ -7619,7 +7782,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
7619
7782
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
7620
7783
|
source: "hls",
|
|
7621
7784
|
vastUrl: podUrl,
|
|
7622
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
7785
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
7623
7786
|
}, this.analyticsContext).catch(function() {});
|
|
7624
7787
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
7625
7788
|
return [
|
|
@@ -8139,7 +8302,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8139
8302
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
8140
8303
|
source: "hls",
|
|
8141
8304
|
vastUrl: vastTagUrl,
|
|
8142
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
8305
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8143
8306
|
}, this.analyticsContext).catch(function() {});
|
|
8144
8307
|
this.timing.clearAdRequestWatchdog();
|
|
8145
8308
|
if (this.timing.activeAdRequestToken !== requestToken) return [
|
|
@@ -9121,7 +9284,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9121
9284
|
if (marker.ptsSeconds != null) detectPayload.ptsSeconds = marker.ptsSeconds;
|
|
9122
9285
|
sendAdDetectTracking(this.config.licenseKey, _object_spread({
|
|
9123
9286
|
source: "scte35",
|
|
9124
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
9287
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
9125
9288
|
}, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
|
|
9126
9289
|
}
|
|
9127
9290
|
var hasPrefetchedAds = this.adBreak.pendingAdBreak && this.adBreak.pendingAdBreak.vastUrls.length > 0;
|
|
@@ -9297,7 +9460,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9297
9460
|
if (fragmentSn !== void 0) detectPayload.detectedAtFragmentSn = fragmentSn;
|
|
9298
9461
|
sendAdDetectTracking(this.config.licenseKey, _object_spread({
|
|
9299
9462
|
source: "scte35",
|
|
9300
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
9463
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
9301
9464
|
}, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
|
|
9302
9465
|
if (this.debug) {
|
|
9303
9466
|
console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
|