stormcloud-video-player 0.8.65 → 0.8.67
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 +1 -1
- package/lib/StormcloudPlayer.cjs +1006 -820
- package/lib/StormcloudPlayer.cjs.map +1 -1
- package/lib/index.cjs +978 -822
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +978 -822
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +674 -741
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +34 -16
- package/lib/player/AdConfigManager.cjs +16 -1
- package/lib/player/AdConfigManager.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +1006 -820
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +1006 -820
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +1006 -820
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +293 -78
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/types.d.cts +3 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +978 -822
- 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/sdk/hlsAdPlayer.cjs
CHANGED
|
@@ -685,6 +685,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
685
685
|
var pendingPlayPromise;
|
|
686
686
|
var currentVastTagUrl;
|
|
687
687
|
var funnelContext = {};
|
|
688
|
+
var mediaProbe;
|
|
689
|
+
var lastPodAdElementCount = 0;
|
|
688
690
|
var mediaCandidates = [];
|
|
689
691
|
var mediaCandidateIndex = 0;
|
|
690
692
|
var mediaStartTimerId;
|
|
@@ -802,6 +804,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
802
804
|
stage: stage,
|
|
803
805
|
breakId: funnelContext.breakId,
|
|
804
806
|
requestId: funnelContext.requestId,
|
|
807
|
+
controllerId: funnelContext.controllerId,
|
|
805
808
|
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0,
|
|
806
809
|
adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
|
|
807
810
|
podIndex: podIndex,
|
|
@@ -991,7 +994,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
991
994
|
});
|
|
992
995
|
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
993
996
|
reason: "accepted",
|
|
994
|
-
// Mixed-content media is often auto-upgraded, so it is kept as a last resort.
|
|
995
997
|
why: insecure ? "insecure_http_deprioritized" : "playable",
|
|
996
998
|
score: score
|
|
997
999
|
}));
|
|
@@ -1019,6 +1021,145 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1019
1021
|
var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
|
|
1020
1022
|
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");
|
|
1021
1023
|
}
|
|
1024
|
+
function getMediaProbe() {
|
|
1025
|
+
if (adVideoElement) return adVideoElement;
|
|
1026
|
+
if (!mediaProbe && typeof document !== "undefined") {
|
|
1027
|
+
mediaProbe = document.createElement("video");
|
|
1028
|
+
}
|
|
1029
|
+
return mediaProbe;
|
|
1030
|
+
}
|
|
1031
|
+
function evaluateMediaFile(mf) {
|
|
1032
|
+
var _mf_textContent;
|
|
1033
|
+
var type = mf.getAttribute("type") || "";
|
|
1034
|
+
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1035
|
+
var delivery = mf.getAttribute("delivery") || void 0;
|
|
1036
|
+
var codec = mf.getAttribute("codec") || void 0;
|
|
1037
|
+
if (!url) {
|
|
1038
|
+
return {
|
|
1039
|
+
category: "missing_media",
|
|
1040
|
+
whyRejected: "empty_url",
|
|
1041
|
+
canPlayType: ""
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
var apiFramework = (mf.getAttribute("apiFramework") || "").toUpperCase();
|
|
1045
|
+
if (apiFramework === "VPAID") {
|
|
1046
|
+
return {
|
|
1047
|
+
category: "vpaid",
|
|
1048
|
+
whyRejected: "vpaid_not_supported",
|
|
1049
|
+
canPlayType: ""
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
try {
|
|
1053
|
+
var protocol = new URL(url).protocol;
|
|
1054
|
+
if (protocol !== "https:" && protocol !== "http:") {
|
|
1055
|
+
return {
|
|
1056
|
+
category: "invalid_url",
|
|
1057
|
+
whyRejected: "protocol_".concat(protocol),
|
|
1058
|
+
canPlayType: ""
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
} catch (unused) {
|
|
1062
|
+
return {
|
|
1063
|
+
category: "invalid_url",
|
|
1064
|
+
whyRejected: "unparseable_url",
|
|
1065
|
+
canPlayType: ""
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1069
|
+
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1070
|
+
var file = {
|
|
1071
|
+
url: url,
|
|
1072
|
+
type: type,
|
|
1073
|
+
width: parseInt(mf.getAttribute("width") || "1920", 10),
|
|
1074
|
+
height: parseInt(mf.getAttribute("height") || "1080", 10),
|
|
1075
|
+
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0,
|
|
1076
|
+
delivery: delivery,
|
|
1077
|
+
codec: codec
|
|
1078
|
+
};
|
|
1079
|
+
if (isAudioMediaFile(file)) {
|
|
1080
|
+
return {
|
|
1081
|
+
category: "audio_only",
|
|
1082
|
+
whyRejected: type.toLowerCase().startsWith("audio/") ? "audio_mime" : "audio_extension",
|
|
1083
|
+
canPlayType: ""
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
var isHls = isHlsMediaFile(file);
|
|
1087
|
+
var hasExplicitDimensions = mf.getAttribute("width") != null && mf.getAttribute("height") != null;
|
|
1088
|
+
if (!isHls && hasExplicitDimensions && (file.width <= 1 || file.height <= 1)) {
|
|
1089
|
+
return {
|
|
1090
|
+
category: "audio_only",
|
|
1091
|
+
whyRejected: "zero_dimensions",
|
|
1092
|
+
canPlayType: ""
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
var probe = getMediaProbe();
|
|
1096
|
+
if (isHls) {
|
|
1097
|
+
var _ref;
|
|
1098
|
+
var nativeHls = (_ref = probe === null || probe === void 0 ? void 0 : probe.canPlayType("application/vnd.apple.mpegurl")) !== null && _ref !== void 0 ? _ref : "";
|
|
1099
|
+
if (import_hls.default.isSupported()) {
|
|
1100
|
+
return {
|
|
1101
|
+
file: file,
|
|
1102
|
+
whyAccepted: "hls_js",
|
|
1103
|
+
canPlayType: nativeHls
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
if (nativeHls !== "") {
|
|
1107
|
+
return {
|
|
1108
|
+
file: file,
|
|
1109
|
+
whyAccepted: "native_hls",
|
|
1110
|
+
canPlayType: nativeHls
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
return {
|
|
1114
|
+
category: "unsupported_hls",
|
|
1115
|
+
whyRejected: "no_hls_support",
|
|
1116
|
+
canPlayType: nativeHls
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
if (!isProgressiveMediaFile(file)) {
|
|
1120
|
+
return {
|
|
1121
|
+
category: "unsupported_mime",
|
|
1122
|
+
whyRejected: "not_a_video_mime",
|
|
1123
|
+
canPlayType: ""
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
if (!probe) {
|
|
1127
|
+
return {
|
|
1128
|
+
file: file,
|
|
1129
|
+
whyAccepted: "no_probe_available",
|
|
1130
|
+
canPlayType: ""
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
var baseType = type || "video/mp4";
|
|
1134
|
+
var canPlay = probe.canPlayType(baseType);
|
|
1135
|
+
if (canPlay === "") {
|
|
1136
|
+
return {
|
|
1137
|
+
category: "unsupported_mime",
|
|
1138
|
+
whyRejected: "canPlayType_empty",
|
|
1139
|
+
canPlayType: canPlay
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
if (codec) {
|
|
1143
|
+
var withCodec = probe.canPlayType("".concat(baseType, '; codecs="').concat(codec, '"'));
|
|
1144
|
+
if (withCodec === "") {
|
|
1145
|
+
return {
|
|
1146
|
+
category: "unsupported_codec",
|
|
1147
|
+
whyRejected: "codec_canPlayType_empty",
|
|
1148
|
+
canPlayType: withCodec
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
return {
|
|
1152
|
+
file: file,
|
|
1153
|
+
whyAccepted: "canPlayType_".concat(withCodec),
|
|
1154
|
+
canPlayType: withCodec
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
return {
|
|
1158
|
+
file: file,
|
|
1159
|
+
whyAccepted: "canPlayType_".concat(canPlay),
|
|
1160
|
+
canPlayType: canPlay
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1022
1163
|
function collectVideoMediaFiles(linear, verbose, stats) {
|
|
1023
1164
|
var mediaFileElements = linear.querySelectorAll(":scope > MediaFiles > MediaFile");
|
|
1024
1165
|
var mediaFiles = [];
|
|
@@ -1028,57 +1169,33 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1028
1169
|
}
|
|
1029
1170
|
mediaFileElements.forEach(function(mf, index) {
|
|
1030
1171
|
var _mf_textContent;
|
|
1031
|
-
var
|
|
1172
|
+
var result = evaluateMediaFile(mf);
|
|
1032
1173
|
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1033
|
-
var
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1174
|
+
var accepted = "file" in result;
|
|
1175
|
+
logFunnel("mediafile_evaluated", {
|
|
1176
|
+
reason: accepted ? "accepted" : result.category,
|
|
1177
|
+
index: index,
|
|
1178
|
+
type: mf.getAttribute("type") || "",
|
|
1179
|
+
delivery: mf.getAttribute("delivery") || void 0,
|
|
1180
|
+
codec: mf.getAttribute("codec") || void 0,
|
|
1181
|
+
apiFramework: mf.getAttribute("apiFramework") || void 0,
|
|
1182
|
+
width: mf.getAttribute("width"),
|
|
1183
|
+
height: mf.getAttribute("height"),
|
|
1184
|
+
fileUrl: redactUrl(url),
|
|
1185
|
+
canPlayType: result.canPlayType,
|
|
1186
|
+
whyAccepted: accepted ? result.whyAccepted : void 0,
|
|
1187
|
+
whyRejected: accepted ? void 0 : result.whyRejected
|
|
1188
|
+
});
|
|
1189
|
+
if ("file" in result) {
|
|
1190
|
+
mediaFiles.push(result.file);
|
|
1050
1191
|
return;
|
|
1051
1192
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
url: url,
|
|
1056
|
-
type: type,
|
|
1057
|
-
width: parseInt(width || "1920", 10),
|
|
1058
|
-
height: parseInt(height || "1080", 10),
|
|
1059
|
-
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
1060
|
-
};
|
|
1061
|
-
if (isAudioMediaFile(mediaFile)) {
|
|
1062
|
-
if (stats) stats.audio++;
|
|
1063
|
-
console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
|
|
1064
|
-
return;
|
|
1193
|
+
if (stats) {
|
|
1194
|
+
var _stats_categories_result_category;
|
|
1195
|
+
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;
|
|
1065
1196
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
if (stats) stats.audio++;
|
|
1069
|
-
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'));
|
|
1070
|
-
return;
|
|
1071
|
-
}
|
|
1072
|
-
if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
|
|
1073
|
-
mediaFiles.push(mediaFile);
|
|
1074
|
-
if (verbose) {
|
|
1075
|
-
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
1076
|
-
}
|
|
1077
|
-
} else {
|
|
1078
|
-
if (stats) stats.unsupported++;
|
|
1079
|
-
if (verbose) {
|
|
1080
|
-
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
1081
|
-
}
|
|
1197
|
+
if (result.category === "audio_only") {
|
|
1198
|
+
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'));
|
|
1082
1199
|
}
|
|
1083
1200
|
});
|
|
1084
1201
|
return mediaFiles;
|
|
@@ -1300,7 +1417,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1300
1417
|
if (adElement.getAttribute("conditionalAd") === "true") {
|
|
1301
1418
|
console.warn("[HlsAdPlayer] Skipping conditional <Ad> (VPAID-only)");
|
|
1302
1419
|
logFunnel("vast_no_supported_media", {
|
|
1303
|
-
reason: "
|
|
1420
|
+
reason: "vpaid",
|
|
1304
1421
|
conditionalAd: true
|
|
1305
1422
|
});
|
|
1306
1423
|
return {
|
|
@@ -1313,9 +1430,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1313
1430
|
var mediaFiles = [];
|
|
1314
1431
|
var rejectStats = {
|
|
1315
1432
|
total: 0,
|
|
1316
|
-
|
|
1317
|
-
audio: 0,
|
|
1318
|
-
unsupported: 0
|
|
1433
|
+
categories: {}
|
|
1319
1434
|
};
|
|
1320
1435
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1321
1436
|
try {
|
|
@@ -1344,10 +1459,39 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1344
1459
|
}
|
|
1345
1460
|
if (!linear) {
|
|
1346
1461
|
console.warn("[HlsAdPlayer] No supported linear media files in <Ad>");
|
|
1347
|
-
var reason =
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1462
|
+
var reason = "missing_media";
|
|
1463
|
+
var top = 0;
|
|
1464
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
1465
|
+
try {
|
|
1466
|
+
for(var _iterator1 = Object.keys(rejectStats.categories)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
1467
|
+
var category = _step1.value;
|
|
1468
|
+
var _rejectStats_categories_category;
|
|
1469
|
+
var count = (_rejectStats_categories_category = rejectStats.categories[category]) !== null && _rejectStats_categories_category !== void 0 ? _rejectStats_categories_category : 0;
|
|
1470
|
+
if (count > top) {
|
|
1471
|
+
top = count;
|
|
1472
|
+
reason = category;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
} catch (err) {
|
|
1476
|
+
_didIteratorError1 = true;
|
|
1477
|
+
_iteratorError1 = err;
|
|
1478
|
+
} finally{
|
|
1479
|
+
try {
|
|
1480
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1481
|
+
_iterator1.return();
|
|
1482
|
+
}
|
|
1483
|
+
} finally{
|
|
1484
|
+
if (_didIteratorError1) {
|
|
1485
|
+
throw _iteratorError1;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
if (rejectStats.total > 0 && top === 0) reason = "other";
|
|
1490
|
+
logFunnel("vast_no_supported_media", {
|
|
1491
|
+
reason: reason,
|
|
1492
|
+
mediaFileCount: rejectStats.total,
|
|
1493
|
+
rejectedByCategory: rejectStats.categories
|
|
1494
|
+
});
|
|
1351
1495
|
return {
|
|
1352
1496
|
type: "empty",
|
|
1353
1497
|
errorUrls: errorUrls,
|
|
@@ -1377,9 +1521,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1377
1521
|
}
|
|
1378
1522
|
}
|
|
1379
1523
|
function fetchVastXml(vastTagUrl) {
|
|
1380
|
-
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
1524
|
+
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include", kind = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "gam";
|
|
1381
1525
|
return _async_to_generator(function() {
|
|
1382
|
-
var controller, timeoutId, requestVast, response, error, error1;
|
|
1526
|
+
var controller, timeoutId, startedAt, attempt, requestVast, response, error, error1;
|
|
1383
1527
|
return _ts_generator(this, function(_state) {
|
|
1384
1528
|
switch(_state.label){
|
|
1385
1529
|
case 0:
|
|
@@ -1391,17 +1535,51 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1391
1535
|
timeoutId = controller ? setTimeout(function() {
|
|
1392
1536
|
return controller.abort();
|
|
1393
1537
|
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
1538
|
+
startedAt = Date.now();
|
|
1539
|
+
attempt = 0;
|
|
1394
1540
|
requestVast = function requestVast(creds) {
|
|
1395
|
-
return
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1541
|
+
return _async_to_generator(function() {
|
|
1542
|
+
var response;
|
|
1543
|
+
return _ts_generator(this, function(_state) {
|
|
1544
|
+
switch(_state.label){
|
|
1545
|
+
case 0:
|
|
1546
|
+
attempt++;
|
|
1547
|
+
if (kind === "gam") {
|
|
1548
|
+
logFunnel("gam_http_request_sent", {
|
|
1549
|
+
attempt: attempt,
|
|
1550
|
+
credentials: creds
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
return [
|
|
1554
|
+
4,
|
|
1555
|
+
fetch(vastTagUrl, _object_spread({
|
|
1556
|
+
mode: "cors",
|
|
1557
|
+
credentials: creds,
|
|
1558
|
+
headers: {
|
|
1559
|
+
"Accept": "application/xml, text/xml, */*"
|
|
1560
|
+
},
|
|
1561
|
+
referrerPolicy: "no-referrer-when-downgrade"
|
|
1562
|
+
}, controller ? {
|
|
1563
|
+
signal: controller.signal
|
|
1564
|
+
} : {}))
|
|
1565
|
+
];
|
|
1566
|
+
case 1:
|
|
1567
|
+
response = _state.sent();
|
|
1568
|
+
if (kind === "gam") {
|
|
1569
|
+
logFunnel("gam_response_received", {
|
|
1570
|
+
attempt: attempt,
|
|
1571
|
+
httpStatus: response.status,
|
|
1572
|
+
ok: response.ok,
|
|
1573
|
+
elapsedMs: Date.now() - startedAt
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
return [
|
|
1577
|
+
2,
|
|
1578
|
+
response
|
|
1579
|
+
];
|
|
1580
|
+
}
|
|
1581
|
+
});
|
|
1582
|
+
})();
|
|
1405
1583
|
};
|
|
1406
1584
|
_state.label = 1;
|
|
1407
1585
|
case 1:
|
|
@@ -1458,7 +1636,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1458
1636
|
];
|
|
1459
1637
|
case 8:
|
|
1460
1638
|
if (!response.ok) {
|
|
1461
|
-
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
1639
|
+
throw new Error("Failed to fetch VAST: HTTP ".concat(response.status, " ").concat(response.statusText));
|
|
1462
1640
|
}
|
|
1463
1641
|
return [
|
|
1464
1642
|
4,
|
|
@@ -1473,7 +1651,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1473
1651
|
error1 = _state.sent();
|
|
1474
1652
|
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1475
1653
|
if (pendingRequestAbortReason) {
|
|
1476
|
-
throw new Error("".concat(pendingRequestAbortReason, "
|
|
1654
|
+
throw new Error("".concat(pendingRequestAbortReason, ": ").concat(vastTagUrl));
|
|
1477
1655
|
}
|
|
1478
1656
|
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1479
1657
|
}
|
|
@@ -1517,7 +1695,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1517
1695
|
]);
|
|
1518
1696
|
return [
|
|
1519
1697
|
4,
|
|
1520
|
-
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit")
|
|
1698
|
+
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit", depth === 0 ? "gam" : "wrapper")
|
|
1521
1699
|
];
|
|
1522
1700
|
case 2:
|
|
1523
1701
|
vastXml = _state.sent();
|
|
@@ -1602,10 +1780,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1602
1780
|
}
|
|
1603
1781
|
function fetchAndParsePod(vastTagUrl) {
|
|
1604
1782
|
return _async_to_generator(function() {
|
|
1605
|
-
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements,
|
|
1783
|
+
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;
|
|
1606
1784
|
return _ts_generator(this, function(_state) {
|
|
1607
1785
|
switch(_state.label){
|
|
1608
1786
|
case 0:
|
|
1787
|
+
lastPodAdElementCount = 0;
|
|
1609
1788
|
return [
|
|
1610
1789
|
4,
|
|
1611
1790
|
fetchVastXml(vastTagUrl)
|
|
@@ -1620,6 +1799,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1620
1799
|
trimmedXml = vastXml.trim();
|
|
1621
1800
|
if (trimmedXml.length === 0) {
|
|
1622
1801
|
console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
|
|
1802
|
+
logFunnel("vast_parsed", {
|
|
1803
|
+
adElementCount: 0,
|
|
1804
|
+
reason: "empty_body"
|
|
1805
|
+
});
|
|
1623
1806
|
return [
|
|
1624
1807
|
2,
|
|
1625
1808
|
[]
|
|
@@ -1628,6 +1811,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1628
1811
|
xmlDoc = parseXml(vastXml);
|
|
1629
1812
|
if (!xmlDoc) {
|
|
1630
1813
|
console.error("[HlsAdPlayer] Pod VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1814
|
+
logFunnel("vast_parsed", {
|
|
1815
|
+
adElementCount: 0,
|
|
1816
|
+
reason: "xml_parse_error"
|
|
1817
|
+
});
|
|
1631
1818
|
return [
|
|
1632
1819
|
2,
|
|
1633
1820
|
[]
|
|
@@ -1635,10 +1822,21 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1635
1822
|
}
|
|
1636
1823
|
root = xmlDoc.documentElement;
|
|
1637
1824
|
adElements = Array.from(root.querySelectorAll(":scope > Ad"));
|
|
1825
|
+
logFunnel("vast_parsed", {
|
|
1826
|
+
reason: adElements.length > 0 ? "has_ads" : "no_ads",
|
|
1827
|
+
vastVersion: (_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : void 0,
|
|
1828
|
+
adElementCount: adElements.length,
|
|
1829
|
+
inlineCount: adElements.filter(function(el) {
|
|
1830
|
+
return el.querySelector(":scope > InLine");
|
|
1831
|
+
}).length,
|
|
1832
|
+
wrapperCount: adElements.filter(function(el) {
|
|
1833
|
+
return el.querySelector(":scope > Wrapper");
|
|
1834
|
+
}).length
|
|
1835
|
+
});
|
|
1638
1836
|
if (adElements.length === 0) {
|
|
1639
1837
|
;
|
|
1640
1838
|
;
|
|
1641
|
-
console.warn("[HlsAdPlayer] No <Ad> elements in VAST ".concat((
|
|
1839
|
+
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)"));
|
|
1642
1840
|
empty = emptyVastResult(root);
|
|
1643
1841
|
if (empty.type === "empty" && ((_empty_errorUrls = empty.errorUrls) === null || _empty_errorUrls === void 0 ? void 0 : _empty_errorUrls.length)) {
|
|
1644
1842
|
;
|
|
@@ -1656,10 +1854,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1656
1854
|
var _parsed_errorUrls, parsed, _parsed_errorCode;
|
|
1657
1855
|
return _ts_generator(this, function(_state) {
|
|
1658
1856
|
parsed = parseAdElement(adElement);
|
|
1659
|
-
if (parsed.type === "inline")
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1857
|
+
if (parsed.type === "inline") {
|
|
1858
|
+
logFunnel("inline_resolved", {
|
|
1859
|
+
depth: 0
|
|
1860
|
+
});
|
|
1861
|
+
return [
|
|
1862
|
+
2,
|
|
1863
|
+
parsed.ad
|
|
1864
|
+
];
|
|
1865
|
+
}
|
|
1663
1866
|
if (parsed.type === "wrapper") {
|
|
1664
1867
|
return [
|
|
1665
1868
|
2,
|
|
@@ -1837,7 +2040,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1837
2040
|
7
|
|
1838
2041
|
];
|
|
1839
2042
|
case 21:
|
|
1840
|
-
console.log("[HlsAdPlayer] Parsed ".concat(ads.length, " ad(s) from VAST ").concat((
|
|
2043
|
+
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"));
|
|
2044
|
+
lastPodAdElementCount = adElements.length;
|
|
1841
2045
|
return [
|
|
1842
2046
|
2,
|
|
1843
2047
|
ads
|
|
@@ -2907,6 +3111,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2907
3111
|
if (!ads.length && pendingRequestAbortReason) {
|
|
2908
3112
|
throw new Error(pendingRequestAbortReason);
|
|
2909
3113
|
}
|
|
3114
|
+
if (!ads.length && lastPodAdElementCount > 0) {
|
|
3115
|
+
console.warn("[HlsAdPlayer] VAST response had ads but none were playable");
|
|
3116
|
+
logFunnel("vast_fill_rejected", {
|
|
3117
|
+
adElementCount: lastPodAdElementCount
|
|
3118
|
+
});
|
|
3119
|
+
emit("ad_error");
|
|
3120
|
+
return [
|
|
3121
|
+
2,
|
|
3122
|
+
Promise.reject(new Error("VAST fill rejected: no playable ad in response"))
|
|
3123
|
+
];
|
|
3124
|
+
}
|
|
2910
3125
|
if (!ads.length) {
|
|
2911
3126
|
console.warn("[HlsAdPlayer] No ads available from VAST response");
|
|
2912
3127
|
logFunnel("no_fill");
|