stormcloud-video-player 0.8.64 → 0.8.66
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/StormcloudPlayer.cjs +1897 -917
- package/lib/StormcloudPlayer.cjs.map +1 -1
- package/lib/index.cjs +1853 -909
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +10 -0
- package/lib/index.js +1853 -909
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +899 -736
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +50 -16
- package/lib/player/AdConfigManager.cjs +16 -1
- package/lib/player/AdConfigManager.cjs.map +1 -1
- package/lib/player/AdTimingService.cjs +9 -1
- package/lib/player/AdTimingService.cjs.map +1 -1
- package/lib/player/AdTimingService.d.cts +1 -0
- package/lib/player/StormcloudVideoPlayer.cjs +1890 -910
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +1890 -910
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +1890 -910
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +975 -175
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -0
- package/lib/types.d.cts +9 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +1854 -910
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/vastMacros.cjs +19 -0
- package/lib/utils/vastMacros.cjs.map +1 -1
- package/lib/utils/vastMacros.d.cts +2 -1
- package/package.json +1 -1
|
@@ -178,6 +178,42 @@ function _object_spread_props(target, source) {
|
|
|
178
178
|
}
|
|
179
179
|
return target;
|
|
180
180
|
}
|
|
181
|
+
function _object_without_properties(source, excluded) {
|
|
182
|
+
if (source == null) return {};
|
|
183
|
+
var target = {}, sourceKeys, key, i;
|
|
184
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
185
|
+
sourceKeys = Reflect.ownKeys(Object(source));
|
|
186
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
187
|
+
key = sourceKeys[i];
|
|
188
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
189
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
190
|
+
target[key] = source[key];
|
|
191
|
+
}
|
|
192
|
+
return target;
|
|
193
|
+
}
|
|
194
|
+
target = _object_without_properties_loose(source, excluded);
|
|
195
|
+
if (Object.getOwnPropertySymbols) {
|
|
196
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
197
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
198
|
+
key = sourceKeys[i];
|
|
199
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
200
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
201
|
+
target[key] = source[key];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return target;
|
|
205
|
+
}
|
|
206
|
+
function _object_without_properties_loose(source, excluded) {
|
|
207
|
+
if (source == null) return {};
|
|
208
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
209
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
210
|
+
key = sourceKeys[i];
|
|
211
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
212
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
213
|
+
target[key] = source[key];
|
|
214
|
+
}
|
|
215
|
+
return target;
|
|
216
|
+
}
|
|
181
217
|
function _possible_constructor_return(self, call) {
|
|
182
218
|
if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
|
|
183
219
|
return _assert_this_initialized(self);
|
|
@@ -294,26 +330,6 @@ function _ts_generator(thisArg, body) {
|
|
|
294
330
|
};
|
|
295
331
|
}
|
|
296
332
|
}
|
|
297
|
-
function _ts_values(o) {
|
|
298
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
299
|
-
if (m) {
|
|
300
|
-
return m.call(o);
|
|
301
|
-
}
|
|
302
|
-
if (o && typeof o.length === "number") {
|
|
303
|
-
return {
|
|
304
|
-
next: function() {
|
|
305
|
-
if (o && i >= o.length) {
|
|
306
|
-
o = void 0;
|
|
307
|
-
}
|
|
308
|
-
return {
|
|
309
|
-
value: o && o[i++],
|
|
310
|
-
done: !o
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
316
|
-
}
|
|
317
333
|
function _type_of(obj) {
|
|
318
334
|
"@swc/helpers - typeof";
|
|
319
335
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
@@ -771,7 +787,7 @@ function toVastMediaErrorCode(error) {
|
|
|
771
787
|
}
|
|
772
788
|
}
|
|
773
789
|
function createHlsAdPlayer(contentVideo, options) {
|
|
774
|
-
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
|
|
790
|
+
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP, _ref;
|
|
775
791
|
var adPlaying = false;
|
|
776
792
|
var originalMutedState = false;
|
|
777
793
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
@@ -803,6 +819,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
803
819
|
var sawDecodedVideoFrame = false;
|
|
804
820
|
var videoFrameCallbackHandle;
|
|
805
821
|
var pendingPlayPromise;
|
|
822
|
+
var currentVastTagUrl;
|
|
823
|
+
var funnelContext = {};
|
|
824
|
+
var mediaProbe;
|
|
825
|
+
var lastPodAdElementCount = 0;
|
|
826
|
+
var mediaCandidates = [];
|
|
827
|
+
var mediaCandidateIndex = 0;
|
|
828
|
+
var mediaStartTimerId;
|
|
829
|
+
var MEDIA_START_TIMEOUT_MS = (_ref = options === null || options === void 0 ? void 0 : options.mediaStartTimeoutMs) !== null && _ref !== void 0 ? _ref : 8e3;
|
|
830
|
+
var VAST_ERROR_MEDIA_TIMEOUT = 402;
|
|
831
|
+
var pendingVastRequests = /* @__PURE__ */ new Set();
|
|
832
|
+
var pendingRequestAbortReason;
|
|
833
|
+
var forcedMuteByAutoplay = false;
|
|
806
834
|
function createTrackingState() {
|
|
807
835
|
return {
|
|
808
836
|
impression: false,
|
|
@@ -853,6 +881,78 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
853
881
|
}
|
|
854
882
|
}
|
|
855
883
|
}
|
|
884
|
+
var SENSITIVE_URL_PARAMS = /* @__PURE__ */ new Set([
|
|
885
|
+
"ppid",
|
|
886
|
+
"rdid",
|
|
887
|
+
"idtype",
|
|
888
|
+
"is_lat",
|
|
889
|
+
"ifa",
|
|
890
|
+
"idfa",
|
|
891
|
+
"aaid",
|
|
892
|
+
"uid",
|
|
893
|
+
"user_id",
|
|
894
|
+
"userid",
|
|
895
|
+
"device_id",
|
|
896
|
+
"deviceid",
|
|
897
|
+
"ip",
|
|
898
|
+
"ua",
|
|
899
|
+
"gdpr_consent",
|
|
900
|
+
"us_privacy",
|
|
901
|
+
"gpp",
|
|
902
|
+
"addtl_consent",
|
|
903
|
+
"cust_params",
|
|
904
|
+
"email"
|
|
905
|
+
]);
|
|
906
|
+
function redactUrl(url) {
|
|
907
|
+
if (!url) return url;
|
|
908
|
+
try {
|
|
909
|
+
var parsed = new URL(url);
|
|
910
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
911
|
+
try {
|
|
912
|
+
for(var _iterator = Array.from(parsed.searchParams.keys())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
913
|
+
var key = _step.value;
|
|
914
|
+
if (SENSITIVE_URL_PARAMS.has(key.toLowerCase())) {
|
|
915
|
+
parsed.searchParams.set(key, "REDACTED");
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
} catch (err) {
|
|
919
|
+
_didIteratorError = true;
|
|
920
|
+
_iteratorError = err;
|
|
921
|
+
} finally{
|
|
922
|
+
try {
|
|
923
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
924
|
+
_iterator.return();
|
|
925
|
+
}
|
|
926
|
+
} finally{
|
|
927
|
+
if (_didIteratorError) {
|
|
928
|
+
throw _iteratorError;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
return parsed.toString();
|
|
933
|
+
} catch (unused) {
|
|
934
|
+
return url.split("?")[0];
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
function logFunnel(stage) {
|
|
938
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
939
|
+
var payload = _object_spread({
|
|
940
|
+
stage: stage,
|
|
941
|
+
breakId: funnelContext.breakId,
|
|
942
|
+
requestId: funnelContext.requestId,
|
|
943
|
+
controllerId: funnelContext.controllerId,
|
|
944
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0,
|
|
945
|
+
adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
|
|
946
|
+
podIndex: podIndex,
|
|
947
|
+
podSize: podAds.length,
|
|
948
|
+
vastUrl: redactUrl(currentVastTagUrl),
|
|
949
|
+
mediaUrl: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url,
|
|
950
|
+
mediaType: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.type,
|
|
951
|
+
muted: adVideoElement ? adVideoElement.muted : void 0
|
|
952
|
+
}, extra);
|
|
953
|
+
console.log("[HlsAdPlayer][FUNNEL] ".concat(stage), payload);
|
|
954
|
+
emit("ad_funnel", payload);
|
|
955
|
+
}
|
|
856
956
|
function buildTrackingMacroContext() {
|
|
857
957
|
var options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
858
958
|
var _options2_ad;
|
|
@@ -892,20 +992,53 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
892
992
|
urls.forEach(function(url) {
|
|
893
993
|
try {
|
|
894
994
|
var trackingUrl = substituteVastTrackingMacros(url, macroContext);
|
|
995
|
+
var trackingHost;
|
|
996
|
+
try {
|
|
997
|
+
trackingHost = new URL(trackingUrl).host;
|
|
998
|
+
} catch (unused) {
|
|
999
|
+
logFunnel("tracking_url_invalid", {
|
|
1000
|
+
trackingUrl: redactUrl(trackingUrl)
|
|
1001
|
+
});
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
var unexpanded = trackingUrl.match(/\[[A-Z_]+\]/g);
|
|
1005
|
+
if (unexpanded) {
|
|
1006
|
+
logFunnel("tracking_url_unexpanded_macro", {
|
|
1007
|
+
trackingHost: trackingHost,
|
|
1008
|
+
macros: Array.from(new Set(unexpanded))
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
895
1011
|
var img = new Image(1, 1);
|
|
896
1012
|
inFlightBeacons.add(img);
|
|
897
1013
|
var timeoutId;
|
|
898
|
-
var release = function release() {
|
|
1014
|
+
var release = function release(outcome) {
|
|
899
1015
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
900
1016
|
img.onload = null;
|
|
901
1017
|
img.onerror = null;
|
|
902
1018
|
inFlightBeacons.delete(img);
|
|
1019
|
+
console.log("[HlsAdPlayer] Tracking pixel settled (".concat(outcome, "): ").concat(trackingUrl));
|
|
1020
|
+
if (outcome !== "load") {
|
|
1021
|
+
logFunnel("tracking_request_settled", {
|
|
1022
|
+
reason: outcome,
|
|
1023
|
+
trackingHost: trackingHost
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
img.onload = function() {
|
|
1028
|
+
return release("load");
|
|
1029
|
+
};
|
|
1030
|
+
img.onerror = function() {
|
|
1031
|
+
return release("error");
|
|
903
1032
|
};
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
1033
|
+
timeoutId = setTimeout(function() {
|
|
1034
|
+
return release("timeout");
|
|
1035
|
+
}, BEACON_TIMEOUT_MS);
|
|
907
1036
|
img.src = trackingUrl;
|
|
908
1037
|
console.log("[HlsAdPlayer] Fired tracking pixel: ".concat(trackingUrl));
|
|
1038
|
+
logFunnel("tracking_request_created", {
|
|
1039
|
+
trackingHost: trackingHost,
|
|
1040
|
+
errorCode: options2 === null || options2 === void 0 ? void 0 : options2.errorCode
|
|
1041
|
+
});
|
|
909
1042
|
} catch (error) {
|
|
910
1043
|
console.warn("[HlsAdPlayer] Error firing tracking pixel:", error);
|
|
911
1044
|
}
|
|
@@ -935,54 +1068,79 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
935
1068
|
bitrate: level.bitrate || 5e6
|
|
936
1069
|
};
|
|
937
1070
|
}
|
|
938
|
-
function
|
|
939
|
-
if (mediaFiles.length === 0) {
|
|
940
|
-
throw new Error("No media files available");
|
|
941
|
-
}
|
|
942
|
-
var firstFile = mediaFiles[0];
|
|
943
|
-
if (!firstFile) {
|
|
944
|
-
throw new Error("No media files available");
|
|
945
|
-
}
|
|
946
|
-
if (mediaFiles.length === 1) {
|
|
947
|
-
return firstFile;
|
|
948
|
-
}
|
|
1071
|
+
function getMediaTargetQuality() {
|
|
949
1072
|
var mainQuality = getMainStreamQuality();
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
1073
|
+
var dpr = typeof window !== "undefined" && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1;
|
|
1074
|
+
var containerWidth = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientWidth) || contentVideo.clientWidth) * dpr;
|
|
1075
|
+
var containerHeight = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientHeight) || contentVideo.clientHeight) * dpr;
|
|
1076
|
+
if (!mainQuality && !(containerWidth > 0 && containerHeight > 0)) {
|
|
1077
|
+
return null;
|
|
1078
|
+
}
|
|
1079
|
+
var base = mainQuality !== null && mainQuality !== void 0 ? mainQuality : {
|
|
1080
|
+
width: containerWidth,
|
|
1081
|
+
height: containerHeight,
|
|
1082
|
+
bitrate: 5e6
|
|
1083
|
+
};
|
|
1084
|
+
var width = containerWidth > 0 ? Math.min(base.width, containerWidth) : base.width;
|
|
1085
|
+
var height = containerHeight > 0 ? Math.min(base.height, containerHeight) : base.height;
|
|
1086
|
+
return {
|
|
1087
|
+
width: width,
|
|
1088
|
+
height: height,
|
|
1089
|
+
bitrate: base.bitrate
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
function rankMediaCandidates(mediaFiles) {
|
|
1093
|
+
var probe = adVideoElement !== null && adVideoElement !== void 0 ? adVideoElement : document.createElement("video");
|
|
1094
|
+
var pageIsHttps = typeof location !== "undefined" && location.protocol === "https:";
|
|
1095
|
+
var target = getMediaTargetQuality();
|
|
1096
|
+
var accepted = [];
|
|
1097
|
+
mediaFiles.forEach(function(file, index) {
|
|
1098
|
+
var isHls = isHlsMediaFile(file);
|
|
1099
|
+
var mimeForProbe = isHls ? "application/vnd.apple.mpegurl" : file.type || "video/mp4";
|
|
1100
|
+
var canPlay2 = probe.canPlayType(mimeForProbe);
|
|
1101
|
+
var playable = isHls ? import_hls.default.isSupported() || canPlay2 !== "" : canPlay2 !== "";
|
|
1102
|
+
var insecure = pageIsHttps && /^http:/i.test(file.url);
|
|
1103
|
+
var details = {
|
|
1104
|
+
index: index,
|
|
1105
|
+
candidateUrl: file.url,
|
|
1106
|
+
candidateType: file.type,
|
|
1107
|
+
width: file.width,
|
|
1108
|
+
height: file.height,
|
|
1109
|
+
bitrate: file.bitrate,
|
|
1110
|
+
canPlayType: canPlay2,
|
|
1111
|
+
hlsJs: isHls ? import_hls.default.isSupported() : void 0
|
|
1112
|
+
};
|
|
1113
|
+
if (!playable) {
|
|
1114
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1115
|
+
reason: "rejected",
|
|
1116
|
+
why: "cannot_play_type"
|
|
1117
|
+
}));
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
var score = 0;
|
|
1121
|
+
if (target) {
|
|
1122
|
+
var resolutionDiff = Math.abs(file.width - target.width) + Math.abs(file.height - target.height);
|
|
1123
|
+
var bitrateDiff = Math.abs((file.bitrate || 5e3) * 1e3 - target.bitrate);
|
|
1124
|
+
score = resolutionDiff * 2 + bitrateDiff / 1e3;
|
|
1125
|
+
}
|
|
1126
|
+
accepted.push({
|
|
963
1127
|
file: file,
|
|
964
1128
|
score: score,
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
}
|
|
1129
|
+
insecure: insecure
|
|
1130
|
+
});
|
|
1131
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1132
|
+
reason: "accepted",
|
|
1133
|
+
why: insecure ? "insecure_http_deprioritized" : "playable",
|
|
1134
|
+
score: score
|
|
1135
|
+
}));
|
|
968
1136
|
});
|
|
969
|
-
|
|
1137
|
+
accepted.sort(function(a, b) {
|
|
1138
|
+
if (a.insecure !== b.insecure) return a.insecure ? 1 : -1;
|
|
970
1139
|
return a.score - b.score;
|
|
971
1140
|
});
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
console.log("[HlsAdPlayer] No best match found, using first media file");
|
|
975
|
-
return firstFile;
|
|
976
|
-
}
|
|
977
|
-
console.log("[HlsAdPlayer] Selected media file:", {
|
|
978
|
-
url: bestMatch.file.url,
|
|
979
|
-
resolution: "".concat(bestMatch.file.width, "x").concat(bestMatch.file.height),
|
|
980
|
-
bitrate: bestMatch.file.bitrate,
|
|
981
|
-
score: bestMatch.score,
|
|
982
|
-
resolutionDiff: bestMatch.resolutionDiff,
|
|
983
|
-
bitrateDiff: bestMatch.bitrateDiff
|
|
1141
|
+
return accepted.map(function(entry) {
|
|
1142
|
+
return entry.file;
|
|
984
1143
|
});
|
|
985
|
-
return bestMatch.file;
|
|
986
1144
|
}
|
|
987
1145
|
function isHlsMediaFile(mediaFile) {
|
|
988
1146
|
var type = mediaFile.type.toLowerCase();
|
|
@@ -999,59 +1157,181 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
999
1157
|
var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
|
|
1000
1158
|
return type.startsWith("audio/") || url.endsWith(".mp3") || url.endsWith(".aac") || url.endsWith(".m4a") || url.endsWith(".ogg") || url.endsWith(".oga") || url.endsWith(".opus") || url.endsWith(".wav") || url.endsWith(".weba");
|
|
1001
1159
|
}
|
|
1002
|
-
function
|
|
1160
|
+
function getMediaProbe() {
|
|
1161
|
+
if (adVideoElement) return adVideoElement;
|
|
1162
|
+
if (!mediaProbe && typeof document !== "undefined") {
|
|
1163
|
+
mediaProbe = document.createElement("video");
|
|
1164
|
+
}
|
|
1165
|
+
return mediaProbe;
|
|
1166
|
+
}
|
|
1167
|
+
function evaluateMediaFile(mf) {
|
|
1168
|
+
var _mf_textContent;
|
|
1169
|
+
var type = mf.getAttribute("type") || "";
|
|
1170
|
+
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1171
|
+
var delivery = mf.getAttribute("delivery") || void 0;
|
|
1172
|
+
var codec = mf.getAttribute("codec") || void 0;
|
|
1173
|
+
if (!url) {
|
|
1174
|
+
return {
|
|
1175
|
+
category: "missing_media",
|
|
1176
|
+
whyRejected: "empty_url",
|
|
1177
|
+
canPlayType: ""
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
var apiFramework = (mf.getAttribute("apiFramework") || "").toUpperCase();
|
|
1181
|
+
if (apiFramework === "VPAID") {
|
|
1182
|
+
return {
|
|
1183
|
+
category: "vpaid",
|
|
1184
|
+
whyRejected: "vpaid_not_supported",
|
|
1185
|
+
canPlayType: ""
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
try {
|
|
1189
|
+
var protocol = new URL(url).protocol;
|
|
1190
|
+
if (protocol !== "https:" && protocol !== "http:") {
|
|
1191
|
+
return {
|
|
1192
|
+
category: "invalid_url",
|
|
1193
|
+
whyRejected: "protocol_".concat(protocol),
|
|
1194
|
+
canPlayType: ""
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
} catch (unused) {
|
|
1198
|
+
return {
|
|
1199
|
+
category: "invalid_url",
|
|
1200
|
+
whyRejected: "unparseable_url",
|
|
1201
|
+
canPlayType: ""
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1205
|
+
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1206
|
+
var file = {
|
|
1207
|
+
url: url,
|
|
1208
|
+
type: type,
|
|
1209
|
+
width: parseInt(mf.getAttribute("width") || "1920", 10),
|
|
1210
|
+
height: parseInt(mf.getAttribute("height") || "1080", 10),
|
|
1211
|
+
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0,
|
|
1212
|
+
delivery: delivery,
|
|
1213
|
+
codec: codec
|
|
1214
|
+
};
|
|
1215
|
+
if (isAudioMediaFile(file)) {
|
|
1216
|
+
return {
|
|
1217
|
+
category: "audio_only",
|
|
1218
|
+
whyRejected: type.toLowerCase().startsWith("audio/") ? "audio_mime" : "audio_extension",
|
|
1219
|
+
canPlayType: ""
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
var isHls = isHlsMediaFile(file);
|
|
1223
|
+
var hasExplicitDimensions = mf.getAttribute("width") != null && mf.getAttribute("height") != null;
|
|
1224
|
+
if (!isHls && hasExplicitDimensions && (file.width <= 1 || file.height <= 1)) {
|
|
1225
|
+
return {
|
|
1226
|
+
category: "audio_only",
|
|
1227
|
+
whyRejected: "zero_dimensions",
|
|
1228
|
+
canPlayType: ""
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
var probe = getMediaProbe();
|
|
1232
|
+
if (isHls) {
|
|
1233
|
+
var _ref;
|
|
1234
|
+
var nativeHls = (_ref = probe === null || probe === void 0 ? void 0 : probe.canPlayType("application/vnd.apple.mpegurl")) !== null && _ref !== void 0 ? _ref : "";
|
|
1235
|
+
if (import_hls.default.isSupported()) {
|
|
1236
|
+
return {
|
|
1237
|
+
file: file,
|
|
1238
|
+
whyAccepted: "hls_js",
|
|
1239
|
+
canPlayType: nativeHls
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
if (nativeHls !== "") {
|
|
1243
|
+
return {
|
|
1244
|
+
file: file,
|
|
1245
|
+
whyAccepted: "native_hls",
|
|
1246
|
+
canPlayType: nativeHls
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
return {
|
|
1250
|
+
category: "unsupported_hls",
|
|
1251
|
+
whyRejected: "no_hls_support",
|
|
1252
|
+
canPlayType: nativeHls
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1255
|
+
if (!isProgressiveMediaFile(file)) {
|
|
1256
|
+
return {
|
|
1257
|
+
category: "unsupported_mime",
|
|
1258
|
+
whyRejected: "not_a_video_mime",
|
|
1259
|
+
canPlayType: ""
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
if (!probe) {
|
|
1263
|
+
return {
|
|
1264
|
+
file: file,
|
|
1265
|
+
whyAccepted: "no_probe_available",
|
|
1266
|
+
canPlayType: ""
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
var baseType = type || "video/mp4";
|
|
1270
|
+
var canPlay2 = probe.canPlayType(baseType);
|
|
1271
|
+
if (canPlay2 === "") {
|
|
1272
|
+
return {
|
|
1273
|
+
category: "unsupported_mime",
|
|
1274
|
+
whyRejected: "canPlayType_empty",
|
|
1275
|
+
canPlayType: canPlay2
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
if (codec) {
|
|
1279
|
+
var withCodec = probe.canPlayType("".concat(baseType, '; codecs="').concat(codec, '"'));
|
|
1280
|
+
if (withCodec === "") {
|
|
1281
|
+
return {
|
|
1282
|
+
category: "unsupported_codec",
|
|
1283
|
+
whyRejected: "codec_canPlayType_empty",
|
|
1284
|
+
canPlayType: withCodec
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
return {
|
|
1288
|
+
file: file,
|
|
1289
|
+
whyAccepted: "canPlayType_".concat(withCodec),
|
|
1290
|
+
canPlayType: withCodec
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
return {
|
|
1294
|
+
file: file,
|
|
1295
|
+
whyAccepted: "canPlayType_".concat(canPlay2),
|
|
1296
|
+
canPlayType: canPlay2
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
function collectVideoMediaFiles(linear, verbose, stats) {
|
|
1003
1300
|
var mediaFileElements = linear.querySelectorAll(":scope > MediaFiles > MediaFile");
|
|
1004
1301
|
var mediaFiles = [];
|
|
1302
|
+
if (stats) stats.total += mediaFileElements.length;
|
|
1005
1303
|
if (verbose) {
|
|
1006
1304
|
console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
|
|
1007
1305
|
}
|
|
1008
1306
|
mediaFileElements.forEach(function(mf, index) {
|
|
1009
1307
|
var _mf_textContent;
|
|
1010
|
-
var
|
|
1308
|
+
var result = evaluateMediaFile(mf);
|
|
1011
1309
|
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1012
|
-
var
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
}
|
|
1030
|
-
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1031
|
-
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1032
|
-
var mediaFile = {
|
|
1033
|
-
url: url,
|
|
1034
|
-
type: type,
|
|
1035
|
-
width: parseInt(width || "1920", 10),
|
|
1036
|
-
height: parseInt(height || "1080", 10),
|
|
1037
|
-
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
1038
|
-
};
|
|
1039
|
-
if (isAudioMediaFile(mediaFile)) {
|
|
1040
|
-
console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
|
|
1310
|
+
var accepted = "file" in result;
|
|
1311
|
+
logFunnel("mediafile_evaluated", {
|
|
1312
|
+
reason: accepted ? "accepted" : result.category,
|
|
1313
|
+
index: index,
|
|
1314
|
+
type: mf.getAttribute("type") || "",
|
|
1315
|
+
delivery: mf.getAttribute("delivery") || void 0,
|
|
1316
|
+
codec: mf.getAttribute("codec") || void 0,
|
|
1317
|
+
apiFramework: mf.getAttribute("apiFramework") || void 0,
|
|
1318
|
+
width: mf.getAttribute("width"),
|
|
1319
|
+
height: mf.getAttribute("height"),
|
|
1320
|
+
fileUrl: redactUrl(url),
|
|
1321
|
+
canPlayType: result.canPlayType,
|
|
1322
|
+
whyAccepted: accepted ? result.whyAccepted : void 0,
|
|
1323
|
+
whyRejected: accepted ? void 0 : result.whyRejected
|
|
1324
|
+
});
|
|
1325
|
+
if ("file" in result) {
|
|
1326
|
+
mediaFiles.push(result.file);
|
|
1041
1327
|
return;
|
|
1042
1328
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
return;
|
|
1329
|
+
if (stats) {
|
|
1330
|
+
var _stats_categories_result_category;
|
|
1331
|
+
stats.categories[result.category] = ((_stats_categories_result_category = stats.categories[result.category]) !== null && _stats_categories_result_category !== void 0 ? _stats_categories_result_category : 0) + 1;
|
|
1047
1332
|
}
|
|
1048
|
-
if (
|
|
1049
|
-
|
|
1050
|
-
if (verbose) {
|
|
1051
|
-
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
1052
|
-
}
|
|
1053
|
-
} else if (verbose) {
|
|
1054
|
-
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
1333
|
+
if (result.category === "audio_only") {
|
|
1334
|
+
console.warn("[HlsAdPlayer] MediaFile ".concat(index, " skipped (audio-only: ").concat(result.whyRejected, ', type="').concat(mf.getAttribute("type") || "", '") — audio-only ads are not played on video inventory'));
|
|
1055
1335
|
}
|
|
1056
1336
|
});
|
|
1057
1337
|
return mediaFiles;
|
|
@@ -1175,26 +1455,58 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1175
1455
|
}
|
|
1176
1456
|
function parseVastXml(xmlString) {
|
|
1177
1457
|
try {
|
|
1178
|
-
var _adElements_find;
|
|
1179
1458
|
var xmlDoc = parseXml(xmlString);
|
|
1180
1459
|
if (!xmlDoc) return {
|
|
1181
1460
|
type: "empty"
|
|
1182
1461
|
};
|
|
1183
1462
|
var root = xmlDoc.documentElement;
|
|
1184
1463
|
var adElements = Array.from(root.querySelectorAll(":scope > Ad"));
|
|
1185
|
-
|
|
1186
|
-
return getAdSequence(el) === void 0;
|
|
1187
|
-
})) !== null && _adElements_find !== void 0 ? _adElements_find : adElements[0];
|
|
1188
|
-
if (!adElement) {
|
|
1464
|
+
if (adElements.length === 0) {
|
|
1189
1465
|
var _root_getAttribute;
|
|
1190
1466
|
console.warn("[HlsAdPlayer] No Ad element found in VAST ".concat((_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : "", " response"));
|
|
1191
1467
|
return emptyVastResult(root);
|
|
1192
1468
|
}
|
|
1193
|
-
var
|
|
1194
|
-
|
|
1195
|
-
|
|
1469
|
+
var ordered = _to_consumable_array(adElements.filter(function(el) {
|
|
1470
|
+
return getAdSequence(el) === void 0;
|
|
1471
|
+
})).concat(_to_consumable_array(adElements.filter(function(el) {
|
|
1472
|
+
return getAdSequence(el) !== void 0;
|
|
1473
|
+
})));
|
|
1474
|
+
var firstEmpty;
|
|
1475
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1476
|
+
try {
|
|
1477
|
+
for(var _iterator = ordered.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1478
|
+
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], adElement = _step_value[1];
|
|
1479
|
+
var parsed = parseAdElement(adElement, true);
|
|
1480
|
+
if (parsed.type === "empty") {
|
|
1481
|
+
firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : firstEmpty = parsed;
|
|
1482
|
+
continue;
|
|
1483
|
+
}
|
|
1484
|
+
if (index > 0) {
|
|
1485
|
+
logFunnel("vast_ad_fallback", {
|
|
1486
|
+
usedAdIndex: index,
|
|
1487
|
+
adCount: ordered.length
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
if (parsed.type === "wrapper") {
|
|
1491
|
+
console.log("[HlsAdPlayer] VAST wrapper detected, following VASTAdTagURI: ".concat(parsed.vastAdTagUri));
|
|
1492
|
+
}
|
|
1493
|
+
return parsed;
|
|
1494
|
+
}
|
|
1495
|
+
} catch (err) {
|
|
1496
|
+
_didIteratorError = true;
|
|
1497
|
+
_iteratorError = err;
|
|
1498
|
+
} finally{
|
|
1499
|
+
try {
|
|
1500
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1501
|
+
_iterator.return();
|
|
1502
|
+
}
|
|
1503
|
+
} finally{
|
|
1504
|
+
if (_didIteratorError) {
|
|
1505
|
+
throw _iteratorError;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1196
1508
|
}
|
|
1197
|
-
return
|
|
1509
|
+
return firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : emptyVastResult(root);
|
|
1198
1510
|
} catch (error) {
|
|
1199
1511
|
console.error("[HlsAdPlayer] Error parsing VAST XML:", error);
|
|
1200
1512
|
return {
|
|
@@ -1240,6 +1552,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1240
1552
|
pushUrls(errorUrls, inLine.querySelectorAll(":scope > Error"));
|
|
1241
1553
|
if (adElement.getAttribute("conditionalAd") === "true") {
|
|
1242
1554
|
console.warn("[HlsAdPlayer] Skipping conditional <Ad> (VPAID-only)");
|
|
1555
|
+
logFunnel("vast_no_supported_media", {
|
|
1556
|
+
reason: "vpaid",
|
|
1557
|
+
conditionalAd: true
|
|
1558
|
+
});
|
|
1243
1559
|
return {
|
|
1244
1560
|
type: "empty",
|
|
1245
1561
|
errorUrls: errorUrls,
|
|
@@ -1248,11 +1564,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1248
1564
|
}
|
|
1249
1565
|
var linear;
|
|
1250
1566
|
var mediaFiles = [];
|
|
1567
|
+
var rejectStats = {
|
|
1568
|
+
total: 0,
|
|
1569
|
+
categories: {}
|
|
1570
|
+
};
|
|
1251
1571
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1252
1572
|
try {
|
|
1253
1573
|
for(var _iterator = Array.from(inLine.querySelectorAll(":scope > Creatives > Creative > Linear"))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1254
1574
|
var candidate = _step.value;
|
|
1255
|
-
var files = collectVideoMediaFiles(candidate, verbose);
|
|
1575
|
+
var files = collectVideoMediaFiles(candidate, verbose, rejectStats);
|
|
1256
1576
|
if (files.length > 0) {
|
|
1257
1577
|
linear = candidate;
|
|
1258
1578
|
mediaFiles = files;
|
|
@@ -1275,6 +1595,39 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1275
1595
|
}
|
|
1276
1596
|
if (!linear) {
|
|
1277
1597
|
console.warn("[HlsAdPlayer] No supported linear media files in <Ad>");
|
|
1598
|
+
var reason = "missing_media";
|
|
1599
|
+
var top = 0;
|
|
1600
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
1601
|
+
try {
|
|
1602
|
+
for(var _iterator1 = Object.keys(rejectStats.categories)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
1603
|
+
var category = _step1.value;
|
|
1604
|
+
var _rejectStats_categories_category;
|
|
1605
|
+
var count = (_rejectStats_categories_category = rejectStats.categories[category]) !== null && _rejectStats_categories_category !== void 0 ? _rejectStats_categories_category : 0;
|
|
1606
|
+
if (count > top) {
|
|
1607
|
+
top = count;
|
|
1608
|
+
reason = category;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
} catch (err) {
|
|
1612
|
+
_didIteratorError1 = true;
|
|
1613
|
+
_iteratorError1 = err;
|
|
1614
|
+
} finally{
|
|
1615
|
+
try {
|
|
1616
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1617
|
+
_iterator1.return();
|
|
1618
|
+
}
|
|
1619
|
+
} finally{
|
|
1620
|
+
if (_didIteratorError1) {
|
|
1621
|
+
throw _iteratorError1;
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
if (rejectStats.total > 0 && top === 0) reason = "other";
|
|
1626
|
+
logFunnel("vast_no_supported_media", {
|
|
1627
|
+
reason: reason,
|
|
1628
|
+
mediaFileCount: rejectStats.total,
|
|
1629
|
+
rejectedByCategory: rejectStats.categories
|
|
1630
|
+
});
|
|
1278
1631
|
return {
|
|
1279
1632
|
type: "empty",
|
|
1280
1633
|
errorUrls: errorUrls,
|
|
@@ -1304,27 +1657,65 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1304
1657
|
}
|
|
1305
1658
|
}
|
|
1306
1659
|
function fetchVastXml(vastTagUrl) {
|
|
1307
|
-
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
1660
|
+
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include", kind = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "gam";
|
|
1308
1661
|
return _async_to_generator(function() {
|
|
1309
|
-
var controller, timeoutId, requestVast, response, error, error1;
|
|
1662
|
+
var controller, timeoutId, startedAt, attempt, requestVast, response, error, error1;
|
|
1310
1663
|
return _ts_generator(this, function(_state) {
|
|
1311
1664
|
switch(_state.label){
|
|
1312
1665
|
case 0:
|
|
1666
|
+
if (destroyed) {
|
|
1667
|
+
throw new Error("VAST request skipped: ad player destroyed");
|
|
1668
|
+
}
|
|
1313
1669
|
controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1670
|
+
if (controller) pendingVastRequests.add(controller);
|
|
1314
1671
|
timeoutId = controller ? setTimeout(function() {
|
|
1315
1672
|
return controller.abort();
|
|
1316
1673
|
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
1674
|
+
startedAt = Date.now();
|
|
1675
|
+
attempt = 0;
|
|
1317
1676
|
requestVast = function requestVast(creds) {
|
|
1318
|
-
return
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1677
|
+
return _async_to_generator(function() {
|
|
1678
|
+
var response;
|
|
1679
|
+
return _ts_generator(this, function(_state) {
|
|
1680
|
+
switch(_state.label){
|
|
1681
|
+
case 0:
|
|
1682
|
+
attempt++;
|
|
1683
|
+
if (kind === "gam") {
|
|
1684
|
+
logFunnel("gam_http_request_sent", {
|
|
1685
|
+
attempt: attempt,
|
|
1686
|
+
credentials: creds
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
return [
|
|
1690
|
+
4,
|
|
1691
|
+
fetch(vastTagUrl, _object_spread({
|
|
1692
|
+
mode: "cors",
|
|
1693
|
+
credentials: creds,
|
|
1694
|
+
headers: {
|
|
1695
|
+
"Accept": "application/xml, text/xml, */*"
|
|
1696
|
+
},
|
|
1697
|
+
referrerPolicy: "no-referrer-when-downgrade"
|
|
1698
|
+
}, controller ? {
|
|
1699
|
+
signal: controller.signal
|
|
1700
|
+
} : {}))
|
|
1701
|
+
];
|
|
1702
|
+
case 1:
|
|
1703
|
+
response = _state.sent();
|
|
1704
|
+
if (kind === "gam") {
|
|
1705
|
+
logFunnel("gam_response_received", {
|
|
1706
|
+
attempt: attempt,
|
|
1707
|
+
httpStatus: response.status,
|
|
1708
|
+
ok: response.ok,
|
|
1709
|
+
elapsedMs: Date.now() - startedAt
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
return [
|
|
1713
|
+
2,
|
|
1714
|
+
response
|
|
1715
|
+
];
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
})();
|
|
1328
1719
|
};
|
|
1329
1720
|
_state.label = 1;
|
|
1330
1721
|
case 1:
|
|
@@ -1359,6 +1750,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1359
1750
|
6
|
|
1360
1751
|
];
|
|
1361
1752
|
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
1753
|
+
logFunnel("vast_credentials_retry", {
|
|
1754
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1755
|
+
});
|
|
1362
1756
|
return [
|
|
1363
1757
|
4,
|
|
1364
1758
|
requestVast("omit")
|
|
@@ -1378,7 +1772,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1378
1772
|
];
|
|
1379
1773
|
case 8:
|
|
1380
1774
|
if (!response.ok) {
|
|
1381
|
-
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
1775
|
+
throw new Error("Failed to fetch VAST: HTTP ".concat(response.status, " ").concat(response.statusText));
|
|
1382
1776
|
}
|
|
1383
1777
|
return [
|
|
1384
1778
|
4,
|
|
@@ -1392,11 +1786,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1392
1786
|
case 10:
|
|
1393
1787
|
error1 = _state.sent();
|
|
1394
1788
|
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1789
|
+
if (pendingRequestAbortReason) {
|
|
1790
|
+
throw new Error("".concat(pendingRequestAbortReason, ": ").concat(vastTagUrl));
|
|
1791
|
+
}
|
|
1395
1792
|
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1396
1793
|
}
|
|
1397
1794
|
throw error1;
|
|
1398
1795
|
case 11:
|
|
1399
1796
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1797
|
+
if (controller) pendingVastRequests.delete(controller);
|
|
1400
1798
|
return [
|
|
1401
1799
|
7
|
|
1402
1800
|
];
|
|
@@ -1410,7 +1808,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1410
1808
|
}
|
|
1411
1809
|
function fetchAndParseVastAd(_0) {
|
|
1412
1810
|
return _async_to_generator(function(vastTagUrl) {
|
|
1413
|
-
var depth, accumulatedTracking, rules, vastXml, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1811
|
+
var depth, accumulatedTracking, rules, vastXml, fetchStartedAt, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1414
1812
|
var _arguments = arguments;
|
|
1415
1813
|
return _ts_generator(this, function(_state) {
|
|
1416
1814
|
switch(_state.label){
|
|
@@ -1418,6 +1816,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1418
1816
|
depth = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : 0, accumulatedTracking = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : createEmptyTrackingUrls(), rules = _arguments.length > 3 && _arguments[3] !== void 0 ? _arguments[3] : {
|
|
1419
1817
|
followAdditionalWrappers: true
|
|
1420
1818
|
};
|
|
1819
|
+
if (destroyed) return [
|
|
1820
|
+
2,
|
|
1821
|
+
null
|
|
1822
|
+
];
|
|
1823
|
+
fetchStartedAt = Date.now();
|
|
1421
1824
|
_state.label = 1;
|
|
1422
1825
|
case 1:
|
|
1423
1826
|
_state.trys.push([
|
|
@@ -1428,7 +1831,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1428
1831
|
]);
|
|
1429
1832
|
return [
|
|
1430
1833
|
4,
|
|
1431
|
-
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit")
|
|
1834
|
+
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit", depth === 0 ? "gam" : "wrapper")
|
|
1432
1835
|
];
|
|
1433
1836
|
case 2:
|
|
1434
1837
|
vastXml = _state.sent();
|
|
@@ -1440,14 +1843,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1440
1843
|
error = _state.sent();
|
|
1441
1844
|
if (depth === 0) throw error;
|
|
1442
1845
|
console.warn("[HlsAdPlayer] Wrapped VAST request failed:", error);
|
|
1443
|
-
|
|
1444
|
-
|
|
1846
|
+
logFunnel("wrapper_fetch", {
|
|
1847
|
+
reason: "failure",
|
|
1848
|
+
depth: depth,
|
|
1849
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
1850
|
+
elapsedMs: Date.now() - fetchStartedAt,
|
|
1851
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1445
1852
|
});
|
|
1853
|
+
if (!destroyed) {
|
|
1854
|
+
fireTrackingPixels(accumulatedTracking.error, {
|
|
1855
|
+
errorCode: VAST_ERROR_WRAPPER_TIMEOUT
|
|
1856
|
+
});
|
|
1857
|
+
}
|
|
1446
1858
|
return [
|
|
1447
1859
|
2,
|
|
1448
1860
|
null
|
|
1449
1861
|
];
|
|
1450
1862
|
case 4:
|
|
1863
|
+
if (destroyed) return [
|
|
1864
|
+
2,
|
|
1865
|
+
null
|
|
1866
|
+
];
|
|
1867
|
+
if (depth > 0) {
|
|
1868
|
+
logFunnel("wrapper_fetch", {
|
|
1869
|
+
reason: "success",
|
|
1870
|
+
depth: depth,
|
|
1871
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
1872
|
+
elapsedMs: Date.now() - fetchStartedAt
|
|
1873
|
+
});
|
|
1874
|
+
}
|
|
1451
1875
|
console.log("[HlsAdPlayer] VAST XML received");
|
|
1452
1876
|
console.log("[HlsAdPlayer] VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1453
1877
|
parsed = parseVastXml(vastXml);
|
|
@@ -1479,6 +1903,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1479
1903
|
];
|
|
1480
1904
|
}
|
|
1481
1905
|
mergeTrackingUrls(parsed.ad.trackingUrls, accumulatedTracking);
|
|
1906
|
+
logFunnel("inline_resolved", {
|
|
1907
|
+
depth: depth
|
|
1908
|
+
});
|
|
1482
1909
|
return [
|
|
1483
1910
|
2,
|
|
1484
1911
|
parsed.ad
|
|
@@ -1489,20 +1916,29 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1489
1916
|
}
|
|
1490
1917
|
function fetchAndParsePod(vastTagUrl) {
|
|
1491
1918
|
return _async_to_generator(function() {
|
|
1492
|
-
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements,
|
|
1919
|
+
var _root_getAttribute, _root_getAttribute1, vastXml, trimmedXml, xmlDoc, root, adElements, _root_getAttribute2, _empty_errorUrls, empty, _empty_errorCode, resolveAd, podElements, buffet, resolveAll, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, ad, err, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, ad1, err;
|
|
1493
1920
|
return _ts_generator(this, function(_state) {
|
|
1494
1921
|
switch(_state.label){
|
|
1495
1922
|
case 0:
|
|
1923
|
+
lastPodAdElementCount = 0;
|
|
1496
1924
|
return [
|
|
1497
1925
|
4,
|
|
1498
1926
|
fetchVastXml(vastTagUrl)
|
|
1499
1927
|
];
|
|
1500
1928
|
case 1:
|
|
1501
1929
|
vastXml = _state.sent();
|
|
1930
|
+
if (destroyed) return [
|
|
1931
|
+
2,
|
|
1932
|
+
[]
|
|
1933
|
+
];
|
|
1502
1934
|
console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
|
|
1503
1935
|
trimmedXml = vastXml.trim();
|
|
1504
1936
|
if (trimmedXml.length === 0) {
|
|
1505
1937
|
console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
|
|
1938
|
+
logFunnel("vast_parsed", {
|
|
1939
|
+
adElementCount: 0,
|
|
1940
|
+
reason: "empty_body"
|
|
1941
|
+
});
|
|
1506
1942
|
return [
|
|
1507
1943
|
2,
|
|
1508
1944
|
[]
|
|
@@ -1511,6 +1947,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1511
1947
|
xmlDoc = parseXml(vastXml);
|
|
1512
1948
|
if (!xmlDoc) {
|
|
1513
1949
|
console.error("[HlsAdPlayer] Pod VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1950
|
+
logFunnel("vast_parsed", {
|
|
1951
|
+
adElementCount: 0,
|
|
1952
|
+
reason: "xml_parse_error"
|
|
1953
|
+
});
|
|
1514
1954
|
return [
|
|
1515
1955
|
2,
|
|
1516
1956
|
[]
|
|
@@ -1518,10 +1958,21 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1518
1958
|
}
|
|
1519
1959
|
root = xmlDoc.documentElement;
|
|
1520
1960
|
adElements = Array.from(root.querySelectorAll(":scope > Ad"));
|
|
1961
|
+
logFunnel("vast_parsed", {
|
|
1962
|
+
reason: adElements.length > 0 ? "has_ads" : "no_ads",
|
|
1963
|
+
vastVersion: (_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : void 0,
|
|
1964
|
+
adElementCount: adElements.length,
|
|
1965
|
+
inlineCount: adElements.filter(function(el) {
|
|
1966
|
+
return el.querySelector(":scope > InLine");
|
|
1967
|
+
}).length,
|
|
1968
|
+
wrapperCount: adElements.filter(function(el) {
|
|
1969
|
+
return el.querySelector(":scope > Wrapper");
|
|
1970
|
+
}).length
|
|
1971
|
+
});
|
|
1521
1972
|
if (adElements.length === 0) {
|
|
1522
1973
|
;
|
|
1523
1974
|
;
|
|
1524
|
-
console.warn("[HlsAdPlayer] No <Ad> elements in VAST ".concat((
|
|
1975
|
+
console.warn("[HlsAdPlayer] No <Ad> elements in VAST ".concat((_root_getAttribute2 = root.getAttribute("version")) !== null && _root_getAttribute2 !== void 0 ? _root_getAttribute2 : "", " pod response (no fill)"));
|
|
1525
1976
|
empty = emptyVastResult(root);
|
|
1526
1977
|
if (empty.type === "empty" && ((_empty_errorUrls = empty.errorUrls) === null || _empty_errorUrls === void 0 ? void 0 : _empty_errorUrls.length)) {
|
|
1527
1978
|
;
|
|
@@ -1539,10 +1990,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1539
1990
|
var _parsed_errorUrls, parsed, _parsed_errorCode;
|
|
1540
1991
|
return _ts_generator(this, function(_state) {
|
|
1541
1992
|
parsed = parseAdElement(adElement);
|
|
1542
|
-
if (parsed.type === "inline")
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1993
|
+
if (parsed.type === "inline") {
|
|
1994
|
+
logFunnel("inline_resolved", {
|
|
1995
|
+
depth: 0
|
|
1996
|
+
});
|
|
1997
|
+
return [
|
|
1998
|
+
2,
|
|
1999
|
+
parsed.ad
|
|
2000
|
+
];
|
|
2001
|
+
}
|
|
1546
2002
|
if (parsed.type === "wrapper") {
|
|
1547
2003
|
return [
|
|
1548
2004
|
2,
|
|
@@ -1720,7 +2176,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1720
2176
|
7
|
|
1721
2177
|
];
|
|
1722
2178
|
case 21:
|
|
1723
|
-
console.log("[HlsAdPlayer] Parsed ".concat(ads.length, " ad(s) from VAST ").concat((
|
|
2179
|
+
console.log("[HlsAdPlayer] Parsed ".concat(ads.length, " ad(s) from VAST ").concat((_root_getAttribute1 = root.getAttribute("version")) !== null && _root_getAttribute1 !== void 0 ? _root_getAttribute1 : "", " pod response"));
|
|
2180
|
+
lastPodAdElementCount = adElements.length;
|
|
1724
2181
|
return [
|
|
1725
2182
|
2,
|
|
1726
2183
|
ads
|
|
@@ -1786,14 +2243,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1786
2243
|
var progress = currentTime / currentAd.duration;
|
|
1787
2244
|
if (progress >= 0.25 && !trackingFired.firstQuartile) {
|
|
1788
2245
|
trackingFired.firstQuartile = true;
|
|
2246
|
+
logFunnel("first_quartile");
|
|
1789
2247
|
fireTrackingPixels(currentAd.trackingUrls.firstQuartile);
|
|
1790
2248
|
}
|
|
1791
2249
|
if (progress >= 0.5 && !trackingFired.midpoint) {
|
|
1792
2250
|
trackingFired.midpoint = true;
|
|
2251
|
+
logFunnel("midpoint");
|
|
1793
2252
|
fireTrackingPixels(currentAd.trackingUrls.midpoint);
|
|
1794
2253
|
}
|
|
1795
2254
|
if (progress >= 0.75 && !trackingFired.thirdQuartile) {
|
|
1796
2255
|
trackingFired.thirdQuartile = true;
|
|
2256
|
+
logFunnel("third_quartile");
|
|
1797
2257
|
fireTrackingPixels(currentAd.trackingUrls.thirdQuartile);
|
|
1798
2258
|
}
|
|
1799
2259
|
};
|
|
@@ -1816,6 +2276,16 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1816
2276
|
if (!trackingFired.impression) {
|
|
1817
2277
|
trackingFired.impression = true;
|
|
1818
2278
|
resolvedAds.add(currentAd);
|
|
2279
|
+
logFunnel("playing", {
|
|
2280
|
+
mutedByAutoplay: forcedMuteByAutoplay,
|
|
2281
|
+
candidateIndex: mediaCandidateIndex
|
|
2282
|
+
});
|
|
2283
|
+
logFunnel("impression_fired", {
|
|
2284
|
+
pixelCount: currentAd.trackingUrls.impression.length
|
|
2285
|
+
});
|
|
2286
|
+
if (currentAd.trackingUrls.impression.length === 0) {
|
|
2287
|
+
console.warn("[HlsAdPlayer] Ad started but VAST contained no <Impression> URLs - GAM will not count it");
|
|
2288
|
+
}
|
|
1819
2289
|
fireTrackingPixels(currentAd.trackingUrls.impression);
|
|
1820
2290
|
fireTrackingPixels(currentAd.trackingUrls.creativeView);
|
|
1821
2291
|
fireTrackingPixels(currentAd.trackingUrls.verificationNotExecuted, {
|
|
@@ -1838,6 +2308,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1838
2308
|
sampleViewability();
|
|
1839
2309
|
settleViewability();
|
|
1840
2310
|
trackingFired.complete = true;
|
|
2311
|
+
logFunnel("complete");
|
|
1841
2312
|
fireTrackingPixels(currentAd.trackingUrls.complete);
|
|
1842
2313
|
console.log("[HlsAdPlayer] Ad completed");
|
|
1843
2314
|
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
|
|
@@ -1846,16 +2317,41 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1846
2317
|
handleAdComplete();
|
|
1847
2318
|
};
|
|
1848
2319
|
var onError = function onError(e) {
|
|
2320
|
+
var _adVideoElement_error, _adVideoElement_error1;
|
|
1849
2321
|
if (!adPlaying) return;
|
|
1850
2322
|
console.error("[HlsAdPlayer] Ad video error:", e);
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
2323
|
+
var vastErrorCode = toVastMediaErrorCode(adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.error);
|
|
2324
|
+
logFunnel("media_error", {
|
|
2325
|
+
mediaErrorCode: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error = adVideoElement.error) === null || _adVideoElement_error === void 0 ? void 0 : _adVideoElement_error.code,
|
|
2326
|
+
errorMessage: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error1 = adVideoElement.error) === null || _adVideoElement_error1 === void 0 ? void 0 : _adVideoElement_error1.message,
|
|
2327
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2328
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2329
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2330
|
+
vastErrorCode: vastErrorCode
|
|
2331
|
+
});
|
|
2332
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2333
|
+
};
|
|
2334
|
+
var onMediaDiagnostic = function onMediaDiagnostic(event) {
|
|
2335
|
+
if (!adPlaying || !adVideoElement || trackingFired.impression) return;
|
|
2336
|
+
if (!adVideoElement.currentSrc) return;
|
|
2337
|
+
logFunnel("media_event", {
|
|
2338
|
+
reason: event.type,
|
|
2339
|
+
readyState: adVideoElement.readyState,
|
|
2340
|
+
networkState: adVideoElement.networkState,
|
|
2341
|
+
currentSrc: adVideoElement.currentSrc
|
|
2342
|
+
});
|
|
1856
2343
|
};
|
|
1857
2344
|
var onVolumeChange = function onVolumeChange() {
|
|
1858
2345
|
if (!currentAd || !adVideoElement) return;
|
|
2346
|
+
if (forcedMuteByAutoplay && !adVideoElement.muted) {
|
|
2347
|
+
var userActivation = navigator.userActivation;
|
|
2348
|
+
if (userActivation && !userActivation.isActive) {
|
|
2349
|
+
logFunnel("unexpected_unmute", {
|
|
2350
|
+
paused: adVideoElement.paused
|
|
2351
|
+
});
|
|
2352
|
+
}
|
|
2353
|
+
forcedMuteByAutoplay = false;
|
|
2354
|
+
}
|
|
1859
2355
|
var muted = adVideoElement.muted || adVideoElement.volume === 0;
|
|
1860
2356
|
if (!trackingFired.start) {
|
|
1861
2357
|
trackingFired.lastMuted = muted;
|
|
@@ -1915,6 +2411,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1915
2411
|
{
|
|
1916
2412
|
type: "play",
|
|
1917
2413
|
handler: onPlay
|
|
2414
|
+
},
|
|
2415
|
+
{
|
|
2416
|
+
type: "stalled",
|
|
2417
|
+
handler: onMediaDiagnostic
|
|
2418
|
+
},
|
|
2419
|
+
{
|
|
2420
|
+
type: "suspend",
|
|
2421
|
+
handler: onMediaDiagnostic
|
|
2422
|
+
},
|
|
2423
|
+
{
|
|
2424
|
+
type: "abort",
|
|
2425
|
+
handler: onMediaDiagnostic
|
|
2426
|
+
},
|
|
2427
|
+
{
|
|
2428
|
+
type: "emptied",
|
|
2429
|
+
handler: onMediaDiagnostic
|
|
1918
2430
|
}
|
|
1919
2431
|
];
|
|
1920
2432
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -2204,16 +2716,51 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2204
2716
|
function settlePendingPlay() {
|
|
2205
2717
|
pendingPlayPromise = void 0;
|
|
2206
2718
|
}
|
|
2719
|
+
function toVastPlayErrorCode(error) {
|
|
2720
|
+
return (error === null || error === void 0 ? void 0 : error.name) === "NotSupportedError" ? VAST_ERROR_NO_SUPPORTED_MEDIA : VAST_ERROR_MEDIA_DISPLAY;
|
|
2721
|
+
}
|
|
2722
|
+
function failAdPlayback(context, error) {
|
|
2723
|
+
var vastErrorCode = toVastPlayErrorCode(error);
|
|
2724
|
+
console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
|
|
2725
|
+
logFunnel("play_failed", {
|
|
2726
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2727
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message,
|
|
2728
|
+
vastErrorCode: vastErrorCode
|
|
2729
|
+
});
|
|
2730
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2731
|
+
}
|
|
2207
2732
|
function startAdPlayback(context) {
|
|
2733
|
+
var isMutedRetry = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
2208
2734
|
if (!adVideoElement) return;
|
|
2735
|
+
var computed = typeof getComputedStyle === "function" && adContainerEl ? getComputedStyle(adContainerEl) : void 0;
|
|
2736
|
+
logFunnel(isMutedRetry ? "muted_retry" : "play_called", {
|
|
2737
|
+
context: context,
|
|
2738
|
+
isConnected: adVideoElement.isConnected,
|
|
2739
|
+
clientWidth: adVideoElement.clientWidth,
|
|
2740
|
+
clientHeight: adVideoElement.clientHeight,
|
|
2741
|
+
containerDisplay: computed === null || computed === void 0 ? void 0 : computed.display,
|
|
2742
|
+
containerVisibility: computed === null || computed === void 0 ? void 0 : computed.visibility
|
|
2743
|
+
});
|
|
2209
2744
|
var playPromise = adVideoElement.play();
|
|
2210
2745
|
pendingPlayPromise = playPromise;
|
|
2211
2746
|
playPromise.catch(function(error) {
|
|
2212
2747
|
if (pendingPlayPromise !== playPromise) {
|
|
2213
2748
|
return;
|
|
2214
2749
|
}
|
|
2215
|
-
|
|
2216
|
-
|
|
2750
|
+
logFunnel("play_rejected", {
|
|
2751
|
+
context: context,
|
|
2752
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2753
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
2754
|
+
});
|
|
2755
|
+
if (!isMutedRetry && (error === null || error === void 0 ? void 0 : error.name) === "NotAllowedError" && adVideoElement && !adVideoElement.muted) {
|
|
2756
|
+
console.warn("[HlsAdPlayer] Unmuted ".concat(context, " blocked by autoplay policy - retrying muted"));
|
|
2757
|
+
originalMutedState = true;
|
|
2758
|
+
forcedMuteByAutoplay = true;
|
|
2759
|
+
adVideoElement.muted = true;
|
|
2760
|
+
startAdPlayback(context, true);
|
|
2761
|
+
return;
|
|
2762
|
+
}
|
|
2763
|
+
failAdPlayback(context, error);
|
|
2217
2764
|
}).finally(function() {
|
|
2218
2765
|
if (pendingPlayPromise === playPromise) {
|
|
2219
2766
|
pendingPlayPromise = void 0;
|
|
@@ -2252,17 +2799,109 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2252
2799
|
adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
|
|
2253
2800
|
adVideoElement.muted = originalMutedState;
|
|
2254
2801
|
}
|
|
2802
|
+
function clearMediaStartTimer() {
|
|
2803
|
+
if (mediaStartTimerId !== void 0) {
|
|
2804
|
+
clearTimeout(mediaStartTimerId);
|
|
2805
|
+
mediaStartTimerId = void 0;
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
function startMediaStartTimer() {
|
|
2809
|
+
clearMediaStartTimer();
|
|
2810
|
+
if (!(MEDIA_START_TIMEOUT_MS > 0)) return;
|
|
2811
|
+
var startedAt = Date.now();
|
|
2812
|
+
mediaStartTimerId = setTimeout(function() {
|
|
2813
|
+
mediaStartTimerId = void 0;
|
|
2814
|
+
if (!adPlaying || trackingFired.impression) return;
|
|
2815
|
+
console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(MEDIA_START_TIMEOUT_MS, "ms"));
|
|
2816
|
+
logFunnel("play_resolved_but_never_started", {
|
|
2817
|
+
timeoutMs: MEDIA_START_TIMEOUT_MS,
|
|
2818
|
+
elapsedMs: Date.now() - startedAt,
|
|
2819
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2820
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2821
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2822
|
+
paused: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.paused,
|
|
2823
|
+
vastErrorCode: VAST_ERROR_MEDIA_TIMEOUT
|
|
2824
|
+
});
|
|
2825
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_TIMEOUT);
|
|
2826
|
+
}, MEDIA_START_TIMEOUT_MS);
|
|
2827
|
+
}
|
|
2828
|
+
function resetVideoElementForNextSource() {
|
|
2829
|
+
clearStallWatchdog();
|
|
2830
|
+
if (requiresMediaPipelineResetAfterAds()) {
|
|
2831
|
+
recreateAdVideoElement();
|
|
2832
|
+
setupAdEventListeners();
|
|
2833
|
+
} else {
|
|
2834
|
+
prepareVideoElementForNewSource();
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
function tryNextMediaCandidate() {
|
|
2838
|
+
if (!currentAd || trackingFired.impression) return false;
|
|
2839
|
+
if (mediaCandidateIndex >= mediaCandidates.length - 1) return false;
|
|
2840
|
+
var failedUrl = currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url;
|
|
2841
|
+
mediaCandidateIndex++;
|
|
2842
|
+
var next = mediaCandidates[mediaCandidateIndex];
|
|
2843
|
+
if (!next) return false;
|
|
2844
|
+
logFunnel("media_fallback", {
|
|
2845
|
+
failedUrl: failedUrl,
|
|
2846
|
+
nextUrl: next.url,
|
|
2847
|
+
nextType: next.type,
|
|
2848
|
+
candidateIndex: mediaCandidateIndex,
|
|
2849
|
+
candidateCount: mediaCandidates.length
|
|
2850
|
+
});
|
|
2851
|
+
resetVideoElementForNextSource();
|
|
2852
|
+
try {
|
|
2853
|
+
loadMediaCandidate(next);
|
|
2854
|
+
return true;
|
|
2855
|
+
} catch (error) {
|
|
2856
|
+
console.error("[HlsAdPlayer] Failed to load fallback media file:", error);
|
|
2857
|
+
return tryNextMediaCandidate();
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
function recoverFromAdFailure(vastErrorCode) {
|
|
2861
|
+
clearMediaStartTimer();
|
|
2862
|
+
if (tryNextMediaCandidate()) return;
|
|
2863
|
+
reportCurrentAdError(vastErrorCode);
|
|
2864
|
+
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) return;
|
|
2865
|
+
handleAdError();
|
|
2866
|
+
}
|
|
2255
2867
|
function loadCurrentAdMedia() {
|
|
2256
2868
|
if (!adVideoElement || !currentAd) {
|
|
2257
2869
|
throw new Error("No ad video element or ad to load");
|
|
2258
2870
|
}
|
|
2259
|
-
|
|
2871
|
+
mediaCandidates = rankMediaCandidates(currentAd.mediaFiles);
|
|
2872
|
+
mediaCandidateIndex = 0;
|
|
2873
|
+
var mediaFile = mediaCandidates[0];
|
|
2260
2874
|
if (!mediaFile) {
|
|
2261
|
-
|
|
2875
|
+
logFunnel("media_unsupported", {
|
|
2876
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA,
|
|
2877
|
+
candidates: currentAd.mediaFiles.length
|
|
2878
|
+
});
|
|
2879
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
2880
|
+
throw new Error("No media file this browser can play");
|
|
2881
|
+
}
|
|
2882
|
+
try {
|
|
2883
|
+
loadMediaCandidate(mediaFile);
|
|
2884
|
+
} catch (error) {
|
|
2885
|
+
if (tryNextMediaCandidate()) return;
|
|
2886
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
2887
|
+
throw error;
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
function loadMediaCandidate(mediaFile) {
|
|
2891
|
+
if (!adVideoElement || !currentAd) {
|
|
2892
|
+
throw new Error("No ad video element or ad to load");
|
|
2262
2893
|
}
|
|
2263
2894
|
currentAdMediaFile = mediaFile;
|
|
2264
2895
|
var isHlsAd = isHlsMediaFile(mediaFile);
|
|
2896
|
+
logFunnel("media_selected", {
|
|
2897
|
+
width: mediaFile.width,
|
|
2898
|
+
height: mediaFile.height,
|
|
2899
|
+
bitrate: mediaFile.bitrate,
|
|
2900
|
+
candidateIndex: mediaCandidateIndex,
|
|
2901
|
+
candidates: mediaCandidates.length
|
|
2902
|
+
});
|
|
2265
2903
|
console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad (pod ").concat(podIndex + 1, "/").concat(podAds.length || 1, ") from: ").concat(mediaFile.url));
|
|
2904
|
+
startMediaStartTimer();
|
|
2266
2905
|
if (isHlsAd && import_hls.default.isSupported()) {
|
|
2267
2906
|
if (adHls) {
|
|
2268
2907
|
adHls.destroy();
|
|
@@ -2271,6 +2910,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2271
2910
|
enableWorker: true,
|
|
2272
2911
|
lowLatencyMode: false
|
|
2273
2912
|
});
|
|
2913
|
+
logFunnel("media_load", {
|
|
2914
|
+
pipeline: "hls.js"
|
|
2915
|
+
});
|
|
2274
2916
|
adHls.loadSource(mediaFile.url);
|
|
2275
2917
|
adHls.attachMedia(adVideoElement);
|
|
2276
2918
|
adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
|
|
@@ -2280,10 +2922,24 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2280
2922
|
adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
|
|
2281
2923
|
console.error("[HlsAdPlayer] HLS error:", data);
|
|
2282
2924
|
if (data.fatal) {
|
|
2283
|
-
|
|
2925
|
+
var _data_response, _data_response1, _data_frag;
|
|
2926
|
+
var vastErrorCode = data.type === import_hls.default.ErrorTypes.NETWORK_ERROR ? 401 : VAST_ERROR_MEDIA_DISPLAY;
|
|
2927
|
+
logFunnel("hls_fatal", {
|
|
2928
|
+
reason: data.details,
|
|
2929
|
+
errorName: data.type,
|
|
2930
|
+
errorMessage: data.details,
|
|
2931
|
+
responseCode: (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.code,
|
|
2932
|
+
responseText: (_data_response1 = data.response) === null || _data_response1 === void 0 ? void 0 : _data_response1.text,
|
|
2933
|
+
fragUrl: (_data_frag = data.frag) === null || _data_frag === void 0 ? void 0 : _data_frag.url,
|
|
2934
|
+
vastErrorCode: vastErrorCode
|
|
2935
|
+
});
|
|
2936
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2284
2937
|
}
|
|
2285
2938
|
});
|
|
2286
2939
|
} else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
|
|
2940
|
+
logFunnel("media_load", {
|
|
2941
|
+
pipeline: "native-hls"
|
|
2942
|
+
});
|
|
2287
2943
|
adVideoElement.src = mediaFile.url;
|
|
2288
2944
|
startAdPlayback("native HLS ad playback");
|
|
2289
2945
|
} else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
|
|
@@ -2291,45 +2947,47 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2291
2947
|
adHls.destroy();
|
|
2292
2948
|
adHls = void 0;
|
|
2293
2949
|
}
|
|
2950
|
+
logFunnel("media_load", {
|
|
2951
|
+
pipeline: "progressive"
|
|
2952
|
+
});
|
|
2294
2953
|
adVideoElement.src = mediaFile.url;
|
|
2295
2954
|
adVideoElement.load();
|
|
2296
2955
|
startAdPlayback("progressive ad playback");
|
|
2297
2956
|
} else {
|
|
2957
|
+
clearMediaStartTimer();
|
|
2958
|
+
logFunnel("media_unsupported", {
|
|
2959
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA
|
|
2960
|
+
});
|
|
2298
2961
|
throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
|
|
2299
2962
|
}
|
|
2300
2963
|
}
|
|
2301
2964
|
function advanceToNextPodAd() {
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
index: podIndex,
|
|
2324
|
-
total: podAds.length
|
|
2325
|
-
});
|
|
2326
|
-
return true;
|
|
2327
|
-
} catch (error) {
|
|
2328
|
-
console.error("[HlsAdPlayer] Failed to load next pod ad:", error);
|
|
2329
|
-
return false;
|
|
2965
|
+
clearMediaStartTimer();
|
|
2966
|
+
while(podIndex < podAds.length - 1){
|
|
2967
|
+
settleViewability();
|
|
2968
|
+
podIndex++;
|
|
2969
|
+
currentAd = podAds[podIndex];
|
|
2970
|
+
currentAdMediaFile = void 0;
|
|
2971
|
+
resetAdTracking();
|
|
2972
|
+
if (currentAd) {
|
|
2973
|
+
console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
|
|
2974
|
+
}
|
|
2975
|
+
resetVideoElementForNextSource();
|
|
2976
|
+
try {
|
|
2977
|
+
loadCurrentAdMedia();
|
|
2978
|
+
emit("pod_ad_started", {
|
|
2979
|
+
index: podIndex,
|
|
2980
|
+
total: podAds.length
|
|
2981
|
+
});
|
|
2982
|
+
return true;
|
|
2983
|
+
} catch (error) {
|
|
2984
|
+
console.error("[HlsAdPlayer] Failed to load next pod ad:", error);
|
|
2985
|
+
}
|
|
2330
2986
|
}
|
|
2987
|
+
return false;
|
|
2331
2988
|
}
|
|
2332
2989
|
function clearStallWatchdog() {
|
|
2990
|
+
clearMediaStartTimer();
|
|
2333
2991
|
if (stallWatchdogId != null) {
|
|
2334
2992
|
clearInterval(stallWatchdogId);
|
|
2335
2993
|
stallWatchdogId = void 0;
|
|
@@ -2345,11 +3003,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2345
3003
|
function handleAdStall() {
|
|
2346
3004
|
console.warn("[HlsAdPlayer] Ad playback stalled (no progress) - recovering to avoid a blank frame");
|
|
2347
3005
|
clearStallWatchdog();
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
handleAdError();
|
|
3006
|
+
logFunnel("stall", {
|
|
3007
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
3008
|
+
});
|
|
3009
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2353
3010
|
}
|
|
2354
3011
|
function getDecodedVideoFrameCount(video) {
|
|
2355
3012
|
try {
|
|
@@ -2411,11 +3068,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2411
3068
|
function handleVideoDecodeFailure() {
|
|
2412
3069
|
console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
|
|
2413
3070
|
clearStallWatchdog();
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
handleAdError();
|
|
3071
|
+
logFunnel("decode_failure", {
|
|
3072
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
3073
|
+
});
|
|
3074
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2419
3075
|
}
|
|
2420
3076
|
function startStallWatchdog() {
|
|
2421
3077
|
clearStallWatchdog();
|
|
@@ -2539,6 +3195,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2539
3195
|
Promise.reject(new Error("Ad already playing"))
|
|
2540
3196
|
];
|
|
2541
3197
|
}
|
|
3198
|
+
if (destroyed) {
|
|
3199
|
+
return [
|
|
3200
|
+
2,
|
|
3201
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
3202
|
+
];
|
|
3203
|
+
}
|
|
3204
|
+
currentVastTagUrl = vastTagUrl;
|
|
3205
|
+
pendingRequestAbortReason = void 0;
|
|
3206
|
+
logFunnel("request_sent");
|
|
2542
3207
|
_state.label = 1;
|
|
2543
3208
|
case 1:
|
|
2544
3209
|
_state.trys.push([
|
|
@@ -2573,8 +3238,29 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2573
3238
|
ads = _state.sent();
|
|
2574
3239
|
_state.label = 4;
|
|
2575
3240
|
case 4:
|
|
3241
|
+
if (destroyed) {
|
|
3242
|
+
return [
|
|
3243
|
+
2,
|
|
3244
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
3245
|
+
];
|
|
3246
|
+
}
|
|
3247
|
+
if (!ads.length && pendingRequestAbortReason) {
|
|
3248
|
+
throw new Error(pendingRequestAbortReason);
|
|
3249
|
+
}
|
|
3250
|
+
if (!ads.length && lastPodAdElementCount > 0) {
|
|
3251
|
+
console.warn("[HlsAdPlayer] VAST response had ads but none were playable");
|
|
3252
|
+
logFunnel("vast_fill_rejected", {
|
|
3253
|
+
adElementCount: lastPodAdElementCount
|
|
3254
|
+
});
|
|
3255
|
+
emit("ad_error");
|
|
3256
|
+
return [
|
|
3257
|
+
2,
|
|
3258
|
+
Promise.reject(new Error("VAST fill rejected: no playable ad in response"))
|
|
3259
|
+
];
|
|
3260
|
+
}
|
|
2576
3261
|
if (!ads.length) {
|
|
2577
3262
|
console.warn("[HlsAdPlayer] No ads available from VAST response");
|
|
3263
|
+
logFunnel("no_fill");
|
|
2578
3264
|
emit("ad_error");
|
|
2579
3265
|
return [
|
|
2580
3266
|
2,
|
|
@@ -2585,6 +3271,23 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2585
3271
|
podIndex = 0;
|
|
2586
3272
|
currentAd = ads[0];
|
|
2587
3273
|
currentAdMediaFile = void 0;
|
|
3274
|
+
logFunnel("vast_received", {
|
|
3275
|
+
adCount: ads.length,
|
|
3276
|
+
durations: ads.map(function(ad) {
|
|
3277
|
+
return ad.duration;
|
|
3278
|
+
}),
|
|
3279
|
+
impressionUrls: ads.map(function(ad) {
|
|
3280
|
+
return ad.trackingUrls.impression.length;
|
|
3281
|
+
})
|
|
3282
|
+
});
|
|
3283
|
+
ads.forEach(function(ad, index) {
|
|
3284
|
+
if (ad.trackingUrls.impression.length === 0) {
|
|
3285
|
+
logFunnel("vast_missing_impression", {
|
|
3286
|
+
adIndex: index,
|
|
3287
|
+
missingAdId: ad.id
|
|
3288
|
+
});
|
|
3289
|
+
}
|
|
3290
|
+
});
|
|
2588
3291
|
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"));
|
|
2589
3292
|
return [
|
|
2590
3293
|
2,
|
|
@@ -2593,6 +3296,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2593
3296
|
case 5:
|
|
2594
3297
|
error = _state.sent();
|
|
2595
3298
|
console.error("[HlsAdPlayer] Error requesting ads:", error);
|
|
3299
|
+
logFunnel("request_failed", {
|
|
3300
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3301
|
+
});
|
|
2596
3302
|
emit("ad_error");
|
|
2597
3303
|
return [
|
|
2598
3304
|
2,
|
|
@@ -2648,13 +3354,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2648
3354
|
adContainerEl.style.pointerEvents = "auto";
|
|
2649
3355
|
}
|
|
2650
3356
|
emit("content_pause");
|
|
2651
|
-
|
|
3357
|
+
try {
|
|
3358
|
+
loadCurrentAdMedia();
|
|
3359
|
+
} catch (loadError) {
|
|
3360
|
+
if (!(podIndex < podAds.length - 1 && advanceToNextPodAd())) {
|
|
3361
|
+
throw loadError;
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
2652
3364
|
return [
|
|
2653
3365
|
2,
|
|
2654
3366
|
Promise.resolve()
|
|
2655
3367
|
];
|
|
2656
3368
|
} catch (error) {
|
|
2657
3369
|
console.error("[HlsAdPlayer] Error playing ad:", error);
|
|
3370
|
+
logFunnel("play_failed", {
|
|
3371
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3372
|
+
});
|
|
2658
3373
|
handleAdError();
|
|
2659
3374
|
return [
|
|
2660
3375
|
2,
|
|
@@ -2696,6 +3411,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2696
3411
|
var previousMutedState;
|
|
2697
3412
|
return _ts_generator(this, function(_state) {
|
|
2698
3413
|
console.log("[HlsAdPlayer] Stopping ad");
|
|
3414
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3415
|
+
logFunnel("stopped_before_start");
|
|
3416
|
+
}
|
|
2699
3417
|
settleViewability();
|
|
2700
3418
|
fireNotUsedForUnplayedAds();
|
|
2701
3419
|
clearStallWatchdog();
|
|
@@ -2728,15 +3446,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2728
3446
|
},
|
|
2729
3447
|
destroy: function destroy() {
|
|
2730
3448
|
console.log("[HlsAdPlayer] Destroying");
|
|
3449
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3450
|
+
logFunnel("stopped_before_start");
|
|
3451
|
+
}
|
|
2731
3452
|
settleViewability();
|
|
2732
3453
|
fireNotUsedForUnplayedAds();
|
|
2733
3454
|
destroyed = true;
|
|
2734
|
-
|
|
3455
|
+
pendingRequestAbortReason = "Ad player destroyed";
|
|
2735
3456
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2736
3457
|
try {
|
|
2737
|
-
for(var _iterator =
|
|
2738
|
-
var
|
|
2739
|
-
|
|
3458
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3459
|
+
var controller = _step.value;
|
|
3460
|
+
controller.abort();
|
|
2740
3461
|
}
|
|
2741
3462
|
} catch (err) {
|
|
2742
3463
|
_didIteratorError = true;
|
|
@@ -2752,6 +3473,28 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2752
3473
|
}
|
|
2753
3474
|
}
|
|
2754
3475
|
}
|
|
3476
|
+
pendingVastRequests.clear();
|
|
3477
|
+
clearStallWatchdog();
|
|
3478
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3479
|
+
try {
|
|
3480
|
+
for(var _iterator1 = pendingTimeouts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3481
|
+
var timeoutId = _step1.value;
|
|
3482
|
+
clearTimeout(timeoutId);
|
|
3483
|
+
}
|
|
3484
|
+
} catch (err) {
|
|
3485
|
+
_didIteratorError1 = true;
|
|
3486
|
+
_iteratorError1 = err;
|
|
3487
|
+
} finally{
|
|
3488
|
+
try {
|
|
3489
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
3490
|
+
_iterator1.return();
|
|
3491
|
+
}
|
|
3492
|
+
} finally{
|
|
3493
|
+
if (_didIteratorError1) {
|
|
3494
|
+
throw _iteratorError1;
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
2755
3498
|
pendingTimeouts = [];
|
|
2756
3499
|
adPlaying = false;
|
|
2757
3500
|
setAdPlayingFlag(false);
|
|
@@ -2771,6 +3514,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2771
3514
|
isAdPlaying: function isAdPlaying() {
|
|
2772
3515
|
return adPlaying;
|
|
2773
3516
|
},
|
|
3517
|
+
setFunnelContext: function setFunnelContext(context) {
|
|
3518
|
+
funnelContext = _object_spread({}, context);
|
|
3519
|
+
},
|
|
3520
|
+
abortPendingRequest: function abortPendingRequest() {
|
|
3521
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "VAST request aborted (timeout)";
|
|
3522
|
+
if (pendingVastRequests.size === 0) return;
|
|
3523
|
+
pendingRequestAbortReason = reason;
|
|
3524
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3525
|
+
try {
|
|
3526
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3527
|
+
var controller = _step.value;
|
|
3528
|
+
controller.abort();
|
|
3529
|
+
}
|
|
3530
|
+
} catch (err) {
|
|
3531
|
+
_didIteratorError = true;
|
|
3532
|
+
_iteratorError = err;
|
|
3533
|
+
} finally{
|
|
3534
|
+
try {
|
|
3535
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3536
|
+
_iterator.return();
|
|
3537
|
+
}
|
|
3538
|
+
} finally{
|
|
3539
|
+
if (_didIteratorError) {
|
|
3540
|
+
throw _iteratorError;
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
pendingVastRequests.clear();
|
|
3545
|
+
},
|
|
2774
3546
|
resize: function resize(width, height) {
|
|
2775
3547
|
console.log("[HlsAdPlayer] Resizing to ".concat(width, "x").concat(height));
|
|
2776
3548
|
if (adContainerEl) {
|
|
@@ -2806,6 +3578,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2806
3578
|
if (adVideoElement && adPlaying) {
|
|
2807
3579
|
var clamped = Math.max(0, Math.min(1, volume));
|
|
2808
3580
|
adVideoElement.volume = clamped;
|
|
3581
|
+
var userActivation = navigator.userActivation;
|
|
3582
|
+
if (clamped > 0 && forcedMuteByAutoplay && userActivation && !userActivation.isActive) {
|
|
3583
|
+
logFunnel("unmute_blocked_without_gesture", {
|
|
3584
|
+
requestedVolume: clamped
|
|
3585
|
+
});
|
|
3586
|
+
return;
|
|
3587
|
+
}
|
|
2809
3588
|
adVideoElement.muted = clamped === 0;
|
|
2810
3589
|
}
|
|
2811
3590
|
},
|
|
@@ -4912,6 +5691,21 @@ function normalizeVastTagUrl(raw) {
|
|
|
4912
5691
|
return raw;
|
|
4913
5692
|
}
|
|
4914
5693
|
}
|
|
5694
|
+
var GAM_AD_HOSTS = /* @__PURE__ */ new Set([
|
|
5695
|
+
"pubads.g.doubleclick.net",
|
|
5696
|
+
"securepubads.g.doubleclick.net"
|
|
5697
|
+
]);
|
|
5698
|
+
function ensureVideoAdType(rawUrl) {
|
|
5699
|
+
try {
|
|
5700
|
+
var url = new URL(rawUrl);
|
|
5701
|
+
if (!GAM_AD_HOSTS.has(url.hostname)) return rawUrl;
|
|
5702
|
+
if (url.searchParams.has("ad_type")) return rawUrl;
|
|
5703
|
+
url.searchParams.set("ad_type", "video");
|
|
5704
|
+
return url.toString();
|
|
5705
|
+
} catch (unused) {
|
|
5706
|
+
return rawUrl;
|
|
5707
|
+
}
|
|
5708
|
+
}
|
|
4915
5709
|
function applyVastMacros(baseUrl, ctx) {
|
|
4916
5710
|
var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
|
|
4917
5711
|
var url;
|
|
@@ -6622,7 +7416,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
6622
7416
|
} : {}), {
|
|
6623
7417
|
consent: this.consentSignals
|
|
6624
7418
|
}));
|
|
6625
|
-
var finalUrl = palNonce.injectNonce(urlWithMacros);
|
|
7419
|
+
var finalUrl = palNonce.injectNonce(ensureVideoAdType(urlWithMacros));
|
|
6626
7420
|
console.log("[StormcloudVideoPlayer] Resolved optimized-pod request URL (pod=".concat(this.podCounter, ", pmad=").concat(podParams.maxAds, ", pmnd=").concat(podParams.minDurationMs, ", pmxd=").concat((_podParams_maxDurationMs = podParams.maxDurationMs) !== null && _podParams_maxDurationMs !== void 0 ? _podParams_maxDurationMs : "?", "):"), finalUrl);
|
|
6627
7421
|
return finalUrl;
|
|
6628
7422
|
}
|
|
@@ -6869,7 +7663,7 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6869
7663
|
{
|
|
6870
7664
|
key: "adFitsRemainingBudget",
|
|
6871
7665
|
value: function adFitsRemainingBudget(durationMs) {
|
|
6872
|
-
if (durationMs <= 0) {
|
|
7666
|
+
if (durationMs <= 0 || this.expectedAdBreakDurationMs == null) {
|
|
6873
7667
|
return true;
|
|
6874
7668
|
}
|
|
6875
7669
|
return durationMs <= this.getDurationBudgetRemainingMs();
|
|
@@ -6928,6 +7722,11 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6928
7722
|
value: function markAdStarted() {
|
|
6929
7723
|
this.currentAdIndex++;
|
|
6930
7724
|
this.totalAdsInBreak = this.currentAdIndex;
|
|
7725
|
+
}
|
|
7726
|
+
},
|
|
7727
|
+
{
|
|
7728
|
+
key: "noteAdRequestSent",
|
|
7729
|
+
value: function noteAdRequestSent() {
|
|
6931
7730
|
this.totalAdRequestsInBreak++;
|
|
6932
7731
|
this.lastAdRequestTime = Date.now();
|
|
6933
7732
|
}
|
|
@@ -6979,6 +7778,9 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6979
7778
|
if (message.includes("timeout")) {
|
|
6980
7779
|
return true;
|
|
6981
7780
|
}
|
|
7781
|
+
if (message.includes("ad player destroyed") || message.includes("aborted")) {
|
|
7782
|
+
return true;
|
|
7783
|
+
}
|
|
6982
7784
|
if (message.includes("rate limit") || message.includes("too many requests")) {
|
|
6983
7785
|
return true;
|
|
6984
7786
|
}
|
|
@@ -8103,6 +8905,18 @@ function resizePlayer(video, adPlayer, debug) {
|
|
|
8103
8905
|
}
|
|
8104
8906
|
}
|
|
8105
8907
|
// src/player/AdBreakOrchestrator.ts
|
|
8908
|
+
var REQUEST_FAILURE_STAGES = /* @__PURE__ */ new Set([
|
|
8909
|
+
"no_fill",
|
|
8910
|
+
"vast_fill_rejected",
|
|
8911
|
+
"request_failed",
|
|
8912
|
+
"media_unsupported",
|
|
8913
|
+
"play_failed",
|
|
8914
|
+
"play_resolved_but_never_started",
|
|
8915
|
+
"hls_fatal",
|
|
8916
|
+
"media_error",
|
|
8917
|
+
"stall",
|
|
8918
|
+
"decode_failure"
|
|
8919
|
+
]);
|
|
8106
8920
|
var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
8107
8921
|
function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
|
|
8108
8922
|
_class_call_check(this, AdBreakOrchestrator);
|
|
@@ -8110,11 +8924,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8110
8924
|
this.showAds = false;
|
|
8111
8925
|
this.isShowingPlaceholder = false;
|
|
8112
8926
|
this.adDetectSentForCurrentBreak = false;
|
|
8113
|
-
this.
|
|
8114
|
-
this.
|
|
8115
|
-
this.
|
|
8927
|
+
this.slotState = "IDLE";
|
|
8928
|
+
this.unusableResponsesInBreak = 0;
|
|
8929
|
+
this.controllerGeneration = 0;
|
|
8930
|
+
this.requestDiagnostics = /* @__PURE__ */ new Map();
|
|
8931
|
+
this.breakFunnel = {};
|
|
8932
|
+
this.controllerCallInFlight = false;
|
|
8933
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8934
|
+
this.opportunityEpoch = -1;
|
|
8116
8935
|
this.adPodQueue = [];
|
|
8117
|
-
this.
|
|
8936
|
+
this.defaultMinRemainingMsToRequestAd = 1e4;
|
|
8937
|
+
this.defaultMaxNoFillsPerBreak = 2;
|
|
8118
8938
|
this.pendingAdBreak = null;
|
|
8119
8939
|
this.host = host;
|
|
8120
8940
|
this.timing = timing;
|
|
@@ -8150,7 +8970,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8150
8970
|
key: "attachImaEventListeners",
|
|
8151
8971
|
value: function attachImaEventListeners() {
|
|
8152
8972
|
var _this = this;
|
|
8153
|
-
var
|
|
8973
|
+
var controller = this.host.getAdPlayer();
|
|
8974
|
+
var generation = this.controllerGeneration;
|
|
8975
|
+
var adPlayer = {
|
|
8976
|
+
on: function on(event, handler) {
|
|
8977
|
+
controller.on(event, function(payload) {
|
|
8978
|
+
if (generation !== _this.controllerGeneration) {
|
|
8979
|
+
_this.logOrchestratorFunnel("stale_callback_ignored", {
|
|
8980
|
+
event: event,
|
|
8981
|
+
staleControllerId: generation,
|
|
8982
|
+
currentControllerId: _this.controllerGeneration
|
|
8983
|
+
});
|
|
8984
|
+
return;
|
|
8985
|
+
}
|
|
8986
|
+
handler(payload);
|
|
8987
|
+
});
|
|
8988
|
+
}
|
|
8989
|
+
};
|
|
8154
8990
|
adPlayer.on("pod_ad_started", function(payload) {
|
|
8155
8991
|
_this.timing.notePodAdStarted();
|
|
8156
8992
|
if (_this.debug) {
|
|
@@ -8164,7 +9000,35 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8164
9000
|
adPlayer.on("ad_interaction", function(event) {
|
|
8165
9001
|
if (event) _this.host.onAdInteraction(event);
|
|
8166
9002
|
});
|
|
9003
|
+
adPlayer.on("ad_funnel", function(payload) {
|
|
9004
|
+
if (!(payload === null || payload === void 0 ? void 0 : payload.stage)) return;
|
|
9005
|
+
var stage = payload.stage;
|
|
9006
|
+
_this.countFunnelStage(stage);
|
|
9007
|
+
if (payload.reason) {
|
|
9008
|
+
_this.countFunnelStage("".concat(stage, ":").concat(payload.reason));
|
|
9009
|
+
}
|
|
9010
|
+
if (stage === "impression_fired" && payload.pixelCount != null) {
|
|
9011
|
+
_this.countFunnelStage("impression_urls", payload.pixelCount);
|
|
9012
|
+
}
|
|
9013
|
+
if (payload.visibilityState === "hidden") {
|
|
9014
|
+
_this.countFunnelStage("while_hidden");
|
|
9015
|
+
}
|
|
9016
|
+
if (stage === "gam_http_request_sent") {
|
|
9017
|
+
if (payload.attempt === 1) {
|
|
9018
|
+
_this.timing.noteAdRequestSent();
|
|
9019
|
+
} else {
|
|
9020
|
+
_this.countFunnelStage("gam_http_request_retry");
|
|
9021
|
+
}
|
|
9022
|
+
}
|
|
9023
|
+
_this.recordRequestDiagnostic(payload);
|
|
9024
|
+
});
|
|
8167
9025
|
adPlayer.on("ad_impression", function() {
|
|
9026
|
+
_this.timing.consecutiveFailures = 0;
|
|
9027
|
+
_this.setSlotState("PLAYING", "impression");
|
|
9028
|
+
if (!_this.playbackStartedForCurrentRequest) {
|
|
9029
|
+
_this.playbackStartedForCurrentRequest = true;
|
|
9030
|
+
_this.timing.markAdStarted();
|
|
9031
|
+
}
|
|
8168
9032
|
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
8169
9033
|
source: "hls",
|
|
8170
9034
|
adIndex: _this.timing.currentAdIndex
|
|
@@ -8179,16 +9043,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8179
9043
|
var remaining = _this.timing.getRemainingAdMs();
|
|
8180
9044
|
_this.timing.consecutiveFailures = 0;
|
|
8181
9045
|
if (_this.debug) {
|
|
8182
|
-
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms
|
|
8183
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
8184
|
-
} : {});
|
|
9046
|
+
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms"));
|
|
8185
9047
|
}
|
|
8186
9048
|
if (_this.inAdBreak) {
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
} else {
|
|
8190
|
-
_this.handleAdPodComplete();
|
|
8191
|
-
}
|
|
9049
|
+
_this.setSlotState("NEEDS_NEXT_AD", "all_ads_completed");
|
|
9050
|
+
_this.requestNextAd("all_ads_completed");
|
|
8192
9051
|
}
|
|
8193
9052
|
});
|
|
8194
9053
|
adPlayer.on("ad_error", function(errorPayload) {
|
|
@@ -8208,7 +9067,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8208
9067
|
}
|
|
8209
9068
|
}
|
|
8210
9069
|
console.error("[AD-ERROR]", errorMessage, errorPayload || "");
|
|
8211
|
-
_this.
|
|
9070
|
+
if (_this.controllerCallInFlight) {
|
|
9071
|
+
return;
|
|
9072
|
+
}
|
|
9073
|
+
_this.handleAdFailure("ad_error");
|
|
8212
9074
|
});
|
|
8213
9075
|
adPlayer.on("content_pause", function() {
|
|
8214
9076
|
_this.timing.clearAdFailsafeTimer();
|
|
@@ -8247,26 +9109,32 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8247
9109
|
}
|
|
8248
9110
|
_this.timing.consecutiveFailures = 0;
|
|
8249
9111
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
8250
|
-
var remaining = _this.timing.getRemainingAdMs();
|
|
8251
9112
|
if (_this.debug) {
|
|
8252
|
-
console.log("[
|
|
8253
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
8254
|
-
} : {});
|
|
8255
|
-
}
|
|
8256
|
-
if (_this.timing.hasTimeToStartAnotherAd()) {
|
|
8257
|
-
_this.tryNextAvailableAdWithRateLimit();
|
|
8258
|
-
} else {
|
|
8259
|
-
_this.handleAdPodComplete();
|
|
9113
|
+
console.log("[AdBreak] content_resume: remaining=".concat(_this.timing.getRemainingAdMs(), "ms"));
|
|
8260
9114
|
}
|
|
9115
|
+
_this.setSlotState("NEEDS_NEXT_AD", "ad_complete");
|
|
9116
|
+
_this.requestNextAd("ad_complete");
|
|
8261
9117
|
});
|
|
8262
9118
|
}
|
|
8263
9119
|
},
|
|
8264
9120
|
{
|
|
8265
9121
|
key: "recreateAdController",
|
|
8266
|
-
value: function recreateAdController() {
|
|
8267
|
-
if (this.
|
|
8268
|
-
console.
|
|
9122
|
+
value: function recreateAdController(reason) {
|
|
9123
|
+
if (reason === "new_request" && (this.slotState === "REQUESTING" || this.slotState === "READY")) {
|
|
9124
|
+
console.warn("[AD-CONTROLLER] destroy during active request", {
|
|
9125
|
+
controllerId: this.controllerGeneration,
|
|
9126
|
+
requestId: this.currentRequestId,
|
|
9127
|
+
state: this.slotState,
|
|
9128
|
+
reason: reason
|
|
9129
|
+
});
|
|
8269
9130
|
}
|
|
9131
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
9132
|
+
controllerId: this.controllerGeneration,
|
|
9133
|
+
requestId: this.currentRequestId,
|
|
9134
|
+
state: this.slotState,
|
|
9135
|
+
reason: reason
|
|
9136
|
+
});
|
|
9137
|
+
this.countFunnelStage("controller_destroy:".concat(reason));
|
|
8270
9138
|
var shouldShowPlaceholder = this.inAdBreak && this.showAds;
|
|
8271
9139
|
var adPlayer = this.host.getAdPlayer();
|
|
8272
9140
|
if (shouldShowPlaceholder && adPlayer) {
|
|
@@ -8279,6 +9147,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8279
9147
|
}
|
|
8280
9148
|
var preservedMutedState = adPlayer.getOriginalMutedState();
|
|
8281
9149
|
var preservedVolumeState = adPlayer.getOriginalVolume();
|
|
9150
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8282
9151
|
if (adPlayer) {
|
|
8283
9152
|
try {
|
|
8284
9153
|
adPlayer.destroy();
|
|
@@ -8292,9 +9161,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8292
9161
|
var continueLiveStreamDuringAds = this.host.shouldContinueLiveStreamDuringAds();
|
|
8293
9162
|
var newAdPlayer = this.host.createAdPlayer(continueLiveStreamDuringAds);
|
|
8294
9163
|
this.host.setAdPlayer(newAdPlayer);
|
|
9164
|
+
this.controllerGeneration++;
|
|
8295
9165
|
newAdPlayer.initialize();
|
|
8296
9166
|
newAdPlayer.updateOriginalMutedState(preservedMutedState, preservedVolumeState);
|
|
8297
9167
|
this.attachImaEventListeners();
|
|
9168
|
+
if (this.debug) {
|
|
9169
|
+
console.log("[AD-CONTROLLER] create", {
|
|
9170
|
+
controllerId: this.controllerGeneration,
|
|
9171
|
+
reason: reason
|
|
9172
|
+
});
|
|
9173
|
+
}
|
|
8298
9174
|
if (shouldShowPlaceholder) {
|
|
8299
9175
|
this.placeholder.show();
|
|
8300
9176
|
newAdPlayer.showPlaceholder();
|
|
@@ -8315,32 +9191,57 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8315
9191
|
}
|
|
8316
9192
|
},
|
|
8317
9193
|
{
|
|
8318
|
-
|
|
8319
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9194
|
+
// ───────────────────────────────────────────────────────────────
|
|
8320
9195
|
// Ad break start
|
|
8321
9196
|
// ───────────────────────────────────────────────────────────────
|
|
8322
|
-
|
|
9197
|
+
key: "isBreakActive",
|
|
9198
|
+
value: function isBreakActive() {
|
|
9199
|
+
return this.slotState !== "IDLE";
|
|
9200
|
+
}
|
|
9201
|
+
},
|
|
9202
|
+
{
|
|
9203
|
+
key: "getSlotState",
|
|
9204
|
+
value: function getSlotState() {
|
|
9205
|
+
return this.slotState;
|
|
9206
|
+
}
|
|
9207
|
+
},
|
|
9208
|
+
{
|
|
9209
|
+
key: "beginVmapBreak",
|
|
9210
|
+
value: function beginVmapBreak(breakKey) {
|
|
9211
|
+
this.breakSource = "vmap";
|
|
9212
|
+
this.followUpBaseVastUrl = void 0;
|
|
9213
|
+
this.unusableResponsesInBreak = 0;
|
|
9214
|
+
this.timing.totalAdRequestsInBreak = 0;
|
|
9215
|
+
this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
|
|
9216
|
+
this.noteOpportunity("vmap", breakKey);
|
|
9217
|
+
}
|
|
9218
|
+
},
|
|
9219
|
+
{
|
|
9220
|
+
key: "handleAdStart",
|
|
9221
|
+
value: function handleAdStart(marker) {
|
|
8323
9222
|
return _async_to_generator(function() {
|
|
8324
|
-
var
|
|
9223
|
+
var baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, epoch, podPlayed;
|
|
8325
9224
|
return _ts_generator(this, function(_state) {
|
|
8326
9225
|
switch(_state.label){
|
|
8327
9226
|
case 0:
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
9227
|
+
if (this.slotState !== "IDLE") {
|
|
9228
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
9229
|
+
source: "scte35",
|
|
9230
|
+
state: this.slotState
|
|
9231
|
+
});
|
|
9232
|
+
return [
|
|
9233
|
+
2
|
|
9234
|
+
];
|
|
8331
9235
|
}
|
|
8332
|
-
|
|
8333
|
-
if (
|
|
8334
|
-
|
|
8335
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
8336
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
8337
|
-
} else {
|
|
9236
|
+
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
9237
|
+
if (!baseVastUrl) {
|
|
9238
|
+
console.warn("[AdBreak] SCTE-35 break started but no direct VAST tag is configured");
|
|
8338
9239
|
this.clearPendingAdBreak();
|
|
8339
9240
|
return [
|
|
8340
9241
|
2
|
|
8341
9242
|
];
|
|
8342
9243
|
}
|
|
8343
|
-
adBreakDurationMs =
|
|
9244
|
+
adBreakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : this.timing.expectedAdBreakDurationMs;
|
|
8344
9245
|
if (this.debug) {
|
|
8345
9246
|
mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
|
|
8346
9247
|
console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
@@ -8348,9 +9249,12 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8348
9249
|
this.timing.failedVastUrls.clear();
|
|
8349
9250
|
this.timing.temporaryFailureUrls.clear();
|
|
8350
9251
|
this.timing.consecutiveFailures = 0;
|
|
8351
|
-
this.continuousFetchingActive = true;
|
|
8352
9252
|
this.isShowingPlaceholder = false;
|
|
8353
9253
|
this.timing.totalAdRequestsInBreak = 0;
|
|
9254
|
+
this.breakSource = "scte35";
|
|
9255
|
+
this.followUpBaseVastUrl = baseVastUrl;
|
|
9256
|
+
this.unusableResponsesInBreak = 0;
|
|
9257
|
+
this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
|
|
8354
9258
|
if (this.adConfig.podAssignedByPrefetch) {
|
|
8355
9259
|
this.adConfig.podAssignedByPrefetch = false;
|
|
8356
9260
|
} else {
|
|
@@ -8368,29 +9272,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8368
9272
|
if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
8369
9273
|
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
8370
9274
|
}
|
|
9275
|
+
this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
|
|
9276
|
+
epoch = this.timing.adBreakEpoch;
|
|
8371
9277
|
return [
|
|
8372
9278
|
4,
|
|
8373
|
-
this.startOptimizedPod(baseVastUrl, adBreakDurationMs
|
|
9279
|
+
this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
|
|
8374
9280
|
];
|
|
8375
9281
|
case 1:
|
|
8376
9282
|
podPlayed = _state.sent();
|
|
8377
|
-
if (
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
];
|
|
8381
|
-
if (this.debug) {
|
|
8382
|
-
console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
|
|
9283
|
+
if (!podPlayed && this.inAdBreak && epoch === this.timing.adBreakEpoch) {
|
|
9284
|
+
this.setSlotState("NEEDS_NEXT_AD", "initial_request_failed");
|
|
9285
|
+
this.requestNextAd("initial_request_failed");
|
|
8383
9286
|
}
|
|
8384
|
-
this.continuousFetchingActive = true;
|
|
8385
|
-
this.startContinuousFetching(baseVastUrl);
|
|
8386
|
-
return [
|
|
8387
|
-
4,
|
|
8388
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
8389
|
-
];
|
|
8390
|
-
case 2:
|
|
8391
|
-
_state.sent();
|
|
8392
|
-
_state.label = 3;
|
|
8393
|
-
case 3:
|
|
8394
9287
|
return [
|
|
8395
9288
|
2
|
|
8396
9289
|
];
|
|
@@ -8404,12 +9297,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8404
9297
|
value: // ───────────────────────────────────────────────────────────────
|
|
8405
9298
|
// Optimized pod (single multi-ad request)
|
|
8406
9299
|
// ───────────────────────────────────────────────────────────────
|
|
8407
|
-
function startOptimizedPod(baseVastUrl, breakDurationMs
|
|
9300
|
+
function startOptimizedPod(baseVastUrl, breakDurationMs) {
|
|
8408
9301
|
return _async_to_generator(function() {
|
|
8409
|
-
var podUrl, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
9302
|
+
var podUrl, prefetched, epoch, generation, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
8410
9303
|
return _ts_generator(this, function(_state) {
|
|
8411
9304
|
switch(_state.label){
|
|
8412
9305
|
case 0:
|
|
9306
|
+
prefetched = !!(this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0);
|
|
8413
9307
|
if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
|
|
8414
9308
|
podUrl = this.pendingAdBreak.vastUrls[0];
|
|
8415
9309
|
this.clearPendingAdBreak();
|
|
@@ -8422,12 +9316,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8422
9316
|
false
|
|
8423
9317
|
];
|
|
8424
9318
|
}
|
|
8425
|
-
this.
|
|
8426
|
-
this.
|
|
9319
|
+
this.noteVastUrlGenerated(podUrl, prefetched ? "prefetch" : "break_start");
|
|
9320
|
+
epoch = this.timing.adBreakEpoch;
|
|
9321
|
+
this.recreateAdController("new_request");
|
|
9322
|
+
generation = this.controllerGeneration;
|
|
8427
9323
|
adPlayer = this.host.getAdPlayer();
|
|
8428
9324
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8429
9325
|
this.timing.activeAdRequestToken = requestToken;
|
|
8430
9326
|
this.currentVastUrl = podUrl;
|
|
9327
|
+
this.setSlotState("REQUESTING", "initial_pod");
|
|
9328
|
+
this.beginFunnelRequest(adPlayer, requestToken, "initial_pod");
|
|
8431
9329
|
_state.label = 1;
|
|
8432
9330
|
case 1:
|
|
8433
9331
|
_state.trys.push([
|
|
@@ -8442,16 +9340,24 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8442
9340
|
];
|
|
8443
9341
|
case 2:
|
|
8444
9342
|
_state.sent();
|
|
9343
|
+
if (this.isStale(epoch, generation)) return [
|
|
9344
|
+
2,
|
|
9345
|
+
true
|
|
9346
|
+
];
|
|
8445
9347
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
8446
|
-
this.timing.lastAdRequestTime = Date.now();
|
|
8447
9348
|
return [
|
|
8448
9349
|
4,
|
|
8449
|
-
|
|
9350
|
+
this.callController(function() {
|
|
9351
|
+
return adPlayer.requestAds(podUrl);
|
|
9352
|
+
})
|
|
8450
9353
|
];
|
|
8451
9354
|
case 3:
|
|
8452
9355
|
_state.sent();
|
|
8453
9356
|
this.timing.clearAdRequestWatchdog();
|
|
8454
|
-
if (this.
|
|
9357
|
+
if (this.isStale(epoch, generation)) {
|
|
9358
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9359
|
+
requestId: requestToken
|
|
9360
|
+
});
|
|
8455
9361
|
return [
|
|
8456
9362
|
2,
|
|
8457
9363
|
true
|
|
@@ -8459,11 +9365,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8459
9365
|
}
|
|
8460
9366
|
podCount = (_ref = (_adPlayer_getPodAdCount = adPlayer.getPodAdCount) === null || _adPlayer_getPodAdCount === void 0 ? void 0 : _adPlayer_getPodAdCount.call(adPlayer)) !== null && _ref !== void 0 ? _ref : 1;
|
|
8461
9367
|
if (podCount < 1) {
|
|
9368
|
+
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9369
|
+
this.timing.activeAdRequestToken = null;
|
|
9370
|
+
}
|
|
9371
|
+
this.recordRequestFailure(new Error("No ads available"), podUrl);
|
|
8462
9372
|
return [
|
|
8463
9373
|
2,
|
|
8464
9374
|
false
|
|
8465
9375
|
];
|
|
8466
9376
|
}
|
|
9377
|
+
this.setSlotState("READY", "vast_ready");
|
|
8467
9378
|
if (this.debug) {
|
|
8468
9379
|
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"));
|
|
8469
9380
|
}
|
|
@@ -8475,18 +9386,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8475
9386
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
8476
9387
|
return [
|
|
8477
9388
|
4,
|
|
8478
|
-
|
|
9389
|
+
this.callController(function() {
|
|
9390
|
+
return adPlayer.play();
|
|
9391
|
+
})
|
|
8479
9392
|
];
|
|
8480
9393
|
case 4:
|
|
8481
9394
|
_state.sent();
|
|
8482
|
-
this.
|
|
9395
|
+
if (this.isStale(epoch, generation)) return [
|
|
9396
|
+
2,
|
|
9397
|
+
true
|
|
9398
|
+
];
|
|
8483
9399
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
8484
9400
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
8485
9401
|
}
|
|
8486
|
-
adPlayer.setAdVolume(
|
|
8487
|
-
this.timing.consecutiveFailures = 0;
|
|
8488
|
-
this.continuousFetchingActive = true;
|
|
8489
|
-
this.startContinuousFetching(baseVastUrl);
|
|
9402
|
+
adPlayer.setAdVolume(getAdAudioVolume(adPlayer));
|
|
8490
9403
|
return [
|
|
8491
9404
|
2,
|
|
8492
9405
|
true
|
|
@@ -8498,14 +9411,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8498
9411
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
8499
9412
|
this.timing.activeAdRequestToken = null;
|
|
8500
9413
|
}
|
|
9414
|
+
if (this.isStale(epoch, generation)) {
|
|
9415
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9416
|
+
requestId: requestToken,
|
|
9417
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
9418
|
+
});
|
|
9419
|
+
return [
|
|
9420
|
+
2,
|
|
9421
|
+
true
|
|
9422
|
+
];
|
|
9423
|
+
}
|
|
8501
9424
|
if (this.debug) {
|
|
8502
9425
|
console.warn("[POD] Optimized pod request/play failed:", error);
|
|
8503
9426
|
}
|
|
8504
|
-
|
|
8505
|
-
this.timing.temporaryFailureUrls.set(podUrl, Date.now());
|
|
8506
|
-
}
|
|
8507
|
-
this.continuousFetchingActive = true;
|
|
8508
|
-
this.recreateAdController();
|
|
9427
|
+
this.recordRequestFailure(error, podUrl);
|
|
8509
9428
|
return [
|
|
8510
9429
|
2,
|
|
8511
9430
|
false
|
|
@@ -8521,168 +9440,204 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8521
9440
|
},
|
|
8522
9441
|
{
|
|
8523
9442
|
// ───────────────────────────────────────────────────────────────
|
|
8524
|
-
//
|
|
9443
|
+
// Next-ad scheduling (single flight)
|
|
8525
9444
|
// ───────────────────────────────────────────────────────────────
|
|
8526
|
-
key: "
|
|
8527
|
-
value: function
|
|
8528
|
-
if (
|
|
9445
|
+
key: "setSlotState",
|
|
9446
|
+
value: function setSlotState(next, reason) {
|
|
9447
|
+
if (this.slotState === next) return;
|
|
9448
|
+
var previous = this.slotState;
|
|
9449
|
+
this.slotState = next;
|
|
9450
|
+
if (this.debug) {
|
|
9451
|
+
console.log("[AdBreak][STATE] ".concat(previous, " -> ").concat(next), {
|
|
9452
|
+
reason: reason,
|
|
9453
|
+
breakId: this.timing.adBreakEpoch,
|
|
9454
|
+
requestId: this.currentRequestId,
|
|
9455
|
+
controllerId: this.controllerGeneration
|
|
9456
|
+
});
|
|
9457
|
+
}
|
|
9458
|
+
}
|
|
9459
|
+
},
|
|
9460
|
+
{
|
|
9461
|
+
key: "isStale",
|
|
9462
|
+
value: function isStale(epoch, generation) {
|
|
9463
|
+
return !this.inAdBreak || epoch !== this.timing.adBreakEpoch || generation !== this.controllerGeneration;
|
|
9464
|
+
}
|
|
9465
|
+
},
|
|
9466
|
+
{
|
|
9467
|
+
key: "getMinRemainingMsToRequestAd",
|
|
9468
|
+
value: function getMinRemainingMsToRequestAd() {
|
|
9469
|
+
var configured = this.host.config.minRemainingMsToRequestAd;
|
|
9470
|
+
var floor = this.timing.getMinRemainingMsToStartAd();
|
|
9471
|
+
if (typeof configured === "number" && configured >= 0) {
|
|
9472
|
+
return Math.max(configured, floor);
|
|
9473
|
+
}
|
|
9474
|
+
return Math.max(this.defaultMinRemainingMsToRequestAd, floor);
|
|
9475
|
+
}
|
|
9476
|
+
},
|
|
9477
|
+
{
|
|
9478
|
+
key: "getMaxNoFillsPerBreak",
|
|
9479
|
+
value: function getMaxNoFillsPerBreak() {
|
|
9480
|
+
var configured = this.host.config.maxNoFillsPerBreak;
|
|
9481
|
+
return typeof configured === "number" && configured > 0 ? configured : this.defaultMaxNoFillsPerBreak;
|
|
9482
|
+
}
|
|
9483
|
+
},
|
|
9484
|
+
{
|
|
9485
|
+
key: "isBreakTimeBounded",
|
|
9486
|
+
value: function isBreakTimeBounded() {
|
|
9487
|
+
return this.breakSource === "scte35" || this.timing.expectedAdBreakDurationMs != null;
|
|
9488
|
+
}
|
|
9489
|
+
},
|
|
9490
|
+
{
|
|
9491
|
+
key: "getStopRequestingReason",
|
|
9492
|
+
value: function getStopRequestingReason(remainingMs) {
|
|
9493
|
+
if (this.breakSource === "vmap") {
|
|
9494
|
+
if (this.adPodQueue.length === 0) return "vmap_queue_empty";
|
|
9495
|
+
} else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl) {
|
|
9496
|
+
return "no_follow_up_source";
|
|
9497
|
+
}
|
|
9498
|
+
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9499
|
+
return "max_consecutive_failures";
|
|
9500
|
+
}
|
|
9501
|
+
if (this.unusableResponsesInBreak >= this.getMaxNoFillsPerBreak()) {
|
|
9502
|
+
return "unusable_response_limit";
|
|
9503
|
+
}
|
|
9504
|
+
if (this.timing.totalAdRequestsInBreak >= this.timing.maxTotalAdRequestsPerBreak) {
|
|
9505
|
+
return "request_cap";
|
|
9506
|
+
}
|
|
9507
|
+
if (this.timing.isGamInCooldown()) {
|
|
9508
|
+
return "gam_cooldown";
|
|
9509
|
+
}
|
|
9510
|
+
if (this.isBreakTimeBounded() && remainingMs < this.getMinRemainingMsToRequestAd()) {
|
|
9511
|
+
return "insufficient_break_time";
|
|
9512
|
+
}
|
|
9513
|
+
return void 0;
|
|
9514
|
+
}
|
|
9515
|
+
},
|
|
9516
|
+
{
|
|
9517
|
+
key: "getNextRequestDelayMs",
|
|
9518
|
+
value: function getNextRequestDelayMs() {
|
|
9519
|
+
var failures = this.timing.consecutiveFailures;
|
|
9520
|
+
var backoff = failures > 0 ? Math.min(this.timing.backoffBaseMs * Math.pow(2, failures), this.timing.maxBackoffMs) : 0;
|
|
9521
|
+
var minInterval = this.timing.minAdRequestIntervalMs + backoff;
|
|
9522
|
+
var sinceLast = Date.now() - this.timing.lastAdRequestTime;
|
|
9523
|
+
return Math.max(0, minInterval - sinceLast);
|
|
9524
|
+
}
|
|
9525
|
+
},
|
|
9526
|
+
{
|
|
9527
|
+
key: "requestNextAd",
|
|
9528
|
+
value: function requestNextAd(trigger) {
|
|
9529
|
+
var _this = this;
|
|
9530
|
+
if (!this.inAdBreak) return;
|
|
9531
|
+
if (this.slotState !== "NEEDS_NEXT_AD") {
|
|
9532
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9533
|
+
trigger: trigger,
|
|
9534
|
+
state: this.slotState,
|
|
9535
|
+
why: "slot_busy"
|
|
9536
|
+
});
|
|
8529
9537
|
return;
|
|
8530
9538
|
}
|
|
8531
|
-
if (this.
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
9539
|
+
if (this.nextAdTimerId != null) {
|
|
9540
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9541
|
+
trigger: trigger,
|
|
9542
|
+
state: this.slotState,
|
|
9543
|
+
why: "request_already_scheduled"
|
|
9544
|
+
});
|
|
8535
9545
|
return;
|
|
8536
9546
|
}
|
|
8537
|
-
|
|
8538
|
-
|
|
9547
|
+
var remainingMs = this.timing.getRemainingAdMs();
|
|
9548
|
+
var stopReason = this.getStopRequestingReason(remainingMs);
|
|
9549
|
+
if (stopReason) {
|
|
9550
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9551
|
+
trigger: trigger,
|
|
9552
|
+
decision: "end_break",
|
|
9553
|
+
reason: stopReason,
|
|
9554
|
+
remainingMs: remainingMs,
|
|
9555
|
+
requestsSent: this.timing.totalAdRequestsInBreak,
|
|
9556
|
+
unusableResponses: this.unusableResponsesInBreak,
|
|
9557
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
9558
|
+
});
|
|
9559
|
+
this.handleAdPodComplete(stopReason);
|
|
9560
|
+
return;
|
|
9561
|
+
}
|
|
9562
|
+
var waitMs = this.getNextRequestDelayMs();
|
|
9563
|
+
if (waitMs > 0 && this.isBreakTimeBounded() && remainingMs - waitMs < this.getMinRemainingMsToRequestAd()) {
|
|
9564
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9565
|
+
trigger: trigger,
|
|
9566
|
+
decision: "end_break",
|
|
9567
|
+
reason: "insufficient_break_time_after_backoff",
|
|
9568
|
+
remainingMs: remainingMs,
|
|
9569
|
+
waitMs: waitMs
|
|
9570
|
+
});
|
|
9571
|
+
this.handleAdPodComplete("insufficient_break_time_after_backoff");
|
|
9572
|
+
return;
|
|
9573
|
+
}
|
|
9574
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9575
|
+
trigger: trigger,
|
|
9576
|
+
decision: waitMs > 0 ? "request_after_delay" : "request_now",
|
|
9577
|
+
waitMs: waitMs,
|
|
9578
|
+
remainingMs: remainingMs,
|
|
9579
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
9580
|
+
});
|
|
9581
|
+
if (waitMs > 0) {
|
|
9582
|
+
if (!this.isShowingPlaceholder) {
|
|
9583
|
+
this.isShowingPlaceholder = true;
|
|
9584
|
+
this.host.getAdPlayer().showPlaceholder();
|
|
9585
|
+
}
|
|
9586
|
+
var epoch = this.timing.adBreakEpoch;
|
|
9587
|
+
this.nextAdTimerId = window.setTimeout(function() {
|
|
9588
|
+
_this.nextAdTimerId = void 0;
|
|
9589
|
+
if (!_this.inAdBreak || epoch !== _this.timing.adBreakEpoch) return;
|
|
9590
|
+
_this.requestNextAd("".concat(trigger, ":after_delay"));
|
|
9591
|
+
}, waitMs);
|
|
9592
|
+
return;
|
|
8539
9593
|
}
|
|
8540
|
-
this.
|
|
8541
|
-
this.continuousFetchLoop(baseVastUrl);
|
|
9594
|
+
void this.requestFollowUpAd(trigger);
|
|
8542
9595
|
}
|
|
8543
9596
|
},
|
|
8544
9597
|
{
|
|
8545
|
-
key: "
|
|
8546
|
-
value: function
|
|
9598
|
+
key: "requestFollowUpAd",
|
|
9599
|
+
value: function requestFollowUpAd(trigger) {
|
|
8547
9600
|
return _async_to_generator(function() {
|
|
8548
|
-
var
|
|
9601
|
+
var url, epoch, unused;
|
|
8549
9602
|
return _ts_generator(this, function(_state) {
|
|
8550
9603
|
switch(_state.label){
|
|
8551
9604
|
case 0:
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
}
|
|
8562
|
-
return [
|
|
8563
|
-
2,
|
|
8564
|
-
"break"
|
|
8565
|
-
];
|
|
8566
|
-
}
|
|
8567
|
-
if (_this.timing.isGamInCooldown()) {
|
|
8568
|
-
if (_this.debug) {
|
|
8569
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping URL generation");
|
|
8570
|
-
}
|
|
8571
|
-
return [
|
|
8572
|
-
2,
|
|
8573
|
-
"break"
|
|
8574
|
-
];
|
|
8575
|
-
}
|
|
8576
|
-
if (_this.timing.consecutiveFailures >= _this.timing.maxConsecutiveFailures) {
|
|
8577
|
-
if (_this.debug) {
|
|
8578
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(_this.timing.consecutiveFailures, "), stopping URL generation"));
|
|
8579
|
-
}
|
|
8580
|
-
return [
|
|
8581
|
-
2,
|
|
8582
|
-
"break"
|
|
8583
|
-
];
|
|
8584
|
-
}
|
|
8585
|
-
if (_this.timing.totalAdRequestsInBreak >= _this.timing.maxTotalAdRequestsPerBreak) {
|
|
8586
|
-
if (_this.debug) {
|
|
8587
|
-
console.log("[CONTINUOUS-FETCH] Maximum ad requests reached (".concat(_this.timing.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
8588
|
-
}
|
|
8589
|
-
return [
|
|
8590
|
-
2,
|
|
8591
|
-
"break"
|
|
8592
|
-
];
|
|
8593
|
-
}
|
|
8594
|
-
maxQueueSize = 5;
|
|
8595
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
8596
|
-
3,
|
|
8597
|
-
2
|
|
8598
|
-
];
|
|
8599
|
-
if (_this.debug) {
|
|
8600
|
-
console.log("[CONTINUOUS-FETCH] URL queue full (".concat(_this.adRequestQueue.length, "), waiting..."));
|
|
8601
|
-
}
|
|
8602
|
-
return [
|
|
8603
|
-
4,
|
|
8604
|
-
new Promise(function(resolve) {
|
|
8605
|
-
return setTimeout(resolve, 1e3);
|
|
8606
|
-
})
|
|
8607
|
-
];
|
|
8608
|
-
case 1:
|
|
8609
|
-
_state.sent();
|
|
8610
|
-
return [
|
|
8611
|
-
2,
|
|
8612
|
-
"continue"
|
|
8613
|
-
];
|
|
8614
|
-
case 2:
|
|
8615
|
-
newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
|
|
8616
|
-
if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
|
|
8617
|
-
3,
|
|
8618
|
-
4
|
|
8619
|
-
];
|
|
8620
|
-
return [
|
|
8621
|
-
4,
|
|
8622
|
-
new Promise(function(resolve) {
|
|
8623
|
-
return setTimeout(resolve, 500);
|
|
8624
|
-
})
|
|
8625
|
-
];
|
|
8626
|
-
case 3:
|
|
8627
|
-
_state.sent();
|
|
8628
|
-
return [
|
|
8629
|
-
2,
|
|
8630
|
-
"continue"
|
|
8631
|
-
];
|
|
8632
|
-
case 4:
|
|
8633
|
-
if (_this.debug) {
|
|
8634
|
-
queuedUrlsPreview = _to_consumable_array(_this.adRequestQueue).concat([
|
|
8635
|
-
newAdUrl
|
|
8636
|
-
]);
|
|
8637
|
-
console.log("[CONTINUOUS-FETCH] Queued VAST URL (queue size: ".concat(queuedUrlsPreview.length, ")"), {
|
|
8638
|
-
queuedUrls: queuedUrlsPreview
|
|
8639
|
-
});
|
|
8640
|
-
}
|
|
8641
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
8642
|
-
generationDelay = _this.timing.consecutiveFailures > 0 ? Math.min(1e3 * Math.pow(2, _this.timing.consecutiveFailures), 5e3) : 500;
|
|
8643
|
-
return [
|
|
8644
|
-
4,
|
|
8645
|
-
new Promise(function(resolve) {
|
|
8646
|
-
return setTimeout(resolve, generationDelay);
|
|
8647
|
-
})
|
|
8648
|
-
];
|
|
8649
|
-
case 5:
|
|
8650
|
-
_state.sent();
|
|
8651
|
-
return [
|
|
8652
|
-
2
|
|
8653
|
-
];
|
|
8654
|
-
}
|
|
8655
|
-
});
|
|
8656
|
-
};
|
|
9605
|
+
if (this.breakSource === "vmap") {
|
|
9606
|
+
url = this.adPodQueue.shift();
|
|
9607
|
+
} else if (this.followUpBaseVastUrl) {
|
|
9608
|
+
url = this.nextAdRequestUrl(this.followUpBaseVastUrl);
|
|
9609
|
+
}
|
|
9610
|
+
if (!url) return [
|
|
9611
|
+
2
|
|
9612
|
+
];
|
|
9613
|
+
this.noteVastUrlGenerated(ensureVideoAdType(url), trigger);
|
|
8657
9614
|
epoch = this.timing.adBreakEpoch;
|
|
8658
9615
|
_state.label = 1;
|
|
8659
9616
|
case 1:
|
|
8660
|
-
|
|
9617
|
+
_state.trys.push([
|
|
9618
|
+
1,
|
|
8661
9619
|
3,
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
return [
|
|
8666
|
-
|
|
8667
|
-
|
|
9620
|
+
,
|
|
9621
|
+
4
|
|
9622
|
+
]);
|
|
9623
|
+
return [
|
|
9624
|
+
4,
|
|
9625
|
+
this.playSingleAd(url, trigger)
|
|
8668
9626
|
];
|
|
8669
9627
|
case 2:
|
|
8670
|
-
|
|
8671
|
-
|
|
9628
|
+
_state.sent();
|
|
9629
|
+
return [
|
|
8672
9630
|
3,
|
|
8673
|
-
|
|
9631
|
+
4
|
|
8674
9632
|
];
|
|
9633
|
+
case 3:
|
|
9634
|
+
unused = _state.sent();
|
|
9635
|
+
this.continueAfterRequestFailure(epoch);
|
|
8675
9636
|
return [
|
|
8676
9637
|
3,
|
|
8677
|
-
|
|
9638
|
+
4
|
|
8678
9639
|
];
|
|
8679
|
-
case
|
|
8680
|
-
this.continuousFetchLoopRunning = false;
|
|
8681
|
-
if (this.debug) {
|
|
8682
|
-
console.log("[CONTINUOUS-FETCH] URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"), this.adRequestQueue.length > 0 ? {
|
|
8683
|
-
queuedUrls: _to_consumable_array(this.adRequestQueue)
|
|
8684
|
-
} : {});
|
|
8685
|
-
}
|
|
9640
|
+
case 4:
|
|
8686
9641
|
return [
|
|
8687
9642
|
2
|
|
8688
9643
|
];
|
|
@@ -8692,236 +9647,318 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8692
9647
|
}
|
|
8693
9648
|
},
|
|
8694
9649
|
{
|
|
8695
|
-
key: "
|
|
8696
|
-
value: function
|
|
8697
|
-
|
|
8698
|
-
this.
|
|
8699
|
-
this.
|
|
8700
|
-
|
|
8701
|
-
|
|
9650
|
+
key: "continueAfterRequestFailure",
|
|
9651
|
+
value: function continueAfterRequestFailure() {
|
|
9652
|
+
var epoch = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.timing.adBreakEpoch;
|
|
9653
|
+
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) return;
|
|
9654
|
+
this.setSlotState("NEEDS_NEXT_AD", "request_failed");
|
|
9655
|
+
this.requestNextAd("after_failure");
|
|
9656
|
+
}
|
|
9657
|
+
},
|
|
9658
|
+
{
|
|
9659
|
+
key: "cancelScheduledRequest",
|
|
9660
|
+
value: function cancelScheduledRequest() {
|
|
9661
|
+
if (this.nextAdTimerId != null) {
|
|
9662
|
+
clearTimeout(this.nextAdTimerId);
|
|
9663
|
+
this.nextAdTimerId = void 0;
|
|
8702
9664
|
}
|
|
8703
9665
|
}
|
|
8704
9666
|
},
|
|
8705
9667
|
{
|
|
8706
|
-
key: "
|
|
8707
|
-
value:
|
|
8708
|
-
|
|
9668
|
+
key: "noteVastUrlGenerated",
|
|
9669
|
+
value: function noteVastUrlGenerated(url, source) {
|
|
9670
|
+
var _ref, _ref1, _ref2, _ref3, _ref4;
|
|
9671
|
+
var params;
|
|
9672
|
+
try {
|
|
9673
|
+
params = new URL(url).searchParams;
|
|
9674
|
+
} catch (unused) {}
|
|
9675
|
+
var adType = (_ref = params === null || params === void 0 ? void 0 : params.get("ad_type")) !== null && _ref !== void 0 ? _ref : void 0;
|
|
9676
|
+
this.logOrchestratorFunnel("vast_url_generated", {
|
|
9677
|
+
source: source,
|
|
9678
|
+
pod: (_ref1 = params === null || params === void 0 ? void 0 : params.get("pod")) !== null && _ref1 !== void 0 ? _ref1 : void 0,
|
|
9679
|
+
pmad: (_ref2 = params === null || params === void 0 ? void 0 : params.get("pmad")) !== null && _ref2 !== void 0 ? _ref2 : void 0,
|
|
9680
|
+
pmnd: (_ref3 = params === null || params === void 0 ? void 0 : params.get("pmnd")) !== null && _ref3 !== void 0 ? _ref3 : void 0,
|
|
9681
|
+
pmxd: (_ref4 = params === null || params === void 0 ? void 0 : params.get("pmxd")) !== null && _ref4 !== void 0 ? _ref4 : void 0,
|
|
9682
|
+
adType: adType
|
|
9683
|
+
});
|
|
9684
|
+
if (adType === "audio" || adType === "audio_video") {
|
|
9685
|
+
console.warn("[AdBreak] VAST tag requests ad_type=".concat(adType, "; GAM may return audio-only creatives, which this video player rejects"));
|
|
9686
|
+
this.countFunnelStage("tag_allows_audio");
|
|
9687
|
+
}
|
|
9688
|
+
}
|
|
9689
|
+
},
|
|
9690
|
+
{
|
|
9691
|
+
key: "recordRequestFailure",
|
|
9692
|
+
value: function recordRequestFailure(error, vastTagUrl) {
|
|
9693
|
+
var _diag_vastAdCount;
|
|
9694
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
9695
|
+
var message = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
9696
|
+
var outcome;
|
|
9697
|
+
if (message.includes("ad_duration_exceeds_budget")) {
|
|
9698
|
+
outcome = "discarded_budget";
|
|
9699
|
+
} else if (message.includes("VAST fill rejected")) {
|
|
9700
|
+
outcome = "fill_rejected";
|
|
9701
|
+
} else if (/no ads available|no fill|nofill/i.test(message)) {
|
|
9702
|
+
outcome = "no_fill";
|
|
9703
|
+
} else if (/timeout/i.test(message)) {
|
|
9704
|
+
outcome = "request_timeout";
|
|
9705
|
+
} else if (/destroyed|aborted/i.test(message)) {
|
|
9706
|
+
outcome = "request_aborted";
|
|
9707
|
+
} else if (diag && ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired) {
|
|
9708
|
+
outcome = "playback_failed";
|
|
9709
|
+
} else {
|
|
9710
|
+
outcome = "request_failed";
|
|
9711
|
+
}
|
|
9712
|
+
this.timing.consecutiveFailures++;
|
|
9713
|
+
if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
|
|
9714
|
+
this.unusableResponsesInBreak++;
|
|
9715
|
+
}
|
|
9716
|
+
if (outcome === "no_fill") {
|
|
9717
|
+
this.timing.recordGamNoFill();
|
|
9718
|
+
}
|
|
9719
|
+
if (diag && !diag.failureReason) {
|
|
9720
|
+
diag.failureReason = "".concat(outcome, ": ").concat(message);
|
|
9721
|
+
}
|
|
9722
|
+
if (this.timing.isTemporaryAdError(error)) {
|
|
9723
|
+
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9724
|
+
} else if (outcome !== "discarded_budget") {
|
|
9725
|
+
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9726
|
+
}
|
|
9727
|
+
this.countFunnelStage("request_outcome:".concat(outcome));
|
|
9728
|
+
this.logOrchestratorFunnel("request_outcome", {
|
|
9729
|
+
outcome: outcome,
|
|
9730
|
+
errorMessage: message,
|
|
9731
|
+
consecutiveFailures: this.timing.consecutiveFailures,
|
|
9732
|
+
unusableResponsesInBreak: this.unusableResponsesInBreak
|
|
9733
|
+
});
|
|
9734
|
+
}
|
|
9735
|
+
},
|
|
9736
|
+
{
|
|
8709
9737
|
// ───────────────────────────────────────────────────────────────
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
backoffDelay = Math.min(this.timing.backoffBaseMs * backoffMultiplier, this.timing.maxBackoffMs);
|
|
8733
|
-
effectiveMinInterval = this.timing.minAdRequestIntervalMs + (this.timing.consecutiveFailures > 0 ? backoffDelay : 0);
|
|
8734
|
-
timeSinceLastRequest = Date.now() - this.timing.lastAdRequestTime;
|
|
8735
|
-
if (!(timeSinceLastRequest < effectiveMinInterval)) return [
|
|
8736
|
-
3,
|
|
8737
|
-
2
|
|
8738
|
-
];
|
|
8739
|
-
waitTime = effectiveMinInterval - timeSinceLastRequest;
|
|
8740
|
-
if (this.debug) {
|
|
8741
|
-
console.log("[CONTINUOUS-FETCH] Rate limiting: waiting ".concat(waitTime, "ms before next request (backoff: ").concat(this.timing.consecutiveFailures, " failures)"));
|
|
8742
|
-
}
|
|
8743
|
-
return [
|
|
8744
|
-
4,
|
|
8745
|
-
new Promise(function(resolve) {
|
|
8746
|
-
return setTimeout(resolve, waitTime);
|
|
8747
|
-
})
|
|
8748
|
-
];
|
|
8749
|
-
case 1:
|
|
8750
|
-
_state.sent();
|
|
8751
|
-
_state.label = 2;
|
|
8752
|
-
case 2:
|
|
8753
|
-
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) {
|
|
8754
|
-
return [
|
|
8755
|
-
2
|
|
8756
|
-
];
|
|
8757
|
-
}
|
|
8758
|
-
return [
|
|
8759
|
-
2,
|
|
8760
|
-
this.tryNextAvailableAd(0)
|
|
8761
|
-
];
|
|
9738
|
+
// Per-request diagnostics
|
|
9739
|
+
// ───────────────────────────────────────────────────────────────
|
|
9740
|
+
key: "recordRequestDiagnostic",
|
|
9741
|
+
value: function recordRequestDiagnostic(payload) {
|
|
9742
|
+
var requestId = payload.requestId;
|
|
9743
|
+
if (typeof requestId !== "number") return;
|
|
9744
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
9745
|
+
if (!diag) return;
|
|
9746
|
+
switch(payload.stage){
|
|
9747
|
+
case "gam_http_request_sent":
|
|
9748
|
+
diag.gamRequestSent++;
|
|
9749
|
+
break;
|
|
9750
|
+
case "gam_response_received":
|
|
9751
|
+
diag.vastHttpStatus = payload.httpStatus;
|
|
9752
|
+
break;
|
|
9753
|
+
case "vast_parsed":
|
|
9754
|
+
diag.vastAdCount = payload.adElementCount;
|
|
9755
|
+
break;
|
|
9756
|
+
case "wrapper_fetch":
|
|
9757
|
+
case "inline_resolved":
|
|
9758
|
+
if (typeof payload.depth === "number") {
|
|
9759
|
+
diag.wrapperDepth = Math.max(diag.wrapperDepth, payload.depth);
|
|
8762
9760
|
}
|
|
9761
|
+
if (payload.stage === "inline_resolved") diag.inlineResolved = true;
|
|
9762
|
+
break;
|
|
9763
|
+
case "mediafile_evaluated":
|
|
9764
|
+
diag.mediaCandidateCount++;
|
|
9765
|
+
if (payload.whyAccepted) diag.supportedMediaCount++;
|
|
9766
|
+
break;
|
|
9767
|
+
case "playing":
|
|
9768
|
+
diag.playStarted = true;
|
|
9769
|
+
break;
|
|
9770
|
+
case "impression_fired":
|
|
9771
|
+
diag.impressionFired = true;
|
|
9772
|
+
break;
|
|
9773
|
+
default:
|
|
9774
|
+
if (REQUEST_FAILURE_STAGES.has(payload.stage) && !diag.failureReason) {
|
|
9775
|
+
diag.failureReason = payload.reason ? "".concat(payload.stage, ":").concat(payload.reason) : payload.stage;
|
|
9776
|
+
}
|
|
9777
|
+
}
|
|
9778
|
+
}
|
|
9779
|
+
},
|
|
9780
|
+
{
|
|
9781
|
+
key: "finalizeRequestDiagnostics",
|
|
9782
|
+
value: function finalizeRequestDiagnostics(requestId, endReason) {
|
|
9783
|
+
var _diag_vastAdCount;
|
|
9784
|
+
if (requestId == null) return;
|
|
9785
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
9786
|
+
if (!diag) return;
|
|
9787
|
+
this.requestDiagnostics.delete(requestId);
|
|
9788
|
+
if (!diag.impressionFired && !diag.failureReason && endReason) {
|
|
9789
|
+
diag.failureReason = endReason;
|
|
9790
|
+
}
|
|
9791
|
+
var gamReturnedAdWithoutImpression = ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired;
|
|
9792
|
+
if (gamReturnedAdWithoutImpression) {
|
|
9793
|
+
this.countFunnelStage("gam_ad_without_impression");
|
|
9794
|
+
}
|
|
9795
|
+
var startedAt = diag.startedAt, fields = _object_without_properties(diag, [
|
|
9796
|
+
"startedAt"
|
|
9797
|
+
]);
|
|
9798
|
+
console.log("[AdBreak][REQUEST] summary", _object_spread_props(_object_spread({}, fields), {
|
|
9799
|
+
durationMs: Date.now() - startedAt,
|
|
9800
|
+
gamReturnedAdWithoutImpression: gamReturnedAdWithoutImpression
|
|
9801
|
+
}));
|
|
9802
|
+
}
|
|
9803
|
+
},
|
|
9804
|
+
{
|
|
9805
|
+
// ───────────────────────────────────────────────────────────────
|
|
9806
|
+
// Single ad playback
|
|
9807
|
+
// ───────────────────────────────────────────────────────────────
|
|
9808
|
+
key: "withCurrentPodBudget",
|
|
9809
|
+
value: function withCurrentPodBudget(rawVastTagUrl) {
|
|
9810
|
+
var vastTagUrl = ensureVideoAdType(rawVastTagUrl);
|
|
9811
|
+
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9812
|
+
if (!(remaining > 0)) return vastTagUrl;
|
|
9813
|
+
try {
|
|
9814
|
+
var url = new URL(vastTagUrl);
|
|
9815
|
+
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
9816
|
+
var maxMs = Math.round(remaining);
|
|
9817
|
+
url.searchParams.set("pmxd", String(maxMs));
|
|
9818
|
+
var minMs = Number(url.searchParams.get("pmnd"));
|
|
9819
|
+
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
9820
|
+
url.searchParams.set("pmnd", String(maxMs));
|
|
9821
|
+
}
|
|
9822
|
+
return url.toString();
|
|
9823
|
+
} catch (unused) {
|
|
9824
|
+
return vastTagUrl;
|
|
9825
|
+
}
|
|
9826
|
+
}
|
|
9827
|
+
},
|
|
9828
|
+
{
|
|
9829
|
+
key: "countFunnelStage",
|
|
9830
|
+
value: function countFunnelStage(stage) {
|
|
9831
|
+
var amount = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
|
|
9832
|
+
var _this_breakFunnel_stage;
|
|
9833
|
+
this.breakFunnel[stage] = ((_this_breakFunnel_stage = this.breakFunnel[stage]) !== null && _this_breakFunnel_stage !== void 0 ? _this_breakFunnel_stage : 0) + amount;
|
|
9834
|
+
}
|
|
9835
|
+
},
|
|
9836
|
+
{
|
|
9837
|
+
key: "logOrchestratorFunnel",
|
|
9838
|
+
value: function logOrchestratorFunnel(stage) {
|
|
9839
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
9840
|
+
this.countFunnelStage(stage);
|
|
9841
|
+
console.log("[AdBreak][FUNNEL] ".concat(stage), _object_spread({
|
|
9842
|
+
breakId: this.timing.adBreakEpoch,
|
|
9843
|
+
requestId: this.currentRequestId,
|
|
9844
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0
|
|
9845
|
+
}, extra));
|
|
9846
|
+
}
|
|
9847
|
+
},
|
|
9848
|
+
{
|
|
9849
|
+
key: "noteOpportunity",
|
|
9850
|
+
value: function noteOpportunity(source, breakKey) {
|
|
9851
|
+
if (breakKey && breakKey === this.opportunityBreakKey && this.opportunityEpoch === this.timing.adBreakEpoch) {
|
|
9852
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
9853
|
+
source: source,
|
|
9854
|
+
breakKey: breakKey
|
|
8763
9855
|
});
|
|
8764
|
-
|
|
9856
|
+
return;
|
|
9857
|
+
}
|
|
9858
|
+
this.opportunityBreakKey = breakKey;
|
|
9859
|
+
this.opportunityEpoch = this.timing.adBreakEpoch;
|
|
9860
|
+
this.logOrchestratorFunnel("opportunity_created", {
|
|
9861
|
+
source: source,
|
|
9862
|
+
breakKey: breakKey,
|
|
9863
|
+
expectedDurationMs: this.timing.expectedAdBreakDurationMs
|
|
9864
|
+
});
|
|
9865
|
+
}
|
|
9866
|
+
},
|
|
9867
|
+
{
|
|
9868
|
+
key: "beginFunnelRequest",
|
|
9869
|
+
value: function beginFunnelRequest(adPlayer, requestToken, trigger) {
|
|
9870
|
+
var _adPlayer_setFunnelContext;
|
|
9871
|
+
if (this.controllerCallInFlight) {
|
|
9872
|
+
this.logOrchestratorFunnel("duplicate_request_detected", {
|
|
9873
|
+
newRequestId: requestToken
|
|
9874
|
+
});
|
|
9875
|
+
}
|
|
9876
|
+
this.finalizeRequestDiagnostics(this.currentRequestId);
|
|
9877
|
+
this.currentRequestId = requestToken;
|
|
9878
|
+
this.requestStartedAt = Date.now();
|
|
9879
|
+
this.requestDiagnostics.set(requestToken, {
|
|
9880
|
+
breakId: this.timing.adBreakEpoch,
|
|
9881
|
+
requestId: requestToken,
|
|
9882
|
+
controllerId: this.controllerGeneration,
|
|
9883
|
+
trigger: trigger,
|
|
9884
|
+
gamRequestSent: 0,
|
|
9885
|
+
wrapperDepth: 0,
|
|
9886
|
+
inlineResolved: false,
|
|
9887
|
+
mediaCandidateCount: 0,
|
|
9888
|
+
supportedMediaCount: 0,
|
|
9889
|
+
playStarted: false,
|
|
9890
|
+
impressionFired: false,
|
|
9891
|
+
startedAt: Date.now()
|
|
9892
|
+
});
|
|
9893
|
+
(_adPlayer_setFunnelContext = adPlayer.setFunnelContext) === null || _adPlayer_setFunnelContext === void 0 ? void 0 : _adPlayer_setFunnelContext.call(adPlayer, {
|
|
9894
|
+
breakId: this.timing.adBreakEpoch,
|
|
9895
|
+
requestId: requestToken,
|
|
9896
|
+
controllerId: this.controllerGeneration
|
|
9897
|
+
});
|
|
9898
|
+
}
|
|
9899
|
+
},
|
|
9900
|
+
{
|
|
9901
|
+
key: "isAdLoadingWithoutPlayback",
|
|
9902
|
+
value: function isAdLoadingWithoutPlayback() {
|
|
9903
|
+
return this.host.getAdPlayer().isAdPlaying() && !this.playbackStartedForCurrentRequest;
|
|
9904
|
+
}
|
|
9905
|
+
},
|
|
9906
|
+
{
|
|
9907
|
+
key: "noteStopBeforeStart",
|
|
9908
|
+
value: function noteStopBeforeStart(reason) {
|
|
9909
|
+
if (!this.isAdLoadingWithoutPlayback()) return;
|
|
9910
|
+
this.logOrchestratorFunnel("ad_stopped_before_start", {
|
|
9911
|
+
reason: reason,
|
|
9912
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
9913
|
+
});
|
|
9914
|
+
}
|
|
9915
|
+
},
|
|
9916
|
+
{
|
|
9917
|
+
key: "handleRequestWatchdogTimeout",
|
|
9918
|
+
value: function handleRequestWatchdogTimeout() {
|
|
9919
|
+
var adPlayer = this.host.getAdPlayer();
|
|
9920
|
+
if (this.controllerCallInFlight && adPlayer.abortPendingRequest) {
|
|
9921
|
+
this.logOrchestratorFunnel("request_aborted_timeout", {
|
|
9922
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
9923
|
+
});
|
|
9924
|
+
adPlayer.abortPendingRequest("VAST request aborted after request watchdog timeout");
|
|
9925
|
+
return;
|
|
9926
|
+
}
|
|
9927
|
+
this.handleAdFailure("request_watchdog_timeout");
|
|
8765
9928
|
}
|
|
8766
9929
|
},
|
|
8767
9930
|
{
|
|
8768
|
-
key: "
|
|
8769
|
-
value: function
|
|
8770
|
-
var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
|
9931
|
+
key: "callController",
|
|
9932
|
+
value: function callController(call) {
|
|
8771
9933
|
return _async_to_generator(function() {
|
|
8772
|
-
var remaining, nextAdUrl, error, errorMessage, maxRetries;
|
|
8773
9934
|
return _ts_generator(this, function(_state) {
|
|
8774
9935
|
switch(_state.label){
|
|
8775
9936
|
case 0:
|
|
8776
|
-
|
|
8777
|
-
return [
|
|
8778
|
-
2
|
|
8779
|
-
];
|
|
8780
|
-
}
|
|
8781
|
-
remaining = this.timing.getRemainingAdMs();
|
|
8782
|
-
if (!this.timing.hasTimeToStartAnotherAd()) {
|
|
8783
|
-
if (this.debug) {
|
|
8784
|
-
console.log("[CONTINUOUS-FETCH] Not enough time remaining (".concat(remaining, "ms) to start another ad, ending ad break"));
|
|
8785
|
-
}
|
|
8786
|
-
this.handleAdPodComplete();
|
|
8787
|
-
return [
|
|
8788
|
-
2
|
|
8789
|
-
];
|
|
8790
|
-
}
|
|
8791
|
-
if (this.timing.isGamInCooldown()) {
|
|
8792
|
-
if (this.debug) {
|
|
8793
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, ending ad break gracefully");
|
|
8794
|
-
}
|
|
8795
|
-
this.handleAdPodComplete();
|
|
8796
|
-
return [
|
|
8797
|
-
2
|
|
8798
|
-
];
|
|
8799
|
-
}
|
|
8800
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
8801
|
-
if (this.debug) {
|
|
8802
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(this.timing.consecutiveFailures, "), ending ad break"));
|
|
8803
|
-
}
|
|
8804
|
-
this.handleAdPodComplete();
|
|
8805
|
-
return [
|
|
8806
|
-
2
|
|
8807
|
-
];
|
|
8808
|
-
}
|
|
8809
|
-
this.timing.cleanupTemporaryFailures();
|
|
9937
|
+
this.controllerCallInFlight = true;
|
|
8810
9938
|
_state.label = 1;
|
|
8811
9939
|
case 1:
|
|
8812
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
8813
|
-
3,
|
|
8814
|
-
9
|
|
8815
|
-
];
|
|
8816
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
8817
|
-
if (!nextAdUrl) return [
|
|
8818
|
-
3,
|
|
8819
|
-
1
|
|
8820
|
-
];
|
|
8821
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) {
|
|
8822
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
|
|
8823
|
-
return [
|
|
8824
|
-
3,
|
|
8825
|
-
1
|
|
8826
|
-
];
|
|
8827
|
-
}
|
|
8828
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) {
|
|
8829
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
|
|
8830
|
-
return [
|
|
8831
|
-
3,
|
|
8832
|
-
1
|
|
8833
|
-
];
|
|
8834
|
-
}
|
|
8835
|
-
if (this.debug) {
|
|
8836
|
-
console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
|
|
8837
|
-
}
|
|
8838
|
-
_state.label = 2;
|
|
8839
|
-
case 2:
|
|
8840
9940
|
_state.trys.push([
|
|
8841
|
-
|
|
8842
|
-
4,
|
|
9941
|
+
1,
|
|
8843
9942
|
,
|
|
8844
|
-
8
|
|
8845
|
-
]);
|
|
8846
|
-
return [
|
|
8847
|
-
4,
|
|
8848
|
-
this.playSingleAd(nextAdUrl)
|
|
8849
|
-
];
|
|
8850
|
-
case 3:
|
|
8851
|
-
_state.sent();
|
|
8852
|
-
this.timing.consecutiveFailures = 0;
|
|
8853
|
-
return [
|
|
8854
9943
|
3,
|
|
8855
|
-
|
|
8856
|
-
];
|
|
8857
|
-
case 4:
|
|
8858
|
-
error = _state.sent();
|
|
8859
|
-
errorMessage = error.message;
|
|
8860
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
|
|
8861
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
8862
|
-
3,
|
|
8863
|
-
6
|
|
8864
|
-
];
|
|
8865
|
-
return [
|
|
8866
|
-
4,
|
|
8867
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
8868
|
-
];
|
|
8869
|
-
case 5:
|
|
8870
|
-
_state.sent();
|
|
8871
|
-
return [
|
|
8872
|
-
2
|
|
8873
|
-
];
|
|
8874
|
-
case 6:
|
|
8875
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
8876
|
-
this.timing.consecutiveFailures++;
|
|
8877
|
-
}
|
|
9944
|
+
4
|
|
9945
|
+
]);
|
|
8878
9946
|
return [
|
|
8879
9947
|
4,
|
|
8880
|
-
|
|
9948
|
+
call()
|
|
8881
9949
|
];
|
|
8882
|
-
case
|
|
9950
|
+
case 2:
|
|
8883
9951
|
_state.sent();
|
|
8884
9952
|
return [
|
|
8885
9953
|
3,
|
|
8886
|
-
|
|
8887
|
-
];
|
|
8888
|
-
case 8:
|
|
8889
|
-
return [
|
|
8890
|
-
2
|
|
8891
|
-
];
|
|
8892
|
-
case 9:
|
|
8893
|
-
maxRetries = 3;
|
|
8894
|
-
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
8895
|
-
3,
|
|
8896
|
-
12
|
|
8897
|
-
];
|
|
8898
|
-
if (this.debug) {
|
|
8899
|
-
console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
8900
|
-
}
|
|
8901
|
-
return [
|
|
8902
|
-
4,
|
|
8903
|
-
new Promise(function(resolve) {
|
|
8904
|
-
return setTimeout(resolve, 500);
|
|
8905
|
-
})
|
|
8906
|
-
];
|
|
8907
|
-
case 10:
|
|
8908
|
-
_state.sent();
|
|
8909
|
-
return [
|
|
8910
|
-
4,
|
|
8911
|
-
this.tryNextAvailableAd(retryCount + 1)
|
|
9954
|
+
4
|
|
8912
9955
|
];
|
|
8913
|
-
case
|
|
8914
|
-
|
|
9956
|
+
case 3:
|
|
9957
|
+
this.controllerCallInFlight = false;
|
|
8915
9958
|
return [
|
|
8916
|
-
|
|
9959
|
+
7
|
|
8917
9960
|
];
|
|
8918
|
-
case
|
|
8919
|
-
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
8920
|
-
this.showPlaceholderAndWaitForAds();
|
|
8921
|
-
} else {
|
|
8922
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] No more ads available, ending ad break");
|
|
8923
|
-
this.handleAdPodComplete();
|
|
8924
|
-
}
|
|
9961
|
+
case 4:
|
|
8925
9962
|
return [
|
|
8926
9963
|
2
|
|
8927
9964
|
];
|
|
@@ -8930,47 +9967,33 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8930
9967
|
}).call(this);
|
|
8931
9968
|
}
|
|
8932
9969
|
},
|
|
8933
|
-
{
|
|
8934
|
-
// ───────────────────────────────────────────────────────────────
|
|
8935
|
-
// Single ad playback
|
|
8936
|
-
// ───────────────────────────────────────────────────────────────
|
|
8937
|
-
key: "withCurrentPodBudget",
|
|
8938
|
-
value: function withCurrentPodBudget(vastTagUrl) {
|
|
8939
|
-
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
8940
|
-
if (!(remaining > 0)) return vastTagUrl;
|
|
8941
|
-
try {
|
|
8942
|
-
var url = new URL(vastTagUrl);
|
|
8943
|
-
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
8944
|
-
var maxMs = Math.round(remaining);
|
|
8945
|
-
url.searchParams.set("pmxd", String(maxMs));
|
|
8946
|
-
var minMs = Number(url.searchParams.get("pmnd"));
|
|
8947
|
-
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
8948
|
-
url.searchParams.set("pmnd", String(maxMs));
|
|
8949
|
-
}
|
|
8950
|
-
return url.toString();
|
|
8951
|
-
} catch (unused) {
|
|
8952
|
-
return vastTagUrl;
|
|
8953
|
-
}
|
|
8954
|
-
}
|
|
8955
|
-
},
|
|
8956
9970
|
{
|
|
8957
9971
|
key: "playSingleAd",
|
|
8958
9972
|
value: function playSingleAd(vastTagUrl) {
|
|
9973
|
+
var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
|
|
8959
9974
|
return _async_to_generator(function() {
|
|
8960
|
-
var
|
|
9975
|
+
var epoch, generation, requestToken, ap, requestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
|
|
8961
9976
|
return _ts_generator(this, function(_state) {
|
|
8962
9977
|
switch(_state.label){
|
|
8963
9978
|
case 0:
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
9979
|
+
if (this.slotState === "REQUESTING" || this.slotState === "READY" || this.slotState === "PLAYING" || this.slotState === "ENDING") {
|
|
9980
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9981
|
+
trigger: trigger,
|
|
9982
|
+
state: this.slotState,
|
|
9983
|
+
why: "request_in_flight"
|
|
9984
|
+
});
|
|
9985
|
+
return [
|
|
9986
|
+
2
|
|
9987
|
+
];
|
|
9988
|
+
}
|
|
8968
9989
|
if (this.timing.failedVastUrls.has(vastTagUrl)) {
|
|
8969
9990
|
if (this.debug) console.warn("[AD-ERROR] Skipping permanently-failed VAST URL:", vastTagUrl);
|
|
9991
|
+
this.timing.consecutiveFailures++;
|
|
8970
9992
|
throw new Error("VAST URL permanently failed");
|
|
8971
9993
|
}
|
|
8972
9994
|
if (this.timing.isUrlInCooldown(vastTagUrl)) {
|
|
8973
9995
|
if (this.debug) console.warn("[AD-ERROR] Skipping URL in cooldown (recent no-fill):", vastTagUrl);
|
|
9996
|
+
this.timing.consecutiveFailures++;
|
|
8974
9997
|
throw new Error("VAST URL in cooldown after no-fill");
|
|
8975
9998
|
}
|
|
8976
9999
|
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
@@ -8981,16 +10004,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8981
10004
|
if (this.debug) console.warn("[CIRCUIT-BREAKER] GAM in cooldown, skipping ad request");
|
|
8982
10005
|
throw new Error("GAM in cooldown");
|
|
8983
10006
|
}
|
|
8984
|
-
this.
|
|
10007
|
+
epoch = this.timing.adBreakEpoch;
|
|
10008
|
+
this.recreateAdController("new_request");
|
|
10009
|
+
generation = this.controllerGeneration;
|
|
8985
10010
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8986
10011
|
this.timing.activeAdRequestToken = requestToken;
|
|
10012
|
+
ap = this.host.getAdPlayer();
|
|
10013
|
+
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
10014
|
+
this.currentVastUrl = requestUrl;
|
|
10015
|
+
this.setSlotState("REQUESTING", trigger);
|
|
10016
|
+
this.beginFunnelRequest(ap, requestToken, trigger);
|
|
8987
10017
|
_state.label = 1;
|
|
8988
10018
|
case 1:
|
|
8989
10019
|
_state.trys.push([
|
|
8990
10020
|
1,
|
|
8991
|
-
|
|
10021
|
+
5,
|
|
8992
10022
|
,
|
|
8993
|
-
|
|
10023
|
+
6
|
|
8994
10024
|
]);
|
|
8995
10025
|
return [
|
|
8996
10026
|
4,
|
|
@@ -8998,265 +10028,87 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8998
10028
|
];
|
|
8999
10029
|
case 2:
|
|
9000
10030
|
_state.sent();
|
|
10031
|
+
if (this.isStale(epoch, generation)) return [
|
|
10032
|
+
2
|
|
10033
|
+
];
|
|
9001
10034
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
9002
|
-
this.timing.lastAdRequestTime = Date.now();
|
|
9003
|
-
ap = this.host.getAdPlayer();
|
|
9004
|
-
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9005
|
-
this.currentVastUrl = requestUrl;
|
|
9006
10035
|
return [
|
|
9007
10036
|
4,
|
|
9008
|
-
|
|
10037
|
+
this.callController(function() {
|
|
10038
|
+
return ap.requestAds(requestUrl);
|
|
10039
|
+
})
|
|
9009
10040
|
];
|
|
9010
10041
|
case 3:
|
|
9011
10042
|
_state.sent();
|
|
10043
|
+
this.timing.clearAdRequestWatchdog();
|
|
10044
|
+
if (this.isStale(epoch, generation)) {
|
|
10045
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
10046
|
+
requestId: requestToken
|
|
10047
|
+
});
|
|
10048
|
+
return [
|
|
10049
|
+
2
|
|
10050
|
+
];
|
|
10051
|
+
}
|
|
9012
10052
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
9013
10053
|
source: "hls",
|
|
9014
10054
|
vastUrl: requestUrl,
|
|
9015
10055
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
9016
10056
|
}, this.analyticsContext).catch(function() {});
|
|
9017
|
-
this.timing.clearAdRequestWatchdog();
|
|
9018
|
-
if (this.timing.activeAdRequestToken !== requestToken) return [
|
|
9019
|
-
2
|
|
9020
|
-
];
|
|
9021
10057
|
if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
|
|
9022
|
-
|
|
9023
|
-
|
|
10058
|
+
;
|
|
10059
|
+
adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
|
|
10060
|
+
remainingMs = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
10061
|
+
this.logOrchestratorFunnel("discarded_budget", {
|
|
10062
|
+
adDurationMs: adDurationS != null ? adDurationS * 1e3 : void 0,
|
|
10063
|
+
remainingMs: remainingMs
|
|
10064
|
+
});
|
|
9024
10065
|
throw new Error("ad_duration_exceeds_budget");
|
|
9025
10066
|
}
|
|
9026
|
-
|
|
9027
|
-
case 4:
|
|
9028
|
-
_state.trys.push([
|
|
9029
|
-
4,
|
|
9030
|
-
6,
|
|
9031
|
-
,
|
|
9032
|
-
7
|
|
9033
|
-
]);
|
|
10067
|
+
this.setSlotState("READY", "vast_ready");
|
|
9034
10068
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
9035
10069
|
return [
|
|
9036
10070
|
4,
|
|
9037
|
-
|
|
10071
|
+
this.callController(function() {
|
|
10072
|
+
return ap.play();
|
|
10073
|
+
})
|
|
9038
10074
|
];
|
|
9039
|
-
case
|
|
10075
|
+
case 4:
|
|
9040
10076
|
_state.sent();
|
|
9041
|
-
this.
|
|
10077
|
+
if (this.isStale(epoch, generation)) return [
|
|
10078
|
+
2
|
|
10079
|
+
];
|
|
9042
10080
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
9043
10081
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
9044
10082
|
}
|
|
9045
10083
|
ap.setAdVolume(getAdAudioVolume(ap));
|
|
9046
|
-
this.timing.consecutiveFailures = 0;
|
|
9047
10084
|
this.timing.temporaryFailureUrls.delete(vastTagUrl);
|
|
9048
10085
|
return [
|
|
9049
10086
|
3,
|
|
9050
|
-
|
|
9051
|
-
];
|
|
9052
|
-
case 6:
|
|
9053
|
-
playError = _state.sent();
|
|
9054
|
-
if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
|
|
9055
|
-
if (this.timing.isTemporaryAdError(playError)) {
|
|
9056
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9057
|
-
if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
|
|
9058
|
-
} else {
|
|
9059
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9060
|
-
if (this.debug) console.log("[AD-ERROR] Permanent play error - URL blacklisted");
|
|
9061
|
-
}
|
|
9062
|
-
this.timing.clearAdFailsafeTimer();
|
|
9063
|
-
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9064
|
-
this.timing.activeAdRequestToken = null;
|
|
9065
|
-
}
|
|
9066
|
-
throw playError;
|
|
9067
|
-
case 7:
|
|
9068
|
-
return [
|
|
9069
|
-
3,
|
|
9070
|
-
9
|
|
10087
|
+
6
|
|
9071
10088
|
];
|
|
9072
|
-
case
|
|
10089
|
+
case 5:
|
|
9073
10090
|
error = _state.sent();
|
|
9074
|
-
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
9075
|
-
if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
|
|
9076
|
-
if (this.timing.isTemporaryAdError(error)) {
|
|
9077
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9078
|
-
if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
|
|
9079
|
-
} else {
|
|
9080
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9081
|
-
if (this.debug) console.log("[AD-ERROR] Permanent error - URL blacklisted:", errorMessage);
|
|
9082
|
-
}
|
|
9083
10091
|
this.timing.clearAdRequestWatchdog();
|
|
9084
10092
|
this.timing.clearAdFailsafeTimer();
|
|
9085
10093
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9086
10094
|
this.timing.activeAdRequestToken = null;
|
|
9087
10095
|
}
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
}
|
|
9094
|
-
});
|
|
9095
|
-
}).call(this);
|
|
9096
|
-
}
|
|
9097
|
-
},
|
|
9098
|
-
{
|
|
9099
|
-
key: "showPlaceholderAndWaitForAds",
|
|
9100
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9101
|
-
// Placeholder wait
|
|
9102
|
-
// ───────────────────────────────────────────────────────────────
|
|
9103
|
-
function showPlaceholderAndWaitForAds() {
|
|
9104
|
-
return _async_to_generator(function() {
|
|
9105
|
-
var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
|
|
9106
|
-
return _ts_generator(this, function(_state) {
|
|
9107
|
-
switch(_state.label){
|
|
9108
|
-
case 0:
|
|
9109
|
-
remaining = this.timing.getRemainingAdMs();
|
|
9110
|
-
waitTime = Math.min(this.maxPlaceholderDurationMs, remaining);
|
|
9111
|
-
if (this.timing.isGamInCooldown()) {
|
|
9112
|
-
if (this.debug) console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping placeholder wait");
|
|
9113
|
-
this.handleAdPodComplete();
|
|
9114
|
-
return [
|
|
9115
|
-
2
|
|
9116
|
-
];
|
|
9117
|
-
}
|
|
9118
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9119
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping placeholder - too many consecutive failures");
|
|
9120
|
-
this.handleAdPodComplete();
|
|
9121
|
-
return [
|
|
9122
|
-
2
|
|
9123
|
-
];
|
|
9124
|
-
}
|
|
9125
|
-
if (waitTime < 1e3) {
|
|
9126
|
-
this.handleAdPodComplete();
|
|
10096
|
+
if (this.isStale(epoch, generation)) {
|
|
10097
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
10098
|
+
requestId: requestToken,
|
|
10099
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
10100
|
+
});
|
|
9127
10101
|
return [
|
|
9128
10102
|
2
|
|
9129
10103
|
];
|
|
9130
10104
|
}
|
|
9131
|
-
if (this.debug)
|
|
9132
|
-
|
|
10105
|
+
if (this.debug) console.error("[AD-ERROR] Ad request failed:", error === null || error === void 0 ? void 0 : error.message);
|
|
10106
|
+
this.recordRequestFailure(error, vastTagUrl);
|
|
10107
|
+
if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
|
|
10108
|
+
this.recreateAdController("discarded_budget");
|
|
9133
10109
|
}
|
|
9134
|
-
|
|
9135
|
-
this.host.getAdPlayer().showPlaceholder();
|
|
9136
|
-
checkInterval = 300;
|
|
9137
|
-
maxChecks = Math.floor(waitTime / checkInterval);
|
|
9138
|
-
i = 0;
|
|
9139
|
-
_state.label = 1;
|
|
9140
|
-
case 1:
|
|
9141
|
-
if (!(i < maxChecks)) return [
|
|
9142
|
-
3,
|
|
9143
|
-
12
|
|
9144
|
-
];
|
|
9145
|
-
return [
|
|
9146
|
-
4,
|
|
9147
|
-
new Promise(function(resolve) {
|
|
9148
|
-
return setTimeout(resolve, checkInterval);
|
|
9149
|
-
})
|
|
9150
|
-
];
|
|
9151
|
-
case 2:
|
|
9152
|
-
_state.sent();
|
|
9153
|
-
if (!this.inAdBreak) return [
|
|
9154
|
-
2
|
|
9155
|
-
];
|
|
9156
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9157
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Too many failures during placeholder wait");
|
|
9158
|
-
return [
|
|
9159
|
-
3,
|
|
9160
|
-
12
|
|
9161
|
-
];
|
|
9162
|
-
}
|
|
9163
|
-
if (!this.timing.hasTimeToStartAnotherAd()) {
|
|
9164
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Not enough time remaining during placeholder wait, ending ad break");
|
|
9165
|
-
return [
|
|
9166
|
-
3,
|
|
9167
|
-
12
|
|
9168
|
-
];
|
|
9169
|
-
}
|
|
9170
|
-
_state.label = 3;
|
|
9171
|
-
case 3:
|
|
9172
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
9173
|
-
3,
|
|
9174
|
-
11
|
|
9175
|
-
];
|
|
9176
|
-
if (!this.timing.hasTimeToStartAnotherAd()) return [
|
|
9177
|
-
3,
|
|
9178
|
-
11
|
|
9179
|
-
];
|
|
9180
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
9181
|
-
if (!nextAdUrl) return [
|
|
9182
|
-
3,
|
|
9183
|
-
3
|
|
9184
|
-
];
|
|
9185
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) return [
|
|
9186
|
-
3,
|
|
9187
|
-
3
|
|
9188
|
-
];
|
|
9189
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) return [
|
|
9190
|
-
3,
|
|
9191
|
-
3
|
|
9192
|
-
];
|
|
9193
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad URL available, requesting via HLS ad player");
|
|
9194
|
-
this.isShowingPlaceholder = false;
|
|
9195
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
9196
|
-
_state.label = 4;
|
|
9197
|
-
case 4:
|
|
9198
|
-
_state.trys.push([
|
|
9199
|
-
4,
|
|
9200
|
-
6,
|
|
9201
|
-
,
|
|
9202
|
-
10
|
|
9203
|
-
]);
|
|
9204
|
-
return [
|
|
9205
|
-
4,
|
|
9206
|
-
this.playSingleAd(nextAdUrl)
|
|
9207
|
-
];
|
|
9208
|
-
case 5:
|
|
9209
|
-
_state.sent();
|
|
9210
|
-
this.timing.consecutiveFailures = 0;
|
|
9211
|
-
return [
|
|
9212
|
-
3,
|
|
9213
|
-
10
|
|
9214
|
-
];
|
|
10110
|
+
throw error;
|
|
9215
10111
|
case 6:
|
|
9216
|
-
error = _state.sent();
|
|
9217
|
-
errorMessage = error.message;
|
|
9218
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
9219
|
-
3,
|
|
9220
|
-
8
|
|
9221
|
-
];
|
|
9222
|
-
return [
|
|
9223
|
-
4,
|
|
9224
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9225
|
-
];
|
|
9226
|
-
case 7:
|
|
9227
|
-
_state.sent();
|
|
9228
|
-
return [
|
|
9229
|
-
2
|
|
9230
|
-
];
|
|
9231
|
-
case 8:
|
|
9232
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
9233
|
-
this.timing.consecutiveFailures++;
|
|
9234
|
-
}
|
|
9235
|
-
return [
|
|
9236
|
-
4,
|
|
9237
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9238
|
-
];
|
|
9239
|
-
case 9:
|
|
9240
|
-
_state.sent();
|
|
9241
|
-
return [
|
|
9242
|
-
3,
|
|
9243
|
-
10
|
|
9244
|
-
];
|
|
9245
|
-
case 10:
|
|
9246
|
-
return [
|
|
9247
|
-
2
|
|
9248
|
-
];
|
|
9249
|
-
case 11:
|
|
9250
|
-
i++;
|
|
9251
|
-
return [
|
|
9252
|
-
3,
|
|
9253
|
-
1
|
|
9254
|
-
];
|
|
9255
|
-
case 12:
|
|
9256
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Placeholder timeout, ending ad break");
|
|
9257
|
-
this.isShowingPlaceholder = false;
|
|
9258
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
9259
|
-
this.handleAdPodComplete();
|
|
9260
10112
|
return [
|
|
9261
10113
|
2
|
|
9262
10114
|
];
|
|
@@ -9269,26 +10121,136 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9269
10121
|
// ───────────────────────────────────────────────────────────────
|
|
9270
10122
|
// Ad break completion
|
|
9271
10123
|
// ───────────────────────────────────────────────────────────────
|
|
10124
|
+
key: "logBreakFunnel",
|
|
10125
|
+
value: function logBreakFunnel(endReason) {
|
|
10126
|
+
var funnel = this.breakFunnel;
|
|
10127
|
+
this.breakFunnel = {};
|
|
10128
|
+
if (Object.keys(funnel).length === 0) return;
|
|
10129
|
+
var count = function count(stage) {
|
|
10130
|
+
var _funnel_stage;
|
|
10131
|
+
return (_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0;
|
|
10132
|
+
};
|
|
10133
|
+
var countPrefix = function countPrefix(prefix) {
|
|
10134
|
+
return Object.keys(funnel).reduce(function(total, stage) {
|
|
10135
|
+
var _funnel_stage;
|
|
10136
|
+
return stage.indexOf(prefix) === 0 ? total + ((_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0) : total;
|
|
10137
|
+
}, 0);
|
|
10138
|
+
};
|
|
10139
|
+
var breakId = this.opportunityEpoch;
|
|
10140
|
+
var requestRetries = count("gam_http_request_retry");
|
|
10141
|
+
var requests = count("gam_http_request_sent") - requestRetries;
|
|
10142
|
+
if (requests > 0 && count("impression_fired") === 0) {
|
|
10143
|
+
console.log("[AdBreak][FUNNEL] break_abandoned_before_start", {
|
|
10144
|
+
breakId: breakId,
|
|
10145
|
+
requests: requests,
|
|
10146
|
+
endReason: endReason
|
|
10147
|
+
});
|
|
10148
|
+
}
|
|
10149
|
+
console.log("[AdBreak][FUNNEL] Break summary", {
|
|
10150
|
+
breakId: breakId,
|
|
10151
|
+
endReason: endReason,
|
|
10152
|
+
opportunities: count("opportunity_created"),
|
|
10153
|
+
vastUrlsGenerated: count("vast_url_generated"),
|
|
10154
|
+
requests: requests,
|
|
10155
|
+
requestRetries: requestRetries,
|
|
10156
|
+
gamResponses: count("gam_response_received"),
|
|
10157
|
+
requestsSuppressed: count("request_suppressed"),
|
|
10158
|
+
duplicates: count("duplicate_request_detected") + count("duplicate_break_start"),
|
|
10159
|
+
filled: count("vast_received"),
|
|
10160
|
+
noFill: count("no_fill"),
|
|
10161
|
+
fillRejected: count("vast_fill_rejected"),
|
|
10162
|
+
gamAdWithoutImpression: count("gam_ad_without_impression"),
|
|
10163
|
+
playbackFailedAfterFill: count("request_outcome:playback_failed"),
|
|
10164
|
+
requestFailed: count("request_failed"),
|
|
10165
|
+
requestAbortedTimeout: count("request_aborted_timeout"),
|
|
10166
|
+
credentialsRetries: count("vast_credentials_retry"),
|
|
10167
|
+
wrapperFailures: count("wrapper_fetch:failure"),
|
|
10168
|
+
noSupportedMedia: count("vast_no_supported_media"),
|
|
10169
|
+
vpaidOnly: count("vast_no_supported_media:vpaid"),
|
|
10170
|
+
audioOnly: count("vast_no_supported_media:audio_only"),
|
|
10171
|
+
mediaFilesEvaluated: count("mediafile_evaluated"),
|
|
10172
|
+
mediaFilesAccepted: count("mediafile_evaluated:accepted"),
|
|
10173
|
+
controllerDestroys: countPrefix("controller_destroy:"),
|
|
10174
|
+
staleCallbacks: count("stale_callback_ignored") + count("stale_request_result_ignored"),
|
|
10175
|
+
tagAllowsAudio: count("tag_allows_audio"),
|
|
10176
|
+
missingImpression: count("vast_missing_impression"),
|
|
10177
|
+
discardedBudget: count("discarded_budget"),
|
|
10178
|
+
mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
|
|
10179
|
+
mediaRejected: count("media_candidate:rejected"),
|
|
10180
|
+
mediaFallbacks: count("media_fallback"),
|
|
10181
|
+
playCalled: count("play_called"),
|
|
10182
|
+
playRejected: count("play_rejected"),
|
|
10183
|
+
mutedRetry: count("muted_retry"),
|
|
10184
|
+
startTimeouts: count("play_resolved_but_never_started"),
|
|
10185
|
+
impressions: count("impression_fired"),
|
|
10186
|
+
impressionUrls: count("impression_urls"),
|
|
10187
|
+
trackingRequests: count("tracking_request_created"),
|
|
10188
|
+
trackingNotLoaded: count("tracking_request_settled:error") + count("tracking_request_settled:timeout"),
|
|
10189
|
+
trackingUnexpandedMacros: count("tracking_url_unexpanded_macro"),
|
|
10190
|
+
trackingInvalidUrls: count("tracking_url_invalid"),
|
|
10191
|
+
vastAdFallbacks: count("vast_ad_fallback"),
|
|
10192
|
+
mediaEvents: count("media_event"),
|
|
10193
|
+
quartile25: count("first_quartile"),
|
|
10194
|
+
quartile50: count("midpoint"),
|
|
10195
|
+
quartile75: count("third_quartile"),
|
|
10196
|
+
complete: count("complete"),
|
|
10197
|
+
stoppedBeforeStart: count("stopped_before_start"),
|
|
10198
|
+
stoppedBeforeStartByBreakEnd: count("ad_stopped_before_start"),
|
|
10199
|
+
unexpectedUnmutes: count("unexpected_unmute"),
|
|
10200
|
+
unmuteBlocked: count("unmute_blocked_without_gesture"),
|
|
10201
|
+
visibilityHidden: count("while_hidden"),
|
|
10202
|
+
playbackFailures: count("play_failed") + count("media_error") + count("hls_fatal") + count("stall") + count("decode_failure") + count("media_unsupported"),
|
|
10203
|
+
stages: funnel
|
|
10204
|
+
});
|
|
10205
|
+
}
|
|
10206
|
+
},
|
|
10207
|
+
{
|
|
9272
10208
|
key: "handleAdPodComplete",
|
|
9273
10209
|
value: function handleAdPodComplete() {
|
|
10210
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "unspecified";
|
|
9274
10211
|
if (this.debug) {
|
|
9275
|
-
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up"
|
|
10212
|
+
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up", {
|
|
10213
|
+
reason: reason
|
|
10214
|
+
});
|
|
9276
10215
|
}
|
|
10216
|
+
var previousState = this.slotState;
|
|
10217
|
+
var alreadyEnded = previousState === "IDLE" && !this.inAdBreak;
|
|
10218
|
+
this.setSlotState("ENDING", reason);
|
|
10219
|
+
this.cancelScheduledRequest();
|
|
10220
|
+
var adPlayer = this.host.getAdPlayer();
|
|
10221
|
+
if (previousState === "REQUESTING") {
|
|
10222
|
+
var _adPlayer_abortPendingRequest;
|
|
10223
|
+
(_adPlayer_abortPendingRequest = adPlayer.abortPendingRequest) === null || _adPlayer_abortPendingRequest === void 0 ? void 0 : _adPlayer_abortPendingRequest.call(adPlayer, "VAST request aborted: ad break ended (".concat(reason, ")"));
|
|
10224
|
+
}
|
|
10225
|
+
if (!alreadyEnded) {
|
|
10226
|
+
console.log("[AD-CONTROLLER] stop", {
|
|
10227
|
+
controllerId: this.controllerGeneration,
|
|
10228
|
+
requestId: this.currentRequestId,
|
|
10229
|
+
state: previousState,
|
|
10230
|
+
reason: reason
|
|
10231
|
+
});
|
|
10232
|
+
}
|
|
10233
|
+
this.finalizeRequestDiagnostics(this.currentRequestId, "break_ended:".concat(reason));
|
|
10234
|
+
this.currentRequestId = void 0;
|
|
9277
10235
|
this.timing.resetForBreakEnd();
|
|
9278
|
-
this.
|
|
10236
|
+
this.placeholder.hide();
|
|
9279
10237
|
this.clearPendingAdBreak();
|
|
9280
10238
|
if (this.isShowingPlaceholder) {
|
|
9281
|
-
|
|
10239
|
+
adPlayer.hidePlaceholder();
|
|
9282
10240
|
this.isShowingPlaceholder = false;
|
|
9283
10241
|
}
|
|
9284
|
-
this.adRequestQueue = [];
|
|
9285
10242
|
this.inAdBreak = false;
|
|
9286
10243
|
this.adDetectSentForCurrentBreak = false;
|
|
9287
10244
|
this.cueManager.activeScte35BreakKey = void 0;
|
|
9288
10245
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
9289
10246
|
this.adPodQueue = [];
|
|
9290
10247
|
this.showAds = false;
|
|
9291
|
-
this.
|
|
10248
|
+
this.breakSource = void 0;
|
|
10249
|
+
this.followUpBaseVastUrl = void 0;
|
|
10250
|
+
this.unusableResponsesInBreak = 0;
|
|
10251
|
+
adPlayer.stop().catch(function() {});
|
|
10252
|
+
if (!alreadyEnded) this.logBreakFunnel(reason);
|
|
10253
|
+
this.setSlotState("IDLE", "break_complete");
|
|
9292
10254
|
var restoredMuted = this.host.getAdPlayer().getOriginalMutedState();
|
|
9293
10255
|
var restoredVolume = this.host.getAdPlayer().getOriginalVolume();
|
|
9294
10256
|
if (this.host.video.muted !== restoredMuted) {
|
|
@@ -9582,25 +10544,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9582
10544
|
{
|
|
9583
10545
|
key: "handleAdFailure",
|
|
9584
10546
|
value: function handleAdFailure() {
|
|
9585
|
-
|
|
9586
|
-
this.
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
}
|
|
9592
|
-
}
|
|
9593
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9594
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Max consecutive failures reached (".concat(this.timing.consecutiveFailures, "), ending ad break gracefully"));
|
|
9595
|
-
this.handleAdPodComplete();
|
|
10547
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "ad_failure";
|
|
10548
|
+
if (!this.inAdBreak) return;
|
|
10549
|
+
if (this.slotState === "REQUESTING" || this.slotState === "ENDING") {
|
|
10550
|
+
this.logOrchestratorFunnel("failure_deferred_to_request", {
|
|
10551
|
+
reason: reason,
|
|
10552
|
+
state: this.slotState
|
|
10553
|
+
});
|
|
9596
10554
|
return;
|
|
9597
10555
|
}
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
this.
|
|
10556
|
+
this.timing.consecutiveFailures++;
|
|
10557
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
10558
|
+
if (diag && !diag.failureReason) diag.failureReason = reason;
|
|
10559
|
+
if (this.debug) {
|
|
10560
|
+
console.log("[AdBreak] Ad failure (".concat(reason, "): remaining=").concat(this.timing.getRemainingAdMs(), "ms, consecutiveFailures=").concat(this.timing.consecutiveFailures));
|
|
9603
10561
|
}
|
|
10562
|
+
this.setSlotState("NEEDS_NEXT_AD", reason);
|
|
10563
|
+
this.requestNextAd(reason);
|
|
9604
10564
|
}
|
|
9605
10565
|
}
|
|
9606
10566
|
]);
|
|
@@ -9640,10 +10600,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9640
10600
|
_this.startScte35AdBreak(marker, cueKey, marker.durationSeconds != null ? marker.durationSeconds * 1e3 : _this.timing.expectedAdBreakDurationMs);
|
|
9641
10601
|
},
|
|
9642
10602
|
onWatchdogTimeout: function onWatchdogTimeout() {
|
|
9643
|
-
return _this.adBreak.
|
|
10603
|
+
return _this.adBreak.handleRequestWatchdogTimeout();
|
|
9644
10604
|
},
|
|
9645
10605
|
onFailsafeTimeout: function onFailsafeTimeout() {
|
|
9646
|
-
return _this.adBreak.handleAdFailure();
|
|
10606
|
+
return _this.adBreak.handleAdFailure("failsafe_timeout");
|
|
9647
10607
|
},
|
|
9648
10608
|
getAdState: function getAdState() {
|
|
9649
10609
|
return {
|
|
@@ -9745,6 +10705,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9745
10705
|
licenseKey: this.config.licenseKey
|
|
9746
10706
|
} : {}, ((_this_hlsEngine = this.hlsEngine) === null || _this_hlsEngine === void 0 ? void 0 : _this_hlsEngine.hls) ? {
|
|
9747
10707
|
mainHlsInstance: this.hlsEngine.hls
|
|
10708
|
+
} : {}, this.config.adMediaStartTimeoutMs != null ? {
|
|
10709
|
+
mediaStartTimeoutMs: this.config.adMediaStartTimeoutMs
|
|
9748
10710
|
} : {}));
|
|
9749
10711
|
}
|
|
9750
10712
|
},
|
|
@@ -9891,6 +10853,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9891
10853
|
adBehavior: adBehavior
|
|
9892
10854
|
});
|
|
9893
10855
|
}
|
|
10856
|
+
if (this.adBreak.isBreakActive()) {
|
|
10857
|
+
console.log("[AD-CONTROLLER] destroy skipped", {
|
|
10858
|
+
reason: "manifest_parsed_during_break",
|
|
10859
|
+
state: this.adBreak.getSlotState()
|
|
10860
|
+
});
|
|
10861
|
+
return [
|
|
10862
|
+
2
|
|
10863
|
+
];
|
|
10864
|
+
}
|
|
10865
|
+
if (this.debug) {
|
|
10866
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
10867
|
+
reason: "manifest_parsed",
|
|
10868
|
+
state: "IDLE"
|
|
10869
|
+
});
|
|
10870
|
+
}
|
|
9894
10871
|
this.adPlayer.destroy();
|
|
9895
10872
|
this.adPlayer = this.createAdPlayer(this.shouldContinueLiveStreamDuringAds());
|
|
9896
10873
|
this.adPlayer.initialize();
|
|
@@ -10072,9 +11049,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10072
11049
|
this.timing.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
10073
11050
|
}
|
|
10074
11051
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
10075
|
-
if (!this.adPlayer.isAdPlaying() && this.timing.activeAdRequestToken === null && this.adBreak.adRequestQueue.length > 0 && this.timing.hasTimeToStartAnotherAd()) {
|
|
10076
|
-
this.adBreak.tryNextAvailableAdWithRateLimit();
|
|
10077
|
-
}
|
|
10078
11052
|
return;
|
|
10079
11053
|
}
|
|
10080
11054
|
if (marker.type === "end") {
|
|
@@ -10086,12 +11060,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10086
11060
|
}
|
|
10087
11061
|
var remaining = this.timing.getRemainingAdMs();
|
|
10088
11062
|
var adPlaying = this.adPlayer.isAdPlaying();
|
|
10089
|
-
var hasQueuedAds = this.adBreak.adRequestQueue.length > 0;
|
|
10090
11063
|
if (this.debug) {
|
|
10091
11064
|
console.log("[StormcloudVideoPlayer] SCTE-35 end marker received:", {
|
|
10092
11065
|
remaining: remaining,
|
|
10093
11066
|
adPlaying: adPlaying,
|
|
10094
|
-
|
|
11067
|
+
adSlotState: this.adBreak.getSlotState(),
|
|
10095
11068
|
activeAdRequest: this.timing.activeAdRequestToken !== null
|
|
10096
11069
|
});
|
|
10097
11070
|
}
|
|
@@ -10099,9 +11072,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10099
11072
|
this.timing.clearAdStartTimer();
|
|
10100
11073
|
this.timing.clearAdStopTimer();
|
|
10101
11074
|
if (adPlaying) {
|
|
11075
|
+
this.adBreak.noteStopBeforeStart("scte_end");
|
|
10102
11076
|
this.adPlayer.stop().catch(function() {});
|
|
10103
11077
|
}
|
|
10104
|
-
this.adBreak.handleAdPodComplete();
|
|
11078
|
+
this.adBreak.handleAdPodComplete("scte_end");
|
|
10105
11079
|
return;
|
|
10106
11080
|
}
|
|
10107
11081
|
}
|
|
@@ -10109,6 +11083,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10109
11083
|
{
|
|
10110
11084
|
key: "startScte35AdBreak",
|
|
10111
11085
|
value: function startScte35AdBreak(marker, cueKey, durationMs) {
|
|
11086
|
+
if (this.adBreak.isBreakActive()) {
|
|
11087
|
+
if (this.debug) {
|
|
11088
|
+
console.log("[StormcloudVideoPlayer] Ignoring SCTE-35 break start: a break is already active", {
|
|
11089
|
+
state: this.adBreak.getSlotState(),
|
|
11090
|
+
cueKey: cueKey
|
|
11091
|
+
});
|
|
11092
|
+
}
|
|
11093
|
+
return;
|
|
11094
|
+
}
|
|
10112
11095
|
this.adBreak.inAdBreak = true;
|
|
10113
11096
|
this.cueManager.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.cueManager.pendingScte35CueKey;
|
|
10114
11097
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
@@ -10138,9 +11121,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10138
11121
|
console.log("[StormcloudVideoPlayer] Ad break boundary reached (overrun=".concat(overrunMs, "ms) - hard-stopping ads and resuming stream"));
|
|
10139
11122
|
}
|
|
10140
11123
|
if (adPlaying) {
|
|
11124
|
+
this.adBreak.noteStopBeforeStart("break_boundary");
|
|
10141
11125
|
this.adPlayer.stop().catch(function() {});
|
|
10142
11126
|
}
|
|
10143
|
-
this.adBreak.handleAdPodComplete();
|
|
11127
|
+
this.adBreak.handleAdPodComplete("break_boundary");
|
|
10144
11128
|
}
|
|
10145
11129
|
},
|
|
10146
11130
|
{
|
|
@@ -10150,14 +11134,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10150
11134
|
key: "startAdPrefetch",
|
|
10151
11135
|
value: function startAdPrefetch(marker, fragmentSn, cueKey) {
|
|
10152
11136
|
if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
|
|
10153
|
-
var
|
|
10154
|
-
|
|
10155
|
-
var baseVastUrl;
|
|
10156
|
-
if (tags && tags.length > 0 && tags[0]) {
|
|
10157
|
-
baseVastUrl = tags[0];
|
|
10158
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
10159
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
10160
|
-
} else {
|
|
11137
|
+
var baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
11138
|
+
if (!baseVastUrl) {
|
|
10161
11139
|
if (this.debug) console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
|
|
10162
11140
|
return;
|
|
10163
11141
|
}
|
|
@@ -10187,8 +11165,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10187
11165
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
10188
11166
|
}, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
|
|
10189
11167
|
if (this.debug) {
|
|
10190
|
-
console.log("[PREFETCH]
|
|
10191
|
-
console.log("[PREFETCH] Pre-generated pod request URL");
|
|
11168
|
+
console.log("[PREFETCH] Pre-generated pod request URL for upcoming ad break");
|
|
10192
11169
|
}
|
|
10193
11170
|
}
|
|
10194
11171
|
},
|
|
@@ -10199,7 +11176,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10199
11176
|
key: "onTimeUpdate",
|
|
10200
11177
|
value: function onTimeUpdate(currentTimeSec) {
|
|
10201
11178
|
var _this = this;
|
|
10202
|
-
if (
|
|
11179
|
+
if (this.adConfig.vmapBreaks.length === 0) return;
|
|
10203
11180
|
if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
|
|
10204
11181
|
var nowMs = currentTimeSec * 1e3;
|
|
10205
11182
|
var breakToPlay = this.adConfig.findBreakForTime(nowMs);
|
|
@@ -10216,7 +11193,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10216
11193
|
key: "onVideoEnded",
|
|
10217
11194
|
value: function onVideoEnded() {
|
|
10218
11195
|
var _this = this;
|
|
10219
|
-
if (
|
|
11196
|
+
if (this.adConfig.vmapBreaks.length === 0) return;
|
|
10220
11197
|
if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
|
|
10221
11198
|
var durationMs = Number.isFinite(this.video.duration) ? Math.floor(this.video.duration * 1e3) : 0;
|
|
10222
11199
|
var postroll = this.adConfig.vmapBreaks.find(function(b) {
|
|
@@ -10266,6 +11243,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10266
11243
|
this.adBreak.showAds = true;
|
|
10267
11244
|
this.adBreak.inAdBreak = true;
|
|
10268
11245
|
this.timing.currentAdBreakStartWallClockMs = Date.now();
|
|
11246
|
+
if (durationMs > 0) {
|
|
11247
|
+
this.timing.setAdBreakDurationBoundary(durationMs);
|
|
11248
|
+
}
|
|
11249
|
+
this.adBreak.beginVmapBreak(key);
|
|
10269
11250
|
_state.label = 1;
|
|
10270
11251
|
case 1:
|
|
10271
11252
|
_state.trys.push([
|
|
@@ -10276,7 +11257,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10276
11257
|
]);
|
|
10277
11258
|
return [
|
|
10278
11259
|
4,
|
|
10279
|
-
this.adBreak.playSingleAd(first)
|
|
11260
|
+
this.adBreak.playSingleAd(first, "vmap")
|
|
10280
11261
|
];
|
|
10281
11262
|
case 2:
|
|
10282
11263
|
_state.sent();
|
|
@@ -10289,7 +11270,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10289
11270
|
if (this.debug) {
|
|
10290
11271
|
console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
|
|
10291
11272
|
}
|
|
10292
|
-
this.adBreak.
|
|
11273
|
+
this.adBreak.continueAfterRequestFailure();
|
|
10293
11274
|
return [
|
|
10294
11275
|
3,
|
|
10295
11276
|
4
|
|
@@ -10431,7 +11412,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10431
11412
|
key: "destroy",
|
|
10432
11413
|
value: function destroy() {
|
|
10433
11414
|
var _this_adPlayer;
|
|
10434
|
-
this.adBreak.
|
|
11415
|
+
this.adBreak.cancelScheduledRequest();
|
|
10435
11416
|
this.timing.destroy();
|
|
10436
11417
|
this.adBreak.clearPendingAdBreak();
|
|
10437
11418
|
this.placeholder.destroy();
|
|
@@ -10455,7 +11436,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10455
11436
|
this.palNonce.sendPlaybackEnd();
|
|
10456
11437
|
}
|
|
10457
11438
|
this.palNonce.reset();
|
|
10458
|
-
this.adBreak.adRequestQueue = [];
|
|
10459
11439
|
this.timing.consecutiveFailures = 0;
|
|
10460
11440
|
}
|
|
10461
11441
|
}
|