stormcloud-video-player 0.8.64 → 0.8.65
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 +927 -133
- package/lib/StormcloudPlayer.cjs.map +1 -1
- package/lib/index.cjs +927 -133
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +7 -0
- package/lib/index.js +927 -133
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +246 -16
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +16 -0
- 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 +927 -133
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +927 -133
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +927 -133
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +700 -115
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -0
- package/lib/types.d.cts +6 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +927 -133
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -957,7 +957,7 @@ function toVastMediaErrorCode(error) {
|
|
|
957
957
|
}
|
|
958
958
|
}
|
|
959
959
|
function createHlsAdPlayer(contentVideo, options) {
|
|
960
|
-
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
|
|
960
|
+
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP, _ref;
|
|
961
961
|
var adPlaying = false;
|
|
962
962
|
var originalMutedState = false;
|
|
963
963
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
@@ -989,6 +989,16 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
989
989
|
var sawDecodedVideoFrame = false;
|
|
990
990
|
var videoFrameCallbackHandle;
|
|
991
991
|
var pendingPlayPromise;
|
|
992
|
+
var currentVastTagUrl;
|
|
993
|
+
var funnelContext = {};
|
|
994
|
+
var mediaCandidates = [];
|
|
995
|
+
var mediaCandidateIndex = 0;
|
|
996
|
+
var mediaStartTimerId;
|
|
997
|
+
var MEDIA_START_TIMEOUT_MS = (_ref = options === null || options === void 0 ? void 0 : options.mediaStartTimeoutMs) !== null && _ref !== void 0 ? _ref : 8e3;
|
|
998
|
+
var VAST_ERROR_MEDIA_TIMEOUT = 402;
|
|
999
|
+
var pendingVastRequests = /* @__PURE__ */ new Set();
|
|
1000
|
+
var pendingRequestAbortReason;
|
|
1001
|
+
var forcedMuteByAutoplay = false;
|
|
992
1002
|
function createTrackingState() {
|
|
993
1003
|
return {
|
|
994
1004
|
impression: false,
|
|
@@ -1039,6 +1049,77 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1039
1049
|
}
|
|
1040
1050
|
}
|
|
1041
1051
|
}
|
|
1052
|
+
var SENSITIVE_URL_PARAMS = /* @__PURE__ */ new Set([
|
|
1053
|
+
"ppid",
|
|
1054
|
+
"rdid",
|
|
1055
|
+
"idtype",
|
|
1056
|
+
"is_lat",
|
|
1057
|
+
"ifa",
|
|
1058
|
+
"idfa",
|
|
1059
|
+
"aaid",
|
|
1060
|
+
"uid",
|
|
1061
|
+
"user_id",
|
|
1062
|
+
"userid",
|
|
1063
|
+
"device_id",
|
|
1064
|
+
"deviceid",
|
|
1065
|
+
"ip",
|
|
1066
|
+
"ua",
|
|
1067
|
+
"gdpr_consent",
|
|
1068
|
+
"us_privacy",
|
|
1069
|
+
"gpp",
|
|
1070
|
+
"addtl_consent",
|
|
1071
|
+
"cust_params",
|
|
1072
|
+
"email"
|
|
1073
|
+
]);
|
|
1074
|
+
function redactUrl(url) {
|
|
1075
|
+
if (!url) return url;
|
|
1076
|
+
try {
|
|
1077
|
+
var parsed = new URL(url);
|
|
1078
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1079
|
+
try {
|
|
1080
|
+
for(var _iterator = Array.from(parsed.searchParams.keys())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1081
|
+
var key = _step.value;
|
|
1082
|
+
if (SENSITIVE_URL_PARAMS.has(key.toLowerCase())) {
|
|
1083
|
+
parsed.searchParams.set(key, "REDACTED");
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
} catch (err) {
|
|
1087
|
+
_didIteratorError = true;
|
|
1088
|
+
_iteratorError = err;
|
|
1089
|
+
} finally{
|
|
1090
|
+
try {
|
|
1091
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1092
|
+
_iterator.return();
|
|
1093
|
+
}
|
|
1094
|
+
} finally{
|
|
1095
|
+
if (_didIteratorError) {
|
|
1096
|
+
throw _iteratorError;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
return parsed.toString();
|
|
1101
|
+
} catch (unused) {
|
|
1102
|
+
return url.split("?")[0];
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
function logFunnel(stage) {
|
|
1106
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1107
|
+
var payload = _object_spread({
|
|
1108
|
+
stage: stage,
|
|
1109
|
+
breakId: funnelContext.breakId,
|
|
1110
|
+
requestId: funnelContext.requestId,
|
|
1111
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0,
|
|
1112
|
+
adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
|
|
1113
|
+
podIndex: podIndex,
|
|
1114
|
+
podSize: podAds.length,
|
|
1115
|
+
vastUrl: redactUrl(currentVastTagUrl),
|
|
1116
|
+
mediaUrl: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url,
|
|
1117
|
+
mediaType: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.type,
|
|
1118
|
+
muted: adVideoElement ? adVideoElement.muted : void 0
|
|
1119
|
+
}, extra);
|
|
1120
|
+
console.log("[HlsAdPlayer][FUNNEL] ".concat(stage), payload);
|
|
1121
|
+
emit("ad_funnel", payload);
|
|
1122
|
+
}
|
|
1042
1123
|
function buildTrackingMacroContext() {
|
|
1043
1124
|
var options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1044
1125
|
var _options2_ad;
|
|
@@ -1078,20 +1159,53 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1078
1159
|
urls.forEach(function(url) {
|
|
1079
1160
|
try {
|
|
1080
1161
|
var trackingUrl = substituteVastTrackingMacros(url, macroContext);
|
|
1162
|
+
var trackingHost;
|
|
1163
|
+
try {
|
|
1164
|
+
trackingHost = new URL(trackingUrl).host;
|
|
1165
|
+
} catch (unused) {
|
|
1166
|
+
logFunnel("tracking_url_invalid", {
|
|
1167
|
+
trackingUrl: redactUrl(trackingUrl)
|
|
1168
|
+
});
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
var unexpanded = trackingUrl.match(/\[[A-Z_]+\]/g);
|
|
1172
|
+
if (unexpanded) {
|
|
1173
|
+
logFunnel("tracking_url_unexpanded_macro", {
|
|
1174
|
+
trackingHost: trackingHost,
|
|
1175
|
+
macros: Array.from(new Set(unexpanded))
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1081
1178
|
var img = new Image(1, 1);
|
|
1082
1179
|
inFlightBeacons.add(img);
|
|
1083
1180
|
var timeoutId;
|
|
1084
|
-
var release = function release() {
|
|
1181
|
+
var release = function release(outcome) {
|
|
1085
1182
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1086
1183
|
img.onload = null;
|
|
1087
1184
|
img.onerror = null;
|
|
1088
1185
|
inFlightBeacons.delete(img);
|
|
1186
|
+
console.log("[HlsAdPlayer] Tracking pixel settled (".concat(outcome, "): ").concat(trackingUrl));
|
|
1187
|
+
if (outcome !== "load") {
|
|
1188
|
+
logFunnel("tracking_request_settled", {
|
|
1189
|
+
reason: outcome,
|
|
1190
|
+
trackingHost: trackingHost
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
};
|
|
1194
|
+
img.onload = function() {
|
|
1195
|
+
return release("load");
|
|
1196
|
+
};
|
|
1197
|
+
img.onerror = function() {
|
|
1198
|
+
return release("error");
|
|
1089
1199
|
};
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1200
|
+
timeoutId = setTimeout(function() {
|
|
1201
|
+
return release("timeout");
|
|
1202
|
+
}, BEACON_TIMEOUT_MS);
|
|
1093
1203
|
img.src = trackingUrl;
|
|
1094
1204
|
console.log("[HlsAdPlayer] Fired tracking pixel: ".concat(trackingUrl));
|
|
1205
|
+
logFunnel("tracking_request_created", {
|
|
1206
|
+
trackingHost: trackingHost,
|
|
1207
|
+
errorCode: options2 === null || options2 === void 0 ? void 0 : options2.errorCode
|
|
1208
|
+
});
|
|
1095
1209
|
} catch (error) {
|
|
1096
1210
|
console.warn("[HlsAdPlayer] Error firing tracking pixel:", error);
|
|
1097
1211
|
}
|
|
@@ -1121,54 +1235,80 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1121
1235
|
bitrate: level.bitrate || 5e6
|
|
1122
1236
|
};
|
|
1123
1237
|
}
|
|
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
|
-
}
|
|
1238
|
+
function getMediaTargetQuality() {
|
|
1135
1239
|
var mainQuality = getMainStreamQuality();
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1240
|
+
var dpr = typeof window !== "undefined" && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1;
|
|
1241
|
+
var containerWidth = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientWidth) || contentVideo.clientWidth) * dpr;
|
|
1242
|
+
var containerHeight = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientHeight) || contentVideo.clientHeight) * dpr;
|
|
1243
|
+
if (!mainQuality && !(containerWidth > 0 && containerHeight > 0)) {
|
|
1244
|
+
return null;
|
|
1245
|
+
}
|
|
1246
|
+
var base = mainQuality !== null && mainQuality !== void 0 ? mainQuality : {
|
|
1247
|
+
width: containerWidth,
|
|
1248
|
+
height: containerHeight,
|
|
1249
|
+
bitrate: 5e6
|
|
1250
|
+
};
|
|
1251
|
+
var width = containerWidth > 0 ? Math.min(base.width, containerWidth) : base.width;
|
|
1252
|
+
var height = containerHeight > 0 ? Math.min(base.height, containerHeight) : base.height;
|
|
1253
|
+
return {
|
|
1254
|
+
width: width,
|
|
1255
|
+
height: height,
|
|
1256
|
+
bitrate: base.bitrate
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
function rankMediaCandidates(mediaFiles) {
|
|
1260
|
+
var probe = adVideoElement !== null && adVideoElement !== void 0 ? adVideoElement : document.createElement("video");
|
|
1261
|
+
var pageIsHttps = typeof location !== "undefined" && location.protocol === "https:";
|
|
1262
|
+
var target = getMediaTargetQuality();
|
|
1263
|
+
var accepted = [];
|
|
1264
|
+
mediaFiles.forEach(function(file, index) {
|
|
1265
|
+
var isHls = isHlsMediaFile(file);
|
|
1266
|
+
var mimeForProbe = isHls ? "application/vnd.apple.mpegurl" : file.type || "video/mp4";
|
|
1267
|
+
var canPlay2 = probe.canPlayType(mimeForProbe);
|
|
1268
|
+
var playable = isHls ? import_hls.default.isSupported() || canPlay2 !== "" : canPlay2 !== "";
|
|
1269
|
+
var insecure = pageIsHttps && /^http:/i.test(file.url);
|
|
1270
|
+
var details = {
|
|
1271
|
+
index: index,
|
|
1272
|
+
candidateUrl: file.url,
|
|
1273
|
+
candidateType: file.type,
|
|
1274
|
+
width: file.width,
|
|
1275
|
+
height: file.height,
|
|
1276
|
+
bitrate: file.bitrate,
|
|
1277
|
+
canPlayType: canPlay2,
|
|
1278
|
+
hlsJs: isHls ? import_hls.default.isSupported() : void 0
|
|
1279
|
+
};
|
|
1280
|
+
if (!playable) {
|
|
1281
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1282
|
+
reason: "rejected",
|
|
1283
|
+
why: "cannot_play_type"
|
|
1284
|
+
}));
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
var score = 0;
|
|
1288
|
+
if (target) {
|
|
1289
|
+
var resolutionDiff = Math.abs(file.width - target.width) + Math.abs(file.height - target.height);
|
|
1290
|
+
var bitrateDiff = Math.abs((file.bitrate || 5e3) * 1e3 - target.bitrate);
|
|
1291
|
+
score = resolutionDiff * 2 + bitrateDiff / 1e3;
|
|
1292
|
+
}
|
|
1293
|
+
accepted.push({
|
|
1149
1294
|
file: file,
|
|
1150
1295
|
score: score,
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
}
|
|
1296
|
+
insecure: insecure
|
|
1297
|
+
});
|
|
1298
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1299
|
+
reason: "accepted",
|
|
1300
|
+
// Mixed-content media is often auto-upgraded, so it is kept as a last resort.
|
|
1301
|
+
why: insecure ? "insecure_http_deprioritized" : "playable",
|
|
1302
|
+
score: score
|
|
1303
|
+
}));
|
|
1154
1304
|
});
|
|
1155
|
-
|
|
1305
|
+
accepted.sort(function(a, b) {
|
|
1306
|
+
if (a.insecure !== b.insecure) return a.insecure ? 1 : -1;
|
|
1156
1307
|
return a.score - b.score;
|
|
1157
1308
|
});
|
|
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
|
|
1309
|
+
return accepted.map(function(entry) {
|
|
1310
|
+
return entry.file;
|
|
1170
1311
|
});
|
|
1171
|
-
return bestMatch.file;
|
|
1172
1312
|
}
|
|
1173
1313
|
function isHlsMediaFile(mediaFile) {
|
|
1174
1314
|
var type = mediaFile.type.toLowerCase();
|
|
@@ -1185,9 +1325,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1185
1325
|
var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
|
|
1186
1326
|
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
1327
|
}
|
|
1188
|
-
function collectVideoMediaFiles(linear, verbose) {
|
|
1328
|
+
function collectVideoMediaFiles(linear, verbose, stats) {
|
|
1189
1329
|
var mediaFileElements = linear.querySelectorAll(":scope > MediaFiles > MediaFile");
|
|
1190
1330
|
var mediaFiles = [];
|
|
1331
|
+
if (stats) stats.total += mediaFileElements.length;
|
|
1191
1332
|
if (verbose) {
|
|
1192
1333
|
console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
|
|
1193
1334
|
}
|
|
@@ -1208,6 +1349,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1208
1349
|
}
|
|
1209
1350
|
var apiFramework = (mf.getAttribute("apiFramework") || "").toUpperCase();
|
|
1210
1351
|
if (apiFramework === "VPAID") {
|
|
1352
|
+
if (stats) stats.vpaid++;
|
|
1211
1353
|
if (verbose) {
|
|
1212
1354
|
console.log("[HlsAdPlayer] MediaFile ".concat(index, " ignored (VPAID creatives are not supported)"));
|
|
1213
1355
|
}
|
|
@@ -1223,11 +1365,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1223
1365
|
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
1224
1366
|
};
|
|
1225
1367
|
if (isAudioMediaFile(mediaFile)) {
|
|
1368
|
+
if (stats) stats.audio++;
|
|
1226
1369
|
console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
|
|
1227
1370
|
return;
|
|
1228
1371
|
}
|
|
1229
1372
|
var hasExplicitDimensions = mf.getAttribute("width") != null && mf.getAttribute("height") != null;
|
|
1230
1373
|
if (!isHlsMediaFile(mediaFile) && hasExplicitDimensions && (mediaFile.width <= 1 || mediaFile.height <= 1)) {
|
|
1374
|
+
if (stats) stats.audio++;
|
|
1231
1375
|
console.warn("[HlsAdPlayer] MediaFile ".concat(index, " skipped (degenerate dimensions ").concat(mediaFile.width, "x").concat(mediaFile.height, ', type="').concat(type, '") — likely an audio-only placeholder rendition'));
|
|
1232
1376
|
return;
|
|
1233
1377
|
}
|
|
@@ -1236,8 +1380,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1236
1380
|
if (verbose) {
|
|
1237
1381
|
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
1238
1382
|
}
|
|
1239
|
-
} else
|
|
1240
|
-
|
|
1383
|
+
} else {
|
|
1384
|
+
if (stats) stats.unsupported++;
|
|
1385
|
+
if (verbose) {
|
|
1386
|
+
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
1387
|
+
}
|
|
1241
1388
|
}
|
|
1242
1389
|
});
|
|
1243
1390
|
return mediaFiles;
|
|
@@ -1361,26 +1508,58 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1361
1508
|
}
|
|
1362
1509
|
function parseVastXml(xmlString) {
|
|
1363
1510
|
try {
|
|
1364
|
-
var _adElements_find;
|
|
1365
1511
|
var xmlDoc = parseXml(xmlString);
|
|
1366
1512
|
if (!xmlDoc) return {
|
|
1367
1513
|
type: "empty"
|
|
1368
1514
|
};
|
|
1369
1515
|
var root = xmlDoc.documentElement;
|
|
1370
1516
|
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) {
|
|
1517
|
+
if (adElements.length === 0) {
|
|
1375
1518
|
var _root_getAttribute;
|
|
1376
1519
|
console.warn("[HlsAdPlayer] No Ad element found in VAST ".concat((_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : "", " response"));
|
|
1377
1520
|
return emptyVastResult(root);
|
|
1378
1521
|
}
|
|
1379
|
-
var
|
|
1380
|
-
|
|
1381
|
-
|
|
1522
|
+
var ordered = _to_consumable_array(adElements.filter(function(el) {
|
|
1523
|
+
return getAdSequence(el) === void 0;
|
|
1524
|
+
})).concat(_to_consumable_array(adElements.filter(function(el) {
|
|
1525
|
+
return getAdSequence(el) !== void 0;
|
|
1526
|
+
})));
|
|
1527
|
+
var firstEmpty;
|
|
1528
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1529
|
+
try {
|
|
1530
|
+
for(var _iterator = ordered.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1531
|
+
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], adElement = _step_value[1];
|
|
1532
|
+
var parsed = parseAdElement(adElement, true);
|
|
1533
|
+
if (parsed.type === "empty") {
|
|
1534
|
+
firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : firstEmpty = parsed;
|
|
1535
|
+
continue;
|
|
1536
|
+
}
|
|
1537
|
+
if (index > 0) {
|
|
1538
|
+
logFunnel("vast_ad_fallback", {
|
|
1539
|
+
usedAdIndex: index,
|
|
1540
|
+
adCount: ordered.length
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
if (parsed.type === "wrapper") {
|
|
1544
|
+
console.log("[HlsAdPlayer] VAST wrapper detected, following VASTAdTagURI: ".concat(parsed.vastAdTagUri));
|
|
1545
|
+
}
|
|
1546
|
+
return parsed;
|
|
1547
|
+
}
|
|
1548
|
+
} catch (err) {
|
|
1549
|
+
_didIteratorError = true;
|
|
1550
|
+
_iteratorError = err;
|
|
1551
|
+
} finally{
|
|
1552
|
+
try {
|
|
1553
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1554
|
+
_iterator.return();
|
|
1555
|
+
}
|
|
1556
|
+
} finally{
|
|
1557
|
+
if (_didIteratorError) {
|
|
1558
|
+
throw _iteratorError;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1382
1561
|
}
|
|
1383
|
-
return
|
|
1562
|
+
return firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : emptyVastResult(root);
|
|
1384
1563
|
} catch (error) {
|
|
1385
1564
|
console.error("[HlsAdPlayer] Error parsing VAST XML:", error);
|
|
1386
1565
|
return {
|
|
@@ -1426,6 +1605,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1426
1605
|
pushUrls(errorUrls, inLine.querySelectorAll(":scope > Error"));
|
|
1427
1606
|
if (adElement.getAttribute("conditionalAd") === "true") {
|
|
1428
1607
|
console.warn("[HlsAdPlayer] Skipping conditional <Ad> (VPAID-only)");
|
|
1608
|
+
logFunnel("vast_no_supported_media", {
|
|
1609
|
+
reason: "vpaid_only",
|
|
1610
|
+
conditionalAd: true
|
|
1611
|
+
});
|
|
1429
1612
|
return {
|
|
1430
1613
|
type: "empty",
|
|
1431
1614
|
errorUrls: errorUrls,
|
|
@@ -1434,11 +1617,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1434
1617
|
}
|
|
1435
1618
|
var linear;
|
|
1436
1619
|
var mediaFiles = [];
|
|
1620
|
+
var rejectStats = {
|
|
1621
|
+
total: 0,
|
|
1622
|
+
vpaid: 0,
|
|
1623
|
+
audio: 0,
|
|
1624
|
+
unsupported: 0
|
|
1625
|
+
};
|
|
1437
1626
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1438
1627
|
try {
|
|
1439
1628
|
for(var _iterator = Array.from(inLine.querySelectorAll(":scope > Creatives > Creative > Linear"))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1440
1629
|
var candidate = _step.value;
|
|
1441
|
-
var files = collectVideoMediaFiles(candidate, verbose);
|
|
1630
|
+
var files = collectVideoMediaFiles(candidate, verbose, rejectStats);
|
|
1442
1631
|
if (files.length > 0) {
|
|
1443
1632
|
linear = candidate;
|
|
1444
1633
|
mediaFiles = files;
|
|
@@ -1461,6 +1650,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1461
1650
|
}
|
|
1462
1651
|
if (!linear) {
|
|
1463
1652
|
console.warn("[HlsAdPlayer] No supported linear media files in <Ad>");
|
|
1653
|
+
var reason = rejectStats.total === 0 ? "no_mediafiles" : rejectStats.vpaid > 0 ? "vpaid_only" : rejectStats.audio > 0 ? "audio_only" : "unsupported_type";
|
|
1654
|
+
logFunnel("vast_no_supported_media", _object_spread({
|
|
1655
|
+
reason: reason
|
|
1656
|
+
}, rejectStats));
|
|
1464
1657
|
return {
|
|
1465
1658
|
type: "empty",
|
|
1466
1659
|
errorUrls: errorUrls,
|
|
@@ -1496,7 +1689,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1496
1689
|
return _ts_generator(this, function(_state) {
|
|
1497
1690
|
switch(_state.label){
|
|
1498
1691
|
case 0:
|
|
1692
|
+
if (destroyed) {
|
|
1693
|
+
throw new Error("VAST request skipped: ad player destroyed");
|
|
1694
|
+
}
|
|
1499
1695
|
controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1696
|
+
if (controller) pendingVastRequests.add(controller);
|
|
1500
1697
|
timeoutId = controller ? setTimeout(function() {
|
|
1501
1698
|
return controller.abort();
|
|
1502
1699
|
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
@@ -1545,6 +1742,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1545
1742
|
6
|
|
1546
1743
|
];
|
|
1547
1744
|
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
1745
|
+
logFunnel("vast_credentials_retry", {
|
|
1746
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1747
|
+
});
|
|
1548
1748
|
return [
|
|
1549
1749
|
4,
|
|
1550
1750
|
requestVast("omit")
|
|
@@ -1578,11 +1778,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1578
1778
|
case 10:
|
|
1579
1779
|
error1 = _state.sent();
|
|
1580
1780
|
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1781
|
+
if (pendingRequestAbortReason) {
|
|
1782
|
+
throw new Error("".concat(pendingRequestAbortReason, " (timeout): ").concat(vastTagUrl));
|
|
1783
|
+
}
|
|
1581
1784
|
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1582
1785
|
}
|
|
1583
1786
|
throw error1;
|
|
1584
1787
|
case 11:
|
|
1585
1788
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1789
|
+
if (controller) pendingVastRequests.delete(controller);
|
|
1586
1790
|
return [
|
|
1587
1791
|
7
|
|
1588
1792
|
];
|
|
@@ -1596,7 +1800,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1596
1800
|
}
|
|
1597
1801
|
function fetchAndParseVastAd(_0) {
|
|
1598
1802
|
return _async_to_generator(function(vastTagUrl) {
|
|
1599
|
-
var depth, accumulatedTracking, rules, vastXml, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1803
|
+
var depth, accumulatedTracking, rules, vastXml, fetchStartedAt, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1600
1804
|
var _arguments = arguments;
|
|
1601
1805
|
return _ts_generator(this, function(_state) {
|
|
1602
1806
|
switch(_state.label){
|
|
@@ -1604,6 +1808,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1604
1808
|
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
1809
|
followAdditionalWrappers: true
|
|
1606
1810
|
};
|
|
1811
|
+
if (destroyed) return [
|
|
1812
|
+
2,
|
|
1813
|
+
null
|
|
1814
|
+
];
|
|
1815
|
+
fetchStartedAt = Date.now();
|
|
1607
1816
|
_state.label = 1;
|
|
1608
1817
|
case 1:
|
|
1609
1818
|
_state.trys.push([
|
|
@@ -1626,14 +1835,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1626
1835
|
error = _state.sent();
|
|
1627
1836
|
if (depth === 0) throw error;
|
|
1628
1837
|
console.warn("[HlsAdPlayer] Wrapped VAST request failed:", error);
|
|
1629
|
-
|
|
1630
|
-
|
|
1838
|
+
logFunnel("wrapper_fetch", {
|
|
1839
|
+
reason: "failure",
|
|
1840
|
+
depth: depth,
|
|
1841
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
1842
|
+
elapsedMs: Date.now() - fetchStartedAt,
|
|
1843
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1631
1844
|
});
|
|
1845
|
+
if (!destroyed) {
|
|
1846
|
+
fireTrackingPixels(accumulatedTracking.error, {
|
|
1847
|
+
errorCode: VAST_ERROR_WRAPPER_TIMEOUT
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1632
1850
|
return [
|
|
1633
1851
|
2,
|
|
1634
1852
|
null
|
|
1635
1853
|
];
|
|
1636
1854
|
case 4:
|
|
1855
|
+
if (destroyed) return [
|
|
1856
|
+
2,
|
|
1857
|
+
null
|
|
1858
|
+
];
|
|
1859
|
+
if (depth > 0) {
|
|
1860
|
+
logFunnel("wrapper_fetch", {
|
|
1861
|
+
reason: "success",
|
|
1862
|
+
depth: depth,
|
|
1863
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
1864
|
+
elapsedMs: Date.now() - fetchStartedAt
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1637
1867
|
console.log("[HlsAdPlayer] VAST XML received");
|
|
1638
1868
|
console.log("[HlsAdPlayer] VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1639
1869
|
parsed = parseVastXml(vastXml);
|
|
@@ -1665,6 +1895,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1665
1895
|
];
|
|
1666
1896
|
}
|
|
1667
1897
|
mergeTrackingUrls(parsed.ad.trackingUrls, accumulatedTracking);
|
|
1898
|
+
logFunnel("inline_resolved", {
|
|
1899
|
+
depth: depth
|
|
1900
|
+
});
|
|
1668
1901
|
return [
|
|
1669
1902
|
2,
|
|
1670
1903
|
parsed.ad
|
|
@@ -1685,6 +1918,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1685
1918
|
];
|
|
1686
1919
|
case 1:
|
|
1687
1920
|
vastXml = _state.sent();
|
|
1921
|
+
if (destroyed) return [
|
|
1922
|
+
2,
|
|
1923
|
+
[]
|
|
1924
|
+
];
|
|
1688
1925
|
console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
|
|
1689
1926
|
trimmedXml = vastXml.trim();
|
|
1690
1927
|
if (trimmedXml.length === 0) {
|
|
@@ -1972,14 +2209,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1972
2209
|
var progress = currentTime / currentAd.duration;
|
|
1973
2210
|
if (progress >= 0.25 && !trackingFired.firstQuartile) {
|
|
1974
2211
|
trackingFired.firstQuartile = true;
|
|
2212
|
+
logFunnel("first_quartile");
|
|
1975
2213
|
fireTrackingPixels(currentAd.trackingUrls.firstQuartile);
|
|
1976
2214
|
}
|
|
1977
2215
|
if (progress >= 0.5 && !trackingFired.midpoint) {
|
|
1978
2216
|
trackingFired.midpoint = true;
|
|
2217
|
+
logFunnel("midpoint");
|
|
1979
2218
|
fireTrackingPixels(currentAd.trackingUrls.midpoint);
|
|
1980
2219
|
}
|
|
1981
2220
|
if (progress >= 0.75 && !trackingFired.thirdQuartile) {
|
|
1982
2221
|
trackingFired.thirdQuartile = true;
|
|
2222
|
+
logFunnel("third_quartile");
|
|
1983
2223
|
fireTrackingPixels(currentAd.trackingUrls.thirdQuartile);
|
|
1984
2224
|
}
|
|
1985
2225
|
};
|
|
@@ -2002,6 +2242,16 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2002
2242
|
if (!trackingFired.impression) {
|
|
2003
2243
|
trackingFired.impression = true;
|
|
2004
2244
|
resolvedAds.add(currentAd);
|
|
2245
|
+
logFunnel("playing", {
|
|
2246
|
+
mutedByAutoplay: forcedMuteByAutoplay,
|
|
2247
|
+
candidateIndex: mediaCandidateIndex
|
|
2248
|
+
});
|
|
2249
|
+
logFunnel("impression_fired", {
|
|
2250
|
+
pixelCount: currentAd.trackingUrls.impression.length
|
|
2251
|
+
});
|
|
2252
|
+
if (currentAd.trackingUrls.impression.length === 0) {
|
|
2253
|
+
console.warn("[HlsAdPlayer] Ad started but VAST contained no <Impression> URLs - GAM will not count it");
|
|
2254
|
+
}
|
|
2005
2255
|
fireTrackingPixels(currentAd.trackingUrls.impression);
|
|
2006
2256
|
fireTrackingPixels(currentAd.trackingUrls.creativeView);
|
|
2007
2257
|
fireTrackingPixels(currentAd.trackingUrls.verificationNotExecuted, {
|
|
@@ -2024,6 +2274,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2024
2274
|
sampleViewability();
|
|
2025
2275
|
settleViewability();
|
|
2026
2276
|
trackingFired.complete = true;
|
|
2277
|
+
logFunnel("complete");
|
|
2027
2278
|
fireTrackingPixels(currentAd.trackingUrls.complete);
|
|
2028
2279
|
console.log("[HlsAdPlayer] Ad completed");
|
|
2029
2280
|
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
|
|
@@ -2032,16 +2283,41 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2032
2283
|
handleAdComplete();
|
|
2033
2284
|
};
|
|
2034
2285
|
var onError = function onError(e) {
|
|
2286
|
+
var _adVideoElement_error, _adVideoElement_error1;
|
|
2035
2287
|
if (!adPlaying) return;
|
|
2036
2288
|
console.error("[HlsAdPlayer] Ad video error:", e);
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2289
|
+
var vastErrorCode = toVastMediaErrorCode(adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.error);
|
|
2290
|
+
logFunnel("media_error", {
|
|
2291
|
+
mediaErrorCode: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error = adVideoElement.error) === null || _adVideoElement_error === void 0 ? void 0 : _adVideoElement_error.code,
|
|
2292
|
+
errorMessage: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error1 = adVideoElement.error) === null || _adVideoElement_error1 === void 0 ? void 0 : _adVideoElement_error1.message,
|
|
2293
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2294
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2295
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2296
|
+
vastErrorCode: vastErrorCode
|
|
2297
|
+
});
|
|
2298
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2299
|
+
};
|
|
2300
|
+
var onMediaDiagnostic = function onMediaDiagnostic(event) {
|
|
2301
|
+
if (!adPlaying || !adVideoElement || trackingFired.impression) return;
|
|
2302
|
+
if (!adVideoElement.currentSrc) return;
|
|
2303
|
+
logFunnel("media_event", {
|
|
2304
|
+
reason: event.type,
|
|
2305
|
+
readyState: adVideoElement.readyState,
|
|
2306
|
+
networkState: adVideoElement.networkState,
|
|
2307
|
+
currentSrc: adVideoElement.currentSrc
|
|
2308
|
+
});
|
|
2042
2309
|
};
|
|
2043
2310
|
var onVolumeChange = function onVolumeChange() {
|
|
2044
2311
|
if (!currentAd || !adVideoElement) return;
|
|
2312
|
+
if (forcedMuteByAutoplay && !adVideoElement.muted) {
|
|
2313
|
+
var userActivation = navigator.userActivation;
|
|
2314
|
+
if (userActivation && !userActivation.isActive) {
|
|
2315
|
+
logFunnel("unexpected_unmute", {
|
|
2316
|
+
paused: adVideoElement.paused
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2319
|
+
forcedMuteByAutoplay = false;
|
|
2320
|
+
}
|
|
2045
2321
|
var muted = adVideoElement.muted || adVideoElement.volume === 0;
|
|
2046
2322
|
if (!trackingFired.start) {
|
|
2047
2323
|
trackingFired.lastMuted = muted;
|
|
@@ -2101,6 +2377,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2101
2377
|
{
|
|
2102
2378
|
type: "play",
|
|
2103
2379
|
handler: onPlay
|
|
2380
|
+
},
|
|
2381
|
+
{
|
|
2382
|
+
type: "stalled",
|
|
2383
|
+
handler: onMediaDiagnostic
|
|
2384
|
+
},
|
|
2385
|
+
{
|
|
2386
|
+
type: "suspend",
|
|
2387
|
+
handler: onMediaDiagnostic
|
|
2388
|
+
},
|
|
2389
|
+
{
|
|
2390
|
+
type: "abort",
|
|
2391
|
+
handler: onMediaDiagnostic
|
|
2392
|
+
},
|
|
2393
|
+
{
|
|
2394
|
+
type: "emptied",
|
|
2395
|
+
handler: onMediaDiagnostic
|
|
2104
2396
|
}
|
|
2105
2397
|
];
|
|
2106
2398
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -2390,16 +2682,51 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2390
2682
|
function settlePendingPlay() {
|
|
2391
2683
|
pendingPlayPromise = void 0;
|
|
2392
2684
|
}
|
|
2685
|
+
function toVastPlayErrorCode(error) {
|
|
2686
|
+
return (error === null || error === void 0 ? void 0 : error.name) === "NotSupportedError" ? VAST_ERROR_NO_SUPPORTED_MEDIA : VAST_ERROR_MEDIA_DISPLAY;
|
|
2687
|
+
}
|
|
2688
|
+
function failAdPlayback(context, error) {
|
|
2689
|
+
var vastErrorCode = toVastPlayErrorCode(error);
|
|
2690
|
+
console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
|
|
2691
|
+
logFunnel("play_failed", {
|
|
2692
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2693
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message,
|
|
2694
|
+
vastErrorCode: vastErrorCode
|
|
2695
|
+
});
|
|
2696
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2697
|
+
}
|
|
2393
2698
|
function startAdPlayback(context) {
|
|
2699
|
+
var isMutedRetry = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
2394
2700
|
if (!adVideoElement) return;
|
|
2701
|
+
var computed = typeof getComputedStyle === "function" && adContainerEl ? getComputedStyle(adContainerEl) : void 0;
|
|
2702
|
+
logFunnel(isMutedRetry ? "muted_retry" : "play_called", {
|
|
2703
|
+
context: context,
|
|
2704
|
+
isConnected: adVideoElement.isConnected,
|
|
2705
|
+
clientWidth: adVideoElement.clientWidth,
|
|
2706
|
+
clientHeight: adVideoElement.clientHeight,
|
|
2707
|
+
containerDisplay: computed === null || computed === void 0 ? void 0 : computed.display,
|
|
2708
|
+
containerVisibility: computed === null || computed === void 0 ? void 0 : computed.visibility
|
|
2709
|
+
});
|
|
2395
2710
|
var playPromise = adVideoElement.play();
|
|
2396
2711
|
pendingPlayPromise = playPromise;
|
|
2397
2712
|
playPromise.catch(function(error) {
|
|
2398
2713
|
if (pendingPlayPromise !== playPromise) {
|
|
2399
2714
|
return;
|
|
2400
2715
|
}
|
|
2401
|
-
|
|
2402
|
-
|
|
2716
|
+
logFunnel("play_rejected", {
|
|
2717
|
+
context: context,
|
|
2718
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2719
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
2720
|
+
});
|
|
2721
|
+
if (!isMutedRetry && (error === null || error === void 0 ? void 0 : error.name) === "NotAllowedError" && adVideoElement && !adVideoElement.muted) {
|
|
2722
|
+
console.warn("[HlsAdPlayer] Unmuted ".concat(context, " blocked by autoplay policy - retrying muted"));
|
|
2723
|
+
originalMutedState = true;
|
|
2724
|
+
forcedMuteByAutoplay = true;
|
|
2725
|
+
adVideoElement.muted = true;
|
|
2726
|
+
startAdPlayback(context, true);
|
|
2727
|
+
return;
|
|
2728
|
+
}
|
|
2729
|
+
failAdPlayback(context, error);
|
|
2403
2730
|
}).finally(function() {
|
|
2404
2731
|
if (pendingPlayPromise === playPromise) {
|
|
2405
2732
|
pendingPlayPromise = void 0;
|
|
@@ -2438,17 +2765,109 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2438
2765
|
adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
|
|
2439
2766
|
adVideoElement.muted = originalMutedState;
|
|
2440
2767
|
}
|
|
2768
|
+
function clearMediaStartTimer() {
|
|
2769
|
+
if (mediaStartTimerId !== void 0) {
|
|
2770
|
+
clearTimeout(mediaStartTimerId);
|
|
2771
|
+
mediaStartTimerId = void 0;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
function startMediaStartTimer() {
|
|
2775
|
+
clearMediaStartTimer();
|
|
2776
|
+
if (!(MEDIA_START_TIMEOUT_MS > 0)) return;
|
|
2777
|
+
var startedAt = Date.now();
|
|
2778
|
+
mediaStartTimerId = setTimeout(function() {
|
|
2779
|
+
mediaStartTimerId = void 0;
|
|
2780
|
+
if (!adPlaying || trackingFired.impression) return;
|
|
2781
|
+
console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(MEDIA_START_TIMEOUT_MS, "ms"));
|
|
2782
|
+
logFunnel("play_resolved_but_never_started", {
|
|
2783
|
+
timeoutMs: MEDIA_START_TIMEOUT_MS,
|
|
2784
|
+
elapsedMs: Date.now() - startedAt,
|
|
2785
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2786
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2787
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2788
|
+
paused: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.paused,
|
|
2789
|
+
vastErrorCode: VAST_ERROR_MEDIA_TIMEOUT
|
|
2790
|
+
});
|
|
2791
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_TIMEOUT);
|
|
2792
|
+
}, MEDIA_START_TIMEOUT_MS);
|
|
2793
|
+
}
|
|
2794
|
+
function resetVideoElementForNextSource() {
|
|
2795
|
+
clearStallWatchdog();
|
|
2796
|
+
if (requiresMediaPipelineResetAfterAds()) {
|
|
2797
|
+
recreateAdVideoElement();
|
|
2798
|
+
setupAdEventListeners();
|
|
2799
|
+
} else {
|
|
2800
|
+
prepareVideoElementForNewSource();
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
function tryNextMediaCandidate() {
|
|
2804
|
+
if (!currentAd || trackingFired.impression) return false;
|
|
2805
|
+
if (mediaCandidateIndex >= mediaCandidates.length - 1) return false;
|
|
2806
|
+
var failedUrl = currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url;
|
|
2807
|
+
mediaCandidateIndex++;
|
|
2808
|
+
var next = mediaCandidates[mediaCandidateIndex];
|
|
2809
|
+
if (!next) return false;
|
|
2810
|
+
logFunnel("media_fallback", {
|
|
2811
|
+
failedUrl: failedUrl,
|
|
2812
|
+
nextUrl: next.url,
|
|
2813
|
+
nextType: next.type,
|
|
2814
|
+
candidateIndex: mediaCandidateIndex,
|
|
2815
|
+
candidateCount: mediaCandidates.length
|
|
2816
|
+
});
|
|
2817
|
+
resetVideoElementForNextSource();
|
|
2818
|
+
try {
|
|
2819
|
+
loadMediaCandidate(next);
|
|
2820
|
+
return true;
|
|
2821
|
+
} catch (error) {
|
|
2822
|
+
console.error("[HlsAdPlayer] Failed to load fallback media file:", error);
|
|
2823
|
+
return tryNextMediaCandidate();
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
function recoverFromAdFailure(vastErrorCode) {
|
|
2827
|
+
clearMediaStartTimer();
|
|
2828
|
+
if (tryNextMediaCandidate()) return;
|
|
2829
|
+
reportCurrentAdError(vastErrorCode);
|
|
2830
|
+
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) return;
|
|
2831
|
+
handleAdError();
|
|
2832
|
+
}
|
|
2441
2833
|
function loadCurrentAdMedia() {
|
|
2442
2834
|
if (!adVideoElement || !currentAd) {
|
|
2443
2835
|
throw new Error("No ad video element or ad to load");
|
|
2444
2836
|
}
|
|
2445
|
-
|
|
2837
|
+
mediaCandidates = rankMediaCandidates(currentAd.mediaFiles);
|
|
2838
|
+
mediaCandidateIndex = 0;
|
|
2839
|
+
var mediaFile = mediaCandidates[0];
|
|
2446
2840
|
if (!mediaFile) {
|
|
2447
|
-
|
|
2841
|
+
logFunnel("media_unsupported", {
|
|
2842
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA,
|
|
2843
|
+
candidates: currentAd.mediaFiles.length
|
|
2844
|
+
});
|
|
2845
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
2846
|
+
throw new Error("No media file this browser can play");
|
|
2847
|
+
}
|
|
2848
|
+
try {
|
|
2849
|
+
loadMediaCandidate(mediaFile);
|
|
2850
|
+
} catch (error) {
|
|
2851
|
+
if (tryNextMediaCandidate()) return;
|
|
2852
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
2853
|
+
throw error;
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
function loadMediaCandidate(mediaFile) {
|
|
2857
|
+
if (!adVideoElement || !currentAd) {
|
|
2858
|
+
throw new Error("No ad video element or ad to load");
|
|
2448
2859
|
}
|
|
2449
2860
|
currentAdMediaFile = mediaFile;
|
|
2450
2861
|
var isHlsAd = isHlsMediaFile(mediaFile);
|
|
2862
|
+
logFunnel("media_selected", {
|
|
2863
|
+
width: mediaFile.width,
|
|
2864
|
+
height: mediaFile.height,
|
|
2865
|
+
bitrate: mediaFile.bitrate,
|
|
2866
|
+
candidateIndex: mediaCandidateIndex,
|
|
2867
|
+
candidates: mediaCandidates.length
|
|
2868
|
+
});
|
|
2451
2869
|
console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad (pod ").concat(podIndex + 1, "/").concat(podAds.length || 1, ") from: ").concat(mediaFile.url));
|
|
2870
|
+
startMediaStartTimer();
|
|
2452
2871
|
if (isHlsAd && import_hls.default.isSupported()) {
|
|
2453
2872
|
if (adHls) {
|
|
2454
2873
|
adHls.destroy();
|
|
@@ -2457,6 +2876,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2457
2876
|
enableWorker: true,
|
|
2458
2877
|
lowLatencyMode: false
|
|
2459
2878
|
});
|
|
2879
|
+
logFunnel("media_load", {
|
|
2880
|
+
pipeline: "hls.js"
|
|
2881
|
+
});
|
|
2460
2882
|
adHls.loadSource(mediaFile.url);
|
|
2461
2883
|
adHls.attachMedia(adVideoElement);
|
|
2462
2884
|
adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
|
|
@@ -2466,10 +2888,24 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2466
2888
|
adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
|
|
2467
2889
|
console.error("[HlsAdPlayer] HLS error:", data);
|
|
2468
2890
|
if (data.fatal) {
|
|
2469
|
-
|
|
2891
|
+
var _data_response, _data_response1, _data_frag;
|
|
2892
|
+
var vastErrorCode = data.type === import_hls.default.ErrorTypes.NETWORK_ERROR ? 401 : VAST_ERROR_MEDIA_DISPLAY;
|
|
2893
|
+
logFunnel("hls_fatal", {
|
|
2894
|
+
reason: data.details,
|
|
2895
|
+
errorName: data.type,
|
|
2896
|
+
errorMessage: data.details,
|
|
2897
|
+
responseCode: (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.code,
|
|
2898
|
+
responseText: (_data_response1 = data.response) === null || _data_response1 === void 0 ? void 0 : _data_response1.text,
|
|
2899
|
+
fragUrl: (_data_frag = data.frag) === null || _data_frag === void 0 ? void 0 : _data_frag.url,
|
|
2900
|
+
vastErrorCode: vastErrorCode
|
|
2901
|
+
});
|
|
2902
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2470
2903
|
}
|
|
2471
2904
|
});
|
|
2472
2905
|
} else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
|
|
2906
|
+
logFunnel("media_load", {
|
|
2907
|
+
pipeline: "native-hls"
|
|
2908
|
+
});
|
|
2473
2909
|
adVideoElement.src = mediaFile.url;
|
|
2474
2910
|
startAdPlayback("native HLS ad playback");
|
|
2475
2911
|
} else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
|
|
@@ -2477,45 +2913,47 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2477
2913
|
adHls.destroy();
|
|
2478
2914
|
adHls = void 0;
|
|
2479
2915
|
}
|
|
2916
|
+
logFunnel("media_load", {
|
|
2917
|
+
pipeline: "progressive"
|
|
2918
|
+
});
|
|
2480
2919
|
adVideoElement.src = mediaFile.url;
|
|
2481
2920
|
adVideoElement.load();
|
|
2482
2921
|
startAdPlayback("progressive ad playback");
|
|
2483
2922
|
} else {
|
|
2923
|
+
clearMediaStartTimer();
|
|
2924
|
+
logFunnel("media_unsupported", {
|
|
2925
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA
|
|
2926
|
+
});
|
|
2484
2927
|
throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
|
|
2485
2928
|
}
|
|
2486
2929
|
}
|
|
2487
2930
|
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;
|
|
2931
|
+
clearMediaStartTimer();
|
|
2932
|
+
while(podIndex < podAds.length - 1){
|
|
2933
|
+
settleViewability();
|
|
2934
|
+
podIndex++;
|
|
2935
|
+
currentAd = podAds[podIndex];
|
|
2936
|
+
currentAdMediaFile = void 0;
|
|
2937
|
+
resetAdTracking();
|
|
2938
|
+
if (currentAd) {
|
|
2939
|
+
console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
|
|
2940
|
+
}
|
|
2941
|
+
resetVideoElementForNextSource();
|
|
2942
|
+
try {
|
|
2943
|
+
loadCurrentAdMedia();
|
|
2944
|
+
emit("pod_ad_started", {
|
|
2945
|
+
index: podIndex,
|
|
2946
|
+
total: podAds.length
|
|
2947
|
+
});
|
|
2948
|
+
return true;
|
|
2949
|
+
} catch (error) {
|
|
2950
|
+
console.error("[HlsAdPlayer] Failed to load next pod ad:", error);
|
|
2951
|
+
}
|
|
2516
2952
|
}
|
|
2953
|
+
return false;
|
|
2517
2954
|
}
|
|
2518
2955
|
function clearStallWatchdog() {
|
|
2956
|
+
clearMediaStartTimer();
|
|
2519
2957
|
if (stallWatchdogId != null) {
|
|
2520
2958
|
clearInterval(stallWatchdogId);
|
|
2521
2959
|
stallWatchdogId = void 0;
|
|
@@ -2531,11 +2969,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2531
2969
|
function handleAdStall() {
|
|
2532
2970
|
console.warn("[HlsAdPlayer] Ad playback stalled (no progress) - recovering to avoid a blank frame");
|
|
2533
2971
|
clearStallWatchdog();
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
handleAdError();
|
|
2972
|
+
logFunnel("stall", {
|
|
2973
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
2974
|
+
});
|
|
2975
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2539
2976
|
}
|
|
2540
2977
|
function getDecodedVideoFrameCount(video) {
|
|
2541
2978
|
try {
|
|
@@ -2597,11 +3034,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2597
3034
|
function handleVideoDecodeFailure() {
|
|
2598
3035
|
console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
|
|
2599
3036
|
clearStallWatchdog();
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
handleAdError();
|
|
3037
|
+
logFunnel("decode_failure", {
|
|
3038
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
3039
|
+
});
|
|
3040
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2605
3041
|
}
|
|
2606
3042
|
function startStallWatchdog() {
|
|
2607
3043
|
clearStallWatchdog();
|
|
@@ -2725,6 +3161,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2725
3161
|
Promise.reject(new Error("Ad already playing"))
|
|
2726
3162
|
];
|
|
2727
3163
|
}
|
|
3164
|
+
if (destroyed) {
|
|
3165
|
+
return [
|
|
3166
|
+
2,
|
|
3167
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
3168
|
+
];
|
|
3169
|
+
}
|
|
3170
|
+
currentVastTagUrl = vastTagUrl;
|
|
3171
|
+
pendingRequestAbortReason = void 0;
|
|
3172
|
+
logFunnel("request_sent");
|
|
2728
3173
|
_state.label = 1;
|
|
2729
3174
|
case 1:
|
|
2730
3175
|
_state.trys.push([
|
|
@@ -2759,8 +3204,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2759
3204
|
ads = _state.sent();
|
|
2760
3205
|
_state.label = 4;
|
|
2761
3206
|
case 4:
|
|
3207
|
+
if (destroyed) {
|
|
3208
|
+
return [
|
|
3209
|
+
2,
|
|
3210
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
3211
|
+
];
|
|
3212
|
+
}
|
|
3213
|
+
if (!ads.length && pendingRequestAbortReason) {
|
|
3214
|
+
throw new Error(pendingRequestAbortReason);
|
|
3215
|
+
}
|
|
2762
3216
|
if (!ads.length) {
|
|
2763
3217
|
console.warn("[HlsAdPlayer] No ads available from VAST response");
|
|
3218
|
+
logFunnel("no_fill");
|
|
2764
3219
|
emit("ad_error");
|
|
2765
3220
|
return [
|
|
2766
3221
|
2,
|
|
@@ -2771,6 +3226,23 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2771
3226
|
podIndex = 0;
|
|
2772
3227
|
currentAd = ads[0];
|
|
2773
3228
|
currentAdMediaFile = void 0;
|
|
3229
|
+
logFunnel("vast_received", {
|
|
3230
|
+
adCount: ads.length,
|
|
3231
|
+
durations: ads.map(function(ad) {
|
|
3232
|
+
return ad.duration;
|
|
3233
|
+
}),
|
|
3234
|
+
impressionUrls: ads.map(function(ad) {
|
|
3235
|
+
return ad.trackingUrls.impression.length;
|
|
3236
|
+
})
|
|
3237
|
+
});
|
|
3238
|
+
ads.forEach(function(ad, index) {
|
|
3239
|
+
if (ad.trackingUrls.impression.length === 0) {
|
|
3240
|
+
logFunnel("vast_missing_impression", {
|
|
3241
|
+
adIndex: index,
|
|
3242
|
+
missingAdId: ad.id
|
|
3243
|
+
});
|
|
3244
|
+
}
|
|
3245
|
+
});
|
|
2774
3246
|
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
3247
|
return [
|
|
2776
3248
|
2,
|
|
@@ -2779,6 +3251,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2779
3251
|
case 5:
|
|
2780
3252
|
error = _state.sent();
|
|
2781
3253
|
console.error("[HlsAdPlayer] Error requesting ads:", error);
|
|
3254
|
+
logFunnel("request_failed", {
|
|
3255
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3256
|
+
});
|
|
2782
3257
|
emit("ad_error");
|
|
2783
3258
|
return [
|
|
2784
3259
|
2,
|
|
@@ -2834,13 +3309,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2834
3309
|
adContainerEl.style.pointerEvents = "auto";
|
|
2835
3310
|
}
|
|
2836
3311
|
emit("content_pause");
|
|
2837
|
-
|
|
3312
|
+
try {
|
|
3313
|
+
loadCurrentAdMedia();
|
|
3314
|
+
} catch (loadError) {
|
|
3315
|
+
if (!(podIndex < podAds.length - 1 && advanceToNextPodAd())) {
|
|
3316
|
+
throw loadError;
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
2838
3319
|
return [
|
|
2839
3320
|
2,
|
|
2840
3321
|
Promise.resolve()
|
|
2841
3322
|
];
|
|
2842
3323
|
} catch (error) {
|
|
2843
3324
|
console.error("[HlsAdPlayer] Error playing ad:", error);
|
|
3325
|
+
logFunnel("play_failed", {
|
|
3326
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3327
|
+
});
|
|
2844
3328
|
handleAdError();
|
|
2845
3329
|
return [
|
|
2846
3330
|
2,
|
|
@@ -2882,6 +3366,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2882
3366
|
var previousMutedState;
|
|
2883
3367
|
return _ts_generator(this, function(_state) {
|
|
2884
3368
|
console.log("[HlsAdPlayer] Stopping ad");
|
|
3369
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3370
|
+
logFunnel("stopped_before_start");
|
|
3371
|
+
}
|
|
2885
3372
|
settleViewability();
|
|
2886
3373
|
fireNotUsedForUnplayedAds();
|
|
2887
3374
|
clearStallWatchdog();
|
|
@@ -2914,15 +3401,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2914
3401
|
},
|
|
2915
3402
|
destroy: function destroy() {
|
|
2916
3403
|
console.log("[HlsAdPlayer] Destroying");
|
|
3404
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3405
|
+
logFunnel("stopped_before_start");
|
|
3406
|
+
}
|
|
2917
3407
|
settleViewability();
|
|
2918
3408
|
fireNotUsedForUnplayedAds();
|
|
2919
3409
|
destroyed = true;
|
|
2920
|
-
|
|
3410
|
+
pendingRequestAbortReason = "Ad player destroyed";
|
|
2921
3411
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2922
3412
|
try {
|
|
2923
|
-
for(var _iterator =
|
|
2924
|
-
var
|
|
2925
|
-
|
|
3413
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3414
|
+
var controller = _step.value;
|
|
3415
|
+
controller.abort();
|
|
2926
3416
|
}
|
|
2927
3417
|
} catch (err) {
|
|
2928
3418
|
_didIteratorError = true;
|
|
@@ -2938,6 +3428,28 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2938
3428
|
}
|
|
2939
3429
|
}
|
|
2940
3430
|
}
|
|
3431
|
+
pendingVastRequests.clear();
|
|
3432
|
+
clearStallWatchdog();
|
|
3433
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3434
|
+
try {
|
|
3435
|
+
for(var _iterator1 = pendingTimeouts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3436
|
+
var timeoutId = _step1.value;
|
|
3437
|
+
clearTimeout(timeoutId);
|
|
3438
|
+
}
|
|
3439
|
+
} catch (err) {
|
|
3440
|
+
_didIteratorError1 = true;
|
|
3441
|
+
_iteratorError1 = err;
|
|
3442
|
+
} finally{
|
|
3443
|
+
try {
|
|
3444
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
3445
|
+
_iterator1.return();
|
|
3446
|
+
}
|
|
3447
|
+
} finally{
|
|
3448
|
+
if (_didIteratorError1) {
|
|
3449
|
+
throw _iteratorError1;
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
2941
3453
|
pendingTimeouts = [];
|
|
2942
3454
|
adPlaying = false;
|
|
2943
3455
|
setAdPlayingFlag(false);
|
|
@@ -2957,6 +3469,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2957
3469
|
isAdPlaying: function isAdPlaying() {
|
|
2958
3470
|
return adPlaying;
|
|
2959
3471
|
},
|
|
3472
|
+
setFunnelContext: function setFunnelContext(context) {
|
|
3473
|
+
funnelContext = _object_spread({}, context);
|
|
3474
|
+
},
|
|
3475
|
+
abortPendingRequest: function abortPendingRequest() {
|
|
3476
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "VAST request aborted (timeout)";
|
|
3477
|
+
if (pendingVastRequests.size === 0) return;
|
|
3478
|
+
pendingRequestAbortReason = reason;
|
|
3479
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3480
|
+
try {
|
|
3481
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3482
|
+
var controller = _step.value;
|
|
3483
|
+
controller.abort();
|
|
3484
|
+
}
|
|
3485
|
+
} catch (err) {
|
|
3486
|
+
_didIteratorError = true;
|
|
3487
|
+
_iteratorError = err;
|
|
3488
|
+
} finally{
|
|
3489
|
+
try {
|
|
3490
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3491
|
+
_iterator.return();
|
|
3492
|
+
}
|
|
3493
|
+
} finally{
|
|
3494
|
+
if (_didIteratorError) {
|
|
3495
|
+
throw _iteratorError;
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
pendingVastRequests.clear();
|
|
3500
|
+
},
|
|
2960
3501
|
resize: function resize(width, height) {
|
|
2961
3502
|
console.log("[HlsAdPlayer] Resizing to ".concat(width, "x").concat(height));
|
|
2962
3503
|
if (adContainerEl) {
|
|
@@ -2992,6 +3533,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2992
3533
|
if (adVideoElement && adPlaying) {
|
|
2993
3534
|
var clamped = Math.max(0, Math.min(1, volume));
|
|
2994
3535
|
adVideoElement.volume = clamped;
|
|
3536
|
+
var userActivation = navigator.userActivation;
|
|
3537
|
+
if (clamped > 0 && forcedMuteByAutoplay && userActivation && !userActivation.isActive) {
|
|
3538
|
+
logFunnel("unmute_blocked_without_gesture", {
|
|
3539
|
+
requestedVolume: clamped
|
|
3540
|
+
});
|
|
3541
|
+
return;
|
|
3542
|
+
}
|
|
2995
3543
|
adVideoElement.muted = clamped === 0;
|
|
2996
3544
|
}
|
|
2997
3545
|
},
|
|
@@ -7061,7 +7609,7 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
7061
7609
|
{
|
|
7062
7610
|
key: "adFitsRemainingBudget",
|
|
7063
7611
|
value: function adFitsRemainingBudget(durationMs) {
|
|
7064
|
-
if (durationMs <= 0) {
|
|
7612
|
+
if (durationMs <= 0 || this.expectedAdBreakDurationMs == null) {
|
|
7065
7613
|
return true;
|
|
7066
7614
|
}
|
|
7067
7615
|
return durationMs <= this.getDurationBudgetRemainingMs();
|
|
@@ -7120,6 +7668,11 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
7120
7668
|
value: function markAdStarted() {
|
|
7121
7669
|
this.currentAdIndex++;
|
|
7122
7670
|
this.totalAdsInBreak = this.currentAdIndex;
|
|
7671
|
+
}
|
|
7672
|
+
},
|
|
7673
|
+
{
|
|
7674
|
+
key: "noteAdRequestSent",
|
|
7675
|
+
value: function noteAdRequestSent() {
|
|
7123
7676
|
this.totalAdRequestsInBreak++;
|
|
7124
7677
|
this.lastAdRequestTime = Date.now();
|
|
7125
7678
|
}
|
|
@@ -7171,6 +7724,9 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
7171
7724
|
if (message.includes("timeout")) {
|
|
7172
7725
|
return true;
|
|
7173
7726
|
}
|
|
7727
|
+
if (message.includes("ad player destroyed") || message.includes("aborted")) {
|
|
7728
|
+
return true;
|
|
7729
|
+
}
|
|
7174
7730
|
if (message.includes("rate limit") || message.includes("too many requests")) {
|
|
7175
7731
|
return true;
|
|
7176
7732
|
}
|
|
@@ -8304,6 +8860,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8304
8860
|
this.adDetectSentForCurrentBreak = false;
|
|
8305
8861
|
this.continuousFetchingActive = false;
|
|
8306
8862
|
this.continuousFetchLoopRunning = false;
|
|
8863
|
+
this.breakFunnel = {};
|
|
8864
|
+
this.controllerCallInFlight = false;
|
|
8865
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8866
|
+
this.opportunityEpoch = -1;
|
|
8307
8867
|
this.adRequestQueue = [];
|
|
8308
8868
|
this.adPodQueue = [];
|
|
8309
8869
|
this.maxPlaceholderDurationMs = 5e3;
|
|
@@ -8356,7 +8916,25 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8356
8916
|
adPlayer.on("ad_interaction", function(event) {
|
|
8357
8917
|
if (event) _this.host.onAdInteraction(event);
|
|
8358
8918
|
});
|
|
8919
|
+
adPlayer.on("ad_funnel", function(payload) {
|
|
8920
|
+
if (!(payload === null || payload === void 0 ? void 0 : payload.stage)) return;
|
|
8921
|
+
_this.countFunnelStage(payload.stage);
|
|
8922
|
+
if (payload.reason) {
|
|
8923
|
+
_this.countFunnelStage("".concat(payload.stage, ":").concat(payload.reason));
|
|
8924
|
+
}
|
|
8925
|
+
if (payload.stage === "impression_fired" && payload.pixelCount != null) {
|
|
8926
|
+
_this.countFunnelStage("impression_urls", payload.pixelCount);
|
|
8927
|
+
}
|
|
8928
|
+
if (payload.visibilityState === "hidden") {
|
|
8929
|
+
_this.countFunnelStage("while_hidden");
|
|
8930
|
+
}
|
|
8931
|
+
});
|
|
8359
8932
|
adPlayer.on("ad_impression", function() {
|
|
8933
|
+
_this.timing.consecutiveFailures = 0;
|
|
8934
|
+
if (!_this.playbackStartedForCurrentRequest) {
|
|
8935
|
+
_this.playbackStartedForCurrentRequest = true;
|
|
8936
|
+
_this.timing.markAdStarted();
|
|
8937
|
+
}
|
|
8360
8938
|
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
8361
8939
|
source: "hls",
|
|
8362
8940
|
adIndex: _this.timing.currentAdIndex
|
|
@@ -8400,6 +8978,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8400
8978
|
}
|
|
8401
8979
|
}
|
|
8402
8980
|
console.error("[AD-ERROR]", errorMessage, errorPayload || "");
|
|
8981
|
+
if (_this.controllerCallInFlight) {
|
|
8982
|
+
_this.timing.recordGamNoFill();
|
|
8983
|
+
return;
|
|
8984
|
+
}
|
|
8403
8985
|
_this.handleAdFailure();
|
|
8404
8986
|
});
|
|
8405
8987
|
adPlayer.on("content_pause", function() {
|
|
@@ -8471,6 +9053,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8471
9053
|
}
|
|
8472
9054
|
var preservedMutedState = adPlayer.getOriginalMutedState();
|
|
8473
9055
|
var preservedVolumeState = adPlayer.getOriginalVolume();
|
|
9056
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8474
9057
|
if (adPlayer) {
|
|
8475
9058
|
try {
|
|
8476
9059
|
adPlayer.destroy();
|
|
@@ -8560,9 +9143,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8560
9143
|
if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
8561
9144
|
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
8562
9145
|
}
|
|
9146
|
+
this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
|
|
8563
9147
|
return [
|
|
8564
9148
|
4,
|
|
8565
|
-
this.startOptimizedPod(baseVastUrl, adBreakDurationMs
|
|
9149
|
+
this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
|
|
8566
9150
|
];
|
|
8567
9151
|
case 1:
|
|
8568
9152
|
podPlayed = _state.sent();
|
|
@@ -8596,7 +9180,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8596
9180
|
value: // ───────────────────────────────────────────────────────────────
|
|
8597
9181
|
// Optimized pod (single multi-ad request)
|
|
8598
9182
|
// ───────────────────────────────────────────────────────────────
|
|
8599
|
-
function startOptimizedPod(baseVastUrl, breakDurationMs
|
|
9183
|
+
function startOptimizedPod(baseVastUrl, breakDurationMs) {
|
|
8600
9184
|
return _async_to_generator(function() {
|
|
8601
9185
|
var podUrl, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
8602
9186
|
return _ts_generator(this, function(_state) {
|
|
@@ -8635,10 +9219,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8635
9219
|
case 2:
|
|
8636
9220
|
_state.sent();
|
|
8637
9221
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
8638
|
-
this.timing.
|
|
9222
|
+
this.timing.noteAdRequestSent();
|
|
9223
|
+
this.beginFunnelRequest(adPlayer, requestToken);
|
|
8639
9224
|
return [
|
|
8640
9225
|
4,
|
|
8641
|
-
|
|
9226
|
+
this.callController(function() {
|
|
9227
|
+
return adPlayer.requestAds(podUrl);
|
|
9228
|
+
})
|
|
8642
9229
|
];
|
|
8643
9230
|
case 3:
|
|
8644
9231
|
_state.sent();
|
|
@@ -8667,16 +9254,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8667
9254
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
8668
9255
|
return [
|
|
8669
9256
|
4,
|
|
8670
|
-
|
|
9257
|
+
this.callController(function() {
|
|
9258
|
+
return adPlayer.play();
|
|
9259
|
+
})
|
|
8671
9260
|
];
|
|
8672
9261
|
case 4:
|
|
8673
9262
|
_state.sent();
|
|
8674
|
-
this.timing.markAdStarted();
|
|
8675
9263
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
8676
9264
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
8677
9265
|
}
|
|
8678
|
-
adPlayer.setAdVolume(
|
|
8679
|
-
this.timing.consecutiveFailures = 0;
|
|
9266
|
+
adPlayer.setAdVolume(getAdAudioVolume(adPlayer));
|
|
8680
9267
|
this.continuousFetchingActive = true;
|
|
8681
9268
|
this.startContinuousFetching(baseVastUrl);
|
|
8682
9269
|
return [
|
|
@@ -9041,7 +9628,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9041
9628
|
];
|
|
9042
9629
|
case 3:
|
|
9043
9630
|
_state.sent();
|
|
9044
|
-
this.timing.consecutiveFailures = 0;
|
|
9045
9631
|
return [
|
|
9046
9632
|
3,
|
|
9047
9633
|
8
|
|
@@ -9054,6 +9640,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9054
9640
|
3,
|
|
9055
9641
|
6
|
|
9056
9642
|
];
|
|
9643
|
+
this.timing.consecutiveFailures++;
|
|
9057
9644
|
return [
|
|
9058
9645
|
4,
|
|
9059
9646
|
this.tryNextAvailableAdWithRateLimit()
|
|
@@ -9145,11 +9732,137 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9145
9732
|
}
|
|
9146
9733
|
}
|
|
9147
9734
|
},
|
|
9735
|
+
{
|
|
9736
|
+
key: "countFunnelStage",
|
|
9737
|
+
value: function countFunnelStage(stage) {
|
|
9738
|
+
var amount = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
|
|
9739
|
+
var _this_breakFunnel_stage;
|
|
9740
|
+
this.breakFunnel[stage] = ((_this_breakFunnel_stage = this.breakFunnel[stage]) !== null && _this_breakFunnel_stage !== void 0 ? _this_breakFunnel_stage : 0) + amount;
|
|
9741
|
+
}
|
|
9742
|
+
},
|
|
9743
|
+
{
|
|
9744
|
+
key: "logOrchestratorFunnel",
|
|
9745
|
+
value: function logOrchestratorFunnel(stage) {
|
|
9746
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
9747
|
+
this.countFunnelStage(stage);
|
|
9748
|
+
console.log("[AdBreak][FUNNEL] ".concat(stage), _object_spread({
|
|
9749
|
+
breakId: this.timing.adBreakEpoch,
|
|
9750
|
+
requestId: this.currentRequestId,
|
|
9751
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0
|
|
9752
|
+
}, extra));
|
|
9753
|
+
}
|
|
9754
|
+
},
|
|
9755
|
+
{
|
|
9756
|
+
key: "noteOpportunity",
|
|
9757
|
+
value: function noteOpportunity(source, breakKey) {
|
|
9758
|
+
if (breakKey && breakKey === this.opportunityBreakKey && this.opportunityEpoch === this.timing.adBreakEpoch) {
|
|
9759
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
9760
|
+
source: source,
|
|
9761
|
+
breakKey: breakKey
|
|
9762
|
+
});
|
|
9763
|
+
return;
|
|
9764
|
+
}
|
|
9765
|
+
this.opportunityBreakKey = breakKey;
|
|
9766
|
+
this.opportunityEpoch = this.timing.adBreakEpoch;
|
|
9767
|
+
this.logOrchestratorFunnel("opportunity_created", {
|
|
9768
|
+
source: source,
|
|
9769
|
+
breakKey: breakKey,
|
|
9770
|
+
expectedDurationMs: this.timing.expectedAdBreakDurationMs
|
|
9771
|
+
});
|
|
9772
|
+
}
|
|
9773
|
+
},
|
|
9774
|
+
{
|
|
9775
|
+
key: "beginFunnelRequest",
|
|
9776
|
+
value: function beginFunnelRequest(adPlayer, requestToken) {
|
|
9777
|
+
var _adPlayer_setFunnelContext;
|
|
9778
|
+
if (this.controllerCallInFlight) {
|
|
9779
|
+
this.logOrchestratorFunnel("duplicate_request_detected", {
|
|
9780
|
+
newRequestId: requestToken
|
|
9781
|
+
});
|
|
9782
|
+
}
|
|
9783
|
+
this.currentRequestId = requestToken;
|
|
9784
|
+
this.requestStartedAt = Date.now();
|
|
9785
|
+
(_adPlayer_setFunnelContext = adPlayer.setFunnelContext) === null || _adPlayer_setFunnelContext === void 0 ? void 0 : _adPlayer_setFunnelContext.call(adPlayer, {
|
|
9786
|
+
breakId: this.timing.adBreakEpoch,
|
|
9787
|
+
requestId: requestToken
|
|
9788
|
+
});
|
|
9789
|
+
}
|
|
9790
|
+
},
|
|
9791
|
+
{
|
|
9792
|
+
key: "isAdLoadingWithoutPlayback",
|
|
9793
|
+
value: function isAdLoadingWithoutPlayback() {
|
|
9794
|
+
return this.host.getAdPlayer().isAdPlaying() && !this.playbackStartedForCurrentRequest;
|
|
9795
|
+
}
|
|
9796
|
+
},
|
|
9797
|
+
{
|
|
9798
|
+
key: "noteStopBeforeStart",
|
|
9799
|
+
value: function noteStopBeforeStart(reason) {
|
|
9800
|
+
if (!this.isAdLoadingWithoutPlayback()) return;
|
|
9801
|
+
this.logOrchestratorFunnel("ad_stopped_before_start", {
|
|
9802
|
+
reason: reason,
|
|
9803
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
9804
|
+
});
|
|
9805
|
+
}
|
|
9806
|
+
},
|
|
9807
|
+
{
|
|
9808
|
+
key: "handleRequestWatchdogTimeout",
|
|
9809
|
+
value: function handleRequestWatchdogTimeout() {
|
|
9810
|
+
var adPlayer = this.host.getAdPlayer();
|
|
9811
|
+
if (this.controllerCallInFlight && adPlayer.abortPendingRequest) {
|
|
9812
|
+
this.logOrchestratorFunnel("request_aborted_timeout", {
|
|
9813
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
9814
|
+
});
|
|
9815
|
+
adPlayer.abortPendingRequest("VAST request aborted after request watchdog timeout");
|
|
9816
|
+
return;
|
|
9817
|
+
}
|
|
9818
|
+
this.handleAdFailure();
|
|
9819
|
+
}
|
|
9820
|
+
},
|
|
9821
|
+
{
|
|
9822
|
+
key: "callController",
|
|
9823
|
+
value: function callController(call) {
|
|
9824
|
+
return _async_to_generator(function() {
|
|
9825
|
+
return _ts_generator(this, function(_state) {
|
|
9826
|
+
switch(_state.label){
|
|
9827
|
+
case 0:
|
|
9828
|
+
this.controllerCallInFlight = true;
|
|
9829
|
+
_state.label = 1;
|
|
9830
|
+
case 1:
|
|
9831
|
+
_state.trys.push([
|
|
9832
|
+
1,
|
|
9833
|
+
,
|
|
9834
|
+
3,
|
|
9835
|
+
4
|
|
9836
|
+
]);
|
|
9837
|
+
return [
|
|
9838
|
+
4,
|
|
9839
|
+
call()
|
|
9840
|
+
];
|
|
9841
|
+
case 2:
|
|
9842
|
+
_state.sent();
|
|
9843
|
+
return [
|
|
9844
|
+
3,
|
|
9845
|
+
4
|
|
9846
|
+
];
|
|
9847
|
+
case 3:
|
|
9848
|
+
this.controllerCallInFlight = false;
|
|
9849
|
+
return [
|
|
9850
|
+
7
|
|
9851
|
+
];
|
|
9852
|
+
case 4:
|
|
9853
|
+
return [
|
|
9854
|
+
2
|
|
9855
|
+
];
|
|
9856
|
+
}
|
|
9857
|
+
});
|
|
9858
|
+
}).call(this);
|
|
9859
|
+
}
|
|
9860
|
+
},
|
|
9148
9861
|
{
|
|
9149
9862
|
key: "playSingleAd",
|
|
9150
9863
|
value: function playSingleAd(vastTagUrl) {
|
|
9151
9864
|
return _async_to_generator(function() {
|
|
9152
|
-
var adPlayer, requestToken, ap, requestUrl, playError, error, errorMessage;
|
|
9865
|
+
var adPlayer, requestToken, ap, requestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, playError, error, errorMessage;
|
|
9153
9866
|
return _ts_generator(this, function(_state) {
|
|
9154
9867
|
switch(_state.label){
|
|
9155
9868
|
case 0:
|
|
@@ -9191,13 +9904,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9191
9904
|
case 2:
|
|
9192
9905
|
_state.sent();
|
|
9193
9906
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
9194
|
-
this.timing.
|
|
9907
|
+
this.timing.noteAdRequestSent();
|
|
9195
9908
|
ap = this.host.getAdPlayer();
|
|
9196
9909
|
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9197
9910
|
this.currentVastUrl = requestUrl;
|
|
9911
|
+
this.beginFunnelRequest(ap, requestToken);
|
|
9198
9912
|
return [
|
|
9199
9913
|
4,
|
|
9200
|
-
|
|
9914
|
+
this.callController(function() {
|
|
9915
|
+
return ap.requestAds(requestUrl);
|
|
9916
|
+
})
|
|
9201
9917
|
];
|
|
9202
9918
|
case 3:
|
|
9203
9919
|
_state.sent();
|
|
@@ -9211,6 +9927,14 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9211
9927
|
2
|
|
9212
9928
|
];
|
|
9213
9929
|
if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
|
|
9930
|
+
;
|
|
9931
|
+
adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
|
|
9932
|
+
remainingMs = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9933
|
+
this.logOrchestratorFunnel("discarded_budget", {
|
|
9934
|
+
vastUrl: requestUrl,
|
|
9935
|
+
adDurationMs: adDurationS != null ? adDurationS * 1e3 : void 0,
|
|
9936
|
+
remainingMs: remainingMs
|
|
9937
|
+
});
|
|
9214
9938
|
this.timing.rejectLoadedAdForDuration(ap);
|
|
9215
9939
|
this.recreateAdController();
|
|
9216
9940
|
throw new Error("ad_duration_exceeds_budget");
|
|
@@ -9226,16 +9950,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9226
9950
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
9227
9951
|
return [
|
|
9228
9952
|
4,
|
|
9229
|
-
|
|
9953
|
+
this.callController(function() {
|
|
9954
|
+
return ap.play();
|
|
9955
|
+
})
|
|
9230
9956
|
];
|
|
9231
9957
|
case 5:
|
|
9232
9958
|
_state.sent();
|
|
9233
|
-
this.timing.markAdStarted();
|
|
9234
9959
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
9235
9960
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
9236
9961
|
}
|
|
9237
9962
|
ap.setAdVolume(getAdAudioVolume(ap));
|
|
9238
|
-
this.timing.consecutiveFailures = 0;
|
|
9239
9963
|
this.timing.temporaryFailureUrls.delete(vastTagUrl);
|
|
9240
9964
|
return [
|
|
9241
9965
|
3,
|
|
@@ -9399,7 +10123,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9399
10123
|
];
|
|
9400
10124
|
case 5:
|
|
9401
10125
|
_state.sent();
|
|
9402
|
-
this.timing.consecutiveFailures = 0;
|
|
9403
10126
|
return [
|
|
9404
10127
|
3,
|
|
9405
10128
|
10
|
|
@@ -9411,6 +10134,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9411
10134
|
3,
|
|
9412
10135
|
8
|
|
9413
10136
|
];
|
|
10137
|
+
this.timing.consecutiveFailures++;
|
|
9414
10138
|
return [
|
|
9415
10139
|
4,
|
|
9416
10140
|
this.tryNextAvailableAdWithRateLimit()
|
|
@@ -9461,6 +10185,67 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9461
10185
|
// ───────────────────────────────────────────────────────────────
|
|
9462
10186
|
// Ad break completion
|
|
9463
10187
|
// ───────────────────────────────────────────────────────────────
|
|
10188
|
+
key: "logBreakFunnel",
|
|
10189
|
+
value: function logBreakFunnel() {
|
|
10190
|
+
var funnel = this.breakFunnel;
|
|
10191
|
+
this.breakFunnel = {};
|
|
10192
|
+
if (Object.keys(funnel).length === 0) return;
|
|
10193
|
+
var count = function count(stage) {
|
|
10194
|
+
var _funnel_stage;
|
|
10195
|
+
return (_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0;
|
|
10196
|
+
};
|
|
10197
|
+
var breakId = this.opportunityEpoch;
|
|
10198
|
+
if (count("request_sent") > 0 && count("impression_fired") === 0) {
|
|
10199
|
+
console.log("[AdBreak][FUNNEL] break_abandoned_before_start", {
|
|
10200
|
+
breakId: breakId,
|
|
10201
|
+
requests: count("request_sent")
|
|
10202
|
+
});
|
|
10203
|
+
}
|
|
10204
|
+
console.log("[AdBreak][FUNNEL] Break summary", {
|
|
10205
|
+
breakId: breakId,
|
|
10206
|
+
opportunities: count("opportunity_created"),
|
|
10207
|
+
requests: count("request_sent"),
|
|
10208
|
+
duplicates: count("duplicate_request_detected") + count("duplicate_break_start"),
|
|
10209
|
+
filled: count("vast_received"),
|
|
10210
|
+
noFill: count("no_fill"),
|
|
10211
|
+
requestFailed: count("request_failed"),
|
|
10212
|
+
requestAbortedTimeout: count("request_aborted_timeout"),
|
|
10213
|
+
credentialsRetries: count("vast_credentials_retry"),
|
|
10214
|
+
wrapperFailures: count("wrapper_fetch:failure"),
|
|
10215
|
+
noSupportedMedia: count("vast_no_supported_media"),
|
|
10216
|
+
vpaidOnly: count("vast_no_supported_media:vpaid_only"),
|
|
10217
|
+
missingImpression: count("vast_missing_impression"),
|
|
10218
|
+
discardedBudget: count("discarded_budget"),
|
|
10219
|
+
mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
|
|
10220
|
+
mediaRejected: count("media_candidate:rejected"),
|
|
10221
|
+
mediaFallbacks: count("media_fallback"),
|
|
10222
|
+
playCalled: count("play_called"),
|
|
10223
|
+
playRejected: count("play_rejected"),
|
|
10224
|
+
mutedRetry: count("muted_retry"),
|
|
10225
|
+
startTimeouts: count("play_resolved_but_never_started"),
|
|
10226
|
+
impressions: count("impression_fired"),
|
|
10227
|
+
impressionUrls: count("impression_urls"),
|
|
10228
|
+
trackingRequests: count("tracking_request_created"),
|
|
10229
|
+
trackingNotLoaded: count("tracking_request_settled:error") + count("tracking_request_settled:timeout"),
|
|
10230
|
+
trackingUnexpandedMacros: count("tracking_url_unexpanded_macro"),
|
|
10231
|
+
trackingInvalidUrls: count("tracking_url_invalid"),
|
|
10232
|
+
vastAdFallbacks: count("vast_ad_fallback"),
|
|
10233
|
+
mediaEvents: count("media_event"),
|
|
10234
|
+
quartile25: count("first_quartile"),
|
|
10235
|
+
quartile50: count("midpoint"),
|
|
10236
|
+
quartile75: count("third_quartile"),
|
|
10237
|
+
complete: count("complete"),
|
|
10238
|
+
stoppedBeforeStart: count("stopped_before_start"),
|
|
10239
|
+
stoppedBeforeStartByBreakEnd: count("ad_stopped_before_start"),
|
|
10240
|
+
unexpectedUnmutes: count("unexpected_unmute"),
|
|
10241
|
+
unmuteBlocked: count("unmute_blocked_without_gesture"),
|
|
10242
|
+
visibilityHidden: count("while_hidden"),
|
|
10243
|
+
playbackFailures: count("play_failed") + count("media_error") + count("hls_fatal") + count("stall") + count("decode_failure") + count("media_unsupported"),
|
|
10244
|
+
stages: funnel
|
|
10245
|
+
});
|
|
10246
|
+
}
|
|
10247
|
+
},
|
|
10248
|
+
{
|
|
9464
10249
|
key: "handleAdPodComplete",
|
|
9465
10250
|
value: function handleAdPodComplete() {
|
|
9466
10251
|
if (this.debug) {
|
|
@@ -9481,6 +10266,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9481
10266
|
this.adPodQueue = [];
|
|
9482
10267
|
this.showAds = false;
|
|
9483
10268
|
this.host.getAdPlayer().stop().catch(function() {});
|
|
10269
|
+
this.logBreakFunnel();
|
|
9484
10270
|
var restoredMuted = this.host.getAdPlayer().getOriginalMutedState();
|
|
9485
10271
|
var restoredVolume = this.host.getAdPlayer().getOriginalVolume();
|
|
9486
10272
|
if (this.host.video.muted !== restoredMuted) {
|
|
@@ -9832,7 +10618,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9832
10618
|
_this.startScte35AdBreak(marker, cueKey, marker.durationSeconds != null ? marker.durationSeconds * 1e3 : _this.timing.expectedAdBreakDurationMs);
|
|
9833
10619
|
},
|
|
9834
10620
|
onWatchdogTimeout: function onWatchdogTimeout() {
|
|
9835
|
-
return _this.adBreak.
|
|
10621
|
+
return _this.adBreak.handleRequestWatchdogTimeout();
|
|
9836
10622
|
},
|
|
9837
10623
|
onFailsafeTimeout: function onFailsafeTimeout() {
|
|
9838
10624
|
return _this.adBreak.handleAdFailure();
|
|
@@ -9937,6 +10723,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9937
10723
|
licenseKey: this.config.licenseKey
|
|
9938
10724
|
} : {}, ((_this_hlsEngine = this.hlsEngine) === null || _this_hlsEngine === void 0 ? void 0 : _this_hlsEngine.hls) ? {
|
|
9939
10725
|
mainHlsInstance: this.hlsEngine.hls
|
|
10726
|
+
} : {}, this.config.adMediaStartTimeoutMs != null ? {
|
|
10727
|
+
mediaStartTimeoutMs: this.config.adMediaStartTimeoutMs
|
|
9940
10728
|
} : {}));
|
|
9941
10729
|
}
|
|
9942
10730
|
},
|
|
@@ -10291,6 +11079,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10291
11079
|
this.timing.clearAdStartTimer();
|
|
10292
11080
|
this.timing.clearAdStopTimer();
|
|
10293
11081
|
if (adPlaying) {
|
|
11082
|
+
this.adBreak.noteStopBeforeStart("scte_end");
|
|
10294
11083
|
this.adPlayer.stop().catch(function() {});
|
|
10295
11084
|
}
|
|
10296
11085
|
this.adBreak.handleAdPodComplete();
|
|
@@ -10330,6 +11119,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10330
11119
|
console.log("[StormcloudVideoPlayer] Ad break boundary reached (overrun=".concat(overrunMs, "ms) - hard-stopping ads and resuming stream"));
|
|
10331
11120
|
}
|
|
10332
11121
|
if (adPlaying) {
|
|
11122
|
+
this.adBreak.noteStopBeforeStart("break_boundary");
|
|
10333
11123
|
this.adPlayer.stop().catch(function() {});
|
|
10334
11124
|
}
|
|
10335
11125
|
this.adBreak.handleAdPodComplete();
|
|
@@ -10458,6 +11248,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10458
11248
|
this.adBreak.showAds = true;
|
|
10459
11249
|
this.adBreak.inAdBreak = true;
|
|
10460
11250
|
this.timing.currentAdBreakStartWallClockMs = Date.now();
|
|
11251
|
+
if (durationMs > 0) {
|
|
11252
|
+
this.timing.setAdBreakDurationBoundary(durationMs);
|
|
11253
|
+
}
|
|
11254
|
+
this.adBreak.noteOpportunity("vmap", key);
|
|
10461
11255
|
_state.label = 1;
|
|
10462
11256
|
case 1:
|
|
10463
11257
|
_state.trys.push([
|