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
package/lib/index.cjs
CHANGED
|
@@ -330,26 +330,6 @@ function _ts_generator(thisArg, body) {
|
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
-
function _ts_values(o) {
|
|
334
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
335
|
-
if (m) {
|
|
336
|
-
return m.call(o);
|
|
337
|
-
}
|
|
338
|
-
if (o && typeof o.length === "number") {
|
|
339
|
-
return {
|
|
340
|
-
next: function() {
|
|
341
|
-
if (o && i >= o.length) {
|
|
342
|
-
o = void 0;
|
|
343
|
-
}
|
|
344
|
-
return {
|
|
345
|
-
value: o && o[i++],
|
|
346
|
-
done: !o
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
352
|
-
}
|
|
353
333
|
function _type_of(obj) {
|
|
354
334
|
"@swc/helpers - typeof";
|
|
355
335
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
@@ -957,7 +937,7 @@ function toVastMediaErrorCode(error) {
|
|
|
957
937
|
}
|
|
958
938
|
}
|
|
959
939
|
function createHlsAdPlayer(contentVideo, options) {
|
|
960
|
-
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
|
|
940
|
+
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP, _ref;
|
|
961
941
|
var adPlaying = false;
|
|
962
942
|
var originalMutedState = false;
|
|
963
943
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
@@ -989,6 +969,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
989
969
|
var sawDecodedVideoFrame = false;
|
|
990
970
|
var videoFrameCallbackHandle;
|
|
991
971
|
var pendingPlayPromise;
|
|
972
|
+
var currentVastTagUrl;
|
|
973
|
+
var funnelContext = {};
|
|
974
|
+
var mediaProbe;
|
|
975
|
+
var lastPodAdElementCount = 0;
|
|
976
|
+
var mediaCandidates = [];
|
|
977
|
+
var mediaCandidateIndex = 0;
|
|
978
|
+
var mediaStartTimerId;
|
|
979
|
+
var MEDIA_START_TIMEOUT_MS = (_ref = options === null || options === void 0 ? void 0 : options.mediaStartTimeoutMs) !== null && _ref !== void 0 ? _ref : 8e3;
|
|
980
|
+
var VAST_ERROR_MEDIA_TIMEOUT = 402;
|
|
981
|
+
var pendingVastRequests = /* @__PURE__ */ new Set();
|
|
982
|
+
var pendingRequestAbortReason;
|
|
983
|
+
var forcedMuteByAutoplay = false;
|
|
992
984
|
function createTrackingState() {
|
|
993
985
|
return {
|
|
994
986
|
impression: false,
|
|
@@ -1039,6 +1031,78 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1039
1031
|
}
|
|
1040
1032
|
}
|
|
1041
1033
|
}
|
|
1034
|
+
var SENSITIVE_URL_PARAMS = /* @__PURE__ */ new Set([
|
|
1035
|
+
"ppid",
|
|
1036
|
+
"rdid",
|
|
1037
|
+
"idtype",
|
|
1038
|
+
"is_lat",
|
|
1039
|
+
"ifa",
|
|
1040
|
+
"idfa",
|
|
1041
|
+
"aaid",
|
|
1042
|
+
"uid",
|
|
1043
|
+
"user_id",
|
|
1044
|
+
"userid",
|
|
1045
|
+
"device_id",
|
|
1046
|
+
"deviceid",
|
|
1047
|
+
"ip",
|
|
1048
|
+
"ua",
|
|
1049
|
+
"gdpr_consent",
|
|
1050
|
+
"us_privacy",
|
|
1051
|
+
"gpp",
|
|
1052
|
+
"addtl_consent",
|
|
1053
|
+
"cust_params",
|
|
1054
|
+
"email"
|
|
1055
|
+
]);
|
|
1056
|
+
function redactUrl(url) {
|
|
1057
|
+
if (!url) return url;
|
|
1058
|
+
try {
|
|
1059
|
+
var parsed = new URL(url);
|
|
1060
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1061
|
+
try {
|
|
1062
|
+
for(var _iterator = Array.from(parsed.searchParams.keys())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1063
|
+
var key = _step.value;
|
|
1064
|
+
if (SENSITIVE_URL_PARAMS.has(key.toLowerCase())) {
|
|
1065
|
+
parsed.searchParams.set(key, "REDACTED");
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
} catch (err) {
|
|
1069
|
+
_didIteratorError = true;
|
|
1070
|
+
_iteratorError = err;
|
|
1071
|
+
} finally{
|
|
1072
|
+
try {
|
|
1073
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1074
|
+
_iterator.return();
|
|
1075
|
+
}
|
|
1076
|
+
} finally{
|
|
1077
|
+
if (_didIteratorError) {
|
|
1078
|
+
throw _iteratorError;
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
return parsed.toString();
|
|
1083
|
+
} catch (unused) {
|
|
1084
|
+
return url.split("?")[0];
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
function logFunnel(stage) {
|
|
1088
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1089
|
+
var payload = _object_spread({
|
|
1090
|
+
stage: stage,
|
|
1091
|
+
breakId: funnelContext.breakId,
|
|
1092
|
+
requestId: funnelContext.requestId,
|
|
1093
|
+
controllerId: funnelContext.controllerId,
|
|
1094
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0,
|
|
1095
|
+
adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
|
|
1096
|
+
podIndex: podIndex,
|
|
1097
|
+
podSize: podAds.length,
|
|
1098
|
+
vastUrl: redactUrl(currentVastTagUrl),
|
|
1099
|
+
mediaUrl: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url,
|
|
1100
|
+
mediaType: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.type,
|
|
1101
|
+
muted: adVideoElement ? adVideoElement.muted : void 0
|
|
1102
|
+
}, extra);
|
|
1103
|
+
console.log("[HlsAdPlayer][FUNNEL] ".concat(stage), payload);
|
|
1104
|
+
emit("ad_funnel", payload);
|
|
1105
|
+
}
|
|
1042
1106
|
function buildTrackingMacroContext() {
|
|
1043
1107
|
var options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1044
1108
|
var _options2_ad;
|
|
@@ -1078,20 +1142,53 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1078
1142
|
urls.forEach(function(url) {
|
|
1079
1143
|
try {
|
|
1080
1144
|
var trackingUrl = substituteVastTrackingMacros(url, macroContext);
|
|
1145
|
+
var trackingHost;
|
|
1146
|
+
try {
|
|
1147
|
+
trackingHost = new URL(trackingUrl).host;
|
|
1148
|
+
} catch (unused) {
|
|
1149
|
+
logFunnel("tracking_url_invalid", {
|
|
1150
|
+
trackingUrl: redactUrl(trackingUrl)
|
|
1151
|
+
});
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
var unexpanded = trackingUrl.match(/\[[A-Z_]+\]/g);
|
|
1155
|
+
if (unexpanded) {
|
|
1156
|
+
logFunnel("tracking_url_unexpanded_macro", {
|
|
1157
|
+
trackingHost: trackingHost,
|
|
1158
|
+
macros: Array.from(new Set(unexpanded))
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1081
1161
|
var img = new Image(1, 1);
|
|
1082
1162
|
inFlightBeacons.add(img);
|
|
1083
1163
|
var timeoutId;
|
|
1084
|
-
var release = function release() {
|
|
1164
|
+
var release = function release(outcome) {
|
|
1085
1165
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1086
1166
|
img.onload = null;
|
|
1087
1167
|
img.onerror = null;
|
|
1088
1168
|
inFlightBeacons.delete(img);
|
|
1169
|
+
console.log("[HlsAdPlayer] Tracking pixel settled (".concat(outcome, "): ").concat(trackingUrl));
|
|
1170
|
+
if (outcome !== "load") {
|
|
1171
|
+
logFunnel("tracking_request_settled", {
|
|
1172
|
+
reason: outcome,
|
|
1173
|
+
trackingHost: trackingHost
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
img.onload = function() {
|
|
1178
|
+
return release("load");
|
|
1089
1179
|
};
|
|
1090
|
-
img.
|
|
1091
|
-
|
|
1092
|
-
|
|
1180
|
+
img.onerror = function() {
|
|
1181
|
+
return release("error");
|
|
1182
|
+
};
|
|
1183
|
+
timeoutId = setTimeout(function() {
|
|
1184
|
+
return release("timeout");
|
|
1185
|
+
}, BEACON_TIMEOUT_MS);
|
|
1093
1186
|
img.src = trackingUrl;
|
|
1094
1187
|
console.log("[HlsAdPlayer] Fired tracking pixel: ".concat(trackingUrl));
|
|
1188
|
+
logFunnel("tracking_request_created", {
|
|
1189
|
+
trackingHost: trackingHost,
|
|
1190
|
+
errorCode: options2 === null || options2 === void 0 ? void 0 : options2.errorCode
|
|
1191
|
+
});
|
|
1095
1192
|
} catch (error) {
|
|
1096
1193
|
console.warn("[HlsAdPlayer] Error firing tracking pixel:", error);
|
|
1097
1194
|
}
|
|
@@ -1121,54 +1218,79 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1121
1218
|
bitrate: level.bitrate || 5e6
|
|
1122
1219
|
};
|
|
1123
1220
|
}
|
|
1124
|
-
function
|
|
1125
|
-
if (mediaFiles.length === 0) {
|
|
1126
|
-
throw new Error("No media files available");
|
|
1127
|
-
}
|
|
1128
|
-
var firstFile = mediaFiles[0];
|
|
1129
|
-
if (!firstFile) {
|
|
1130
|
-
throw new Error("No media files available");
|
|
1131
|
-
}
|
|
1132
|
-
if (mediaFiles.length === 1) {
|
|
1133
|
-
return firstFile;
|
|
1134
|
-
}
|
|
1221
|
+
function getMediaTargetQuality() {
|
|
1135
1222
|
var mainQuality = getMainStreamQuality();
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1223
|
+
var dpr = typeof window !== "undefined" && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1;
|
|
1224
|
+
var containerWidth = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientWidth) || contentVideo.clientWidth) * dpr;
|
|
1225
|
+
var containerHeight = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientHeight) || contentVideo.clientHeight) * dpr;
|
|
1226
|
+
if (!mainQuality && !(containerWidth > 0 && containerHeight > 0)) {
|
|
1227
|
+
return null;
|
|
1228
|
+
}
|
|
1229
|
+
var base = mainQuality !== null && mainQuality !== void 0 ? mainQuality : {
|
|
1230
|
+
width: containerWidth,
|
|
1231
|
+
height: containerHeight,
|
|
1232
|
+
bitrate: 5e6
|
|
1233
|
+
};
|
|
1234
|
+
var width = containerWidth > 0 ? Math.min(base.width, containerWidth) : base.width;
|
|
1235
|
+
var height = containerHeight > 0 ? Math.min(base.height, containerHeight) : base.height;
|
|
1236
|
+
return {
|
|
1237
|
+
width: width,
|
|
1238
|
+
height: height,
|
|
1239
|
+
bitrate: base.bitrate
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
function rankMediaCandidates(mediaFiles) {
|
|
1243
|
+
var probe = adVideoElement !== null && adVideoElement !== void 0 ? adVideoElement : document.createElement("video");
|
|
1244
|
+
var pageIsHttps = typeof location !== "undefined" && location.protocol === "https:";
|
|
1245
|
+
var target = getMediaTargetQuality();
|
|
1246
|
+
var accepted = [];
|
|
1247
|
+
mediaFiles.forEach(function(file, index) {
|
|
1248
|
+
var isHls = isHlsMediaFile(file);
|
|
1249
|
+
var mimeForProbe = isHls ? "application/vnd.apple.mpegurl" : file.type || "video/mp4";
|
|
1250
|
+
var canPlay2 = probe.canPlayType(mimeForProbe);
|
|
1251
|
+
var playable = isHls ? import_hls.default.isSupported() || canPlay2 !== "" : canPlay2 !== "";
|
|
1252
|
+
var insecure = pageIsHttps && /^http:/i.test(file.url);
|
|
1253
|
+
var details = {
|
|
1254
|
+
index: index,
|
|
1255
|
+
candidateUrl: file.url,
|
|
1256
|
+
candidateType: file.type,
|
|
1257
|
+
width: file.width,
|
|
1258
|
+
height: file.height,
|
|
1259
|
+
bitrate: file.bitrate,
|
|
1260
|
+
canPlayType: canPlay2,
|
|
1261
|
+
hlsJs: isHls ? import_hls.default.isSupported() : void 0
|
|
1262
|
+
};
|
|
1263
|
+
if (!playable) {
|
|
1264
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1265
|
+
reason: "rejected",
|
|
1266
|
+
why: "cannot_play_type"
|
|
1267
|
+
}));
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
var score = 0;
|
|
1271
|
+
if (target) {
|
|
1272
|
+
var resolutionDiff = Math.abs(file.width - target.width) + Math.abs(file.height - target.height);
|
|
1273
|
+
var bitrateDiff = Math.abs((file.bitrate || 5e3) * 1e3 - target.bitrate);
|
|
1274
|
+
score = resolutionDiff * 2 + bitrateDiff / 1e3;
|
|
1275
|
+
}
|
|
1276
|
+
accepted.push({
|
|
1149
1277
|
file: file,
|
|
1150
1278
|
score: score,
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
}
|
|
1279
|
+
insecure: insecure
|
|
1280
|
+
});
|
|
1281
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1282
|
+
reason: "accepted",
|
|
1283
|
+
why: insecure ? "insecure_http_deprioritized" : "playable",
|
|
1284
|
+
score: score
|
|
1285
|
+
}));
|
|
1154
1286
|
});
|
|
1155
|
-
|
|
1287
|
+
accepted.sort(function(a, b) {
|
|
1288
|
+
if (a.insecure !== b.insecure) return a.insecure ? 1 : -1;
|
|
1156
1289
|
return a.score - b.score;
|
|
1157
1290
|
});
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
console.log("[HlsAdPlayer] No best match found, using first media file");
|
|
1161
|
-
return firstFile;
|
|
1162
|
-
}
|
|
1163
|
-
console.log("[HlsAdPlayer] Selected media file:", {
|
|
1164
|
-
url: bestMatch.file.url,
|
|
1165
|
-
resolution: "".concat(bestMatch.file.width, "x").concat(bestMatch.file.height),
|
|
1166
|
-
bitrate: bestMatch.file.bitrate,
|
|
1167
|
-
score: bestMatch.score,
|
|
1168
|
-
resolutionDiff: bestMatch.resolutionDiff,
|
|
1169
|
-
bitrateDiff: bestMatch.bitrateDiff
|
|
1291
|
+
return accepted.map(function(entry) {
|
|
1292
|
+
return entry.file;
|
|
1170
1293
|
});
|
|
1171
|
-
return bestMatch.file;
|
|
1172
1294
|
}
|
|
1173
1295
|
function isHlsMediaFile(mediaFile) {
|
|
1174
1296
|
var type = mediaFile.type.toLowerCase();
|
|
@@ -1185,59 +1307,181 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1185
1307
|
var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
|
|
1186
1308
|
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");
|
|
1187
1309
|
}
|
|
1188
|
-
function
|
|
1310
|
+
function getMediaProbe() {
|
|
1311
|
+
if (adVideoElement) return adVideoElement;
|
|
1312
|
+
if (!mediaProbe && typeof document !== "undefined") {
|
|
1313
|
+
mediaProbe = document.createElement("video");
|
|
1314
|
+
}
|
|
1315
|
+
return mediaProbe;
|
|
1316
|
+
}
|
|
1317
|
+
function evaluateMediaFile(mf) {
|
|
1318
|
+
var _mf_textContent;
|
|
1319
|
+
var type = mf.getAttribute("type") || "";
|
|
1320
|
+
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1321
|
+
var delivery = mf.getAttribute("delivery") || void 0;
|
|
1322
|
+
var codec = mf.getAttribute("codec") || void 0;
|
|
1323
|
+
if (!url) {
|
|
1324
|
+
return {
|
|
1325
|
+
category: "missing_media",
|
|
1326
|
+
whyRejected: "empty_url",
|
|
1327
|
+
canPlayType: ""
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
var apiFramework = (mf.getAttribute("apiFramework") || "").toUpperCase();
|
|
1331
|
+
if (apiFramework === "VPAID") {
|
|
1332
|
+
return {
|
|
1333
|
+
category: "vpaid",
|
|
1334
|
+
whyRejected: "vpaid_not_supported",
|
|
1335
|
+
canPlayType: ""
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
try {
|
|
1339
|
+
var protocol = new URL(url).protocol;
|
|
1340
|
+
if (protocol !== "https:" && protocol !== "http:") {
|
|
1341
|
+
return {
|
|
1342
|
+
category: "invalid_url",
|
|
1343
|
+
whyRejected: "protocol_".concat(protocol),
|
|
1344
|
+
canPlayType: ""
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
} catch (unused) {
|
|
1348
|
+
return {
|
|
1349
|
+
category: "invalid_url",
|
|
1350
|
+
whyRejected: "unparseable_url",
|
|
1351
|
+
canPlayType: ""
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1355
|
+
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1356
|
+
var file = {
|
|
1357
|
+
url: url,
|
|
1358
|
+
type: type,
|
|
1359
|
+
width: parseInt(mf.getAttribute("width") || "1920", 10),
|
|
1360
|
+
height: parseInt(mf.getAttribute("height") || "1080", 10),
|
|
1361
|
+
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0,
|
|
1362
|
+
delivery: delivery,
|
|
1363
|
+
codec: codec
|
|
1364
|
+
};
|
|
1365
|
+
if (isAudioMediaFile(file)) {
|
|
1366
|
+
return {
|
|
1367
|
+
category: "audio_only",
|
|
1368
|
+
whyRejected: type.toLowerCase().startsWith("audio/") ? "audio_mime" : "audio_extension",
|
|
1369
|
+
canPlayType: ""
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
var isHls = isHlsMediaFile(file);
|
|
1373
|
+
var hasExplicitDimensions = mf.getAttribute("width") != null && mf.getAttribute("height") != null;
|
|
1374
|
+
if (!isHls && hasExplicitDimensions && (file.width <= 1 || file.height <= 1)) {
|
|
1375
|
+
return {
|
|
1376
|
+
category: "audio_only",
|
|
1377
|
+
whyRejected: "zero_dimensions",
|
|
1378
|
+
canPlayType: ""
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
var probe = getMediaProbe();
|
|
1382
|
+
if (isHls) {
|
|
1383
|
+
var _ref;
|
|
1384
|
+
var nativeHls = (_ref = probe === null || probe === void 0 ? void 0 : probe.canPlayType("application/vnd.apple.mpegurl")) !== null && _ref !== void 0 ? _ref : "";
|
|
1385
|
+
if (import_hls.default.isSupported()) {
|
|
1386
|
+
return {
|
|
1387
|
+
file: file,
|
|
1388
|
+
whyAccepted: "hls_js",
|
|
1389
|
+
canPlayType: nativeHls
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
if (nativeHls !== "") {
|
|
1393
|
+
return {
|
|
1394
|
+
file: file,
|
|
1395
|
+
whyAccepted: "native_hls",
|
|
1396
|
+
canPlayType: nativeHls
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
return {
|
|
1400
|
+
category: "unsupported_hls",
|
|
1401
|
+
whyRejected: "no_hls_support",
|
|
1402
|
+
canPlayType: nativeHls
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
if (!isProgressiveMediaFile(file)) {
|
|
1406
|
+
return {
|
|
1407
|
+
category: "unsupported_mime",
|
|
1408
|
+
whyRejected: "not_a_video_mime",
|
|
1409
|
+
canPlayType: ""
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
if (!probe) {
|
|
1413
|
+
return {
|
|
1414
|
+
file: file,
|
|
1415
|
+
whyAccepted: "no_probe_available",
|
|
1416
|
+
canPlayType: ""
|
|
1417
|
+
};
|
|
1418
|
+
}
|
|
1419
|
+
var baseType = type || "video/mp4";
|
|
1420
|
+
var canPlay2 = probe.canPlayType(baseType);
|
|
1421
|
+
if (canPlay2 === "") {
|
|
1422
|
+
return {
|
|
1423
|
+
category: "unsupported_mime",
|
|
1424
|
+
whyRejected: "canPlayType_empty",
|
|
1425
|
+
canPlayType: canPlay2
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
if (codec) {
|
|
1429
|
+
var withCodec = probe.canPlayType("".concat(baseType, '; codecs="').concat(codec, '"'));
|
|
1430
|
+
if (withCodec === "") {
|
|
1431
|
+
return {
|
|
1432
|
+
category: "unsupported_codec",
|
|
1433
|
+
whyRejected: "codec_canPlayType_empty",
|
|
1434
|
+
canPlayType: withCodec
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
return {
|
|
1438
|
+
file: file,
|
|
1439
|
+
whyAccepted: "canPlayType_".concat(withCodec),
|
|
1440
|
+
canPlayType: withCodec
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
return {
|
|
1444
|
+
file: file,
|
|
1445
|
+
whyAccepted: "canPlayType_".concat(canPlay2),
|
|
1446
|
+
canPlayType: canPlay2
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
function collectVideoMediaFiles(linear, verbose, stats) {
|
|
1189
1450
|
var mediaFileElements = linear.querySelectorAll(":scope > MediaFiles > MediaFile");
|
|
1190
1451
|
var mediaFiles = [];
|
|
1452
|
+
if (stats) stats.total += mediaFileElements.length;
|
|
1191
1453
|
if (verbose) {
|
|
1192
1454
|
console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
|
|
1193
1455
|
}
|
|
1194
1456
|
mediaFileElements.forEach(function(mf, index) {
|
|
1195
1457
|
var _mf_textContent;
|
|
1196
|
-
var
|
|
1458
|
+
var result = evaluateMediaFile(mf);
|
|
1197
1459
|
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1198
|
-
var
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
}
|
|
1216
|
-
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1217
|
-
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1218
|
-
var mediaFile = {
|
|
1219
|
-
url: url,
|
|
1220
|
-
type: type,
|
|
1221
|
-
width: parseInt(width || "1920", 10),
|
|
1222
|
-
height: parseInt(height || "1080", 10),
|
|
1223
|
-
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
1224
|
-
};
|
|
1225
|
-
if (isAudioMediaFile(mediaFile)) {
|
|
1226
|
-
console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
|
|
1460
|
+
var accepted = "file" in result;
|
|
1461
|
+
logFunnel("mediafile_evaluated", {
|
|
1462
|
+
reason: accepted ? "accepted" : result.category,
|
|
1463
|
+
index: index,
|
|
1464
|
+
type: mf.getAttribute("type") || "",
|
|
1465
|
+
delivery: mf.getAttribute("delivery") || void 0,
|
|
1466
|
+
codec: mf.getAttribute("codec") || void 0,
|
|
1467
|
+
apiFramework: mf.getAttribute("apiFramework") || void 0,
|
|
1468
|
+
width: mf.getAttribute("width"),
|
|
1469
|
+
height: mf.getAttribute("height"),
|
|
1470
|
+
fileUrl: redactUrl(url),
|
|
1471
|
+
canPlayType: result.canPlayType,
|
|
1472
|
+
whyAccepted: accepted ? result.whyAccepted : void 0,
|
|
1473
|
+
whyRejected: accepted ? void 0 : result.whyRejected
|
|
1474
|
+
});
|
|
1475
|
+
if ("file" in result) {
|
|
1476
|
+
mediaFiles.push(result.file);
|
|
1227
1477
|
return;
|
|
1228
1478
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
return;
|
|
1479
|
+
if (stats) {
|
|
1480
|
+
var _stats_categories_result_category;
|
|
1481
|
+
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;
|
|
1233
1482
|
}
|
|
1234
|
-
if (
|
|
1235
|
-
|
|
1236
|
-
if (verbose) {
|
|
1237
|
-
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
1238
|
-
}
|
|
1239
|
-
} else if (verbose) {
|
|
1240
|
-
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
1483
|
+
if (result.category === "audio_only") {
|
|
1484
|
+
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'));
|
|
1241
1485
|
}
|
|
1242
1486
|
});
|
|
1243
1487
|
return mediaFiles;
|
|
@@ -1361,26 +1605,58 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1361
1605
|
}
|
|
1362
1606
|
function parseVastXml(xmlString) {
|
|
1363
1607
|
try {
|
|
1364
|
-
var _adElements_find;
|
|
1365
1608
|
var xmlDoc = parseXml(xmlString);
|
|
1366
1609
|
if (!xmlDoc) return {
|
|
1367
1610
|
type: "empty"
|
|
1368
1611
|
};
|
|
1369
1612
|
var root = xmlDoc.documentElement;
|
|
1370
1613
|
var adElements = Array.from(root.querySelectorAll(":scope > Ad"));
|
|
1371
|
-
|
|
1372
|
-
return getAdSequence(el) === void 0;
|
|
1373
|
-
})) !== null && _adElements_find !== void 0 ? _adElements_find : adElements[0];
|
|
1374
|
-
if (!adElement) {
|
|
1614
|
+
if (adElements.length === 0) {
|
|
1375
1615
|
var _root_getAttribute;
|
|
1376
1616
|
console.warn("[HlsAdPlayer] No Ad element found in VAST ".concat((_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : "", " response"));
|
|
1377
1617
|
return emptyVastResult(root);
|
|
1378
1618
|
}
|
|
1379
|
-
var
|
|
1380
|
-
|
|
1381
|
-
|
|
1619
|
+
var ordered = _to_consumable_array(adElements.filter(function(el) {
|
|
1620
|
+
return getAdSequence(el) === void 0;
|
|
1621
|
+
})).concat(_to_consumable_array(adElements.filter(function(el) {
|
|
1622
|
+
return getAdSequence(el) !== void 0;
|
|
1623
|
+
})));
|
|
1624
|
+
var firstEmpty;
|
|
1625
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1626
|
+
try {
|
|
1627
|
+
for(var _iterator = ordered.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1628
|
+
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], adElement = _step_value[1];
|
|
1629
|
+
var parsed = parseAdElement(adElement, true);
|
|
1630
|
+
if (parsed.type === "empty") {
|
|
1631
|
+
firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : firstEmpty = parsed;
|
|
1632
|
+
continue;
|
|
1633
|
+
}
|
|
1634
|
+
if (index > 0) {
|
|
1635
|
+
logFunnel("vast_ad_fallback", {
|
|
1636
|
+
usedAdIndex: index,
|
|
1637
|
+
adCount: ordered.length
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
if (parsed.type === "wrapper") {
|
|
1641
|
+
console.log("[HlsAdPlayer] VAST wrapper detected, following VASTAdTagURI: ".concat(parsed.vastAdTagUri));
|
|
1642
|
+
}
|
|
1643
|
+
return parsed;
|
|
1644
|
+
}
|
|
1645
|
+
} catch (err) {
|
|
1646
|
+
_didIteratorError = true;
|
|
1647
|
+
_iteratorError = err;
|
|
1648
|
+
} finally{
|
|
1649
|
+
try {
|
|
1650
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1651
|
+
_iterator.return();
|
|
1652
|
+
}
|
|
1653
|
+
} finally{
|
|
1654
|
+
if (_didIteratorError) {
|
|
1655
|
+
throw _iteratorError;
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1382
1658
|
}
|
|
1383
|
-
return
|
|
1659
|
+
return firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : emptyVastResult(root);
|
|
1384
1660
|
} catch (error) {
|
|
1385
1661
|
console.error("[HlsAdPlayer] Error parsing VAST XML:", error);
|
|
1386
1662
|
return {
|
|
@@ -1426,6 +1702,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1426
1702
|
pushUrls(errorUrls, inLine.querySelectorAll(":scope > Error"));
|
|
1427
1703
|
if (adElement.getAttribute("conditionalAd") === "true") {
|
|
1428
1704
|
console.warn("[HlsAdPlayer] Skipping conditional <Ad> (VPAID-only)");
|
|
1705
|
+
logFunnel("vast_no_supported_media", {
|
|
1706
|
+
reason: "vpaid",
|
|
1707
|
+
conditionalAd: true
|
|
1708
|
+
});
|
|
1429
1709
|
return {
|
|
1430
1710
|
type: "empty",
|
|
1431
1711
|
errorUrls: errorUrls,
|
|
@@ -1434,11 +1714,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1434
1714
|
}
|
|
1435
1715
|
var linear;
|
|
1436
1716
|
var mediaFiles = [];
|
|
1717
|
+
var rejectStats = {
|
|
1718
|
+
total: 0,
|
|
1719
|
+
categories: {}
|
|
1720
|
+
};
|
|
1437
1721
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1438
1722
|
try {
|
|
1439
1723
|
for(var _iterator = Array.from(inLine.querySelectorAll(":scope > Creatives > Creative > Linear"))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1440
1724
|
var candidate = _step.value;
|
|
1441
|
-
var files = collectVideoMediaFiles(candidate, verbose);
|
|
1725
|
+
var files = collectVideoMediaFiles(candidate, verbose, rejectStats);
|
|
1442
1726
|
if (files.length > 0) {
|
|
1443
1727
|
linear = candidate;
|
|
1444
1728
|
mediaFiles = files;
|
|
@@ -1461,6 +1745,39 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1461
1745
|
}
|
|
1462
1746
|
if (!linear) {
|
|
1463
1747
|
console.warn("[HlsAdPlayer] No supported linear media files in <Ad>");
|
|
1748
|
+
var reason = "missing_media";
|
|
1749
|
+
var top = 0;
|
|
1750
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
1751
|
+
try {
|
|
1752
|
+
for(var _iterator1 = Object.keys(rejectStats.categories)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
1753
|
+
var category = _step1.value;
|
|
1754
|
+
var _rejectStats_categories_category;
|
|
1755
|
+
var count = (_rejectStats_categories_category = rejectStats.categories[category]) !== null && _rejectStats_categories_category !== void 0 ? _rejectStats_categories_category : 0;
|
|
1756
|
+
if (count > top) {
|
|
1757
|
+
top = count;
|
|
1758
|
+
reason = category;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
} catch (err) {
|
|
1762
|
+
_didIteratorError1 = true;
|
|
1763
|
+
_iteratorError1 = err;
|
|
1764
|
+
} finally{
|
|
1765
|
+
try {
|
|
1766
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1767
|
+
_iterator1.return();
|
|
1768
|
+
}
|
|
1769
|
+
} finally{
|
|
1770
|
+
if (_didIteratorError1) {
|
|
1771
|
+
throw _iteratorError1;
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
if (rejectStats.total > 0 && top === 0) reason = "other";
|
|
1776
|
+
logFunnel("vast_no_supported_media", {
|
|
1777
|
+
reason: reason,
|
|
1778
|
+
mediaFileCount: rejectStats.total,
|
|
1779
|
+
rejectedByCategory: rejectStats.categories
|
|
1780
|
+
});
|
|
1464
1781
|
return {
|
|
1465
1782
|
type: "empty",
|
|
1466
1783
|
errorUrls: errorUrls,
|
|
@@ -1490,27 +1807,65 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1490
1807
|
}
|
|
1491
1808
|
}
|
|
1492
1809
|
function fetchVastXml(vastTagUrl) {
|
|
1493
|
-
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
1810
|
+
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include", kind = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "gam";
|
|
1494
1811
|
return _async_to_generator(function() {
|
|
1495
|
-
var controller, timeoutId, requestVast, response, error, error1;
|
|
1812
|
+
var controller, timeoutId, startedAt, attempt, requestVast, response, error, error1;
|
|
1496
1813
|
return _ts_generator(this, function(_state) {
|
|
1497
1814
|
switch(_state.label){
|
|
1498
1815
|
case 0:
|
|
1816
|
+
if (destroyed) {
|
|
1817
|
+
throw new Error("VAST request skipped: ad player destroyed");
|
|
1818
|
+
}
|
|
1499
1819
|
controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1820
|
+
if (controller) pendingVastRequests.add(controller);
|
|
1500
1821
|
timeoutId = controller ? setTimeout(function() {
|
|
1501
1822
|
return controller.abort();
|
|
1502
1823
|
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
1824
|
+
startedAt = Date.now();
|
|
1825
|
+
attempt = 0;
|
|
1503
1826
|
requestVast = function requestVast(creds) {
|
|
1504
|
-
return
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1827
|
+
return _async_to_generator(function() {
|
|
1828
|
+
var response;
|
|
1829
|
+
return _ts_generator(this, function(_state) {
|
|
1830
|
+
switch(_state.label){
|
|
1831
|
+
case 0:
|
|
1832
|
+
attempt++;
|
|
1833
|
+
if (kind === "gam") {
|
|
1834
|
+
logFunnel("gam_http_request_sent", {
|
|
1835
|
+
attempt: attempt,
|
|
1836
|
+
credentials: creds
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
return [
|
|
1840
|
+
4,
|
|
1841
|
+
fetch(vastTagUrl, _object_spread({
|
|
1842
|
+
mode: "cors",
|
|
1843
|
+
credentials: creds,
|
|
1844
|
+
headers: {
|
|
1845
|
+
"Accept": "application/xml, text/xml, */*"
|
|
1846
|
+
},
|
|
1847
|
+
referrerPolicy: "no-referrer-when-downgrade"
|
|
1848
|
+
}, controller ? {
|
|
1849
|
+
signal: controller.signal
|
|
1850
|
+
} : {}))
|
|
1851
|
+
];
|
|
1852
|
+
case 1:
|
|
1853
|
+
response = _state.sent();
|
|
1854
|
+
if (kind === "gam") {
|
|
1855
|
+
logFunnel("gam_response_received", {
|
|
1856
|
+
attempt: attempt,
|
|
1857
|
+
httpStatus: response.status,
|
|
1858
|
+
ok: response.ok,
|
|
1859
|
+
elapsedMs: Date.now() - startedAt
|
|
1860
|
+
});
|
|
1861
|
+
}
|
|
1862
|
+
return [
|
|
1863
|
+
2,
|
|
1864
|
+
response
|
|
1865
|
+
];
|
|
1866
|
+
}
|
|
1867
|
+
});
|
|
1868
|
+
})();
|
|
1514
1869
|
};
|
|
1515
1870
|
_state.label = 1;
|
|
1516
1871
|
case 1:
|
|
@@ -1545,6 +1900,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1545
1900
|
6
|
|
1546
1901
|
];
|
|
1547
1902
|
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
1903
|
+
logFunnel("vast_credentials_retry", {
|
|
1904
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1905
|
+
});
|
|
1548
1906
|
return [
|
|
1549
1907
|
4,
|
|
1550
1908
|
requestVast("omit")
|
|
@@ -1564,7 +1922,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1564
1922
|
];
|
|
1565
1923
|
case 8:
|
|
1566
1924
|
if (!response.ok) {
|
|
1567
|
-
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
1925
|
+
throw new Error("Failed to fetch VAST: HTTP ".concat(response.status, " ").concat(response.statusText));
|
|
1568
1926
|
}
|
|
1569
1927
|
return [
|
|
1570
1928
|
4,
|
|
@@ -1578,11 +1936,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1578
1936
|
case 10:
|
|
1579
1937
|
error1 = _state.sent();
|
|
1580
1938
|
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1939
|
+
if (pendingRequestAbortReason) {
|
|
1940
|
+
throw new Error("".concat(pendingRequestAbortReason, ": ").concat(vastTagUrl));
|
|
1941
|
+
}
|
|
1581
1942
|
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1582
1943
|
}
|
|
1583
1944
|
throw error1;
|
|
1584
1945
|
case 11:
|
|
1585
1946
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1947
|
+
if (controller) pendingVastRequests.delete(controller);
|
|
1586
1948
|
return [
|
|
1587
1949
|
7
|
|
1588
1950
|
];
|
|
@@ -1596,7 +1958,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1596
1958
|
}
|
|
1597
1959
|
function fetchAndParseVastAd(_0) {
|
|
1598
1960
|
return _async_to_generator(function(vastTagUrl) {
|
|
1599
|
-
var depth, accumulatedTracking, rules, vastXml, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1961
|
+
var depth, accumulatedTracking, rules, vastXml, fetchStartedAt, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1600
1962
|
var _arguments = arguments;
|
|
1601
1963
|
return _ts_generator(this, function(_state) {
|
|
1602
1964
|
switch(_state.label){
|
|
@@ -1604,6 +1966,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1604
1966
|
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] : {
|
|
1605
1967
|
followAdditionalWrappers: true
|
|
1606
1968
|
};
|
|
1969
|
+
if (destroyed) return [
|
|
1970
|
+
2,
|
|
1971
|
+
null
|
|
1972
|
+
];
|
|
1973
|
+
fetchStartedAt = Date.now();
|
|
1607
1974
|
_state.label = 1;
|
|
1608
1975
|
case 1:
|
|
1609
1976
|
_state.trys.push([
|
|
@@ -1614,7 +1981,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1614
1981
|
]);
|
|
1615
1982
|
return [
|
|
1616
1983
|
4,
|
|
1617
|
-
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit")
|
|
1984
|
+
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit", depth === 0 ? "gam" : "wrapper")
|
|
1618
1985
|
];
|
|
1619
1986
|
case 2:
|
|
1620
1987
|
vastXml = _state.sent();
|
|
@@ -1626,14 +1993,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1626
1993
|
error = _state.sent();
|
|
1627
1994
|
if (depth === 0) throw error;
|
|
1628
1995
|
console.warn("[HlsAdPlayer] Wrapped VAST request failed:", error);
|
|
1629
|
-
|
|
1630
|
-
|
|
1996
|
+
logFunnel("wrapper_fetch", {
|
|
1997
|
+
reason: "failure",
|
|
1998
|
+
depth: depth,
|
|
1999
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
2000
|
+
elapsedMs: Date.now() - fetchStartedAt,
|
|
2001
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1631
2002
|
});
|
|
2003
|
+
if (!destroyed) {
|
|
2004
|
+
fireTrackingPixels(accumulatedTracking.error, {
|
|
2005
|
+
errorCode: VAST_ERROR_WRAPPER_TIMEOUT
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
1632
2008
|
return [
|
|
1633
2009
|
2,
|
|
1634
2010
|
null
|
|
1635
2011
|
];
|
|
1636
2012
|
case 4:
|
|
2013
|
+
if (destroyed) return [
|
|
2014
|
+
2,
|
|
2015
|
+
null
|
|
2016
|
+
];
|
|
2017
|
+
if (depth > 0) {
|
|
2018
|
+
logFunnel("wrapper_fetch", {
|
|
2019
|
+
reason: "success",
|
|
2020
|
+
depth: depth,
|
|
2021
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
2022
|
+
elapsedMs: Date.now() - fetchStartedAt
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
1637
2025
|
console.log("[HlsAdPlayer] VAST XML received");
|
|
1638
2026
|
console.log("[HlsAdPlayer] VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1639
2027
|
parsed = parseVastXml(vastXml);
|
|
@@ -1665,6 +2053,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1665
2053
|
];
|
|
1666
2054
|
}
|
|
1667
2055
|
mergeTrackingUrls(parsed.ad.trackingUrls, accumulatedTracking);
|
|
2056
|
+
logFunnel("inline_resolved", {
|
|
2057
|
+
depth: depth
|
|
2058
|
+
});
|
|
1668
2059
|
return [
|
|
1669
2060
|
2,
|
|
1670
2061
|
parsed.ad
|
|
@@ -1675,20 +2066,29 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1675
2066
|
}
|
|
1676
2067
|
function fetchAndParsePod(vastTagUrl) {
|
|
1677
2068
|
return _async_to_generator(function() {
|
|
1678
|
-
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements,
|
|
2069
|
+
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;
|
|
1679
2070
|
return _ts_generator(this, function(_state) {
|
|
1680
2071
|
switch(_state.label){
|
|
1681
2072
|
case 0:
|
|
2073
|
+
lastPodAdElementCount = 0;
|
|
1682
2074
|
return [
|
|
1683
2075
|
4,
|
|
1684
2076
|
fetchVastXml(vastTagUrl)
|
|
1685
2077
|
];
|
|
1686
2078
|
case 1:
|
|
1687
2079
|
vastXml = _state.sent();
|
|
2080
|
+
if (destroyed) return [
|
|
2081
|
+
2,
|
|
2082
|
+
[]
|
|
2083
|
+
];
|
|
1688
2084
|
console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
|
|
1689
2085
|
trimmedXml = vastXml.trim();
|
|
1690
2086
|
if (trimmedXml.length === 0) {
|
|
1691
2087
|
console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
|
|
2088
|
+
logFunnel("vast_parsed", {
|
|
2089
|
+
adElementCount: 0,
|
|
2090
|
+
reason: "empty_body"
|
|
2091
|
+
});
|
|
1692
2092
|
return [
|
|
1693
2093
|
2,
|
|
1694
2094
|
[]
|
|
@@ -1697,6 +2097,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1697
2097
|
xmlDoc = parseXml(vastXml);
|
|
1698
2098
|
if (!xmlDoc) {
|
|
1699
2099
|
console.error("[HlsAdPlayer] Pod VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
2100
|
+
logFunnel("vast_parsed", {
|
|
2101
|
+
adElementCount: 0,
|
|
2102
|
+
reason: "xml_parse_error"
|
|
2103
|
+
});
|
|
1700
2104
|
return [
|
|
1701
2105
|
2,
|
|
1702
2106
|
[]
|
|
@@ -1704,10 +2108,21 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1704
2108
|
}
|
|
1705
2109
|
root = xmlDoc.documentElement;
|
|
1706
2110
|
adElements = Array.from(root.querySelectorAll(":scope > Ad"));
|
|
2111
|
+
logFunnel("vast_parsed", {
|
|
2112
|
+
reason: adElements.length > 0 ? "has_ads" : "no_ads",
|
|
2113
|
+
vastVersion: (_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : void 0,
|
|
2114
|
+
adElementCount: adElements.length,
|
|
2115
|
+
inlineCount: adElements.filter(function(el) {
|
|
2116
|
+
return el.querySelector(":scope > InLine");
|
|
2117
|
+
}).length,
|
|
2118
|
+
wrapperCount: adElements.filter(function(el) {
|
|
2119
|
+
return el.querySelector(":scope > Wrapper");
|
|
2120
|
+
}).length
|
|
2121
|
+
});
|
|
1707
2122
|
if (adElements.length === 0) {
|
|
1708
2123
|
;
|
|
1709
2124
|
;
|
|
1710
|
-
console.warn("[HlsAdPlayer] No <Ad> elements in VAST ".concat((
|
|
2125
|
+
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)"));
|
|
1711
2126
|
empty = emptyVastResult(root);
|
|
1712
2127
|
if (empty.type === "empty" && ((_empty_errorUrls = empty.errorUrls) === null || _empty_errorUrls === void 0 ? void 0 : _empty_errorUrls.length)) {
|
|
1713
2128
|
;
|
|
@@ -1725,10 +2140,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1725
2140
|
var _parsed_errorUrls, parsed, _parsed_errorCode;
|
|
1726
2141
|
return _ts_generator(this, function(_state) {
|
|
1727
2142
|
parsed = parseAdElement(adElement);
|
|
1728
|
-
if (parsed.type === "inline")
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
2143
|
+
if (parsed.type === "inline") {
|
|
2144
|
+
logFunnel("inline_resolved", {
|
|
2145
|
+
depth: 0
|
|
2146
|
+
});
|
|
2147
|
+
return [
|
|
2148
|
+
2,
|
|
2149
|
+
parsed.ad
|
|
2150
|
+
];
|
|
2151
|
+
}
|
|
1732
2152
|
if (parsed.type === "wrapper") {
|
|
1733
2153
|
return [
|
|
1734
2154
|
2,
|
|
@@ -1906,7 +2326,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1906
2326
|
7
|
|
1907
2327
|
];
|
|
1908
2328
|
case 21:
|
|
1909
|
-
console.log("[HlsAdPlayer] Parsed ".concat(ads.length, " ad(s) from VAST ").concat((
|
|
2329
|
+
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"));
|
|
2330
|
+
lastPodAdElementCount = adElements.length;
|
|
1910
2331
|
return [
|
|
1911
2332
|
2,
|
|
1912
2333
|
ads
|
|
@@ -1972,14 +2393,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1972
2393
|
var progress = currentTime / currentAd.duration;
|
|
1973
2394
|
if (progress >= 0.25 && !trackingFired.firstQuartile) {
|
|
1974
2395
|
trackingFired.firstQuartile = true;
|
|
2396
|
+
logFunnel("first_quartile");
|
|
1975
2397
|
fireTrackingPixels(currentAd.trackingUrls.firstQuartile);
|
|
1976
2398
|
}
|
|
1977
2399
|
if (progress >= 0.5 && !trackingFired.midpoint) {
|
|
1978
2400
|
trackingFired.midpoint = true;
|
|
2401
|
+
logFunnel("midpoint");
|
|
1979
2402
|
fireTrackingPixels(currentAd.trackingUrls.midpoint);
|
|
1980
2403
|
}
|
|
1981
2404
|
if (progress >= 0.75 && !trackingFired.thirdQuartile) {
|
|
1982
2405
|
trackingFired.thirdQuartile = true;
|
|
2406
|
+
logFunnel("third_quartile");
|
|
1983
2407
|
fireTrackingPixels(currentAd.trackingUrls.thirdQuartile);
|
|
1984
2408
|
}
|
|
1985
2409
|
};
|
|
@@ -2002,6 +2426,16 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2002
2426
|
if (!trackingFired.impression) {
|
|
2003
2427
|
trackingFired.impression = true;
|
|
2004
2428
|
resolvedAds.add(currentAd);
|
|
2429
|
+
logFunnel("playing", {
|
|
2430
|
+
mutedByAutoplay: forcedMuteByAutoplay,
|
|
2431
|
+
candidateIndex: mediaCandidateIndex
|
|
2432
|
+
});
|
|
2433
|
+
logFunnel("impression_fired", {
|
|
2434
|
+
pixelCount: currentAd.trackingUrls.impression.length
|
|
2435
|
+
});
|
|
2436
|
+
if (currentAd.trackingUrls.impression.length === 0) {
|
|
2437
|
+
console.warn("[HlsAdPlayer] Ad started but VAST contained no <Impression> URLs - GAM will not count it");
|
|
2438
|
+
}
|
|
2005
2439
|
fireTrackingPixels(currentAd.trackingUrls.impression);
|
|
2006
2440
|
fireTrackingPixels(currentAd.trackingUrls.creativeView);
|
|
2007
2441
|
fireTrackingPixels(currentAd.trackingUrls.verificationNotExecuted, {
|
|
@@ -2024,6 +2458,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2024
2458
|
sampleViewability();
|
|
2025
2459
|
settleViewability();
|
|
2026
2460
|
trackingFired.complete = true;
|
|
2461
|
+
logFunnel("complete");
|
|
2027
2462
|
fireTrackingPixels(currentAd.trackingUrls.complete);
|
|
2028
2463
|
console.log("[HlsAdPlayer] Ad completed");
|
|
2029
2464
|
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
|
|
@@ -2032,16 +2467,41 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2032
2467
|
handleAdComplete();
|
|
2033
2468
|
};
|
|
2034
2469
|
var onError = function onError(e) {
|
|
2470
|
+
var _adVideoElement_error, _adVideoElement_error1;
|
|
2035
2471
|
if (!adPlaying) return;
|
|
2036
2472
|
console.error("[HlsAdPlayer] Ad video error:", e);
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2473
|
+
var vastErrorCode = toVastMediaErrorCode(adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.error);
|
|
2474
|
+
logFunnel("media_error", {
|
|
2475
|
+
mediaErrorCode: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error = adVideoElement.error) === null || _adVideoElement_error === void 0 ? void 0 : _adVideoElement_error.code,
|
|
2476
|
+
errorMessage: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error1 = adVideoElement.error) === null || _adVideoElement_error1 === void 0 ? void 0 : _adVideoElement_error1.message,
|
|
2477
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2478
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2479
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2480
|
+
vastErrorCode: vastErrorCode
|
|
2481
|
+
});
|
|
2482
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2483
|
+
};
|
|
2484
|
+
var onMediaDiagnostic = function onMediaDiagnostic(event) {
|
|
2485
|
+
if (!adPlaying || !adVideoElement || trackingFired.impression) return;
|
|
2486
|
+
if (!adVideoElement.currentSrc) return;
|
|
2487
|
+
logFunnel("media_event", {
|
|
2488
|
+
reason: event.type,
|
|
2489
|
+
readyState: adVideoElement.readyState,
|
|
2490
|
+
networkState: adVideoElement.networkState,
|
|
2491
|
+
currentSrc: adVideoElement.currentSrc
|
|
2492
|
+
});
|
|
2042
2493
|
};
|
|
2043
2494
|
var onVolumeChange = function onVolumeChange() {
|
|
2044
2495
|
if (!currentAd || !adVideoElement) return;
|
|
2496
|
+
if (forcedMuteByAutoplay && !adVideoElement.muted) {
|
|
2497
|
+
var userActivation = navigator.userActivation;
|
|
2498
|
+
if (userActivation && !userActivation.isActive) {
|
|
2499
|
+
logFunnel("unexpected_unmute", {
|
|
2500
|
+
paused: adVideoElement.paused
|
|
2501
|
+
});
|
|
2502
|
+
}
|
|
2503
|
+
forcedMuteByAutoplay = false;
|
|
2504
|
+
}
|
|
2045
2505
|
var muted = adVideoElement.muted || adVideoElement.volume === 0;
|
|
2046
2506
|
if (!trackingFired.start) {
|
|
2047
2507
|
trackingFired.lastMuted = muted;
|
|
@@ -2101,6 +2561,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2101
2561
|
{
|
|
2102
2562
|
type: "play",
|
|
2103
2563
|
handler: onPlay
|
|
2564
|
+
},
|
|
2565
|
+
{
|
|
2566
|
+
type: "stalled",
|
|
2567
|
+
handler: onMediaDiagnostic
|
|
2568
|
+
},
|
|
2569
|
+
{
|
|
2570
|
+
type: "suspend",
|
|
2571
|
+
handler: onMediaDiagnostic
|
|
2572
|
+
},
|
|
2573
|
+
{
|
|
2574
|
+
type: "abort",
|
|
2575
|
+
handler: onMediaDiagnostic
|
|
2576
|
+
},
|
|
2577
|
+
{
|
|
2578
|
+
type: "emptied",
|
|
2579
|
+
handler: onMediaDiagnostic
|
|
2104
2580
|
}
|
|
2105
2581
|
];
|
|
2106
2582
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -2390,16 +2866,51 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2390
2866
|
function settlePendingPlay() {
|
|
2391
2867
|
pendingPlayPromise = void 0;
|
|
2392
2868
|
}
|
|
2869
|
+
function toVastPlayErrorCode(error) {
|
|
2870
|
+
return (error === null || error === void 0 ? void 0 : error.name) === "NotSupportedError" ? VAST_ERROR_NO_SUPPORTED_MEDIA : VAST_ERROR_MEDIA_DISPLAY;
|
|
2871
|
+
}
|
|
2872
|
+
function failAdPlayback(context, error) {
|
|
2873
|
+
var vastErrorCode = toVastPlayErrorCode(error);
|
|
2874
|
+
console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
|
|
2875
|
+
logFunnel("play_failed", {
|
|
2876
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2877
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message,
|
|
2878
|
+
vastErrorCode: vastErrorCode
|
|
2879
|
+
});
|
|
2880
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2881
|
+
}
|
|
2393
2882
|
function startAdPlayback(context) {
|
|
2883
|
+
var isMutedRetry = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
2394
2884
|
if (!adVideoElement) return;
|
|
2885
|
+
var computed = typeof getComputedStyle === "function" && adContainerEl ? getComputedStyle(adContainerEl) : void 0;
|
|
2886
|
+
logFunnel(isMutedRetry ? "muted_retry" : "play_called", {
|
|
2887
|
+
context: context,
|
|
2888
|
+
isConnected: adVideoElement.isConnected,
|
|
2889
|
+
clientWidth: adVideoElement.clientWidth,
|
|
2890
|
+
clientHeight: adVideoElement.clientHeight,
|
|
2891
|
+
containerDisplay: computed === null || computed === void 0 ? void 0 : computed.display,
|
|
2892
|
+
containerVisibility: computed === null || computed === void 0 ? void 0 : computed.visibility
|
|
2893
|
+
});
|
|
2395
2894
|
var playPromise = adVideoElement.play();
|
|
2396
2895
|
pendingPlayPromise = playPromise;
|
|
2397
2896
|
playPromise.catch(function(error) {
|
|
2398
2897
|
if (pendingPlayPromise !== playPromise) {
|
|
2399
2898
|
return;
|
|
2400
2899
|
}
|
|
2401
|
-
|
|
2402
|
-
|
|
2900
|
+
logFunnel("play_rejected", {
|
|
2901
|
+
context: context,
|
|
2902
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2903
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
2904
|
+
});
|
|
2905
|
+
if (!isMutedRetry && (error === null || error === void 0 ? void 0 : error.name) === "NotAllowedError" && adVideoElement && !adVideoElement.muted) {
|
|
2906
|
+
console.warn("[HlsAdPlayer] Unmuted ".concat(context, " blocked by autoplay policy - retrying muted"));
|
|
2907
|
+
originalMutedState = true;
|
|
2908
|
+
forcedMuteByAutoplay = true;
|
|
2909
|
+
adVideoElement.muted = true;
|
|
2910
|
+
startAdPlayback(context, true);
|
|
2911
|
+
return;
|
|
2912
|
+
}
|
|
2913
|
+
failAdPlayback(context, error);
|
|
2403
2914
|
}).finally(function() {
|
|
2404
2915
|
if (pendingPlayPromise === playPromise) {
|
|
2405
2916
|
pendingPlayPromise = void 0;
|
|
@@ -2438,17 +2949,109 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2438
2949
|
adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
|
|
2439
2950
|
adVideoElement.muted = originalMutedState;
|
|
2440
2951
|
}
|
|
2952
|
+
function clearMediaStartTimer() {
|
|
2953
|
+
if (mediaStartTimerId !== void 0) {
|
|
2954
|
+
clearTimeout(mediaStartTimerId);
|
|
2955
|
+
mediaStartTimerId = void 0;
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
function startMediaStartTimer() {
|
|
2959
|
+
clearMediaStartTimer();
|
|
2960
|
+
if (!(MEDIA_START_TIMEOUT_MS > 0)) return;
|
|
2961
|
+
var startedAt = Date.now();
|
|
2962
|
+
mediaStartTimerId = setTimeout(function() {
|
|
2963
|
+
mediaStartTimerId = void 0;
|
|
2964
|
+
if (!adPlaying || trackingFired.impression) return;
|
|
2965
|
+
console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(MEDIA_START_TIMEOUT_MS, "ms"));
|
|
2966
|
+
logFunnel("play_resolved_but_never_started", {
|
|
2967
|
+
timeoutMs: MEDIA_START_TIMEOUT_MS,
|
|
2968
|
+
elapsedMs: Date.now() - startedAt,
|
|
2969
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2970
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2971
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2972
|
+
paused: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.paused,
|
|
2973
|
+
vastErrorCode: VAST_ERROR_MEDIA_TIMEOUT
|
|
2974
|
+
});
|
|
2975
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_TIMEOUT);
|
|
2976
|
+
}, MEDIA_START_TIMEOUT_MS);
|
|
2977
|
+
}
|
|
2978
|
+
function resetVideoElementForNextSource() {
|
|
2979
|
+
clearStallWatchdog();
|
|
2980
|
+
if (requiresMediaPipelineResetAfterAds()) {
|
|
2981
|
+
recreateAdVideoElement();
|
|
2982
|
+
setupAdEventListeners();
|
|
2983
|
+
} else {
|
|
2984
|
+
prepareVideoElementForNewSource();
|
|
2985
|
+
}
|
|
2986
|
+
}
|
|
2987
|
+
function tryNextMediaCandidate() {
|
|
2988
|
+
if (!currentAd || trackingFired.impression) return false;
|
|
2989
|
+
if (mediaCandidateIndex >= mediaCandidates.length - 1) return false;
|
|
2990
|
+
var failedUrl = currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url;
|
|
2991
|
+
mediaCandidateIndex++;
|
|
2992
|
+
var next = mediaCandidates[mediaCandidateIndex];
|
|
2993
|
+
if (!next) return false;
|
|
2994
|
+
logFunnel("media_fallback", {
|
|
2995
|
+
failedUrl: failedUrl,
|
|
2996
|
+
nextUrl: next.url,
|
|
2997
|
+
nextType: next.type,
|
|
2998
|
+
candidateIndex: mediaCandidateIndex,
|
|
2999
|
+
candidateCount: mediaCandidates.length
|
|
3000
|
+
});
|
|
3001
|
+
resetVideoElementForNextSource();
|
|
3002
|
+
try {
|
|
3003
|
+
loadMediaCandidate(next);
|
|
3004
|
+
return true;
|
|
3005
|
+
} catch (error) {
|
|
3006
|
+
console.error("[HlsAdPlayer] Failed to load fallback media file:", error);
|
|
3007
|
+
return tryNextMediaCandidate();
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
function recoverFromAdFailure(vastErrorCode) {
|
|
3011
|
+
clearMediaStartTimer();
|
|
3012
|
+
if (tryNextMediaCandidate()) return;
|
|
3013
|
+
reportCurrentAdError(vastErrorCode);
|
|
3014
|
+
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) return;
|
|
3015
|
+
handleAdError();
|
|
3016
|
+
}
|
|
2441
3017
|
function loadCurrentAdMedia() {
|
|
2442
3018
|
if (!adVideoElement || !currentAd) {
|
|
2443
3019
|
throw new Error("No ad video element or ad to load");
|
|
2444
3020
|
}
|
|
2445
|
-
|
|
3021
|
+
mediaCandidates = rankMediaCandidates(currentAd.mediaFiles);
|
|
3022
|
+
mediaCandidateIndex = 0;
|
|
3023
|
+
var mediaFile = mediaCandidates[0];
|
|
2446
3024
|
if (!mediaFile) {
|
|
2447
|
-
|
|
3025
|
+
logFunnel("media_unsupported", {
|
|
3026
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA,
|
|
3027
|
+
candidates: currentAd.mediaFiles.length
|
|
3028
|
+
});
|
|
3029
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
3030
|
+
throw new Error("No media file this browser can play");
|
|
3031
|
+
}
|
|
3032
|
+
try {
|
|
3033
|
+
loadMediaCandidate(mediaFile);
|
|
3034
|
+
} catch (error) {
|
|
3035
|
+
if (tryNextMediaCandidate()) return;
|
|
3036
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
3037
|
+
throw error;
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
function loadMediaCandidate(mediaFile) {
|
|
3041
|
+
if (!adVideoElement || !currentAd) {
|
|
3042
|
+
throw new Error("No ad video element or ad to load");
|
|
2448
3043
|
}
|
|
2449
3044
|
currentAdMediaFile = mediaFile;
|
|
2450
3045
|
var isHlsAd = isHlsMediaFile(mediaFile);
|
|
3046
|
+
logFunnel("media_selected", {
|
|
3047
|
+
width: mediaFile.width,
|
|
3048
|
+
height: mediaFile.height,
|
|
3049
|
+
bitrate: mediaFile.bitrate,
|
|
3050
|
+
candidateIndex: mediaCandidateIndex,
|
|
3051
|
+
candidates: mediaCandidates.length
|
|
3052
|
+
});
|
|
2451
3053
|
console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad (pod ").concat(podIndex + 1, "/").concat(podAds.length || 1, ") from: ").concat(mediaFile.url));
|
|
3054
|
+
startMediaStartTimer();
|
|
2452
3055
|
if (isHlsAd && import_hls.default.isSupported()) {
|
|
2453
3056
|
if (adHls) {
|
|
2454
3057
|
adHls.destroy();
|
|
@@ -2457,6 +3060,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2457
3060
|
enableWorker: true,
|
|
2458
3061
|
lowLatencyMode: false
|
|
2459
3062
|
});
|
|
3063
|
+
logFunnel("media_load", {
|
|
3064
|
+
pipeline: "hls.js"
|
|
3065
|
+
});
|
|
2460
3066
|
adHls.loadSource(mediaFile.url);
|
|
2461
3067
|
adHls.attachMedia(adVideoElement);
|
|
2462
3068
|
adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
|
|
@@ -2466,10 +3072,24 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2466
3072
|
adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
|
|
2467
3073
|
console.error("[HlsAdPlayer] HLS error:", data);
|
|
2468
3074
|
if (data.fatal) {
|
|
2469
|
-
|
|
3075
|
+
var _data_response, _data_response1, _data_frag;
|
|
3076
|
+
var vastErrorCode = data.type === import_hls.default.ErrorTypes.NETWORK_ERROR ? 401 : VAST_ERROR_MEDIA_DISPLAY;
|
|
3077
|
+
logFunnel("hls_fatal", {
|
|
3078
|
+
reason: data.details,
|
|
3079
|
+
errorName: data.type,
|
|
3080
|
+
errorMessage: data.details,
|
|
3081
|
+
responseCode: (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.code,
|
|
3082
|
+
responseText: (_data_response1 = data.response) === null || _data_response1 === void 0 ? void 0 : _data_response1.text,
|
|
3083
|
+
fragUrl: (_data_frag = data.frag) === null || _data_frag === void 0 ? void 0 : _data_frag.url,
|
|
3084
|
+
vastErrorCode: vastErrorCode
|
|
3085
|
+
});
|
|
3086
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2470
3087
|
}
|
|
2471
3088
|
});
|
|
2472
3089
|
} else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
|
|
3090
|
+
logFunnel("media_load", {
|
|
3091
|
+
pipeline: "native-hls"
|
|
3092
|
+
});
|
|
2473
3093
|
adVideoElement.src = mediaFile.url;
|
|
2474
3094
|
startAdPlayback("native HLS ad playback");
|
|
2475
3095
|
} else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
|
|
@@ -2477,45 +3097,47 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2477
3097
|
adHls.destroy();
|
|
2478
3098
|
adHls = void 0;
|
|
2479
3099
|
}
|
|
3100
|
+
logFunnel("media_load", {
|
|
3101
|
+
pipeline: "progressive"
|
|
3102
|
+
});
|
|
2480
3103
|
adVideoElement.src = mediaFile.url;
|
|
2481
3104
|
adVideoElement.load();
|
|
2482
3105
|
startAdPlayback("progressive ad playback");
|
|
2483
3106
|
} else {
|
|
3107
|
+
clearMediaStartTimer();
|
|
3108
|
+
logFunnel("media_unsupported", {
|
|
3109
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA
|
|
3110
|
+
});
|
|
2484
3111
|
throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
|
|
2485
3112
|
}
|
|
2486
3113
|
}
|
|
2487
3114
|
function advanceToNextPodAd() {
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
index: podIndex,
|
|
2510
|
-
total: podAds.length
|
|
2511
|
-
});
|
|
2512
|
-
return true;
|
|
2513
|
-
} catch (error) {
|
|
2514
|
-
console.error("[HlsAdPlayer] Failed to load next pod ad:", error);
|
|
2515
|
-
return false;
|
|
3115
|
+
clearMediaStartTimer();
|
|
3116
|
+
while(podIndex < podAds.length - 1){
|
|
3117
|
+
settleViewability();
|
|
3118
|
+
podIndex++;
|
|
3119
|
+
currentAd = podAds[podIndex];
|
|
3120
|
+
currentAdMediaFile = void 0;
|
|
3121
|
+
resetAdTracking();
|
|
3122
|
+
if (currentAd) {
|
|
3123
|
+
console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
|
|
3124
|
+
}
|
|
3125
|
+
resetVideoElementForNextSource();
|
|
3126
|
+
try {
|
|
3127
|
+
loadCurrentAdMedia();
|
|
3128
|
+
emit("pod_ad_started", {
|
|
3129
|
+
index: podIndex,
|
|
3130
|
+
total: podAds.length
|
|
3131
|
+
});
|
|
3132
|
+
return true;
|
|
3133
|
+
} catch (error) {
|
|
3134
|
+
console.error("[HlsAdPlayer] Failed to load next pod ad:", error);
|
|
3135
|
+
}
|
|
2516
3136
|
}
|
|
3137
|
+
return false;
|
|
2517
3138
|
}
|
|
2518
3139
|
function clearStallWatchdog() {
|
|
3140
|
+
clearMediaStartTimer();
|
|
2519
3141
|
if (stallWatchdogId != null) {
|
|
2520
3142
|
clearInterval(stallWatchdogId);
|
|
2521
3143
|
stallWatchdogId = void 0;
|
|
@@ -2531,11 +3153,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2531
3153
|
function handleAdStall() {
|
|
2532
3154
|
console.warn("[HlsAdPlayer] Ad playback stalled (no progress) - recovering to avoid a blank frame");
|
|
2533
3155
|
clearStallWatchdog();
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
handleAdError();
|
|
3156
|
+
logFunnel("stall", {
|
|
3157
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
3158
|
+
});
|
|
3159
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2539
3160
|
}
|
|
2540
3161
|
function getDecodedVideoFrameCount(video) {
|
|
2541
3162
|
try {
|
|
@@ -2597,11 +3218,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2597
3218
|
function handleVideoDecodeFailure() {
|
|
2598
3219
|
console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
|
|
2599
3220
|
clearStallWatchdog();
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
handleAdError();
|
|
3221
|
+
logFunnel("decode_failure", {
|
|
3222
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
3223
|
+
});
|
|
3224
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2605
3225
|
}
|
|
2606
3226
|
function startStallWatchdog() {
|
|
2607
3227
|
clearStallWatchdog();
|
|
@@ -2725,6 +3345,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2725
3345
|
Promise.reject(new Error("Ad already playing"))
|
|
2726
3346
|
];
|
|
2727
3347
|
}
|
|
3348
|
+
if (destroyed) {
|
|
3349
|
+
return [
|
|
3350
|
+
2,
|
|
3351
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
3352
|
+
];
|
|
3353
|
+
}
|
|
3354
|
+
currentVastTagUrl = vastTagUrl;
|
|
3355
|
+
pendingRequestAbortReason = void 0;
|
|
3356
|
+
logFunnel("request_sent");
|
|
2728
3357
|
_state.label = 1;
|
|
2729
3358
|
case 1:
|
|
2730
3359
|
_state.trys.push([
|
|
@@ -2759,8 +3388,29 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2759
3388
|
ads = _state.sent();
|
|
2760
3389
|
_state.label = 4;
|
|
2761
3390
|
case 4:
|
|
3391
|
+
if (destroyed) {
|
|
3392
|
+
return [
|
|
3393
|
+
2,
|
|
3394
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
3395
|
+
];
|
|
3396
|
+
}
|
|
3397
|
+
if (!ads.length && pendingRequestAbortReason) {
|
|
3398
|
+
throw new Error(pendingRequestAbortReason);
|
|
3399
|
+
}
|
|
3400
|
+
if (!ads.length && lastPodAdElementCount > 0) {
|
|
3401
|
+
console.warn("[HlsAdPlayer] VAST response had ads but none were playable");
|
|
3402
|
+
logFunnel("vast_fill_rejected", {
|
|
3403
|
+
adElementCount: lastPodAdElementCount
|
|
3404
|
+
});
|
|
3405
|
+
emit("ad_error");
|
|
3406
|
+
return [
|
|
3407
|
+
2,
|
|
3408
|
+
Promise.reject(new Error("VAST fill rejected: no playable ad in response"))
|
|
3409
|
+
];
|
|
3410
|
+
}
|
|
2762
3411
|
if (!ads.length) {
|
|
2763
3412
|
console.warn("[HlsAdPlayer] No ads available from VAST response");
|
|
3413
|
+
logFunnel("no_fill");
|
|
2764
3414
|
emit("ad_error");
|
|
2765
3415
|
return [
|
|
2766
3416
|
2,
|
|
@@ -2771,6 +3421,23 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2771
3421
|
podIndex = 0;
|
|
2772
3422
|
currentAd = ads[0];
|
|
2773
3423
|
currentAdMediaFile = void 0;
|
|
3424
|
+
logFunnel("vast_received", {
|
|
3425
|
+
adCount: ads.length,
|
|
3426
|
+
durations: ads.map(function(ad) {
|
|
3427
|
+
return ad.duration;
|
|
3428
|
+
}),
|
|
3429
|
+
impressionUrls: ads.map(function(ad) {
|
|
3430
|
+
return ad.trackingUrls.impression.length;
|
|
3431
|
+
})
|
|
3432
|
+
});
|
|
3433
|
+
ads.forEach(function(ad, index) {
|
|
3434
|
+
if (ad.trackingUrls.impression.length === 0) {
|
|
3435
|
+
logFunnel("vast_missing_impression", {
|
|
3436
|
+
adIndex: index,
|
|
3437
|
+
missingAdId: ad.id
|
|
3438
|
+
});
|
|
3439
|
+
}
|
|
3440
|
+
});
|
|
2774
3441
|
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"));
|
|
2775
3442
|
return [
|
|
2776
3443
|
2,
|
|
@@ -2779,6 +3446,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2779
3446
|
case 5:
|
|
2780
3447
|
error = _state.sent();
|
|
2781
3448
|
console.error("[HlsAdPlayer] Error requesting ads:", error);
|
|
3449
|
+
logFunnel("request_failed", {
|
|
3450
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3451
|
+
});
|
|
2782
3452
|
emit("ad_error");
|
|
2783
3453
|
return [
|
|
2784
3454
|
2,
|
|
@@ -2834,13 +3504,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2834
3504
|
adContainerEl.style.pointerEvents = "auto";
|
|
2835
3505
|
}
|
|
2836
3506
|
emit("content_pause");
|
|
2837
|
-
|
|
3507
|
+
try {
|
|
3508
|
+
loadCurrentAdMedia();
|
|
3509
|
+
} catch (loadError) {
|
|
3510
|
+
if (!(podIndex < podAds.length - 1 && advanceToNextPodAd())) {
|
|
3511
|
+
throw loadError;
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
2838
3514
|
return [
|
|
2839
3515
|
2,
|
|
2840
3516
|
Promise.resolve()
|
|
2841
3517
|
];
|
|
2842
3518
|
} catch (error) {
|
|
2843
3519
|
console.error("[HlsAdPlayer] Error playing ad:", error);
|
|
3520
|
+
logFunnel("play_failed", {
|
|
3521
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3522
|
+
});
|
|
2844
3523
|
handleAdError();
|
|
2845
3524
|
return [
|
|
2846
3525
|
2,
|
|
@@ -2882,6 +3561,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2882
3561
|
var previousMutedState;
|
|
2883
3562
|
return _ts_generator(this, function(_state) {
|
|
2884
3563
|
console.log("[HlsAdPlayer] Stopping ad");
|
|
3564
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3565
|
+
logFunnel("stopped_before_start");
|
|
3566
|
+
}
|
|
2885
3567
|
settleViewability();
|
|
2886
3568
|
fireNotUsedForUnplayedAds();
|
|
2887
3569
|
clearStallWatchdog();
|
|
@@ -2914,15 +3596,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2914
3596
|
},
|
|
2915
3597
|
destroy: function destroy() {
|
|
2916
3598
|
console.log("[HlsAdPlayer] Destroying");
|
|
3599
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3600
|
+
logFunnel("stopped_before_start");
|
|
3601
|
+
}
|
|
2917
3602
|
settleViewability();
|
|
2918
3603
|
fireNotUsedForUnplayedAds();
|
|
2919
3604
|
destroyed = true;
|
|
2920
|
-
|
|
3605
|
+
pendingRequestAbortReason = "Ad player destroyed";
|
|
2921
3606
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2922
3607
|
try {
|
|
2923
|
-
for(var _iterator =
|
|
2924
|
-
var
|
|
2925
|
-
|
|
3608
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3609
|
+
var controller = _step.value;
|
|
3610
|
+
controller.abort();
|
|
2926
3611
|
}
|
|
2927
3612
|
} catch (err) {
|
|
2928
3613
|
_didIteratorError = true;
|
|
@@ -2938,6 +3623,28 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2938
3623
|
}
|
|
2939
3624
|
}
|
|
2940
3625
|
}
|
|
3626
|
+
pendingVastRequests.clear();
|
|
3627
|
+
clearStallWatchdog();
|
|
3628
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3629
|
+
try {
|
|
3630
|
+
for(var _iterator1 = pendingTimeouts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3631
|
+
var timeoutId = _step1.value;
|
|
3632
|
+
clearTimeout(timeoutId);
|
|
3633
|
+
}
|
|
3634
|
+
} catch (err) {
|
|
3635
|
+
_didIteratorError1 = true;
|
|
3636
|
+
_iteratorError1 = err;
|
|
3637
|
+
} finally{
|
|
3638
|
+
try {
|
|
3639
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
3640
|
+
_iterator1.return();
|
|
3641
|
+
}
|
|
3642
|
+
} finally{
|
|
3643
|
+
if (_didIteratorError1) {
|
|
3644
|
+
throw _iteratorError1;
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
2941
3648
|
pendingTimeouts = [];
|
|
2942
3649
|
adPlaying = false;
|
|
2943
3650
|
setAdPlayingFlag(false);
|
|
@@ -2957,6 +3664,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2957
3664
|
isAdPlaying: function isAdPlaying() {
|
|
2958
3665
|
return adPlaying;
|
|
2959
3666
|
},
|
|
3667
|
+
setFunnelContext: function setFunnelContext(context) {
|
|
3668
|
+
funnelContext = _object_spread({}, context);
|
|
3669
|
+
},
|
|
3670
|
+
abortPendingRequest: function abortPendingRequest() {
|
|
3671
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "VAST request aborted (timeout)";
|
|
3672
|
+
if (pendingVastRequests.size === 0) return;
|
|
3673
|
+
pendingRequestAbortReason = reason;
|
|
3674
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3675
|
+
try {
|
|
3676
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3677
|
+
var controller = _step.value;
|
|
3678
|
+
controller.abort();
|
|
3679
|
+
}
|
|
3680
|
+
} catch (err) {
|
|
3681
|
+
_didIteratorError = true;
|
|
3682
|
+
_iteratorError = err;
|
|
3683
|
+
} finally{
|
|
3684
|
+
try {
|
|
3685
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3686
|
+
_iterator.return();
|
|
3687
|
+
}
|
|
3688
|
+
} finally{
|
|
3689
|
+
if (_didIteratorError) {
|
|
3690
|
+
throw _iteratorError;
|
|
3691
|
+
}
|
|
3692
|
+
}
|
|
3693
|
+
}
|
|
3694
|
+
pendingVastRequests.clear();
|
|
3695
|
+
},
|
|
2960
3696
|
resize: function resize(width, height) {
|
|
2961
3697
|
console.log("[HlsAdPlayer] Resizing to ".concat(width, "x").concat(height));
|
|
2962
3698
|
if (adContainerEl) {
|
|
@@ -2992,6 +3728,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2992
3728
|
if (adVideoElement && adPlaying) {
|
|
2993
3729
|
var clamped = Math.max(0, Math.min(1, volume));
|
|
2994
3730
|
adVideoElement.volume = clamped;
|
|
3731
|
+
var userActivation = navigator.userActivation;
|
|
3732
|
+
if (clamped > 0 && forcedMuteByAutoplay && userActivation && !userActivation.isActive) {
|
|
3733
|
+
logFunnel("unmute_blocked_without_gesture", {
|
|
3734
|
+
requestedVolume: clamped
|
|
3735
|
+
});
|
|
3736
|
+
return;
|
|
3737
|
+
}
|
|
2995
3738
|
adVideoElement.muted = clamped === 0;
|
|
2996
3739
|
}
|
|
2997
3740
|
},
|
|
@@ -5104,6 +5847,21 @@ function normalizeVastTagUrl(raw) {
|
|
|
5104
5847
|
return raw;
|
|
5105
5848
|
}
|
|
5106
5849
|
}
|
|
5850
|
+
var GAM_AD_HOSTS = /* @__PURE__ */ new Set([
|
|
5851
|
+
"pubads.g.doubleclick.net",
|
|
5852
|
+
"securepubads.g.doubleclick.net"
|
|
5853
|
+
]);
|
|
5854
|
+
function ensureVideoAdType(rawUrl) {
|
|
5855
|
+
try {
|
|
5856
|
+
var url = new URL(rawUrl);
|
|
5857
|
+
if (!GAM_AD_HOSTS.has(url.hostname)) return rawUrl;
|
|
5858
|
+
if (url.searchParams.has("ad_type")) return rawUrl;
|
|
5859
|
+
url.searchParams.set("ad_type", "video");
|
|
5860
|
+
return url.toString();
|
|
5861
|
+
} catch (unused) {
|
|
5862
|
+
return rawUrl;
|
|
5863
|
+
}
|
|
5864
|
+
}
|
|
5107
5865
|
function applyVastMacros(baseUrl, ctx) {
|
|
5108
5866
|
var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
|
|
5109
5867
|
var url;
|
|
@@ -6814,7 +7572,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
6814
7572
|
} : {}), {
|
|
6815
7573
|
consent: this.consentSignals
|
|
6816
7574
|
}));
|
|
6817
|
-
var finalUrl = palNonce.injectNonce(urlWithMacros);
|
|
7575
|
+
var finalUrl = palNonce.injectNonce(ensureVideoAdType(urlWithMacros));
|
|
6818
7576
|
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);
|
|
6819
7577
|
return finalUrl;
|
|
6820
7578
|
}
|
|
@@ -7061,7 +7819,7 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
7061
7819
|
{
|
|
7062
7820
|
key: "adFitsRemainingBudget",
|
|
7063
7821
|
value: function adFitsRemainingBudget(durationMs) {
|
|
7064
|
-
if (durationMs <= 0) {
|
|
7822
|
+
if (durationMs <= 0 || this.expectedAdBreakDurationMs == null) {
|
|
7065
7823
|
return true;
|
|
7066
7824
|
}
|
|
7067
7825
|
return durationMs <= this.getDurationBudgetRemainingMs();
|
|
@@ -7120,6 +7878,11 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
7120
7878
|
value: function markAdStarted() {
|
|
7121
7879
|
this.currentAdIndex++;
|
|
7122
7880
|
this.totalAdsInBreak = this.currentAdIndex;
|
|
7881
|
+
}
|
|
7882
|
+
},
|
|
7883
|
+
{
|
|
7884
|
+
key: "noteAdRequestSent",
|
|
7885
|
+
value: function noteAdRequestSent() {
|
|
7123
7886
|
this.totalAdRequestsInBreak++;
|
|
7124
7887
|
this.lastAdRequestTime = Date.now();
|
|
7125
7888
|
}
|
|
@@ -7171,6 +7934,9 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
7171
7934
|
if (message.includes("timeout")) {
|
|
7172
7935
|
return true;
|
|
7173
7936
|
}
|
|
7937
|
+
if (message.includes("ad player destroyed") || message.includes("aborted")) {
|
|
7938
|
+
return true;
|
|
7939
|
+
}
|
|
7174
7940
|
if (message.includes("rate limit") || message.includes("too many requests")) {
|
|
7175
7941
|
return true;
|
|
7176
7942
|
}
|
|
@@ -8295,6 +9061,18 @@ function resizePlayer(video, adPlayer, debug) {
|
|
|
8295
9061
|
}
|
|
8296
9062
|
}
|
|
8297
9063
|
// src/player/AdBreakOrchestrator.ts
|
|
9064
|
+
var REQUEST_FAILURE_STAGES = /* @__PURE__ */ new Set([
|
|
9065
|
+
"no_fill",
|
|
9066
|
+
"vast_fill_rejected",
|
|
9067
|
+
"request_failed",
|
|
9068
|
+
"media_unsupported",
|
|
9069
|
+
"play_failed",
|
|
9070
|
+
"play_resolved_but_never_started",
|
|
9071
|
+
"hls_fatal",
|
|
9072
|
+
"media_error",
|
|
9073
|
+
"stall",
|
|
9074
|
+
"decode_failure"
|
|
9075
|
+
]);
|
|
8298
9076
|
var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
8299
9077
|
function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
|
|
8300
9078
|
_class_call_check(this, AdBreakOrchestrator);
|
|
@@ -8302,11 +9080,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8302
9080
|
this.showAds = false;
|
|
8303
9081
|
this.isShowingPlaceholder = false;
|
|
8304
9082
|
this.adDetectSentForCurrentBreak = false;
|
|
8305
|
-
this.
|
|
8306
|
-
this.
|
|
8307
|
-
this.
|
|
9083
|
+
this.slotState = "IDLE";
|
|
9084
|
+
this.unusableResponsesInBreak = 0;
|
|
9085
|
+
this.controllerGeneration = 0;
|
|
9086
|
+
this.requestDiagnostics = /* @__PURE__ */ new Map();
|
|
9087
|
+
this.breakFunnel = {};
|
|
9088
|
+
this.controllerCallInFlight = false;
|
|
9089
|
+
this.playbackStartedForCurrentRequest = false;
|
|
9090
|
+
this.opportunityEpoch = -1;
|
|
8308
9091
|
this.adPodQueue = [];
|
|
8309
|
-
this.
|
|
9092
|
+
this.defaultMinRemainingMsToRequestAd = 1e4;
|
|
9093
|
+
this.defaultMaxNoFillsPerBreak = 2;
|
|
8310
9094
|
this.pendingAdBreak = null;
|
|
8311
9095
|
this.host = host;
|
|
8312
9096
|
this.timing = timing;
|
|
@@ -8342,7 +9126,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8342
9126
|
key: "attachImaEventListeners",
|
|
8343
9127
|
value: function attachImaEventListeners() {
|
|
8344
9128
|
var _this = this;
|
|
8345
|
-
var
|
|
9129
|
+
var controller = this.host.getAdPlayer();
|
|
9130
|
+
var generation = this.controllerGeneration;
|
|
9131
|
+
var adPlayer = {
|
|
9132
|
+
on: function on(event, handler) {
|
|
9133
|
+
controller.on(event, function(payload) {
|
|
9134
|
+
if (generation !== _this.controllerGeneration) {
|
|
9135
|
+
_this.logOrchestratorFunnel("stale_callback_ignored", {
|
|
9136
|
+
event: event,
|
|
9137
|
+
staleControllerId: generation,
|
|
9138
|
+
currentControllerId: _this.controllerGeneration
|
|
9139
|
+
});
|
|
9140
|
+
return;
|
|
9141
|
+
}
|
|
9142
|
+
handler(payload);
|
|
9143
|
+
});
|
|
9144
|
+
}
|
|
9145
|
+
};
|
|
8346
9146
|
adPlayer.on("pod_ad_started", function(payload) {
|
|
8347
9147
|
_this.timing.notePodAdStarted();
|
|
8348
9148
|
if (_this.debug) {
|
|
@@ -8356,7 +9156,35 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8356
9156
|
adPlayer.on("ad_interaction", function(event) {
|
|
8357
9157
|
if (event) _this.host.onAdInteraction(event);
|
|
8358
9158
|
});
|
|
9159
|
+
adPlayer.on("ad_funnel", function(payload) {
|
|
9160
|
+
if (!(payload === null || payload === void 0 ? void 0 : payload.stage)) return;
|
|
9161
|
+
var stage = payload.stage;
|
|
9162
|
+
_this.countFunnelStage(stage);
|
|
9163
|
+
if (payload.reason) {
|
|
9164
|
+
_this.countFunnelStage("".concat(stage, ":").concat(payload.reason));
|
|
9165
|
+
}
|
|
9166
|
+
if (stage === "impression_fired" && payload.pixelCount != null) {
|
|
9167
|
+
_this.countFunnelStage("impression_urls", payload.pixelCount);
|
|
9168
|
+
}
|
|
9169
|
+
if (payload.visibilityState === "hidden") {
|
|
9170
|
+
_this.countFunnelStage("while_hidden");
|
|
9171
|
+
}
|
|
9172
|
+
if (stage === "gam_http_request_sent") {
|
|
9173
|
+
if (payload.attempt === 1) {
|
|
9174
|
+
_this.timing.noteAdRequestSent();
|
|
9175
|
+
} else {
|
|
9176
|
+
_this.countFunnelStage("gam_http_request_retry");
|
|
9177
|
+
}
|
|
9178
|
+
}
|
|
9179
|
+
_this.recordRequestDiagnostic(payload);
|
|
9180
|
+
});
|
|
8359
9181
|
adPlayer.on("ad_impression", function() {
|
|
9182
|
+
_this.timing.consecutiveFailures = 0;
|
|
9183
|
+
_this.setSlotState("PLAYING", "impression");
|
|
9184
|
+
if (!_this.playbackStartedForCurrentRequest) {
|
|
9185
|
+
_this.playbackStartedForCurrentRequest = true;
|
|
9186
|
+
_this.timing.markAdStarted();
|
|
9187
|
+
}
|
|
8360
9188
|
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
8361
9189
|
source: "hls",
|
|
8362
9190
|
adIndex: _this.timing.currentAdIndex
|
|
@@ -8371,16 +9199,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8371
9199
|
var remaining = _this.timing.getRemainingAdMs();
|
|
8372
9200
|
_this.timing.consecutiveFailures = 0;
|
|
8373
9201
|
if (_this.debug) {
|
|
8374
|
-
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms
|
|
8375
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
8376
|
-
} : {});
|
|
9202
|
+
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms"));
|
|
8377
9203
|
}
|
|
8378
9204
|
if (_this.inAdBreak) {
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
} else {
|
|
8382
|
-
_this.handleAdPodComplete();
|
|
8383
|
-
}
|
|
9205
|
+
_this.setSlotState("NEEDS_NEXT_AD", "all_ads_completed");
|
|
9206
|
+
_this.requestNextAd("all_ads_completed");
|
|
8384
9207
|
}
|
|
8385
9208
|
});
|
|
8386
9209
|
adPlayer.on("ad_error", function(errorPayload) {
|
|
@@ -8400,7 +9223,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8400
9223
|
}
|
|
8401
9224
|
}
|
|
8402
9225
|
console.error("[AD-ERROR]", errorMessage, errorPayload || "");
|
|
8403
|
-
_this.
|
|
9226
|
+
if (_this.controllerCallInFlight) {
|
|
9227
|
+
return;
|
|
9228
|
+
}
|
|
9229
|
+
_this.handleAdFailure("ad_error");
|
|
8404
9230
|
});
|
|
8405
9231
|
adPlayer.on("content_pause", function() {
|
|
8406
9232
|
_this.timing.clearAdFailsafeTimer();
|
|
@@ -8439,26 +9265,32 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8439
9265
|
}
|
|
8440
9266
|
_this.timing.consecutiveFailures = 0;
|
|
8441
9267
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
8442
|
-
var remaining = _this.timing.getRemainingAdMs();
|
|
8443
9268
|
if (_this.debug) {
|
|
8444
|
-
console.log("[
|
|
8445
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
8446
|
-
} : {});
|
|
8447
|
-
}
|
|
8448
|
-
if (_this.timing.hasTimeToStartAnotherAd()) {
|
|
8449
|
-
_this.tryNextAvailableAdWithRateLimit();
|
|
8450
|
-
} else {
|
|
8451
|
-
_this.handleAdPodComplete();
|
|
9269
|
+
console.log("[AdBreak] content_resume: remaining=".concat(_this.timing.getRemainingAdMs(), "ms"));
|
|
8452
9270
|
}
|
|
9271
|
+
_this.setSlotState("NEEDS_NEXT_AD", "ad_complete");
|
|
9272
|
+
_this.requestNextAd("ad_complete");
|
|
8453
9273
|
});
|
|
8454
9274
|
}
|
|
8455
9275
|
},
|
|
8456
9276
|
{
|
|
8457
9277
|
key: "recreateAdController",
|
|
8458
|
-
value: function recreateAdController() {
|
|
8459
|
-
if (this.
|
|
8460
|
-
console.
|
|
9278
|
+
value: function recreateAdController(reason) {
|
|
9279
|
+
if (reason === "new_request" && (this.slotState === "REQUESTING" || this.slotState === "READY")) {
|
|
9280
|
+
console.warn("[AD-CONTROLLER] destroy during active request", {
|
|
9281
|
+
controllerId: this.controllerGeneration,
|
|
9282
|
+
requestId: this.currentRequestId,
|
|
9283
|
+
state: this.slotState,
|
|
9284
|
+
reason: reason
|
|
9285
|
+
});
|
|
8461
9286
|
}
|
|
9287
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
9288
|
+
controllerId: this.controllerGeneration,
|
|
9289
|
+
requestId: this.currentRequestId,
|
|
9290
|
+
state: this.slotState,
|
|
9291
|
+
reason: reason
|
|
9292
|
+
});
|
|
9293
|
+
this.countFunnelStage("controller_destroy:".concat(reason));
|
|
8462
9294
|
var shouldShowPlaceholder = this.inAdBreak && this.showAds;
|
|
8463
9295
|
var adPlayer = this.host.getAdPlayer();
|
|
8464
9296
|
if (shouldShowPlaceholder && adPlayer) {
|
|
@@ -8471,6 +9303,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8471
9303
|
}
|
|
8472
9304
|
var preservedMutedState = adPlayer.getOriginalMutedState();
|
|
8473
9305
|
var preservedVolumeState = adPlayer.getOriginalVolume();
|
|
9306
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8474
9307
|
if (adPlayer) {
|
|
8475
9308
|
try {
|
|
8476
9309
|
adPlayer.destroy();
|
|
@@ -8484,9 +9317,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8484
9317
|
var continueLiveStreamDuringAds = this.host.shouldContinueLiveStreamDuringAds();
|
|
8485
9318
|
var newAdPlayer = this.host.createAdPlayer(continueLiveStreamDuringAds);
|
|
8486
9319
|
this.host.setAdPlayer(newAdPlayer);
|
|
9320
|
+
this.controllerGeneration++;
|
|
8487
9321
|
newAdPlayer.initialize();
|
|
8488
9322
|
newAdPlayer.updateOriginalMutedState(preservedMutedState, preservedVolumeState);
|
|
8489
9323
|
this.attachImaEventListeners();
|
|
9324
|
+
if (this.debug) {
|
|
9325
|
+
console.log("[AD-CONTROLLER] create", {
|
|
9326
|
+
controllerId: this.controllerGeneration,
|
|
9327
|
+
reason: reason
|
|
9328
|
+
});
|
|
9329
|
+
}
|
|
8490
9330
|
if (shouldShowPlaceholder) {
|
|
8491
9331
|
this.placeholder.show();
|
|
8492
9332
|
newAdPlayer.showPlaceholder();
|
|
@@ -8507,32 +9347,57 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8507
9347
|
}
|
|
8508
9348
|
},
|
|
8509
9349
|
{
|
|
8510
|
-
|
|
8511
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9350
|
+
// ───────────────────────────────────────────────────────────────
|
|
8512
9351
|
// Ad break start
|
|
8513
9352
|
// ───────────────────────────────────────────────────────────────
|
|
8514
|
-
|
|
9353
|
+
key: "isBreakActive",
|
|
9354
|
+
value: function isBreakActive() {
|
|
9355
|
+
return this.slotState !== "IDLE";
|
|
9356
|
+
}
|
|
9357
|
+
},
|
|
9358
|
+
{
|
|
9359
|
+
key: "getSlotState",
|
|
9360
|
+
value: function getSlotState() {
|
|
9361
|
+
return this.slotState;
|
|
9362
|
+
}
|
|
9363
|
+
},
|
|
9364
|
+
{
|
|
9365
|
+
key: "beginVmapBreak",
|
|
9366
|
+
value: function beginVmapBreak(breakKey) {
|
|
9367
|
+
this.breakSource = "vmap";
|
|
9368
|
+
this.followUpBaseVastUrl = void 0;
|
|
9369
|
+
this.unusableResponsesInBreak = 0;
|
|
9370
|
+
this.timing.totalAdRequestsInBreak = 0;
|
|
9371
|
+
this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
|
|
9372
|
+
this.noteOpportunity("vmap", breakKey);
|
|
9373
|
+
}
|
|
9374
|
+
},
|
|
9375
|
+
{
|
|
9376
|
+
key: "handleAdStart",
|
|
9377
|
+
value: function handleAdStart(marker) {
|
|
8515
9378
|
return _async_to_generator(function() {
|
|
8516
|
-
var
|
|
9379
|
+
var baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, epoch, podPlayed;
|
|
8517
9380
|
return _ts_generator(this, function(_state) {
|
|
8518
9381
|
switch(_state.label){
|
|
8519
9382
|
case 0:
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
9383
|
+
if (this.slotState !== "IDLE") {
|
|
9384
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
9385
|
+
source: "scte35",
|
|
9386
|
+
state: this.slotState
|
|
9387
|
+
});
|
|
9388
|
+
return [
|
|
9389
|
+
2
|
|
9390
|
+
];
|
|
8523
9391
|
}
|
|
8524
|
-
|
|
8525
|
-
if (
|
|
8526
|
-
|
|
8527
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
8528
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
8529
|
-
} else {
|
|
9392
|
+
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
9393
|
+
if (!baseVastUrl) {
|
|
9394
|
+
console.warn("[AdBreak] SCTE-35 break started but no direct VAST tag is configured");
|
|
8530
9395
|
this.clearPendingAdBreak();
|
|
8531
9396
|
return [
|
|
8532
9397
|
2
|
|
8533
9398
|
];
|
|
8534
9399
|
}
|
|
8535
|
-
adBreakDurationMs =
|
|
9400
|
+
adBreakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : this.timing.expectedAdBreakDurationMs;
|
|
8536
9401
|
if (this.debug) {
|
|
8537
9402
|
mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
|
|
8538
9403
|
console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
@@ -8540,9 +9405,12 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8540
9405
|
this.timing.failedVastUrls.clear();
|
|
8541
9406
|
this.timing.temporaryFailureUrls.clear();
|
|
8542
9407
|
this.timing.consecutiveFailures = 0;
|
|
8543
|
-
this.continuousFetchingActive = true;
|
|
8544
9408
|
this.isShowingPlaceholder = false;
|
|
8545
9409
|
this.timing.totalAdRequestsInBreak = 0;
|
|
9410
|
+
this.breakSource = "scte35";
|
|
9411
|
+
this.followUpBaseVastUrl = baseVastUrl;
|
|
9412
|
+
this.unusableResponsesInBreak = 0;
|
|
9413
|
+
this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
|
|
8546
9414
|
if (this.adConfig.podAssignedByPrefetch) {
|
|
8547
9415
|
this.adConfig.podAssignedByPrefetch = false;
|
|
8548
9416
|
} else {
|
|
@@ -8560,29 +9428,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8560
9428
|
if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
8561
9429
|
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
8562
9430
|
}
|
|
9431
|
+
this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
|
|
9432
|
+
epoch = this.timing.adBreakEpoch;
|
|
8563
9433
|
return [
|
|
8564
9434
|
4,
|
|
8565
|
-
this.startOptimizedPod(baseVastUrl, adBreakDurationMs
|
|
9435
|
+
this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
|
|
8566
9436
|
];
|
|
8567
9437
|
case 1:
|
|
8568
9438
|
podPlayed = _state.sent();
|
|
8569
|
-
if (
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
];
|
|
8573
|
-
if (this.debug) {
|
|
8574
|
-
console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
|
|
9439
|
+
if (!podPlayed && this.inAdBreak && epoch === this.timing.adBreakEpoch) {
|
|
9440
|
+
this.setSlotState("NEEDS_NEXT_AD", "initial_request_failed");
|
|
9441
|
+
this.requestNextAd("initial_request_failed");
|
|
8575
9442
|
}
|
|
8576
|
-
this.continuousFetchingActive = true;
|
|
8577
|
-
this.startContinuousFetching(baseVastUrl);
|
|
8578
|
-
return [
|
|
8579
|
-
4,
|
|
8580
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
8581
|
-
];
|
|
8582
|
-
case 2:
|
|
8583
|
-
_state.sent();
|
|
8584
|
-
_state.label = 3;
|
|
8585
|
-
case 3:
|
|
8586
9443
|
return [
|
|
8587
9444
|
2
|
|
8588
9445
|
];
|
|
@@ -8596,12 +9453,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8596
9453
|
value: // ───────────────────────────────────────────────────────────────
|
|
8597
9454
|
// Optimized pod (single multi-ad request)
|
|
8598
9455
|
// ───────────────────────────────────────────────────────────────
|
|
8599
|
-
function startOptimizedPod(baseVastUrl, breakDurationMs
|
|
9456
|
+
function startOptimizedPod(baseVastUrl, breakDurationMs) {
|
|
8600
9457
|
return _async_to_generator(function() {
|
|
8601
|
-
var podUrl, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
9458
|
+
var podUrl, prefetched, epoch, generation, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
8602
9459
|
return _ts_generator(this, function(_state) {
|
|
8603
9460
|
switch(_state.label){
|
|
8604
9461
|
case 0:
|
|
9462
|
+
prefetched = !!(this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0);
|
|
8605
9463
|
if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
|
|
8606
9464
|
podUrl = this.pendingAdBreak.vastUrls[0];
|
|
8607
9465
|
this.clearPendingAdBreak();
|
|
@@ -8614,12 +9472,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8614
9472
|
false
|
|
8615
9473
|
];
|
|
8616
9474
|
}
|
|
8617
|
-
this.
|
|
8618
|
-
this.
|
|
9475
|
+
this.noteVastUrlGenerated(podUrl, prefetched ? "prefetch" : "break_start");
|
|
9476
|
+
epoch = this.timing.adBreakEpoch;
|
|
9477
|
+
this.recreateAdController("new_request");
|
|
9478
|
+
generation = this.controllerGeneration;
|
|
8619
9479
|
adPlayer = this.host.getAdPlayer();
|
|
8620
9480
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8621
9481
|
this.timing.activeAdRequestToken = requestToken;
|
|
8622
9482
|
this.currentVastUrl = podUrl;
|
|
9483
|
+
this.setSlotState("REQUESTING", "initial_pod");
|
|
9484
|
+
this.beginFunnelRequest(adPlayer, requestToken, "initial_pod");
|
|
8623
9485
|
_state.label = 1;
|
|
8624
9486
|
case 1:
|
|
8625
9487
|
_state.trys.push([
|
|
@@ -8634,16 +9496,24 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8634
9496
|
];
|
|
8635
9497
|
case 2:
|
|
8636
9498
|
_state.sent();
|
|
9499
|
+
if (this.isStale(epoch, generation)) return [
|
|
9500
|
+
2,
|
|
9501
|
+
true
|
|
9502
|
+
];
|
|
8637
9503
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
8638
|
-
this.timing.lastAdRequestTime = Date.now();
|
|
8639
9504
|
return [
|
|
8640
9505
|
4,
|
|
8641
|
-
|
|
9506
|
+
this.callController(function() {
|
|
9507
|
+
return adPlayer.requestAds(podUrl);
|
|
9508
|
+
})
|
|
8642
9509
|
];
|
|
8643
9510
|
case 3:
|
|
8644
9511
|
_state.sent();
|
|
8645
9512
|
this.timing.clearAdRequestWatchdog();
|
|
8646
|
-
if (this.
|
|
9513
|
+
if (this.isStale(epoch, generation)) {
|
|
9514
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9515
|
+
requestId: requestToken
|
|
9516
|
+
});
|
|
8647
9517
|
return [
|
|
8648
9518
|
2,
|
|
8649
9519
|
true
|
|
@@ -8651,11 +9521,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8651
9521
|
}
|
|
8652
9522
|
podCount = (_ref = (_adPlayer_getPodAdCount = adPlayer.getPodAdCount) === null || _adPlayer_getPodAdCount === void 0 ? void 0 : _adPlayer_getPodAdCount.call(adPlayer)) !== null && _ref !== void 0 ? _ref : 1;
|
|
8653
9523
|
if (podCount < 1) {
|
|
9524
|
+
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9525
|
+
this.timing.activeAdRequestToken = null;
|
|
9526
|
+
}
|
|
9527
|
+
this.recordRequestFailure(new Error("No ads available"), podUrl);
|
|
8654
9528
|
return [
|
|
8655
9529
|
2,
|
|
8656
9530
|
false
|
|
8657
9531
|
];
|
|
8658
9532
|
}
|
|
9533
|
+
this.setSlotState("READY", "vast_ready");
|
|
8659
9534
|
if (this.debug) {
|
|
8660
9535
|
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"));
|
|
8661
9536
|
}
|
|
@@ -8667,18 +9542,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8667
9542
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
8668
9543
|
return [
|
|
8669
9544
|
4,
|
|
8670
|
-
|
|
9545
|
+
this.callController(function() {
|
|
9546
|
+
return adPlayer.play();
|
|
9547
|
+
})
|
|
8671
9548
|
];
|
|
8672
9549
|
case 4:
|
|
8673
9550
|
_state.sent();
|
|
8674
|
-
this.
|
|
9551
|
+
if (this.isStale(epoch, generation)) return [
|
|
9552
|
+
2,
|
|
9553
|
+
true
|
|
9554
|
+
];
|
|
8675
9555
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
8676
9556
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
8677
9557
|
}
|
|
8678
|
-
adPlayer.setAdVolume(
|
|
8679
|
-
this.timing.consecutiveFailures = 0;
|
|
8680
|
-
this.continuousFetchingActive = true;
|
|
8681
|
-
this.startContinuousFetching(baseVastUrl);
|
|
9558
|
+
adPlayer.setAdVolume(getAdAudioVolume(adPlayer));
|
|
8682
9559
|
return [
|
|
8683
9560
|
2,
|
|
8684
9561
|
true
|
|
@@ -8690,14 +9567,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8690
9567
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
8691
9568
|
this.timing.activeAdRequestToken = null;
|
|
8692
9569
|
}
|
|
9570
|
+
if (this.isStale(epoch, generation)) {
|
|
9571
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9572
|
+
requestId: requestToken,
|
|
9573
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
9574
|
+
});
|
|
9575
|
+
return [
|
|
9576
|
+
2,
|
|
9577
|
+
true
|
|
9578
|
+
];
|
|
9579
|
+
}
|
|
8693
9580
|
if (this.debug) {
|
|
8694
9581
|
console.warn("[POD] Optimized pod request/play failed:", error);
|
|
8695
9582
|
}
|
|
8696
|
-
|
|
8697
|
-
this.timing.temporaryFailureUrls.set(podUrl, Date.now());
|
|
8698
|
-
}
|
|
8699
|
-
this.continuousFetchingActive = true;
|
|
8700
|
-
this.recreateAdController();
|
|
9583
|
+
this.recordRequestFailure(error, podUrl);
|
|
8701
9584
|
return [
|
|
8702
9585
|
2,
|
|
8703
9586
|
false
|
|
@@ -8713,168 +9596,204 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8713
9596
|
},
|
|
8714
9597
|
{
|
|
8715
9598
|
// ───────────────────────────────────────────────────────────────
|
|
8716
|
-
//
|
|
9599
|
+
// Next-ad scheduling (single flight)
|
|
8717
9600
|
// ───────────────────────────────────────────────────────────────
|
|
8718
|
-
key: "
|
|
8719
|
-
value: function
|
|
8720
|
-
if (
|
|
9601
|
+
key: "setSlotState",
|
|
9602
|
+
value: function setSlotState(next, reason) {
|
|
9603
|
+
if (this.slotState === next) return;
|
|
9604
|
+
var previous = this.slotState;
|
|
9605
|
+
this.slotState = next;
|
|
9606
|
+
if (this.debug) {
|
|
9607
|
+
console.log("[AdBreak][STATE] ".concat(previous, " -> ").concat(next), {
|
|
9608
|
+
reason: reason,
|
|
9609
|
+
breakId: this.timing.adBreakEpoch,
|
|
9610
|
+
requestId: this.currentRequestId,
|
|
9611
|
+
controllerId: this.controllerGeneration
|
|
9612
|
+
});
|
|
9613
|
+
}
|
|
9614
|
+
}
|
|
9615
|
+
},
|
|
9616
|
+
{
|
|
9617
|
+
key: "isStale",
|
|
9618
|
+
value: function isStale(epoch, generation) {
|
|
9619
|
+
return !this.inAdBreak || epoch !== this.timing.adBreakEpoch || generation !== this.controllerGeneration;
|
|
9620
|
+
}
|
|
9621
|
+
},
|
|
9622
|
+
{
|
|
9623
|
+
key: "getMinRemainingMsToRequestAd",
|
|
9624
|
+
value: function getMinRemainingMsToRequestAd() {
|
|
9625
|
+
var configured = this.host.config.minRemainingMsToRequestAd;
|
|
9626
|
+
var floor = this.timing.getMinRemainingMsToStartAd();
|
|
9627
|
+
if (typeof configured === "number" && configured >= 0) {
|
|
9628
|
+
return Math.max(configured, floor);
|
|
9629
|
+
}
|
|
9630
|
+
return Math.max(this.defaultMinRemainingMsToRequestAd, floor);
|
|
9631
|
+
}
|
|
9632
|
+
},
|
|
9633
|
+
{
|
|
9634
|
+
key: "getMaxNoFillsPerBreak",
|
|
9635
|
+
value: function getMaxNoFillsPerBreak() {
|
|
9636
|
+
var configured = this.host.config.maxNoFillsPerBreak;
|
|
9637
|
+
return typeof configured === "number" && configured > 0 ? configured : this.defaultMaxNoFillsPerBreak;
|
|
9638
|
+
}
|
|
9639
|
+
},
|
|
9640
|
+
{
|
|
9641
|
+
key: "isBreakTimeBounded",
|
|
9642
|
+
value: function isBreakTimeBounded() {
|
|
9643
|
+
return this.breakSource === "scte35" || this.timing.expectedAdBreakDurationMs != null;
|
|
9644
|
+
}
|
|
9645
|
+
},
|
|
9646
|
+
{
|
|
9647
|
+
key: "getStopRequestingReason",
|
|
9648
|
+
value: function getStopRequestingReason(remainingMs) {
|
|
9649
|
+
if (this.breakSource === "vmap") {
|
|
9650
|
+
if (this.adPodQueue.length === 0) return "vmap_queue_empty";
|
|
9651
|
+
} else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl) {
|
|
9652
|
+
return "no_follow_up_source";
|
|
9653
|
+
}
|
|
9654
|
+
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9655
|
+
return "max_consecutive_failures";
|
|
9656
|
+
}
|
|
9657
|
+
if (this.unusableResponsesInBreak >= this.getMaxNoFillsPerBreak()) {
|
|
9658
|
+
return "unusable_response_limit";
|
|
9659
|
+
}
|
|
9660
|
+
if (this.timing.totalAdRequestsInBreak >= this.timing.maxTotalAdRequestsPerBreak) {
|
|
9661
|
+
return "request_cap";
|
|
9662
|
+
}
|
|
9663
|
+
if (this.timing.isGamInCooldown()) {
|
|
9664
|
+
return "gam_cooldown";
|
|
9665
|
+
}
|
|
9666
|
+
if (this.isBreakTimeBounded() && remainingMs < this.getMinRemainingMsToRequestAd()) {
|
|
9667
|
+
return "insufficient_break_time";
|
|
9668
|
+
}
|
|
9669
|
+
return void 0;
|
|
9670
|
+
}
|
|
9671
|
+
},
|
|
9672
|
+
{
|
|
9673
|
+
key: "getNextRequestDelayMs",
|
|
9674
|
+
value: function getNextRequestDelayMs() {
|
|
9675
|
+
var failures = this.timing.consecutiveFailures;
|
|
9676
|
+
var backoff = failures > 0 ? Math.min(this.timing.backoffBaseMs * Math.pow(2, failures), this.timing.maxBackoffMs) : 0;
|
|
9677
|
+
var minInterval = this.timing.minAdRequestIntervalMs + backoff;
|
|
9678
|
+
var sinceLast = Date.now() - this.timing.lastAdRequestTime;
|
|
9679
|
+
return Math.max(0, minInterval - sinceLast);
|
|
9680
|
+
}
|
|
9681
|
+
},
|
|
9682
|
+
{
|
|
9683
|
+
key: "requestNextAd",
|
|
9684
|
+
value: function requestNextAd(trigger) {
|
|
9685
|
+
var _this = this;
|
|
9686
|
+
if (!this.inAdBreak) return;
|
|
9687
|
+
if (this.slotState !== "NEEDS_NEXT_AD") {
|
|
9688
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9689
|
+
trigger: trigger,
|
|
9690
|
+
state: this.slotState,
|
|
9691
|
+
why: "slot_busy"
|
|
9692
|
+
});
|
|
8721
9693
|
return;
|
|
8722
9694
|
}
|
|
8723
|
-
if (this.
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
9695
|
+
if (this.nextAdTimerId != null) {
|
|
9696
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9697
|
+
trigger: trigger,
|
|
9698
|
+
state: this.slotState,
|
|
9699
|
+
why: "request_already_scheduled"
|
|
9700
|
+
});
|
|
8727
9701
|
return;
|
|
8728
9702
|
}
|
|
8729
|
-
|
|
8730
|
-
|
|
9703
|
+
var remainingMs = this.timing.getRemainingAdMs();
|
|
9704
|
+
var stopReason = this.getStopRequestingReason(remainingMs);
|
|
9705
|
+
if (stopReason) {
|
|
9706
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9707
|
+
trigger: trigger,
|
|
9708
|
+
decision: "end_break",
|
|
9709
|
+
reason: stopReason,
|
|
9710
|
+
remainingMs: remainingMs,
|
|
9711
|
+
requestsSent: this.timing.totalAdRequestsInBreak,
|
|
9712
|
+
unusableResponses: this.unusableResponsesInBreak,
|
|
9713
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
9714
|
+
});
|
|
9715
|
+
this.handleAdPodComplete(stopReason);
|
|
9716
|
+
return;
|
|
9717
|
+
}
|
|
9718
|
+
var waitMs = this.getNextRequestDelayMs();
|
|
9719
|
+
if (waitMs > 0 && this.isBreakTimeBounded() && remainingMs - waitMs < this.getMinRemainingMsToRequestAd()) {
|
|
9720
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9721
|
+
trigger: trigger,
|
|
9722
|
+
decision: "end_break",
|
|
9723
|
+
reason: "insufficient_break_time_after_backoff",
|
|
9724
|
+
remainingMs: remainingMs,
|
|
9725
|
+
waitMs: waitMs
|
|
9726
|
+
});
|
|
9727
|
+
this.handleAdPodComplete("insufficient_break_time_after_backoff");
|
|
9728
|
+
return;
|
|
9729
|
+
}
|
|
9730
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9731
|
+
trigger: trigger,
|
|
9732
|
+
decision: waitMs > 0 ? "request_after_delay" : "request_now",
|
|
9733
|
+
waitMs: waitMs,
|
|
9734
|
+
remainingMs: remainingMs,
|
|
9735
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
9736
|
+
});
|
|
9737
|
+
if (waitMs > 0) {
|
|
9738
|
+
if (!this.isShowingPlaceholder) {
|
|
9739
|
+
this.isShowingPlaceholder = true;
|
|
9740
|
+
this.host.getAdPlayer().showPlaceholder();
|
|
9741
|
+
}
|
|
9742
|
+
var epoch = this.timing.adBreakEpoch;
|
|
9743
|
+
this.nextAdTimerId = window.setTimeout(function() {
|
|
9744
|
+
_this.nextAdTimerId = void 0;
|
|
9745
|
+
if (!_this.inAdBreak || epoch !== _this.timing.adBreakEpoch) return;
|
|
9746
|
+
_this.requestNextAd("".concat(trigger, ":after_delay"));
|
|
9747
|
+
}, waitMs);
|
|
9748
|
+
return;
|
|
8731
9749
|
}
|
|
8732
|
-
this.
|
|
8733
|
-
this.continuousFetchLoop(baseVastUrl);
|
|
9750
|
+
void this.requestFollowUpAd(trigger);
|
|
8734
9751
|
}
|
|
8735
9752
|
},
|
|
8736
9753
|
{
|
|
8737
|
-
key: "
|
|
8738
|
-
value: function
|
|
9754
|
+
key: "requestFollowUpAd",
|
|
9755
|
+
value: function requestFollowUpAd(trigger) {
|
|
8739
9756
|
return _async_to_generator(function() {
|
|
8740
|
-
var
|
|
9757
|
+
var url, epoch, unused;
|
|
8741
9758
|
return _ts_generator(this, function(_state) {
|
|
8742
9759
|
switch(_state.label){
|
|
8743
9760
|
case 0:
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
}
|
|
8754
|
-
return [
|
|
8755
|
-
2,
|
|
8756
|
-
"break"
|
|
8757
|
-
];
|
|
8758
|
-
}
|
|
8759
|
-
if (_this.timing.isGamInCooldown()) {
|
|
8760
|
-
if (_this.debug) {
|
|
8761
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping URL generation");
|
|
8762
|
-
}
|
|
8763
|
-
return [
|
|
8764
|
-
2,
|
|
8765
|
-
"break"
|
|
8766
|
-
];
|
|
8767
|
-
}
|
|
8768
|
-
if (_this.timing.consecutiveFailures >= _this.timing.maxConsecutiveFailures) {
|
|
8769
|
-
if (_this.debug) {
|
|
8770
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(_this.timing.consecutiveFailures, "), stopping URL generation"));
|
|
8771
|
-
}
|
|
8772
|
-
return [
|
|
8773
|
-
2,
|
|
8774
|
-
"break"
|
|
8775
|
-
];
|
|
8776
|
-
}
|
|
8777
|
-
if (_this.timing.totalAdRequestsInBreak >= _this.timing.maxTotalAdRequestsPerBreak) {
|
|
8778
|
-
if (_this.debug) {
|
|
8779
|
-
console.log("[CONTINUOUS-FETCH] Maximum ad requests reached (".concat(_this.timing.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
8780
|
-
}
|
|
8781
|
-
return [
|
|
8782
|
-
2,
|
|
8783
|
-
"break"
|
|
8784
|
-
];
|
|
8785
|
-
}
|
|
8786
|
-
maxQueueSize = 5;
|
|
8787
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
8788
|
-
3,
|
|
8789
|
-
2
|
|
8790
|
-
];
|
|
8791
|
-
if (_this.debug) {
|
|
8792
|
-
console.log("[CONTINUOUS-FETCH] URL queue full (".concat(_this.adRequestQueue.length, "), waiting..."));
|
|
8793
|
-
}
|
|
8794
|
-
return [
|
|
8795
|
-
4,
|
|
8796
|
-
new Promise(function(resolve) {
|
|
8797
|
-
return setTimeout(resolve, 1e3);
|
|
8798
|
-
})
|
|
8799
|
-
];
|
|
8800
|
-
case 1:
|
|
8801
|
-
_state.sent();
|
|
8802
|
-
return [
|
|
8803
|
-
2,
|
|
8804
|
-
"continue"
|
|
8805
|
-
];
|
|
8806
|
-
case 2:
|
|
8807
|
-
newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
|
|
8808
|
-
if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
|
|
8809
|
-
3,
|
|
8810
|
-
4
|
|
8811
|
-
];
|
|
8812
|
-
return [
|
|
8813
|
-
4,
|
|
8814
|
-
new Promise(function(resolve) {
|
|
8815
|
-
return setTimeout(resolve, 500);
|
|
8816
|
-
})
|
|
8817
|
-
];
|
|
8818
|
-
case 3:
|
|
8819
|
-
_state.sent();
|
|
8820
|
-
return [
|
|
8821
|
-
2,
|
|
8822
|
-
"continue"
|
|
8823
|
-
];
|
|
8824
|
-
case 4:
|
|
8825
|
-
if (_this.debug) {
|
|
8826
|
-
queuedUrlsPreview = _to_consumable_array(_this.adRequestQueue).concat([
|
|
8827
|
-
newAdUrl
|
|
8828
|
-
]);
|
|
8829
|
-
console.log("[CONTINUOUS-FETCH] Queued VAST URL (queue size: ".concat(queuedUrlsPreview.length, ")"), {
|
|
8830
|
-
queuedUrls: queuedUrlsPreview
|
|
8831
|
-
});
|
|
8832
|
-
}
|
|
8833
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
8834
|
-
generationDelay = _this.timing.consecutiveFailures > 0 ? Math.min(1e3 * Math.pow(2, _this.timing.consecutiveFailures), 5e3) : 500;
|
|
8835
|
-
return [
|
|
8836
|
-
4,
|
|
8837
|
-
new Promise(function(resolve) {
|
|
8838
|
-
return setTimeout(resolve, generationDelay);
|
|
8839
|
-
})
|
|
8840
|
-
];
|
|
8841
|
-
case 5:
|
|
8842
|
-
_state.sent();
|
|
8843
|
-
return [
|
|
8844
|
-
2
|
|
8845
|
-
];
|
|
8846
|
-
}
|
|
8847
|
-
});
|
|
8848
|
-
};
|
|
9761
|
+
if (this.breakSource === "vmap") {
|
|
9762
|
+
url = this.adPodQueue.shift();
|
|
9763
|
+
} else if (this.followUpBaseVastUrl) {
|
|
9764
|
+
url = this.nextAdRequestUrl(this.followUpBaseVastUrl);
|
|
9765
|
+
}
|
|
9766
|
+
if (!url) return [
|
|
9767
|
+
2
|
|
9768
|
+
];
|
|
9769
|
+
this.noteVastUrlGenerated(ensureVideoAdType(url), trigger);
|
|
8849
9770
|
epoch = this.timing.adBreakEpoch;
|
|
8850
9771
|
_state.label = 1;
|
|
8851
9772
|
case 1:
|
|
8852
|
-
|
|
9773
|
+
_state.trys.push([
|
|
9774
|
+
1,
|
|
8853
9775
|
3,
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
9776
|
+
,
|
|
9777
|
+
4
|
|
9778
|
+
]);
|
|
8857
9779
|
return [
|
|
8858
|
-
|
|
8859
|
-
|
|
9780
|
+
4,
|
|
9781
|
+
this.playSingleAd(url, trigger)
|
|
8860
9782
|
];
|
|
8861
9783
|
case 2:
|
|
8862
|
-
|
|
8863
|
-
|
|
9784
|
+
_state.sent();
|
|
9785
|
+
return [
|
|
8864
9786
|
3,
|
|
8865
|
-
|
|
9787
|
+
4
|
|
8866
9788
|
];
|
|
9789
|
+
case 3:
|
|
9790
|
+
unused = _state.sent();
|
|
9791
|
+
this.continueAfterRequestFailure(epoch);
|
|
8867
9792
|
return [
|
|
8868
9793
|
3,
|
|
8869
|
-
|
|
9794
|
+
4
|
|
8870
9795
|
];
|
|
8871
|
-
case
|
|
8872
|
-
this.continuousFetchLoopRunning = false;
|
|
8873
|
-
if (this.debug) {
|
|
8874
|
-
console.log("[CONTINUOUS-FETCH] URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"), this.adRequestQueue.length > 0 ? {
|
|
8875
|
-
queuedUrls: _to_consumable_array(this.adRequestQueue)
|
|
8876
|
-
} : {});
|
|
8877
|
-
}
|
|
9796
|
+
case 4:
|
|
8878
9797
|
return [
|
|
8879
9798
|
2
|
|
8880
9799
|
];
|
|
@@ -8884,236 +9803,318 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8884
9803
|
}
|
|
8885
9804
|
},
|
|
8886
9805
|
{
|
|
8887
|
-
key: "
|
|
8888
|
-
value: function
|
|
8889
|
-
|
|
8890
|
-
this.
|
|
8891
|
-
this.
|
|
8892
|
-
|
|
8893
|
-
|
|
9806
|
+
key: "continueAfterRequestFailure",
|
|
9807
|
+
value: function continueAfterRequestFailure() {
|
|
9808
|
+
var epoch = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.timing.adBreakEpoch;
|
|
9809
|
+
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) return;
|
|
9810
|
+
this.setSlotState("NEEDS_NEXT_AD", "request_failed");
|
|
9811
|
+
this.requestNextAd("after_failure");
|
|
9812
|
+
}
|
|
9813
|
+
},
|
|
9814
|
+
{
|
|
9815
|
+
key: "cancelScheduledRequest",
|
|
9816
|
+
value: function cancelScheduledRequest() {
|
|
9817
|
+
if (this.nextAdTimerId != null) {
|
|
9818
|
+
clearTimeout(this.nextAdTimerId);
|
|
9819
|
+
this.nextAdTimerId = void 0;
|
|
8894
9820
|
}
|
|
8895
9821
|
}
|
|
8896
9822
|
},
|
|
8897
9823
|
{
|
|
8898
|
-
key: "
|
|
8899
|
-
value:
|
|
8900
|
-
|
|
9824
|
+
key: "noteVastUrlGenerated",
|
|
9825
|
+
value: function noteVastUrlGenerated(url, source) {
|
|
9826
|
+
var _ref, _ref1, _ref2, _ref3, _ref4;
|
|
9827
|
+
var params;
|
|
9828
|
+
try {
|
|
9829
|
+
params = new URL(url).searchParams;
|
|
9830
|
+
} catch (unused) {}
|
|
9831
|
+
var adType = (_ref = params === null || params === void 0 ? void 0 : params.get("ad_type")) !== null && _ref !== void 0 ? _ref : void 0;
|
|
9832
|
+
this.logOrchestratorFunnel("vast_url_generated", {
|
|
9833
|
+
source: source,
|
|
9834
|
+
pod: (_ref1 = params === null || params === void 0 ? void 0 : params.get("pod")) !== null && _ref1 !== void 0 ? _ref1 : void 0,
|
|
9835
|
+
pmad: (_ref2 = params === null || params === void 0 ? void 0 : params.get("pmad")) !== null && _ref2 !== void 0 ? _ref2 : void 0,
|
|
9836
|
+
pmnd: (_ref3 = params === null || params === void 0 ? void 0 : params.get("pmnd")) !== null && _ref3 !== void 0 ? _ref3 : void 0,
|
|
9837
|
+
pmxd: (_ref4 = params === null || params === void 0 ? void 0 : params.get("pmxd")) !== null && _ref4 !== void 0 ? _ref4 : void 0,
|
|
9838
|
+
adType: adType
|
|
9839
|
+
});
|
|
9840
|
+
if (adType === "audio" || adType === "audio_video") {
|
|
9841
|
+
console.warn("[AdBreak] VAST tag requests ad_type=".concat(adType, "; GAM may return audio-only creatives, which this video player rejects"));
|
|
9842
|
+
this.countFunnelStage("tag_allows_audio");
|
|
9843
|
+
}
|
|
9844
|
+
}
|
|
9845
|
+
},
|
|
9846
|
+
{
|
|
9847
|
+
key: "recordRequestFailure",
|
|
9848
|
+
value: function recordRequestFailure(error, vastTagUrl) {
|
|
9849
|
+
var _diag_vastAdCount;
|
|
9850
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
9851
|
+
var message = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
9852
|
+
var outcome;
|
|
9853
|
+
if (message.includes("ad_duration_exceeds_budget")) {
|
|
9854
|
+
outcome = "discarded_budget";
|
|
9855
|
+
} else if (message.includes("VAST fill rejected")) {
|
|
9856
|
+
outcome = "fill_rejected";
|
|
9857
|
+
} else if (/no ads available|no fill|nofill/i.test(message)) {
|
|
9858
|
+
outcome = "no_fill";
|
|
9859
|
+
} else if (/timeout/i.test(message)) {
|
|
9860
|
+
outcome = "request_timeout";
|
|
9861
|
+
} else if (/destroyed|aborted/i.test(message)) {
|
|
9862
|
+
outcome = "request_aborted";
|
|
9863
|
+
} else if (diag && ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired) {
|
|
9864
|
+
outcome = "playback_failed";
|
|
9865
|
+
} else {
|
|
9866
|
+
outcome = "request_failed";
|
|
9867
|
+
}
|
|
9868
|
+
this.timing.consecutiveFailures++;
|
|
9869
|
+
if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
|
|
9870
|
+
this.unusableResponsesInBreak++;
|
|
9871
|
+
}
|
|
9872
|
+
if (outcome === "no_fill") {
|
|
9873
|
+
this.timing.recordGamNoFill();
|
|
9874
|
+
}
|
|
9875
|
+
if (diag && !diag.failureReason) {
|
|
9876
|
+
diag.failureReason = "".concat(outcome, ": ").concat(message);
|
|
9877
|
+
}
|
|
9878
|
+
if (this.timing.isTemporaryAdError(error)) {
|
|
9879
|
+
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9880
|
+
} else if (outcome !== "discarded_budget") {
|
|
9881
|
+
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9882
|
+
}
|
|
9883
|
+
this.countFunnelStage("request_outcome:".concat(outcome));
|
|
9884
|
+
this.logOrchestratorFunnel("request_outcome", {
|
|
9885
|
+
outcome: outcome,
|
|
9886
|
+
errorMessage: message,
|
|
9887
|
+
consecutiveFailures: this.timing.consecutiveFailures,
|
|
9888
|
+
unusableResponsesInBreak: this.unusableResponsesInBreak
|
|
9889
|
+
});
|
|
9890
|
+
}
|
|
9891
|
+
},
|
|
9892
|
+
{
|
|
8901
9893
|
// ───────────────────────────────────────────────────────────────
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
backoffDelay = Math.min(this.timing.backoffBaseMs * backoffMultiplier, this.timing.maxBackoffMs);
|
|
8925
|
-
effectiveMinInterval = this.timing.minAdRequestIntervalMs + (this.timing.consecutiveFailures > 0 ? backoffDelay : 0);
|
|
8926
|
-
timeSinceLastRequest = Date.now() - this.timing.lastAdRequestTime;
|
|
8927
|
-
if (!(timeSinceLastRequest < effectiveMinInterval)) return [
|
|
8928
|
-
3,
|
|
8929
|
-
2
|
|
8930
|
-
];
|
|
8931
|
-
waitTime = effectiveMinInterval - timeSinceLastRequest;
|
|
8932
|
-
if (this.debug) {
|
|
8933
|
-
console.log("[CONTINUOUS-FETCH] Rate limiting: waiting ".concat(waitTime, "ms before next request (backoff: ").concat(this.timing.consecutiveFailures, " failures)"));
|
|
8934
|
-
}
|
|
8935
|
-
return [
|
|
8936
|
-
4,
|
|
8937
|
-
new Promise(function(resolve) {
|
|
8938
|
-
return setTimeout(resolve, waitTime);
|
|
8939
|
-
})
|
|
8940
|
-
];
|
|
8941
|
-
case 1:
|
|
8942
|
-
_state.sent();
|
|
8943
|
-
_state.label = 2;
|
|
8944
|
-
case 2:
|
|
8945
|
-
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) {
|
|
8946
|
-
return [
|
|
8947
|
-
2
|
|
8948
|
-
];
|
|
8949
|
-
}
|
|
8950
|
-
return [
|
|
8951
|
-
2,
|
|
8952
|
-
this.tryNextAvailableAd(0)
|
|
8953
|
-
];
|
|
9894
|
+
// Per-request diagnostics
|
|
9895
|
+
// ───────────────────────────────────────────────────────────────
|
|
9896
|
+
key: "recordRequestDiagnostic",
|
|
9897
|
+
value: function recordRequestDiagnostic(payload) {
|
|
9898
|
+
var requestId = payload.requestId;
|
|
9899
|
+
if (typeof requestId !== "number") return;
|
|
9900
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
9901
|
+
if (!diag) return;
|
|
9902
|
+
switch(payload.stage){
|
|
9903
|
+
case "gam_http_request_sent":
|
|
9904
|
+
diag.gamRequestSent++;
|
|
9905
|
+
break;
|
|
9906
|
+
case "gam_response_received":
|
|
9907
|
+
diag.vastHttpStatus = payload.httpStatus;
|
|
9908
|
+
break;
|
|
9909
|
+
case "vast_parsed":
|
|
9910
|
+
diag.vastAdCount = payload.adElementCount;
|
|
9911
|
+
break;
|
|
9912
|
+
case "wrapper_fetch":
|
|
9913
|
+
case "inline_resolved":
|
|
9914
|
+
if (typeof payload.depth === "number") {
|
|
9915
|
+
diag.wrapperDepth = Math.max(diag.wrapperDepth, payload.depth);
|
|
8954
9916
|
}
|
|
9917
|
+
if (payload.stage === "inline_resolved") diag.inlineResolved = true;
|
|
9918
|
+
break;
|
|
9919
|
+
case "mediafile_evaluated":
|
|
9920
|
+
diag.mediaCandidateCount++;
|
|
9921
|
+
if (payload.whyAccepted) diag.supportedMediaCount++;
|
|
9922
|
+
break;
|
|
9923
|
+
case "playing":
|
|
9924
|
+
diag.playStarted = true;
|
|
9925
|
+
break;
|
|
9926
|
+
case "impression_fired":
|
|
9927
|
+
diag.impressionFired = true;
|
|
9928
|
+
break;
|
|
9929
|
+
default:
|
|
9930
|
+
if (REQUEST_FAILURE_STAGES.has(payload.stage) && !diag.failureReason) {
|
|
9931
|
+
diag.failureReason = payload.reason ? "".concat(payload.stage, ":").concat(payload.reason) : payload.stage;
|
|
9932
|
+
}
|
|
9933
|
+
}
|
|
9934
|
+
}
|
|
9935
|
+
},
|
|
9936
|
+
{
|
|
9937
|
+
key: "finalizeRequestDiagnostics",
|
|
9938
|
+
value: function finalizeRequestDiagnostics(requestId, endReason) {
|
|
9939
|
+
var _diag_vastAdCount;
|
|
9940
|
+
if (requestId == null) return;
|
|
9941
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
9942
|
+
if (!diag) return;
|
|
9943
|
+
this.requestDiagnostics.delete(requestId);
|
|
9944
|
+
if (!diag.impressionFired && !diag.failureReason && endReason) {
|
|
9945
|
+
diag.failureReason = endReason;
|
|
9946
|
+
}
|
|
9947
|
+
var gamReturnedAdWithoutImpression = ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired;
|
|
9948
|
+
if (gamReturnedAdWithoutImpression) {
|
|
9949
|
+
this.countFunnelStage("gam_ad_without_impression");
|
|
9950
|
+
}
|
|
9951
|
+
var startedAt = diag.startedAt, fields = _object_without_properties(diag, [
|
|
9952
|
+
"startedAt"
|
|
9953
|
+
]);
|
|
9954
|
+
console.log("[AdBreak][REQUEST] summary", _object_spread_props(_object_spread({}, fields), {
|
|
9955
|
+
durationMs: Date.now() - startedAt,
|
|
9956
|
+
gamReturnedAdWithoutImpression: gamReturnedAdWithoutImpression
|
|
9957
|
+
}));
|
|
9958
|
+
}
|
|
9959
|
+
},
|
|
9960
|
+
{
|
|
9961
|
+
// ───────────────────────────────────────────────────────────────
|
|
9962
|
+
// Single ad playback
|
|
9963
|
+
// ───────────────────────────────────────────────────────────────
|
|
9964
|
+
key: "withCurrentPodBudget",
|
|
9965
|
+
value: function withCurrentPodBudget(rawVastTagUrl) {
|
|
9966
|
+
var vastTagUrl = ensureVideoAdType(rawVastTagUrl);
|
|
9967
|
+
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9968
|
+
if (!(remaining > 0)) return vastTagUrl;
|
|
9969
|
+
try {
|
|
9970
|
+
var url = new URL(vastTagUrl);
|
|
9971
|
+
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
9972
|
+
var maxMs = Math.round(remaining);
|
|
9973
|
+
url.searchParams.set("pmxd", String(maxMs));
|
|
9974
|
+
var minMs = Number(url.searchParams.get("pmnd"));
|
|
9975
|
+
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
9976
|
+
url.searchParams.set("pmnd", String(maxMs));
|
|
9977
|
+
}
|
|
9978
|
+
return url.toString();
|
|
9979
|
+
} catch (unused) {
|
|
9980
|
+
return vastTagUrl;
|
|
9981
|
+
}
|
|
9982
|
+
}
|
|
9983
|
+
},
|
|
9984
|
+
{
|
|
9985
|
+
key: "countFunnelStage",
|
|
9986
|
+
value: function countFunnelStage(stage) {
|
|
9987
|
+
var amount = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
|
|
9988
|
+
var _this_breakFunnel_stage;
|
|
9989
|
+
this.breakFunnel[stage] = ((_this_breakFunnel_stage = this.breakFunnel[stage]) !== null && _this_breakFunnel_stage !== void 0 ? _this_breakFunnel_stage : 0) + amount;
|
|
9990
|
+
}
|
|
9991
|
+
},
|
|
9992
|
+
{
|
|
9993
|
+
key: "logOrchestratorFunnel",
|
|
9994
|
+
value: function logOrchestratorFunnel(stage) {
|
|
9995
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
9996
|
+
this.countFunnelStage(stage);
|
|
9997
|
+
console.log("[AdBreak][FUNNEL] ".concat(stage), _object_spread({
|
|
9998
|
+
breakId: this.timing.adBreakEpoch,
|
|
9999
|
+
requestId: this.currentRequestId,
|
|
10000
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0
|
|
10001
|
+
}, extra));
|
|
10002
|
+
}
|
|
10003
|
+
},
|
|
10004
|
+
{
|
|
10005
|
+
key: "noteOpportunity",
|
|
10006
|
+
value: function noteOpportunity(source, breakKey) {
|
|
10007
|
+
if (breakKey && breakKey === this.opportunityBreakKey && this.opportunityEpoch === this.timing.adBreakEpoch) {
|
|
10008
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
10009
|
+
source: source,
|
|
10010
|
+
breakKey: breakKey
|
|
8955
10011
|
});
|
|
8956
|
-
|
|
10012
|
+
return;
|
|
10013
|
+
}
|
|
10014
|
+
this.opportunityBreakKey = breakKey;
|
|
10015
|
+
this.opportunityEpoch = this.timing.adBreakEpoch;
|
|
10016
|
+
this.logOrchestratorFunnel("opportunity_created", {
|
|
10017
|
+
source: source,
|
|
10018
|
+
breakKey: breakKey,
|
|
10019
|
+
expectedDurationMs: this.timing.expectedAdBreakDurationMs
|
|
10020
|
+
});
|
|
10021
|
+
}
|
|
10022
|
+
},
|
|
10023
|
+
{
|
|
10024
|
+
key: "beginFunnelRequest",
|
|
10025
|
+
value: function beginFunnelRequest(adPlayer, requestToken, trigger) {
|
|
10026
|
+
var _adPlayer_setFunnelContext;
|
|
10027
|
+
if (this.controllerCallInFlight) {
|
|
10028
|
+
this.logOrchestratorFunnel("duplicate_request_detected", {
|
|
10029
|
+
newRequestId: requestToken
|
|
10030
|
+
});
|
|
10031
|
+
}
|
|
10032
|
+
this.finalizeRequestDiagnostics(this.currentRequestId);
|
|
10033
|
+
this.currentRequestId = requestToken;
|
|
10034
|
+
this.requestStartedAt = Date.now();
|
|
10035
|
+
this.requestDiagnostics.set(requestToken, {
|
|
10036
|
+
breakId: this.timing.adBreakEpoch,
|
|
10037
|
+
requestId: requestToken,
|
|
10038
|
+
controllerId: this.controllerGeneration,
|
|
10039
|
+
trigger: trigger,
|
|
10040
|
+
gamRequestSent: 0,
|
|
10041
|
+
wrapperDepth: 0,
|
|
10042
|
+
inlineResolved: false,
|
|
10043
|
+
mediaCandidateCount: 0,
|
|
10044
|
+
supportedMediaCount: 0,
|
|
10045
|
+
playStarted: false,
|
|
10046
|
+
impressionFired: false,
|
|
10047
|
+
startedAt: Date.now()
|
|
10048
|
+
});
|
|
10049
|
+
(_adPlayer_setFunnelContext = adPlayer.setFunnelContext) === null || _adPlayer_setFunnelContext === void 0 ? void 0 : _adPlayer_setFunnelContext.call(adPlayer, {
|
|
10050
|
+
breakId: this.timing.adBreakEpoch,
|
|
10051
|
+
requestId: requestToken,
|
|
10052
|
+
controllerId: this.controllerGeneration
|
|
10053
|
+
});
|
|
10054
|
+
}
|
|
10055
|
+
},
|
|
10056
|
+
{
|
|
10057
|
+
key: "isAdLoadingWithoutPlayback",
|
|
10058
|
+
value: function isAdLoadingWithoutPlayback() {
|
|
10059
|
+
return this.host.getAdPlayer().isAdPlaying() && !this.playbackStartedForCurrentRequest;
|
|
10060
|
+
}
|
|
10061
|
+
},
|
|
10062
|
+
{
|
|
10063
|
+
key: "noteStopBeforeStart",
|
|
10064
|
+
value: function noteStopBeforeStart(reason) {
|
|
10065
|
+
if (!this.isAdLoadingWithoutPlayback()) return;
|
|
10066
|
+
this.logOrchestratorFunnel("ad_stopped_before_start", {
|
|
10067
|
+
reason: reason,
|
|
10068
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
10069
|
+
});
|
|
10070
|
+
}
|
|
10071
|
+
},
|
|
10072
|
+
{
|
|
10073
|
+
key: "handleRequestWatchdogTimeout",
|
|
10074
|
+
value: function handleRequestWatchdogTimeout() {
|
|
10075
|
+
var adPlayer = this.host.getAdPlayer();
|
|
10076
|
+
if (this.controllerCallInFlight && adPlayer.abortPendingRequest) {
|
|
10077
|
+
this.logOrchestratorFunnel("request_aborted_timeout", {
|
|
10078
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
10079
|
+
});
|
|
10080
|
+
adPlayer.abortPendingRequest("VAST request aborted after request watchdog timeout");
|
|
10081
|
+
return;
|
|
10082
|
+
}
|
|
10083
|
+
this.handleAdFailure("request_watchdog_timeout");
|
|
8957
10084
|
}
|
|
8958
10085
|
},
|
|
8959
10086
|
{
|
|
8960
|
-
key: "
|
|
8961
|
-
value: function
|
|
8962
|
-
var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
|
10087
|
+
key: "callController",
|
|
10088
|
+
value: function callController(call) {
|
|
8963
10089
|
return _async_to_generator(function() {
|
|
8964
|
-
var remaining, nextAdUrl, error, errorMessage, maxRetries;
|
|
8965
10090
|
return _ts_generator(this, function(_state) {
|
|
8966
10091
|
switch(_state.label){
|
|
8967
10092
|
case 0:
|
|
8968
|
-
|
|
8969
|
-
return [
|
|
8970
|
-
2
|
|
8971
|
-
];
|
|
8972
|
-
}
|
|
8973
|
-
remaining = this.timing.getRemainingAdMs();
|
|
8974
|
-
if (!this.timing.hasTimeToStartAnotherAd()) {
|
|
8975
|
-
if (this.debug) {
|
|
8976
|
-
console.log("[CONTINUOUS-FETCH] Not enough time remaining (".concat(remaining, "ms) to start another ad, ending ad break"));
|
|
8977
|
-
}
|
|
8978
|
-
this.handleAdPodComplete();
|
|
8979
|
-
return [
|
|
8980
|
-
2
|
|
8981
|
-
];
|
|
8982
|
-
}
|
|
8983
|
-
if (this.timing.isGamInCooldown()) {
|
|
8984
|
-
if (this.debug) {
|
|
8985
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, ending ad break gracefully");
|
|
8986
|
-
}
|
|
8987
|
-
this.handleAdPodComplete();
|
|
8988
|
-
return [
|
|
8989
|
-
2
|
|
8990
|
-
];
|
|
8991
|
-
}
|
|
8992
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
8993
|
-
if (this.debug) {
|
|
8994
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(this.timing.consecutiveFailures, "), ending ad break"));
|
|
8995
|
-
}
|
|
8996
|
-
this.handleAdPodComplete();
|
|
8997
|
-
return [
|
|
8998
|
-
2
|
|
8999
|
-
];
|
|
9000
|
-
}
|
|
9001
|
-
this.timing.cleanupTemporaryFailures();
|
|
10093
|
+
this.controllerCallInFlight = true;
|
|
9002
10094
|
_state.label = 1;
|
|
9003
10095
|
case 1:
|
|
9004
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
9005
|
-
3,
|
|
9006
|
-
9
|
|
9007
|
-
];
|
|
9008
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
9009
|
-
if (!nextAdUrl) return [
|
|
9010
|
-
3,
|
|
9011
|
-
1
|
|
9012
|
-
];
|
|
9013
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) {
|
|
9014
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
|
|
9015
|
-
return [
|
|
9016
|
-
3,
|
|
9017
|
-
1
|
|
9018
|
-
];
|
|
9019
|
-
}
|
|
9020
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) {
|
|
9021
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
|
|
9022
|
-
return [
|
|
9023
|
-
3,
|
|
9024
|
-
1
|
|
9025
|
-
];
|
|
9026
|
-
}
|
|
9027
|
-
if (this.debug) {
|
|
9028
|
-
console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
|
|
9029
|
-
}
|
|
9030
|
-
_state.label = 2;
|
|
9031
|
-
case 2:
|
|
9032
10096
|
_state.trys.push([
|
|
9033
|
-
|
|
9034
|
-
4,
|
|
10097
|
+
1,
|
|
9035
10098
|
,
|
|
9036
|
-
8
|
|
9037
|
-
]);
|
|
9038
|
-
return [
|
|
9039
|
-
4,
|
|
9040
|
-
this.playSingleAd(nextAdUrl)
|
|
9041
|
-
];
|
|
9042
|
-
case 3:
|
|
9043
|
-
_state.sent();
|
|
9044
|
-
this.timing.consecutiveFailures = 0;
|
|
9045
|
-
return [
|
|
9046
10099
|
3,
|
|
9047
|
-
|
|
9048
|
-
];
|
|
9049
|
-
case 4:
|
|
9050
|
-
error = _state.sent();
|
|
9051
|
-
errorMessage = error.message;
|
|
9052
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
|
|
9053
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
9054
|
-
3,
|
|
9055
|
-
6
|
|
9056
|
-
];
|
|
9057
|
-
return [
|
|
9058
|
-
4,
|
|
9059
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9060
|
-
];
|
|
9061
|
-
case 5:
|
|
9062
|
-
_state.sent();
|
|
9063
|
-
return [
|
|
9064
|
-
2
|
|
9065
|
-
];
|
|
9066
|
-
case 6:
|
|
9067
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
9068
|
-
this.timing.consecutiveFailures++;
|
|
9069
|
-
}
|
|
10100
|
+
4
|
|
10101
|
+
]);
|
|
9070
10102
|
return [
|
|
9071
10103
|
4,
|
|
9072
|
-
|
|
10104
|
+
call()
|
|
9073
10105
|
];
|
|
9074
|
-
case
|
|
10106
|
+
case 2:
|
|
9075
10107
|
_state.sent();
|
|
9076
10108
|
return [
|
|
9077
10109
|
3,
|
|
9078
|
-
|
|
9079
|
-
];
|
|
9080
|
-
case 8:
|
|
9081
|
-
return [
|
|
9082
|
-
2
|
|
9083
|
-
];
|
|
9084
|
-
case 9:
|
|
9085
|
-
maxRetries = 3;
|
|
9086
|
-
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
9087
|
-
3,
|
|
9088
|
-
12
|
|
9089
|
-
];
|
|
9090
|
-
if (this.debug) {
|
|
9091
|
-
console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
9092
|
-
}
|
|
9093
|
-
return [
|
|
9094
|
-
4,
|
|
9095
|
-
new Promise(function(resolve) {
|
|
9096
|
-
return setTimeout(resolve, 500);
|
|
9097
|
-
})
|
|
9098
|
-
];
|
|
9099
|
-
case 10:
|
|
9100
|
-
_state.sent();
|
|
9101
|
-
return [
|
|
9102
|
-
4,
|
|
9103
|
-
this.tryNextAvailableAd(retryCount + 1)
|
|
10110
|
+
4
|
|
9104
10111
|
];
|
|
9105
|
-
case
|
|
9106
|
-
|
|
10112
|
+
case 3:
|
|
10113
|
+
this.controllerCallInFlight = false;
|
|
9107
10114
|
return [
|
|
9108
|
-
|
|
10115
|
+
7
|
|
9109
10116
|
];
|
|
9110
|
-
case
|
|
9111
|
-
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
9112
|
-
this.showPlaceholderAndWaitForAds();
|
|
9113
|
-
} else {
|
|
9114
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] No more ads available, ending ad break");
|
|
9115
|
-
this.handleAdPodComplete();
|
|
9116
|
-
}
|
|
10117
|
+
case 4:
|
|
9117
10118
|
return [
|
|
9118
10119
|
2
|
|
9119
10120
|
];
|
|
@@ -9122,47 +10123,33 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9122
10123
|
}).call(this);
|
|
9123
10124
|
}
|
|
9124
10125
|
},
|
|
9125
|
-
{
|
|
9126
|
-
// ───────────────────────────────────────────────────────────────
|
|
9127
|
-
// Single ad playback
|
|
9128
|
-
// ───────────────────────────────────────────────────────────────
|
|
9129
|
-
key: "withCurrentPodBudget",
|
|
9130
|
-
value: function withCurrentPodBudget(vastTagUrl) {
|
|
9131
|
-
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9132
|
-
if (!(remaining > 0)) return vastTagUrl;
|
|
9133
|
-
try {
|
|
9134
|
-
var url = new URL(vastTagUrl);
|
|
9135
|
-
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
9136
|
-
var maxMs = Math.round(remaining);
|
|
9137
|
-
url.searchParams.set("pmxd", String(maxMs));
|
|
9138
|
-
var minMs = Number(url.searchParams.get("pmnd"));
|
|
9139
|
-
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
9140
|
-
url.searchParams.set("pmnd", String(maxMs));
|
|
9141
|
-
}
|
|
9142
|
-
return url.toString();
|
|
9143
|
-
} catch (unused) {
|
|
9144
|
-
return vastTagUrl;
|
|
9145
|
-
}
|
|
9146
|
-
}
|
|
9147
|
-
},
|
|
9148
10126
|
{
|
|
9149
10127
|
key: "playSingleAd",
|
|
9150
10128
|
value: function playSingleAd(vastTagUrl) {
|
|
10129
|
+
var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
|
|
9151
10130
|
return _async_to_generator(function() {
|
|
9152
|
-
var
|
|
10131
|
+
var epoch, generation, requestToken, ap, requestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
|
|
9153
10132
|
return _ts_generator(this, function(_state) {
|
|
9154
10133
|
switch(_state.label){
|
|
9155
10134
|
case 0:
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
10135
|
+
if (this.slotState === "REQUESTING" || this.slotState === "READY" || this.slotState === "PLAYING" || this.slotState === "ENDING") {
|
|
10136
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
10137
|
+
trigger: trigger,
|
|
10138
|
+
state: this.slotState,
|
|
10139
|
+
why: "request_in_flight"
|
|
10140
|
+
});
|
|
10141
|
+
return [
|
|
10142
|
+
2
|
|
10143
|
+
];
|
|
10144
|
+
}
|
|
9160
10145
|
if (this.timing.failedVastUrls.has(vastTagUrl)) {
|
|
9161
10146
|
if (this.debug) console.warn("[AD-ERROR] Skipping permanently-failed VAST URL:", vastTagUrl);
|
|
10147
|
+
this.timing.consecutiveFailures++;
|
|
9162
10148
|
throw new Error("VAST URL permanently failed");
|
|
9163
10149
|
}
|
|
9164
10150
|
if (this.timing.isUrlInCooldown(vastTagUrl)) {
|
|
9165
10151
|
if (this.debug) console.warn("[AD-ERROR] Skipping URL in cooldown (recent no-fill):", vastTagUrl);
|
|
10152
|
+
this.timing.consecutiveFailures++;
|
|
9166
10153
|
throw new Error("VAST URL in cooldown after no-fill");
|
|
9167
10154
|
}
|
|
9168
10155
|
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
@@ -9173,16 +10160,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9173
10160
|
if (this.debug) console.warn("[CIRCUIT-BREAKER] GAM in cooldown, skipping ad request");
|
|
9174
10161
|
throw new Error("GAM in cooldown");
|
|
9175
10162
|
}
|
|
9176
|
-
this.
|
|
10163
|
+
epoch = this.timing.adBreakEpoch;
|
|
10164
|
+
this.recreateAdController("new_request");
|
|
10165
|
+
generation = this.controllerGeneration;
|
|
9177
10166
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
9178
10167
|
this.timing.activeAdRequestToken = requestToken;
|
|
10168
|
+
ap = this.host.getAdPlayer();
|
|
10169
|
+
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
10170
|
+
this.currentVastUrl = requestUrl;
|
|
10171
|
+
this.setSlotState("REQUESTING", trigger);
|
|
10172
|
+
this.beginFunnelRequest(ap, requestToken, trigger);
|
|
9179
10173
|
_state.label = 1;
|
|
9180
10174
|
case 1:
|
|
9181
10175
|
_state.trys.push([
|
|
9182
10176
|
1,
|
|
9183
|
-
|
|
10177
|
+
5,
|
|
9184
10178
|
,
|
|
9185
|
-
|
|
10179
|
+
6
|
|
9186
10180
|
]);
|
|
9187
10181
|
return [
|
|
9188
10182
|
4,
|
|
@@ -9190,265 +10184,87 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9190
10184
|
];
|
|
9191
10185
|
case 2:
|
|
9192
10186
|
_state.sent();
|
|
10187
|
+
if (this.isStale(epoch, generation)) return [
|
|
10188
|
+
2
|
|
10189
|
+
];
|
|
9193
10190
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
9194
|
-
this.timing.lastAdRequestTime = Date.now();
|
|
9195
|
-
ap = this.host.getAdPlayer();
|
|
9196
|
-
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9197
|
-
this.currentVastUrl = requestUrl;
|
|
9198
10191
|
return [
|
|
9199
10192
|
4,
|
|
9200
|
-
|
|
10193
|
+
this.callController(function() {
|
|
10194
|
+
return ap.requestAds(requestUrl);
|
|
10195
|
+
})
|
|
9201
10196
|
];
|
|
9202
10197
|
case 3:
|
|
9203
10198
|
_state.sent();
|
|
10199
|
+
this.timing.clearAdRequestWatchdog();
|
|
10200
|
+
if (this.isStale(epoch, generation)) {
|
|
10201
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
10202
|
+
requestId: requestToken
|
|
10203
|
+
});
|
|
10204
|
+
return [
|
|
10205
|
+
2
|
|
10206
|
+
];
|
|
10207
|
+
}
|
|
9204
10208
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
9205
10209
|
source: "hls",
|
|
9206
10210
|
vastUrl: requestUrl,
|
|
9207
10211
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
9208
10212
|
}, this.analyticsContext).catch(function() {});
|
|
9209
|
-
this.timing.clearAdRequestWatchdog();
|
|
9210
|
-
if (this.timing.activeAdRequestToken !== requestToken) return [
|
|
9211
|
-
2
|
|
9212
|
-
];
|
|
9213
10213
|
if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
|
|
9214
|
-
|
|
9215
|
-
|
|
10214
|
+
;
|
|
10215
|
+
adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
|
|
10216
|
+
remainingMs = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
10217
|
+
this.logOrchestratorFunnel("discarded_budget", {
|
|
10218
|
+
adDurationMs: adDurationS != null ? adDurationS * 1e3 : void 0,
|
|
10219
|
+
remainingMs: remainingMs
|
|
10220
|
+
});
|
|
9216
10221
|
throw new Error("ad_duration_exceeds_budget");
|
|
9217
10222
|
}
|
|
9218
|
-
|
|
9219
|
-
case 4:
|
|
9220
|
-
_state.trys.push([
|
|
9221
|
-
4,
|
|
9222
|
-
6,
|
|
9223
|
-
,
|
|
9224
|
-
7
|
|
9225
|
-
]);
|
|
10223
|
+
this.setSlotState("READY", "vast_ready");
|
|
9226
10224
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
9227
10225
|
return [
|
|
9228
10226
|
4,
|
|
9229
|
-
|
|
10227
|
+
this.callController(function() {
|
|
10228
|
+
return ap.play();
|
|
10229
|
+
})
|
|
9230
10230
|
];
|
|
9231
|
-
case
|
|
10231
|
+
case 4:
|
|
9232
10232
|
_state.sent();
|
|
9233
|
-
this.
|
|
10233
|
+
if (this.isStale(epoch, generation)) return [
|
|
10234
|
+
2
|
|
10235
|
+
];
|
|
9234
10236
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
9235
10237
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
9236
10238
|
}
|
|
9237
10239
|
ap.setAdVolume(getAdAudioVolume(ap));
|
|
9238
|
-
this.timing.consecutiveFailures = 0;
|
|
9239
10240
|
this.timing.temporaryFailureUrls.delete(vastTagUrl);
|
|
9240
10241
|
return [
|
|
9241
10242
|
3,
|
|
9242
|
-
|
|
9243
|
-
];
|
|
9244
|
-
case 6:
|
|
9245
|
-
playError = _state.sent();
|
|
9246
|
-
if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
|
|
9247
|
-
if (this.timing.isTemporaryAdError(playError)) {
|
|
9248
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9249
|
-
if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
|
|
9250
|
-
} else {
|
|
9251
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9252
|
-
if (this.debug) console.log("[AD-ERROR] Permanent play error - URL blacklisted");
|
|
9253
|
-
}
|
|
9254
|
-
this.timing.clearAdFailsafeTimer();
|
|
9255
|
-
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9256
|
-
this.timing.activeAdRequestToken = null;
|
|
9257
|
-
}
|
|
9258
|
-
throw playError;
|
|
9259
|
-
case 7:
|
|
9260
|
-
return [
|
|
9261
|
-
3,
|
|
9262
|
-
9
|
|
10243
|
+
6
|
|
9263
10244
|
];
|
|
9264
|
-
case
|
|
10245
|
+
case 5:
|
|
9265
10246
|
error = _state.sent();
|
|
9266
|
-
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
9267
|
-
if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
|
|
9268
|
-
if (this.timing.isTemporaryAdError(error)) {
|
|
9269
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9270
|
-
if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
|
|
9271
|
-
} else {
|
|
9272
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9273
|
-
if (this.debug) console.log("[AD-ERROR] Permanent error - URL blacklisted:", errorMessage);
|
|
9274
|
-
}
|
|
9275
10247
|
this.timing.clearAdRequestWatchdog();
|
|
9276
10248
|
this.timing.clearAdFailsafeTimer();
|
|
9277
10249
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9278
10250
|
this.timing.activeAdRequestToken = null;
|
|
9279
10251
|
}
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
}
|
|
9286
|
-
});
|
|
9287
|
-
}).call(this);
|
|
9288
|
-
}
|
|
9289
|
-
},
|
|
9290
|
-
{
|
|
9291
|
-
key: "showPlaceholderAndWaitForAds",
|
|
9292
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9293
|
-
// Placeholder wait
|
|
9294
|
-
// ───────────────────────────────────────────────────────────────
|
|
9295
|
-
function showPlaceholderAndWaitForAds() {
|
|
9296
|
-
return _async_to_generator(function() {
|
|
9297
|
-
var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
|
|
9298
|
-
return _ts_generator(this, function(_state) {
|
|
9299
|
-
switch(_state.label){
|
|
9300
|
-
case 0:
|
|
9301
|
-
remaining = this.timing.getRemainingAdMs();
|
|
9302
|
-
waitTime = Math.min(this.maxPlaceholderDurationMs, remaining);
|
|
9303
|
-
if (this.timing.isGamInCooldown()) {
|
|
9304
|
-
if (this.debug) console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping placeholder wait");
|
|
9305
|
-
this.handleAdPodComplete();
|
|
9306
|
-
return [
|
|
9307
|
-
2
|
|
9308
|
-
];
|
|
9309
|
-
}
|
|
9310
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9311
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping placeholder - too many consecutive failures");
|
|
9312
|
-
this.handleAdPodComplete();
|
|
9313
|
-
return [
|
|
9314
|
-
2
|
|
9315
|
-
];
|
|
9316
|
-
}
|
|
9317
|
-
if (waitTime < 1e3) {
|
|
9318
|
-
this.handleAdPodComplete();
|
|
10252
|
+
if (this.isStale(epoch, generation)) {
|
|
10253
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
10254
|
+
requestId: requestToken,
|
|
10255
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
10256
|
+
});
|
|
9319
10257
|
return [
|
|
9320
10258
|
2
|
|
9321
10259
|
];
|
|
9322
10260
|
}
|
|
9323
|
-
if (this.debug)
|
|
9324
|
-
|
|
10261
|
+
if (this.debug) console.error("[AD-ERROR] Ad request failed:", error === null || error === void 0 ? void 0 : error.message);
|
|
10262
|
+
this.recordRequestFailure(error, vastTagUrl);
|
|
10263
|
+
if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
|
|
10264
|
+
this.recreateAdController("discarded_budget");
|
|
9325
10265
|
}
|
|
9326
|
-
|
|
9327
|
-
this.host.getAdPlayer().showPlaceholder();
|
|
9328
|
-
checkInterval = 300;
|
|
9329
|
-
maxChecks = Math.floor(waitTime / checkInterval);
|
|
9330
|
-
i = 0;
|
|
9331
|
-
_state.label = 1;
|
|
9332
|
-
case 1:
|
|
9333
|
-
if (!(i < maxChecks)) return [
|
|
9334
|
-
3,
|
|
9335
|
-
12
|
|
9336
|
-
];
|
|
9337
|
-
return [
|
|
9338
|
-
4,
|
|
9339
|
-
new Promise(function(resolve) {
|
|
9340
|
-
return setTimeout(resolve, checkInterval);
|
|
9341
|
-
})
|
|
9342
|
-
];
|
|
9343
|
-
case 2:
|
|
9344
|
-
_state.sent();
|
|
9345
|
-
if (!this.inAdBreak) return [
|
|
9346
|
-
2
|
|
9347
|
-
];
|
|
9348
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9349
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Too many failures during placeholder wait");
|
|
9350
|
-
return [
|
|
9351
|
-
3,
|
|
9352
|
-
12
|
|
9353
|
-
];
|
|
9354
|
-
}
|
|
9355
|
-
if (!this.timing.hasTimeToStartAnotherAd()) {
|
|
9356
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Not enough time remaining during placeholder wait, ending ad break");
|
|
9357
|
-
return [
|
|
9358
|
-
3,
|
|
9359
|
-
12
|
|
9360
|
-
];
|
|
9361
|
-
}
|
|
9362
|
-
_state.label = 3;
|
|
9363
|
-
case 3:
|
|
9364
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
9365
|
-
3,
|
|
9366
|
-
11
|
|
9367
|
-
];
|
|
9368
|
-
if (!this.timing.hasTimeToStartAnotherAd()) return [
|
|
9369
|
-
3,
|
|
9370
|
-
11
|
|
9371
|
-
];
|
|
9372
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
9373
|
-
if (!nextAdUrl) return [
|
|
9374
|
-
3,
|
|
9375
|
-
3
|
|
9376
|
-
];
|
|
9377
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) return [
|
|
9378
|
-
3,
|
|
9379
|
-
3
|
|
9380
|
-
];
|
|
9381
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) return [
|
|
9382
|
-
3,
|
|
9383
|
-
3
|
|
9384
|
-
];
|
|
9385
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad URL available, requesting via HLS ad player");
|
|
9386
|
-
this.isShowingPlaceholder = false;
|
|
9387
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
9388
|
-
_state.label = 4;
|
|
9389
|
-
case 4:
|
|
9390
|
-
_state.trys.push([
|
|
9391
|
-
4,
|
|
9392
|
-
6,
|
|
9393
|
-
,
|
|
9394
|
-
10
|
|
9395
|
-
]);
|
|
9396
|
-
return [
|
|
9397
|
-
4,
|
|
9398
|
-
this.playSingleAd(nextAdUrl)
|
|
9399
|
-
];
|
|
9400
|
-
case 5:
|
|
9401
|
-
_state.sent();
|
|
9402
|
-
this.timing.consecutiveFailures = 0;
|
|
9403
|
-
return [
|
|
9404
|
-
3,
|
|
9405
|
-
10
|
|
9406
|
-
];
|
|
10266
|
+
throw error;
|
|
9407
10267
|
case 6:
|
|
9408
|
-
error = _state.sent();
|
|
9409
|
-
errorMessage = error.message;
|
|
9410
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
9411
|
-
3,
|
|
9412
|
-
8
|
|
9413
|
-
];
|
|
9414
|
-
return [
|
|
9415
|
-
4,
|
|
9416
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9417
|
-
];
|
|
9418
|
-
case 7:
|
|
9419
|
-
_state.sent();
|
|
9420
|
-
return [
|
|
9421
|
-
2
|
|
9422
|
-
];
|
|
9423
|
-
case 8:
|
|
9424
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
9425
|
-
this.timing.consecutiveFailures++;
|
|
9426
|
-
}
|
|
9427
|
-
return [
|
|
9428
|
-
4,
|
|
9429
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9430
|
-
];
|
|
9431
|
-
case 9:
|
|
9432
|
-
_state.sent();
|
|
9433
|
-
return [
|
|
9434
|
-
3,
|
|
9435
|
-
10
|
|
9436
|
-
];
|
|
9437
|
-
case 10:
|
|
9438
|
-
return [
|
|
9439
|
-
2
|
|
9440
|
-
];
|
|
9441
|
-
case 11:
|
|
9442
|
-
i++;
|
|
9443
|
-
return [
|
|
9444
|
-
3,
|
|
9445
|
-
1
|
|
9446
|
-
];
|
|
9447
|
-
case 12:
|
|
9448
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Placeholder timeout, ending ad break");
|
|
9449
|
-
this.isShowingPlaceholder = false;
|
|
9450
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
9451
|
-
this.handleAdPodComplete();
|
|
9452
10268
|
return [
|
|
9453
10269
|
2
|
|
9454
10270
|
];
|
|
@@ -9461,26 +10277,136 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9461
10277
|
// ───────────────────────────────────────────────────────────────
|
|
9462
10278
|
// Ad break completion
|
|
9463
10279
|
// ───────────────────────────────────────────────────────────────
|
|
10280
|
+
key: "logBreakFunnel",
|
|
10281
|
+
value: function logBreakFunnel(endReason) {
|
|
10282
|
+
var funnel = this.breakFunnel;
|
|
10283
|
+
this.breakFunnel = {};
|
|
10284
|
+
if (Object.keys(funnel).length === 0) return;
|
|
10285
|
+
var count = function count(stage) {
|
|
10286
|
+
var _funnel_stage;
|
|
10287
|
+
return (_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0;
|
|
10288
|
+
};
|
|
10289
|
+
var countPrefix = function countPrefix(prefix) {
|
|
10290
|
+
return Object.keys(funnel).reduce(function(total, stage) {
|
|
10291
|
+
var _funnel_stage;
|
|
10292
|
+
return stage.indexOf(prefix) === 0 ? total + ((_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0) : total;
|
|
10293
|
+
}, 0);
|
|
10294
|
+
};
|
|
10295
|
+
var breakId = this.opportunityEpoch;
|
|
10296
|
+
var requestRetries = count("gam_http_request_retry");
|
|
10297
|
+
var requests = count("gam_http_request_sent") - requestRetries;
|
|
10298
|
+
if (requests > 0 && count("impression_fired") === 0) {
|
|
10299
|
+
console.log("[AdBreak][FUNNEL] break_abandoned_before_start", {
|
|
10300
|
+
breakId: breakId,
|
|
10301
|
+
requests: requests,
|
|
10302
|
+
endReason: endReason
|
|
10303
|
+
});
|
|
10304
|
+
}
|
|
10305
|
+
console.log("[AdBreak][FUNNEL] Break summary", {
|
|
10306
|
+
breakId: breakId,
|
|
10307
|
+
endReason: endReason,
|
|
10308
|
+
opportunities: count("opportunity_created"),
|
|
10309
|
+
vastUrlsGenerated: count("vast_url_generated"),
|
|
10310
|
+
requests: requests,
|
|
10311
|
+
requestRetries: requestRetries,
|
|
10312
|
+
gamResponses: count("gam_response_received"),
|
|
10313
|
+
requestsSuppressed: count("request_suppressed"),
|
|
10314
|
+
duplicates: count("duplicate_request_detected") + count("duplicate_break_start"),
|
|
10315
|
+
filled: count("vast_received"),
|
|
10316
|
+
noFill: count("no_fill"),
|
|
10317
|
+
fillRejected: count("vast_fill_rejected"),
|
|
10318
|
+
gamAdWithoutImpression: count("gam_ad_without_impression"),
|
|
10319
|
+
playbackFailedAfterFill: count("request_outcome:playback_failed"),
|
|
10320
|
+
requestFailed: count("request_failed"),
|
|
10321
|
+
requestAbortedTimeout: count("request_aborted_timeout"),
|
|
10322
|
+
credentialsRetries: count("vast_credentials_retry"),
|
|
10323
|
+
wrapperFailures: count("wrapper_fetch:failure"),
|
|
10324
|
+
noSupportedMedia: count("vast_no_supported_media"),
|
|
10325
|
+
vpaidOnly: count("vast_no_supported_media:vpaid"),
|
|
10326
|
+
audioOnly: count("vast_no_supported_media:audio_only"),
|
|
10327
|
+
mediaFilesEvaluated: count("mediafile_evaluated"),
|
|
10328
|
+
mediaFilesAccepted: count("mediafile_evaluated:accepted"),
|
|
10329
|
+
controllerDestroys: countPrefix("controller_destroy:"),
|
|
10330
|
+
staleCallbacks: count("stale_callback_ignored") + count("stale_request_result_ignored"),
|
|
10331
|
+
tagAllowsAudio: count("tag_allows_audio"),
|
|
10332
|
+
missingImpression: count("vast_missing_impression"),
|
|
10333
|
+
discardedBudget: count("discarded_budget"),
|
|
10334
|
+
mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
|
|
10335
|
+
mediaRejected: count("media_candidate:rejected"),
|
|
10336
|
+
mediaFallbacks: count("media_fallback"),
|
|
10337
|
+
playCalled: count("play_called"),
|
|
10338
|
+
playRejected: count("play_rejected"),
|
|
10339
|
+
mutedRetry: count("muted_retry"),
|
|
10340
|
+
startTimeouts: count("play_resolved_but_never_started"),
|
|
10341
|
+
impressions: count("impression_fired"),
|
|
10342
|
+
impressionUrls: count("impression_urls"),
|
|
10343
|
+
trackingRequests: count("tracking_request_created"),
|
|
10344
|
+
trackingNotLoaded: count("tracking_request_settled:error") + count("tracking_request_settled:timeout"),
|
|
10345
|
+
trackingUnexpandedMacros: count("tracking_url_unexpanded_macro"),
|
|
10346
|
+
trackingInvalidUrls: count("tracking_url_invalid"),
|
|
10347
|
+
vastAdFallbacks: count("vast_ad_fallback"),
|
|
10348
|
+
mediaEvents: count("media_event"),
|
|
10349
|
+
quartile25: count("first_quartile"),
|
|
10350
|
+
quartile50: count("midpoint"),
|
|
10351
|
+
quartile75: count("third_quartile"),
|
|
10352
|
+
complete: count("complete"),
|
|
10353
|
+
stoppedBeforeStart: count("stopped_before_start"),
|
|
10354
|
+
stoppedBeforeStartByBreakEnd: count("ad_stopped_before_start"),
|
|
10355
|
+
unexpectedUnmutes: count("unexpected_unmute"),
|
|
10356
|
+
unmuteBlocked: count("unmute_blocked_without_gesture"),
|
|
10357
|
+
visibilityHidden: count("while_hidden"),
|
|
10358
|
+
playbackFailures: count("play_failed") + count("media_error") + count("hls_fatal") + count("stall") + count("decode_failure") + count("media_unsupported"),
|
|
10359
|
+
stages: funnel
|
|
10360
|
+
});
|
|
10361
|
+
}
|
|
10362
|
+
},
|
|
10363
|
+
{
|
|
9464
10364
|
key: "handleAdPodComplete",
|
|
9465
10365
|
value: function handleAdPodComplete() {
|
|
10366
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "unspecified";
|
|
9466
10367
|
if (this.debug) {
|
|
9467
|
-
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up"
|
|
10368
|
+
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up", {
|
|
10369
|
+
reason: reason
|
|
10370
|
+
});
|
|
9468
10371
|
}
|
|
10372
|
+
var previousState = this.slotState;
|
|
10373
|
+
var alreadyEnded = previousState === "IDLE" && !this.inAdBreak;
|
|
10374
|
+
this.setSlotState("ENDING", reason);
|
|
10375
|
+
this.cancelScheduledRequest();
|
|
10376
|
+
var adPlayer = this.host.getAdPlayer();
|
|
10377
|
+
if (previousState === "REQUESTING") {
|
|
10378
|
+
var _adPlayer_abortPendingRequest;
|
|
10379
|
+
(_adPlayer_abortPendingRequest = adPlayer.abortPendingRequest) === null || _adPlayer_abortPendingRequest === void 0 ? void 0 : _adPlayer_abortPendingRequest.call(adPlayer, "VAST request aborted: ad break ended (".concat(reason, ")"));
|
|
10380
|
+
}
|
|
10381
|
+
if (!alreadyEnded) {
|
|
10382
|
+
console.log("[AD-CONTROLLER] stop", {
|
|
10383
|
+
controllerId: this.controllerGeneration,
|
|
10384
|
+
requestId: this.currentRequestId,
|
|
10385
|
+
state: previousState,
|
|
10386
|
+
reason: reason
|
|
10387
|
+
});
|
|
10388
|
+
}
|
|
10389
|
+
this.finalizeRequestDiagnostics(this.currentRequestId, "break_ended:".concat(reason));
|
|
10390
|
+
this.currentRequestId = void 0;
|
|
9469
10391
|
this.timing.resetForBreakEnd();
|
|
9470
|
-
this.
|
|
10392
|
+
this.placeholder.hide();
|
|
9471
10393
|
this.clearPendingAdBreak();
|
|
9472
10394
|
if (this.isShowingPlaceholder) {
|
|
9473
|
-
|
|
10395
|
+
adPlayer.hidePlaceholder();
|
|
9474
10396
|
this.isShowingPlaceholder = false;
|
|
9475
10397
|
}
|
|
9476
|
-
this.adRequestQueue = [];
|
|
9477
10398
|
this.inAdBreak = false;
|
|
9478
10399
|
this.adDetectSentForCurrentBreak = false;
|
|
9479
10400
|
this.cueManager.activeScte35BreakKey = void 0;
|
|
9480
10401
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
9481
10402
|
this.adPodQueue = [];
|
|
9482
10403
|
this.showAds = false;
|
|
9483
|
-
this.
|
|
10404
|
+
this.breakSource = void 0;
|
|
10405
|
+
this.followUpBaseVastUrl = void 0;
|
|
10406
|
+
this.unusableResponsesInBreak = 0;
|
|
10407
|
+
adPlayer.stop().catch(function() {});
|
|
10408
|
+
if (!alreadyEnded) this.logBreakFunnel(reason);
|
|
10409
|
+
this.setSlotState("IDLE", "break_complete");
|
|
9484
10410
|
var restoredMuted = this.host.getAdPlayer().getOriginalMutedState();
|
|
9485
10411
|
var restoredVolume = this.host.getAdPlayer().getOriginalVolume();
|
|
9486
10412
|
if (this.host.video.muted !== restoredMuted) {
|
|
@@ -9774,25 +10700,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9774
10700
|
{
|
|
9775
10701
|
key: "handleAdFailure",
|
|
9776
10702
|
value: function handleAdFailure() {
|
|
9777
|
-
|
|
9778
|
-
this.
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
}
|
|
9784
|
-
}
|
|
9785
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9786
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Max consecutive failures reached (".concat(this.timing.consecutiveFailures, "), ending ad break gracefully"));
|
|
9787
|
-
this.handleAdPodComplete();
|
|
10703
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "ad_failure";
|
|
10704
|
+
if (!this.inAdBreak) return;
|
|
10705
|
+
if (this.slotState === "REQUESTING" || this.slotState === "ENDING") {
|
|
10706
|
+
this.logOrchestratorFunnel("failure_deferred_to_request", {
|
|
10707
|
+
reason: reason,
|
|
10708
|
+
state: this.slotState
|
|
10709
|
+
});
|
|
9788
10710
|
return;
|
|
9789
10711
|
}
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
this.
|
|
10712
|
+
this.timing.consecutiveFailures++;
|
|
10713
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
10714
|
+
if (diag && !diag.failureReason) diag.failureReason = reason;
|
|
10715
|
+
if (this.debug) {
|
|
10716
|
+
console.log("[AdBreak] Ad failure (".concat(reason, "): remaining=").concat(this.timing.getRemainingAdMs(), "ms, consecutiveFailures=").concat(this.timing.consecutiveFailures));
|
|
9795
10717
|
}
|
|
10718
|
+
this.setSlotState("NEEDS_NEXT_AD", reason);
|
|
10719
|
+
this.requestNextAd(reason);
|
|
9796
10720
|
}
|
|
9797
10721
|
}
|
|
9798
10722
|
]);
|
|
@@ -9832,10 +10756,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9832
10756
|
_this.startScte35AdBreak(marker, cueKey, marker.durationSeconds != null ? marker.durationSeconds * 1e3 : _this.timing.expectedAdBreakDurationMs);
|
|
9833
10757
|
},
|
|
9834
10758
|
onWatchdogTimeout: function onWatchdogTimeout() {
|
|
9835
|
-
return _this.adBreak.
|
|
10759
|
+
return _this.adBreak.handleRequestWatchdogTimeout();
|
|
9836
10760
|
},
|
|
9837
10761
|
onFailsafeTimeout: function onFailsafeTimeout() {
|
|
9838
|
-
return _this.adBreak.handleAdFailure();
|
|
10762
|
+
return _this.adBreak.handleAdFailure("failsafe_timeout");
|
|
9839
10763
|
},
|
|
9840
10764
|
getAdState: function getAdState() {
|
|
9841
10765
|
return {
|
|
@@ -9937,6 +10861,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9937
10861
|
licenseKey: this.config.licenseKey
|
|
9938
10862
|
} : {}, ((_this_hlsEngine = this.hlsEngine) === null || _this_hlsEngine === void 0 ? void 0 : _this_hlsEngine.hls) ? {
|
|
9939
10863
|
mainHlsInstance: this.hlsEngine.hls
|
|
10864
|
+
} : {}, this.config.adMediaStartTimeoutMs != null ? {
|
|
10865
|
+
mediaStartTimeoutMs: this.config.adMediaStartTimeoutMs
|
|
9940
10866
|
} : {}));
|
|
9941
10867
|
}
|
|
9942
10868
|
},
|
|
@@ -10083,6 +11009,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10083
11009
|
adBehavior: adBehavior
|
|
10084
11010
|
});
|
|
10085
11011
|
}
|
|
11012
|
+
if (this.adBreak.isBreakActive()) {
|
|
11013
|
+
console.log("[AD-CONTROLLER] destroy skipped", {
|
|
11014
|
+
reason: "manifest_parsed_during_break",
|
|
11015
|
+
state: this.adBreak.getSlotState()
|
|
11016
|
+
});
|
|
11017
|
+
return [
|
|
11018
|
+
2
|
|
11019
|
+
];
|
|
11020
|
+
}
|
|
11021
|
+
if (this.debug) {
|
|
11022
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
11023
|
+
reason: "manifest_parsed",
|
|
11024
|
+
state: "IDLE"
|
|
11025
|
+
});
|
|
11026
|
+
}
|
|
10086
11027
|
this.adPlayer.destroy();
|
|
10087
11028
|
this.adPlayer = this.createAdPlayer(this.shouldContinueLiveStreamDuringAds());
|
|
10088
11029
|
this.adPlayer.initialize();
|
|
@@ -10264,9 +11205,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10264
11205
|
this.timing.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
10265
11206
|
}
|
|
10266
11207
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
10267
|
-
if (!this.adPlayer.isAdPlaying() && this.timing.activeAdRequestToken === null && this.adBreak.adRequestQueue.length > 0 && this.timing.hasTimeToStartAnotherAd()) {
|
|
10268
|
-
this.adBreak.tryNextAvailableAdWithRateLimit();
|
|
10269
|
-
}
|
|
10270
11208
|
return;
|
|
10271
11209
|
}
|
|
10272
11210
|
if (marker.type === "end") {
|
|
@@ -10278,12 +11216,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10278
11216
|
}
|
|
10279
11217
|
var remaining = this.timing.getRemainingAdMs();
|
|
10280
11218
|
var adPlaying = this.adPlayer.isAdPlaying();
|
|
10281
|
-
var hasQueuedAds = this.adBreak.adRequestQueue.length > 0;
|
|
10282
11219
|
if (this.debug) {
|
|
10283
11220
|
console.log("[StormcloudVideoPlayer] SCTE-35 end marker received:", {
|
|
10284
11221
|
remaining: remaining,
|
|
10285
11222
|
adPlaying: adPlaying,
|
|
10286
|
-
|
|
11223
|
+
adSlotState: this.adBreak.getSlotState(),
|
|
10287
11224
|
activeAdRequest: this.timing.activeAdRequestToken !== null
|
|
10288
11225
|
});
|
|
10289
11226
|
}
|
|
@@ -10291,9 +11228,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10291
11228
|
this.timing.clearAdStartTimer();
|
|
10292
11229
|
this.timing.clearAdStopTimer();
|
|
10293
11230
|
if (adPlaying) {
|
|
11231
|
+
this.adBreak.noteStopBeforeStart("scte_end");
|
|
10294
11232
|
this.adPlayer.stop().catch(function() {});
|
|
10295
11233
|
}
|
|
10296
|
-
this.adBreak.handleAdPodComplete();
|
|
11234
|
+
this.adBreak.handleAdPodComplete("scte_end");
|
|
10297
11235
|
return;
|
|
10298
11236
|
}
|
|
10299
11237
|
}
|
|
@@ -10301,6 +11239,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10301
11239
|
{
|
|
10302
11240
|
key: "startScte35AdBreak",
|
|
10303
11241
|
value: function startScte35AdBreak(marker, cueKey, durationMs) {
|
|
11242
|
+
if (this.adBreak.isBreakActive()) {
|
|
11243
|
+
if (this.debug) {
|
|
11244
|
+
console.log("[StormcloudVideoPlayer] Ignoring SCTE-35 break start: a break is already active", {
|
|
11245
|
+
state: this.adBreak.getSlotState(),
|
|
11246
|
+
cueKey: cueKey
|
|
11247
|
+
});
|
|
11248
|
+
}
|
|
11249
|
+
return;
|
|
11250
|
+
}
|
|
10304
11251
|
this.adBreak.inAdBreak = true;
|
|
10305
11252
|
this.cueManager.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.cueManager.pendingScte35CueKey;
|
|
10306
11253
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
@@ -10330,9 +11277,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10330
11277
|
console.log("[StormcloudVideoPlayer] Ad break boundary reached (overrun=".concat(overrunMs, "ms) - hard-stopping ads and resuming stream"));
|
|
10331
11278
|
}
|
|
10332
11279
|
if (adPlaying) {
|
|
11280
|
+
this.adBreak.noteStopBeforeStart("break_boundary");
|
|
10333
11281
|
this.adPlayer.stop().catch(function() {});
|
|
10334
11282
|
}
|
|
10335
|
-
this.adBreak.handleAdPodComplete();
|
|
11283
|
+
this.adBreak.handleAdPodComplete("break_boundary");
|
|
10336
11284
|
}
|
|
10337
11285
|
},
|
|
10338
11286
|
{
|
|
@@ -10342,14 +11290,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10342
11290
|
key: "startAdPrefetch",
|
|
10343
11291
|
value: function startAdPrefetch(marker, fragmentSn, cueKey) {
|
|
10344
11292
|
if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
|
|
10345
|
-
var
|
|
10346
|
-
|
|
10347
|
-
var baseVastUrl;
|
|
10348
|
-
if (tags && tags.length > 0 && tags[0]) {
|
|
10349
|
-
baseVastUrl = tags[0];
|
|
10350
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
10351
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
10352
|
-
} else {
|
|
11293
|
+
var baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
11294
|
+
if (!baseVastUrl) {
|
|
10353
11295
|
if (this.debug) console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
|
|
10354
11296
|
return;
|
|
10355
11297
|
}
|
|
@@ -10379,8 +11321,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10379
11321
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
10380
11322
|
}, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
|
|
10381
11323
|
if (this.debug) {
|
|
10382
|
-
console.log("[PREFETCH]
|
|
10383
|
-
console.log("[PREFETCH] Pre-generated pod request URL");
|
|
11324
|
+
console.log("[PREFETCH] Pre-generated pod request URL for upcoming ad break");
|
|
10384
11325
|
}
|
|
10385
11326
|
}
|
|
10386
11327
|
},
|
|
@@ -10391,7 +11332,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10391
11332
|
key: "onTimeUpdate",
|
|
10392
11333
|
value: function onTimeUpdate(currentTimeSec) {
|
|
10393
11334
|
var _this = this;
|
|
10394
|
-
if (
|
|
11335
|
+
if (this.adConfig.vmapBreaks.length === 0) return;
|
|
10395
11336
|
if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
|
|
10396
11337
|
var nowMs = currentTimeSec * 1e3;
|
|
10397
11338
|
var breakToPlay = this.adConfig.findBreakForTime(nowMs);
|
|
@@ -10408,7 +11349,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10408
11349
|
key: "onVideoEnded",
|
|
10409
11350
|
value: function onVideoEnded() {
|
|
10410
11351
|
var _this = this;
|
|
10411
|
-
if (
|
|
11352
|
+
if (this.adConfig.vmapBreaks.length === 0) return;
|
|
10412
11353
|
if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
|
|
10413
11354
|
var durationMs = Number.isFinite(this.video.duration) ? Math.floor(this.video.duration * 1e3) : 0;
|
|
10414
11355
|
var postroll = this.adConfig.vmapBreaks.find(function(b) {
|
|
@@ -10458,6 +11399,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10458
11399
|
this.adBreak.showAds = true;
|
|
10459
11400
|
this.adBreak.inAdBreak = true;
|
|
10460
11401
|
this.timing.currentAdBreakStartWallClockMs = Date.now();
|
|
11402
|
+
if (durationMs > 0) {
|
|
11403
|
+
this.timing.setAdBreakDurationBoundary(durationMs);
|
|
11404
|
+
}
|
|
11405
|
+
this.adBreak.beginVmapBreak(key);
|
|
10461
11406
|
_state.label = 1;
|
|
10462
11407
|
case 1:
|
|
10463
11408
|
_state.trys.push([
|
|
@@ -10468,7 +11413,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10468
11413
|
]);
|
|
10469
11414
|
return [
|
|
10470
11415
|
4,
|
|
10471
|
-
this.adBreak.playSingleAd(first)
|
|
11416
|
+
this.adBreak.playSingleAd(first, "vmap")
|
|
10472
11417
|
];
|
|
10473
11418
|
case 2:
|
|
10474
11419
|
_state.sent();
|
|
@@ -10481,7 +11426,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10481
11426
|
if (this.debug) {
|
|
10482
11427
|
console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
|
|
10483
11428
|
}
|
|
10484
|
-
this.adBreak.
|
|
11429
|
+
this.adBreak.continueAfterRequestFailure();
|
|
10485
11430
|
return [
|
|
10486
11431
|
3,
|
|
10487
11432
|
4
|
|
@@ -10623,7 +11568,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10623
11568
|
key: "destroy",
|
|
10624
11569
|
value: function destroy() {
|
|
10625
11570
|
var _this_adPlayer;
|
|
10626
|
-
this.adBreak.
|
|
11571
|
+
this.adBreak.cancelScheduledRequest();
|
|
10627
11572
|
this.timing.destroy();
|
|
10628
11573
|
this.adBreak.clearPendingAdBreak();
|
|
10629
11574
|
this.placeholder.destroy();
|
|
@@ -10647,7 +11592,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10647
11592
|
this.palNonce.sendPlaybackEnd();
|
|
10648
11593
|
}
|
|
10649
11594
|
this.palNonce.reset();
|
|
10650
|
-
this.adBreak.adRequestQueue = [];
|
|
10651
11595
|
this.timing.consecutiveFailures = 0;
|
|
10652
11596
|
}
|
|
10653
11597
|
}
|