stormcloud-video-player 0.8.65 → 0.8.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/StormcloudPlayer.cjs +1006 -820
- package/lib/StormcloudPlayer.cjs.map +1 -1
- package/lib/index.cjs +970 -820
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +970 -820
- 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 +970 -820
- 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
|
@@ -143,6 +143,42 @@ function _object_spread_props(target, source) {
|
|
|
143
143
|
}
|
|
144
144
|
return target;
|
|
145
145
|
}
|
|
146
|
+
function _object_without_properties(source, excluded) {
|
|
147
|
+
if (source == null) return {};
|
|
148
|
+
var target = {}, sourceKeys, key, i;
|
|
149
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
150
|
+
sourceKeys = Reflect.ownKeys(Object(source));
|
|
151
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
152
|
+
key = sourceKeys[i];
|
|
153
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
154
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
155
|
+
target[key] = source[key];
|
|
156
|
+
}
|
|
157
|
+
return target;
|
|
158
|
+
}
|
|
159
|
+
target = _object_without_properties_loose(source, excluded);
|
|
160
|
+
if (Object.getOwnPropertySymbols) {
|
|
161
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
162
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
163
|
+
key = sourceKeys[i];
|
|
164
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
165
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
166
|
+
target[key] = source[key];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return target;
|
|
170
|
+
}
|
|
171
|
+
function _object_without_properties_loose(source, excluded) {
|
|
172
|
+
if (source == null) return {};
|
|
173
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
174
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
175
|
+
key = sourceKeys[i];
|
|
176
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
177
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
178
|
+
target[key] = source[key];
|
|
179
|
+
}
|
|
180
|
+
return target;
|
|
181
|
+
}
|
|
146
182
|
function _sliced_to_array(arr, i) {
|
|
147
183
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
148
184
|
}
|
|
@@ -248,26 +284,6 @@ function _ts_generator(thisArg, body) {
|
|
|
248
284
|
};
|
|
249
285
|
}
|
|
250
286
|
}
|
|
251
|
-
function _ts_values(o) {
|
|
252
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
253
|
-
if (m) {
|
|
254
|
-
return m.call(o);
|
|
255
|
-
}
|
|
256
|
-
if (o && typeof o.length === "number") {
|
|
257
|
-
return {
|
|
258
|
-
next: function() {
|
|
259
|
-
if (o && i >= o.length) {
|
|
260
|
-
o = void 0;
|
|
261
|
-
}
|
|
262
|
-
return {
|
|
263
|
-
value: o && o[i++],
|
|
264
|
-
done: !o
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
270
|
-
}
|
|
271
287
|
function _type_of(obj) {
|
|
272
288
|
"@swc/helpers - typeof";
|
|
273
289
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
@@ -758,6 +774,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
758
774
|
var pendingPlayPromise;
|
|
759
775
|
var currentVastTagUrl;
|
|
760
776
|
var funnelContext = {};
|
|
777
|
+
var mediaProbe;
|
|
778
|
+
var lastPodAdElementCount = 0;
|
|
761
779
|
var mediaCandidates = [];
|
|
762
780
|
var mediaCandidateIndex = 0;
|
|
763
781
|
var mediaStartTimerId;
|
|
@@ -875,6 +893,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
875
893
|
stage: stage,
|
|
876
894
|
breakId: funnelContext.breakId,
|
|
877
895
|
requestId: funnelContext.requestId,
|
|
896
|
+
controllerId: funnelContext.controllerId,
|
|
878
897
|
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0,
|
|
879
898
|
adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
|
|
880
899
|
podIndex: podIndex,
|
|
@@ -1064,7 +1083,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1064
1083
|
});
|
|
1065
1084
|
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1066
1085
|
reason: "accepted",
|
|
1067
|
-
// Mixed-content media is often auto-upgraded, so it is kept as a last resort.
|
|
1068
1086
|
why: insecure ? "insecure_http_deprioritized" : "playable",
|
|
1069
1087
|
score: score
|
|
1070
1088
|
}));
|
|
@@ -1092,6 +1110,145 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1092
1110
|
var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
|
|
1093
1111
|
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");
|
|
1094
1112
|
}
|
|
1113
|
+
function getMediaProbe() {
|
|
1114
|
+
if (adVideoElement) return adVideoElement;
|
|
1115
|
+
if (!mediaProbe && typeof document !== "undefined") {
|
|
1116
|
+
mediaProbe = document.createElement("video");
|
|
1117
|
+
}
|
|
1118
|
+
return mediaProbe;
|
|
1119
|
+
}
|
|
1120
|
+
function evaluateMediaFile(mf) {
|
|
1121
|
+
var _mf_textContent;
|
|
1122
|
+
var type = mf.getAttribute("type") || "";
|
|
1123
|
+
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1124
|
+
var delivery = mf.getAttribute("delivery") || void 0;
|
|
1125
|
+
var codec = mf.getAttribute("codec") || void 0;
|
|
1126
|
+
if (!url) {
|
|
1127
|
+
return {
|
|
1128
|
+
category: "missing_media",
|
|
1129
|
+
whyRejected: "empty_url",
|
|
1130
|
+
canPlayType: ""
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
var apiFramework = (mf.getAttribute("apiFramework") || "").toUpperCase();
|
|
1134
|
+
if (apiFramework === "VPAID") {
|
|
1135
|
+
return {
|
|
1136
|
+
category: "vpaid",
|
|
1137
|
+
whyRejected: "vpaid_not_supported",
|
|
1138
|
+
canPlayType: ""
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
try {
|
|
1142
|
+
var protocol = new URL(url).protocol;
|
|
1143
|
+
if (protocol !== "https:" && protocol !== "http:") {
|
|
1144
|
+
return {
|
|
1145
|
+
category: "invalid_url",
|
|
1146
|
+
whyRejected: "protocol_".concat(protocol),
|
|
1147
|
+
canPlayType: ""
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
} catch (unused) {
|
|
1151
|
+
return {
|
|
1152
|
+
category: "invalid_url",
|
|
1153
|
+
whyRejected: "unparseable_url",
|
|
1154
|
+
canPlayType: ""
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1158
|
+
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1159
|
+
var file = {
|
|
1160
|
+
url: url,
|
|
1161
|
+
type: type,
|
|
1162
|
+
width: parseInt(mf.getAttribute("width") || "1920", 10),
|
|
1163
|
+
height: parseInt(mf.getAttribute("height") || "1080", 10),
|
|
1164
|
+
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0,
|
|
1165
|
+
delivery: delivery,
|
|
1166
|
+
codec: codec
|
|
1167
|
+
};
|
|
1168
|
+
if (isAudioMediaFile(file)) {
|
|
1169
|
+
return {
|
|
1170
|
+
category: "audio_only",
|
|
1171
|
+
whyRejected: type.toLowerCase().startsWith("audio/") ? "audio_mime" : "audio_extension",
|
|
1172
|
+
canPlayType: ""
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
var isHls = isHlsMediaFile(file);
|
|
1176
|
+
var hasExplicitDimensions = mf.getAttribute("width") != null && mf.getAttribute("height") != null;
|
|
1177
|
+
if (!isHls && hasExplicitDimensions && (file.width <= 1 || file.height <= 1)) {
|
|
1178
|
+
return {
|
|
1179
|
+
category: "audio_only",
|
|
1180
|
+
whyRejected: "zero_dimensions",
|
|
1181
|
+
canPlayType: ""
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
var probe = getMediaProbe();
|
|
1185
|
+
if (isHls) {
|
|
1186
|
+
var _ref;
|
|
1187
|
+
var nativeHls = (_ref = probe === null || probe === void 0 ? void 0 : probe.canPlayType("application/vnd.apple.mpegurl")) !== null && _ref !== void 0 ? _ref : "";
|
|
1188
|
+
if (import_hls.default.isSupported()) {
|
|
1189
|
+
return {
|
|
1190
|
+
file: file,
|
|
1191
|
+
whyAccepted: "hls_js",
|
|
1192
|
+
canPlayType: nativeHls
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
if (nativeHls !== "") {
|
|
1196
|
+
return {
|
|
1197
|
+
file: file,
|
|
1198
|
+
whyAccepted: "native_hls",
|
|
1199
|
+
canPlayType: nativeHls
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
return {
|
|
1203
|
+
category: "unsupported_hls",
|
|
1204
|
+
whyRejected: "no_hls_support",
|
|
1205
|
+
canPlayType: nativeHls
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
if (!isProgressiveMediaFile(file)) {
|
|
1209
|
+
return {
|
|
1210
|
+
category: "unsupported_mime",
|
|
1211
|
+
whyRejected: "not_a_video_mime",
|
|
1212
|
+
canPlayType: ""
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
if (!probe) {
|
|
1216
|
+
return {
|
|
1217
|
+
file: file,
|
|
1218
|
+
whyAccepted: "no_probe_available",
|
|
1219
|
+
canPlayType: ""
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
var baseType = type || "video/mp4";
|
|
1223
|
+
var canPlay = probe.canPlayType(baseType);
|
|
1224
|
+
if (canPlay === "") {
|
|
1225
|
+
return {
|
|
1226
|
+
category: "unsupported_mime",
|
|
1227
|
+
whyRejected: "canPlayType_empty",
|
|
1228
|
+
canPlayType: canPlay
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
if (codec) {
|
|
1232
|
+
var withCodec = probe.canPlayType("".concat(baseType, '; codecs="').concat(codec, '"'));
|
|
1233
|
+
if (withCodec === "") {
|
|
1234
|
+
return {
|
|
1235
|
+
category: "unsupported_codec",
|
|
1236
|
+
whyRejected: "codec_canPlayType_empty",
|
|
1237
|
+
canPlayType: withCodec
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
return {
|
|
1241
|
+
file: file,
|
|
1242
|
+
whyAccepted: "canPlayType_".concat(withCodec),
|
|
1243
|
+
canPlayType: withCodec
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
return {
|
|
1247
|
+
file: file,
|
|
1248
|
+
whyAccepted: "canPlayType_".concat(canPlay),
|
|
1249
|
+
canPlayType: canPlay
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1095
1252
|
function collectVideoMediaFiles(linear, verbose, stats) {
|
|
1096
1253
|
var mediaFileElements = linear.querySelectorAll(":scope > MediaFiles > MediaFile");
|
|
1097
1254
|
var mediaFiles = [];
|
|
@@ -1101,57 +1258,33 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1101
1258
|
}
|
|
1102
1259
|
mediaFileElements.forEach(function(mf, index) {
|
|
1103
1260
|
var _mf_textContent;
|
|
1104
|
-
var
|
|
1261
|
+
var result = evaluateMediaFile(mf);
|
|
1105
1262
|
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1106
|
-
var
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
return;
|
|
1124
|
-
}
|
|
1125
|
-
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1126
|
-
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1127
|
-
var mediaFile = {
|
|
1128
|
-
url: url,
|
|
1129
|
-
type: type,
|
|
1130
|
-
width: parseInt(width || "1920", 10),
|
|
1131
|
-
height: parseInt(height || "1080", 10),
|
|
1132
|
-
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
1133
|
-
};
|
|
1134
|
-
if (isAudioMediaFile(mediaFile)) {
|
|
1135
|
-
if (stats) stats.audio++;
|
|
1136
|
-
console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
|
|
1263
|
+
var accepted = "file" in result;
|
|
1264
|
+
logFunnel("mediafile_evaluated", {
|
|
1265
|
+
reason: accepted ? "accepted" : result.category,
|
|
1266
|
+
index: index,
|
|
1267
|
+
type: mf.getAttribute("type") || "",
|
|
1268
|
+
delivery: mf.getAttribute("delivery") || void 0,
|
|
1269
|
+
codec: mf.getAttribute("codec") || void 0,
|
|
1270
|
+
apiFramework: mf.getAttribute("apiFramework") || void 0,
|
|
1271
|
+
width: mf.getAttribute("width"),
|
|
1272
|
+
height: mf.getAttribute("height"),
|
|
1273
|
+
fileUrl: redactUrl(url),
|
|
1274
|
+
canPlayType: result.canPlayType,
|
|
1275
|
+
whyAccepted: accepted ? result.whyAccepted : void 0,
|
|
1276
|
+
whyRejected: accepted ? void 0 : result.whyRejected
|
|
1277
|
+
});
|
|
1278
|
+
if ("file" in result) {
|
|
1279
|
+
mediaFiles.push(result.file);
|
|
1137
1280
|
return;
|
|
1138
1281
|
}
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
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'));
|
|
1143
|
-
return;
|
|
1282
|
+
if (stats) {
|
|
1283
|
+
var _stats_categories_result_category;
|
|
1284
|
+
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;
|
|
1144
1285
|
}
|
|
1145
|
-
if (
|
|
1146
|
-
|
|
1147
|
-
if (verbose) {
|
|
1148
|
-
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
1149
|
-
}
|
|
1150
|
-
} else {
|
|
1151
|
-
if (stats) stats.unsupported++;
|
|
1152
|
-
if (verbose) {
|
|
1153
|
-
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
1154
|
-
}
|
|
1286
|
+
if (result.category === "audio_only") {
|
|
1287
|
+
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'));
|
|
1155
1288
|
}
|
|
1156
1289
|
});
|
|
1157
1290
|
return mediaFiles;
|
|
@@ -1373,7 +1506,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1373
1506
|
if (adElement.getAttribute("conditionalAd") === "true") {
|
|
1374
1507
|
console.warn("[HlsAdPlayer] Skipping conditional <Ad> (VPAID-only)");
|
|
1375
1508
|
logFunnel("vast_no_supported_media", {
|
|
1376
|
-
reason: "
|
|
1509
|
+
reason: "vpaid",
|
|
1377
1510
|
conditionalAd: true
|
|
1378
1511
|
});
|
|
1379
1512
|
return {
|
|
@@ -1386,9 +1519,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1386
1519
|
var mediaFiles = [];
|
|
1387
1520
|
var rejectStats = {
|
|
1388
1521
|
total: 0,
|
|
1389
|
-
|
|
1390
|
-
audio: 0,
|
|
1391
|
-
unsupported: 0
|
|
1522
|
+
categories: {}
|
|
1392
1523
|
};
|
|
1393
1524
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1394
1525
|
try {
|
|
@@ -1417,10 +1548,39 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1417
1548
|
}
|
|
1418
1549
|
if (!linear) {
|
|
1419
1550
|
console.warn("[HlsAdPlayer] No supported linear media files in <Ad>");
|
|
1420
|
-
var reason =
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1551
|
+
var reason = "missing_media";
|
|
1552
|
+
var top = 0;
|
|
1553
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
1554
|
+
try {
|
|
1555
|
+
for(var _iterator1 = Object.keys(rejectStats.categories)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
1556
|
+
var category = _step1.value;
|
|
1557
|
+
var _rejectStats_categories_category;
|
|
1558
|
+
var count = (_rejectStats_categories_category = rejectStats.categories[category]) !== null && _rejectStats_categories_category !== void 0 ? _rejectStats_categories_category : 0;
|
|
1559
|
+
if (count > top) {
|
|
1560
|
+
top = count;
|
|
1561
|
+
reason = category;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
} catch (err) {
|
|
1565
|
+
_didIteratorError1 = true;
|
|
1566
|
+
_iteratorError1 = err;
|
|
1567
|
+
} finally{
|
|
1568
|
+
try {
|
|
1569
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1570
|
+
_iterator1.return();
|
|
1571
|
+
}
|
|
1572
|
+
} finally{
|
|
1573
|
+
if (_didIteratorError1) {
|
|
1574
|
+
throw _iteratorError1;
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
if (rejectStats.total > 0 && top === 0) reason = "other";
|
|
1579
|
+
logFunnel("vast_no_supported_media", {
|
|
1580
|
+
reason: reason,
|
|
1581
|
+
mediaFileCount: rejectStats.total,
|
|
1582
|
+
rejectedByCategory: rejectStats.categories
|
|
1583
|
+
});
|
|
1424
1584
|
return {
|
|
1425
1585
|
type: "empty",
|
|
1426
1586
|
errorUrls: errorUrls,
|
|
@@ -1450,9 +1610,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1450
1610
|
}
|
|
1451
1611
|
}
|
|
1452
1612
|
function fetchVastXml(vastTagUrl) {
|
|
1453
|
-
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
1613
|
+
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include", kind = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "gam";
|
|
1454
1614
|
return _async_to_generator(function() {
|
|
1455
|
-
var controller, timeoutId, requestVast, response, error, error1;
|
|
1615
|
+
var controller, timeoutId, startedAt, attempt, requestVast, response, error, error1;
|
|
1456
1616
|
return _ts_generator(this, function(_state) {
|
|
1457
1617
|
switch(_state.label){
|
|
1458
1618
|
case 0:
|
|
@@ -1464,17 +1624,51 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1464
1624
|
timeoutId = controller ? setTimeout(function() {
|
|
1465
1625
|
return controller.abort();
|
|
1466
1626
|
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
1627
|
+
startedAt = Date.now();
|
|
1628
|
+
attempt = 0;
|
|
1467
1629
|
requestVast = function requestVast(creds) {
|
|
1468
|
-
return
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1630
|
+
return _async_to_generator(function() {
|
|
1631
|
+
var response;
|
|
1632
|
+
return _ts_generator(this, function(_state) {
|
|
1633
|
+
switch(_state.label){
|
|
1634
|
+
case 0:
|
|
1635
|
+
attempt++;
|
|
1636
|
+
if (kind === "gam") {
|
|
1637
|
+
logFunnel("gam_http_request_sent", {
|
|
1638
|
+
attempt: attempt,
|
|
1639
|
+
credentials: creds
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
return [
|
|
1643
|
+
4,
|
|
1644
|
+
fetch(vastTagUrl, _object_spread({
|
|
1645
|
+
mode: "cors",
|
|
1646
|
+
credentials: creds,
|
|
1647
|
+
headers: {
|
|
1648
|
+
"Accept": "application/xml, text/xml, */*"
|
|
1649
|
+
},
|
|
1650
|
+
referrerPolicy: "no-referrer-when-downgrade"
|
|
1651
|
+
}, controller ? {
|
|
1652
|
+
signal: controller.signal
|
|
1653
|
+
} : {}))
|
|
1654
|
+
];
|
|
1655
|
+
case 1:
|
|
1656
|
+
response = _state.sent();
|
|
1657
|
+
if (kind === "gam") {
|
|
1658
|
+
logFunnel("gam_response_received", {
|
|
1659
|
+
attempt: attempt,
|
|
1660
|
+
httpStatus: response.status,
|
|
1661
|
+
ok: response.ok,
|
|
1662
|
+
elapsedMs: Date.now() - startedAt
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
return [
|
|
1666
|
+
2,
|
|
1667
|
+
response
|
|
1668
|
+
];
|
|
1669
|
+
}
|
|
1670
|
+
});
|
|
1671
|
+
})();
|
|
1478
1672
|
};
|
|
1479
1673
|
_state.label = 1;
|
|
1480
1674
|
case 1:
|
|
@@ -1531,7 +1725,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1531
1725
|
];
|
|
1532
1726
|
case 8:
|
|
1533
1727
|
if (!response.ok) {
|
|
1534
|
-
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
1728
|
+
throw new Error("Failed to fetch VAST: HTTP ".concat(response.status, " ").concat(response.statusText));
|
|
1535
1729
|
}
|
|
1536
1730
|
return [
|
|
1537
1731
|
4,
|
|
@@ -1546,7 +1740,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1546
1740
|
error1 = _state.sent();
|
|
1547
1741
|
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1548
1742
|
if (pendingRequestAbortReason) {
|
|
1549
|
-
throw new Error("".concat(pendingRequestAbortReason, "
|
|
1743
|
+
throw new Error("".concat(pendingRequestAbortReason, ": ").concat(vastTagUrl));
|
|
1550
1744
|
}
|
|
1551
1745
|
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1552
1746
|
}
|
|
@@ -1590,7 +1784,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1590
1784
|
]);
|
|
1591
1785
|
return [
|
|
1592
1786
|
4,
|
|
1593
|
-
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit")
|
|
1787
|
+
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit", depth === 0 ? "gam" : "wrapper")
|
|
1594
1788
|
];
|
|
1595
1789
|
case 2:
|
|
1596
1790
|
vastXml = _state.sent();
|
|
@@ -1675,10 +1869,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1675
1869
|
}
|
|
1676
1870
|
function fetchAndParsePod(vastTagUrl) {
|
|
1677
1871
|
return _async_to_generator(function() {
|
|
1678
|
-
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements,
|
|
1872
|
+
var _root_getAttribute, _root_getAttribute1, vastXml, trimmedXml, xmlDoc, root, adElements, _root_getAttribute2, _empty_errorUrls, empty, _empty_errorCode, resolveAd, podElements, buffet, resolveAll, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, ad, err, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, ad1, err;
|
|
1679
1873
|
return _ts_generator(this, function(_state) {
|
|
1680
1874
|
switch(_state.label){
|
|
1681
1875
|
case 0:
|
|
1876
|
+
lastPodAdElementCount = 0;
|
|
1682
1877
|
return [
|
|
1683
1878
|
4,
|
|
1684
1879
|
fetchVastXml(vastTagUrl)
|
|
@@ -1693,6 +1888,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1693
1888
|
trimmedXml = vastXml.trim();
|
|
1694
1889
|
if (trimmedXml.length === 0) {
|
|
1695
1890
|
console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
|
|
1891
|
+
logFunnel("vast_parsed", {
|
|
1892
|
+
adElementCount: 0,
|
|
1893
|
+
reason: "empty_body"
|
|
1894
|
+
});
|
|
1696
1895
|
return [
|
|
1697
1896
|
2,
|
|
1698
1897
|
[]
|
|
@@ -1701,6 +1900,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1701
1900
|
xmlDoc = parseXml(vastXml);
|
|
1702
1901
|
if (!xmlDoc) {
|
|
1703
1902
|
console.error("[HlsAdPlayer] Pod VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1903
|
+
logFunnel("vast_parsed", {
|
|
1904
|
+
adElementCount: 0,
|
|
1905
|
+
reason: "xml_parse_error"
|
|
1906
|
+
});
|
|
1704
1907
|
return [
|
|
1705
1908
|
2,
|
|
1706
1909
|
[]
|
|
@@ -1708,10 +1911,21 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1708
1911
|
}
|
|
1709
1912
|
root = xmlDoc.documentElement;
|
|
1710
1913
|
adElements = Array.from(root.querySelectorAll(":scope > Ad"));
|
|
1914
|
+
logFunnel("vast_parsed", {
|
|
1915
|
+
reason: adElements.length > 0 ? "has_ads" : "no_ads",
|
|
1916
|
+
vastVersion: (_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : void 0,
|
|
1917
|
+
adElementCount: adElements.length,
|
|
1918
|
+
inlineCount: adElements.filter(function(el) {
|
|
1919
|
+
return el.querySelector(":scope > InLine");
|
|
1920
|
+
}).length,
|
|
1921
|
+
wrapperCount: adElements.filter(function(el) {
|
|
1922
|
+
return el.querySelector(":scope > Wrapper");
|
|
1923
|
+
}).length
|
|
1924
|
+
});
|
|
1711
1925
|
if (adElements.length === 0) {
|
|
1712
1926
|
;
|
|
1713
1927
|
;
|
|
1714
|
-
console.warn("[HlsAdPlayer] No <Ad> elements in VAST ".concat((
|
|
1928
|
+
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)"));
|
|
1715
1929
|
empty = emptyVastResult(root);
|
|
1716
1930
|
if (empty.type === "empty" && ((_empty_errorUrls = empty.errorUrls) === null || _empty_errorUrls === void 0 ? void 0 : _empty_errorUrls.length)) {
|
|
1717
1931
|
;
|
|
@@ -1729,10 +1943,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1729
1943
|
var _parsed_errorUrls, parsed, _parsed_errorCode;
|
|
1730
1944
|
return _ts_generator(this, function(_state) {
|
|
1731
1945
|
parsed = parseAdElement(adElement);
|
|
1732
|
-
if (parsed.type === "inline")
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1946
|
+
if (parsed.type === "inline") {
|
|
1947
|
+
logFunnel("inline_resolved", {
|
|
1948
|
+
depth: 0
|
|
1949
|
+
});
|
|
1950
|
+
return [
|
|
1951
|
+
2,
|
|
1952
|
+
parsed.ad
|
|
1953
|
+
];
|
|
1954
|
+
}
|
|
1736
1955
|
if (parsed.type === "wrapper") {
|
|
1737
1956
|
return [
|
|
1738
1957
|
2,
|
|
@@ -1910,7 +2129,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1910
2129
|
7
|
|
1911
2130
|
];
|
|
1912
2131
|
case 21:
|
|
1913
|
-
console.log("[HlsAdPlayer] Parsed ".concat(ads.length, " ad(s) from VAST ").concat((
|
|
2132
|
+
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"));
|
|
2133
|
+
lastPodAdElementCount = adElements.length;
|
|
1914
2134
|
return [
|
|
1915
2135
|
2,
|
|
1916
2136
|
ads
|
|
@@ -2980,6 +3200,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2980
3200
|
if (!ads.length && pendingRequestAbortReason) {
|
|
2981
3201
|
throw new Error(pendingRequestAbortReason);
|
|
2982
3202
|
}
|
|
3203
|
+
if (!ads.length && lastPodAdElementCount > 0) {
|
|
3204
|
+
console.warn("[HlsAdPlayer] VAST response had ads but none were playable");
|
|
3205
|
+
logFunnel("vast_fill_rejected", {
|
|
3206
|
+
adElementCount: lastPodAdElementCount
|
|
3207
|
+
});
|
|
3208
|
+
emit("ad_error");
|
|
3209
|
+
return [
|
|
3210
|
+
2,
|
|
3211
|
+
Promise.reject(new Error("VAST fill rejected: no playable ad in response"))
|
|
3212
|
+
];
|
|
3213
|
+
}
|
|
2983
3214
|
if (!ads.length) {
|
|
2984
3215
|
console.warn("[HlsAdPlayer] No ads available from VAST response");
|
|
2985
3216
|
logFunnel("no_fill");
|
|
@@ -5413,6 +5644,21 @@ function normalizeVastTagUrl(raw) {
|
|
|
5413
5644
|
return raw;
|
|
5414
5645
|
}
|
|
5415
5646
|
}
|
|
5647
|
+
var GAM_AD_HOSTS = /* @__PURE__ */ new Set([
|
|
5648
|
+
"pubads.g.doubleclick.net",
|
|
5649
|
+
"securepubads.g.doubleclick.net"
|
|
5650
|
+
]);
|
|
5651
|
+
function ensureVideoAdType(rawUrl) {
|
|
5652
|
+
try {
|
|
5653
|
+
var url = new URL(rawUrl);
|
|
5654
|
+
if (!GAM_AD_HOSTS.has(url.hostname)) return rawUrl;
|
|
5655
|
+
if (url.searchParams.has("ad_type")) return rawUrl;
|
|
5656
|
+
url.searchParams.set("ad_type", "video");
|
|
5657
|
+
return url.toString();
|
|
5658
|
+
} catch (unused) {
|
|
5659
|
+
return rawUrl;
|
|
5660
|
+
}
|
|
5661
|
+
}
|
|
5416
5662
|
function applyVastMacros(baseUrl, ctx) {
|
|
5417
5663
|
var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
|
|
5418
5664
|
var url;
|
|
@@ -7123,7 +7369,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
7123
7369
|
} : {}), {
|
|
7124
7370
|
consent: this.consentSignals
|
|
7125
7371
|
}));
|
|
7126
|
-
var finalUrl = palNonce.injectNonce(urlWithMacros);
|
|
7372
|
+
var finalUrl = palNonce.injectNonce(ensureVideoAdType(urlWithMacros));
|
|
7127
7373
|
console.log("[StormcloudVideoPlayer] Resolved optimized-pod request URL (pod=".concat(this.podCounter, ", pmad=").concat(podParams.maxAds, ", pmnd=").concat(podParams.minDurationMs, ", pmxd=").concat((_podParams_maxDurationMs = podParams.maxDurationMs) !== null && _podParams_maxDurationMs !== void 0 ? _podParams_maxDurationMs : "?", "):"), finalUrl);
|
|
7128
7374
|
return finalUrl;
|
|
7129
7375
|
}
|
|
@@ -8612,6 +8858,18 @@ function resizePlayer(video, adPlayer, debug) {
|
|
|
8612
8858
|
}
|
|
8613
8859
|
}
|
|
8614
8860
|
// src/player/AdBreakOrchestrator.ts
|
|
8861
|
+
var REQUEST_FAILURE_STAGES = /* @__PURE__ */ new Set([
|
|
8862
|
+
"no_fill",
|
|
8863
|
+
"vast_fill_rejected",
|
|
8864
|
+
"request_failed",
|
|
8865
|
+
"media_unsupported",
|
|
8866
|
+
"play_failed",
|
|
8867
|
+
"play_resolved_but_never_started",
|
|
8868
|
+
"hls_fatal",
|
|
8869
|
+
"media_error",
|
|
8870
|
+
"stall",
|
|
8871
|
+
"decode_failure"
|
|
8872
|
+
]);
|
|
8615
8873
|
var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
8616
8874
|
function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
|
|
8617
8875
|
_class_call_check(this, AdBreakOrchestrator);
|
|
@@ -8619,15 +8877,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8619
8877
|
this.showAds = false;
|
|
8620
8878
|
this.isShowingPlaceholder = false;
|
|
8621
8879
|
this.adDetectSentForCurrentBreak = false;
|
|
8622
|
-
this.
|
|
8623
|
-
this.
|
|
8880
|
+
this.slotState = "IDLE";
|
|
8881
|
+
this.unusableResponsesInBreak = 0;
|
|
8882
|
+
this.controllerGeneration = 0;
|
|
8883
|
+
this.requestDiagnostics = /* @__PURE__ */ new Map();
|
|
8624
8884
|
this.breakFunnel = {};
|
|
8625
8885
|
this.controllerCallInFlight = false;
|
|
8626
8886
|
this.playbackStartedForCurrentRequest = false;
|
|
8627
8887
|
this.opportunityEpoch = -1;
|
|
8628
|
-
this.adRequestQueue = [];
|
|
8629
8888
|
this.adPodQueue = [];
|
|
8630
|
-
this.
|
|
8889
|
+
this.defaultMinRemainingMsToRequestAd = 1e4;
|
|
8890
|
+
this.defaultMaxNoFillsPerBreak = 2;
|
|
8631
8891
|
this.pendingAdBreak = null;
|
|
8632
8892
|
this.host = host;
|
|
8633
8893
|
this.timing = timing;
|
|
@@ -8663,7 +8923,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8663
8923
|
key: "attachImaEventListeners",
|
|
8664
8924
|
value: function attachImaEventListeners() {
|
|
8665
8925
|
var _this = this;
|
|
8666
|
-
var
|
|
8926
|
+
var controller = this.host.getAdPlayer();
|
|
8927
|
+
var generation = this.controllerGeneration;
|
|
8928
|
+
var adPlayer = {
|
|
8929
|
+
on: function on(event, handler) {
|
|
8930
|
+
controller.on(event, function(payload) {
|
|
8931
|
+
if (generation !== _this.controllerGeneration) {
|
|
8932
|
+
_this.logOrchestratorFunnel("stale_callback_ignored", {
|
|
8933
|
+
event: event,
|
|
8934
|
+
staleControllerId: generation,
|
|
8935
|
+
currentControllerId: _this.controllerGeneration
|
|
8936
|
+
});
|
|
8937
|
+
return;
|
|
8938
|
+
}
|
|
8939
|
+
handler(payload);
|
|
8940
|
+
});
|
|
8941
|
+
}
|
|
8942
|
+
};
|
|
8667
8943
|
adPlayer.on("pod_ad_started", function(payload) {
|
|
8668
8944
|
_this.timing.notePodAdStarted();
|
|
8669
8945
|
if (_this.debug) {
|
|
@@ -8679,19 +8955,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8679
8955
|
});
|
|
8680
8956
|
adPlayer.on("ad_funnel", function(payload) {
|
|
8681
8957
|
if (!(payload === null || payload === void 0 ? void 0 : payload.stage)) return;
|
|
8682
|
-
|
|
8958
|
+
var stage = payload.stage;
|
|
8959
|
+
_this.countFunnelStage(stage);
|
|
8683
8960
|
if (payload.reason) {
|
|
8684
|
-
_this.countFunnelStage("".concat(
|
|
8961
|
+
_this.countFunnelStage("".concat(stage, ":").concat(payload.reason));
|
|
8685
8962
|
}
|
|
8686
|
-
if (
|
|
8963
|
+
if (stage === "impression_fired" && payload.pixelCount != null) {
|
|
8687
8964
|
_this.countFunnelStage("impression_urls", payload.pixelCount);
|
|
8688
8965
|
}
|
|
8689
8966
|
if (payload.visibilityState === "hidden") {
|
|
8690
8967
|
_this.countFunnelStage("while_hidden");
|
|
8691
8968
|
}
|
|
8969
|
+
if (stage === "gam_http_request_sent") {
|
|
8970
|
+
if (payload.attempt === 1) {
|
|
8971
|
+
_this.timing.noteAdRequestSent();
|
|
8972
|
+
} else {
|
|
8973
|
+
_this.countFunnelStage("gam_http_request_retry");
|
|
8974
|
+
}
|
|
8975
|
+
}
|
|
8976
|
+
_this.recordRequestDiagnostic(payload);
|
|
8692
8977
|
});
|
|
8693
8978
|
adPlayer.on("ad_impression", function() {
|
|
8694
8979
|
_this.timing.consecutiveFailures = 0;
|
|
8980
|
+
_this.setSlotState("PLAYING", "impression");
|
|
8695
8981
|
if (!_this.playbackStartedForCurrentRequest) {
|
|
8696
8982
|
_this.playbackStartedForCurrentRequest = true;
|
|
8697
8983
|
_this.timing.markAdStarted();
|
|
@@ -8710,16 +8996,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8710
8996
|
var remaining = _this.timing.getRemainingAdMs();
|
|
8711
8997
|
_this.timing.consecutiveFailures = 0;
|
|
8712
8998
|
if (_this.debug) {
|
|
8713
|
-
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms
|
|
8714
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
8715
|
-
} : {});
|
|
8999
|
+
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms"));
|
|
8716
9000
|
}
|
|
8717
9001
|
if (_this.inAdBreak) {
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
} else {
|
|
8721
|
-
_this.handleAdPodComplete();
|
|
8722
|
-
}
|
|
9002
|
+
_this.setSlotState("NEEDS_NEXT_AD", "all_ads_completed");
|
|
9003
|
+
_this.requestNextAd("all_ads_completed");
|
|
8723
9004
|
}
|
|
8724
9005
|
});
|
|
8725
9006
|
adPlayer.on("ad_error", function(errorPayload) {
|
|
@@ -8740,10 +9021,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8740
9021
|
}
|
|
8741
9022
|
console.error("[AD-ERROR]", errorMessage, errorPayload || "");
|
|
8742
9023
|
if (_this.controllerCallInFlight) {
|
|
8743
|
-
_this.timing.recordGamNoFill();
|
|
8744
9024
|
return;
|
|
8745
9025
|
}
|
|
8746
|
-
_this.handleAdFailure();
|
|
9026
|
+
_this.handleAdFailure("ad_error");
|
|
8747
9027
|
});
|
|
8748
9028
|
adPlayer.on("content_pause", function() {
|
|
8749
9029
|
_this.timing.clearAdFailsafeTimer();
|
|
@@ -8782,26 +9062,32 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8782
9062
|
}
|
|
8783
9063
|
_this.timing.consecutiveFailures = 0;
|
|
8784
9064
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
8785
|
-
var remaining = _this.timing.getRemainingAdMs();
|
|
8786
9065
|
if (_this.debug) {
|
|
8787
|
-
console.log("[
|
|
8788
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
8789
|
-
} : {});
|
|
8790
|
-
}
|
|
8791
|
-
if (_this.timing.hasTimeToStartAnotherAd()) {
|
|
8792
|
-
_this.tryNextAvailableAdWithRateLimit();
|
|
8793
|
-
} else {
|
|
8794
|
-
_this.handleAdPodComplete();
|
|
9066
|
+
console.log("[AdBreak] content_resume: remaining=".concat(_this.timing.getRemainingAdMs(), "ms"));
|
|
8795
9067
|
}
|
|
9068
|
+
_this.setSlotState("NEEDS_NEXT_AD", "ad_complete");
|
|
9069
|
+
_this.requestNextAd("ad_complete");
|
|
8796
9070
|
});
|
|
8797
9071
|
}
|
|
8798
9072
|
},
|
|
8799
9073
|
{
|
|
8800
9074
|
key: "recreateAdController",
|
|
8801
|
-
value: function recreateAdController() {
|
|
8802
|
-
if (this.
|
|
8803
|
-
console.
|
|
9075
|
+
value: function recreateAdController(reason) {
|
|
9076
|
+
if (reason === "new_request" && (this.slotState === "REQUESTING" || this.slotState === "READY")) {
|
|
9077
|
+
console.warn("[AD-CONTROLLER] destroy during active request", {
|
|
9078
|
+
controllerId: this.controllerGeneration,
|
|
9079
|
+
requestId: this.currentRequestId,
|
|
9080
|
+
state: this.slotState,
|
|
9081
|
+
reason: reason
|
|
9082
|
+
});
|
|
8804
9083
|
}
|
|
9084
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
9085
|
+
controllerId: this.controllerGeneration,
|
|
9086
|
+
requestId: this.currentRequestId,
|
|
9087
|
+
state: this.slotState,
|
|
9088
|
+
reason: reason
|
|
9089
|
+
});
|
|
9090
|
+
this.countFunnelStage("controller_destroy:".concat(reason));
|
|
8805
9091
|
var shouldShowPlaceholder = this.inAdBreak && this.showAds;
|
|
8806
9092
|
var adPlayer = this.host.getAdPlayer();
|
|
8807
9093
|
if (shouldShowPlaceholder && adPlayer) {
|
|
@@ -8828,9 +9114,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8828
9114
|
var continueLiveStreamDuringAds = this.host.shouldContinueLiveStreamDuringAds();
|
|
8829
9115
|
var newAdPlayer = this.host.createAdPlayer(continueLiveStreamDuringAds);
|
|
8830
9116
|
this.host.setAdPlayer(newAdPlayer);
|
|
9117
|
+
this.controllerGeneration++;
|
|
8831
9118
|
newAdPlayer.initialize();
|
|
8832
9119
|
newAdPlayer.updateOriginalMutedState(preservedMutedState, preservedVolumeState);
|
|
8833
9120
|
this.attachImaEventListeners();
|
|
9121
|
+
if (this.debug) {
|
|
9122
|
+
console.log("[AD-CONTROLLER] create", {
|
|
9123
|
+
controllerId: this.controllerGeneration,
|
|
9124
|
+
reason: reason
|
|
9125
|
+
});
|
|
9126
|
+
}
|
|
8834
9127
|
if (shouldShowPlaceholder) {
|
|
8835
9128
|
this.placeholder.show();
|
|
8836
9129
|
newAdPlayer.showPlaceholder();
|
|
@@ -8851,32 +9144,57 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8851
9144
|
}
|
|
8852
9145
|
},
|
|
8853
9146
|
{
|
|
8854
|
-
|
|
8855
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9147
|
+
// ───────────────────────────────────────────────────────────────
|
|
8856
9148
|
// Ad break start
|
|
8857
9149
|
// ───────────────────────────────────────────────────────────────
|
|
8858
|
-
|
|
9150
|
+
key: "isBreakActive",
|
|
9151
|
+
value: function isBreakActive() {
|
|
9152
|
+
return this.slotState !== "IDLE";
|
|
9153
|
+
}
|
|
9154
|
+
},
|
|
9155
|
+
{
|
|
9156
|
+
key: "getSlotState",
|
|
9157
|
+
value: function getSlotState() {
|
|
9158
|
+
return this.slotState;
|
|
9159
|
+
}
|
|
9160
|
+
},
|
|
9161
|
+
{
|
|
9162
|
+
key: "beginVmapBreak",
|
|
9163
|
+
value: function beginVmapBreak(breakKey) {
|
|
9164
|
+
this.breakSource = "vmap";
|
|
9165
|
+
this.followUpBaseVastUrl = void 0;
|
|
9166
|
+
this.unusableResponsesInBreak = 0;
|
|
9167
|
+
this.timing.totalAdRequestsInBreak = 0;
|
|
9168
|
+
this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
|
|
9169
|
+
this.noteOpportunity("vmap", breakKey);
|
|
9170
|
+
}
|
|
9171
|
+
},
|
|
9172
|
+
{
|
|
9173
|
+
key: "handleAdStart",
|
|
9174
|
+
value: function handleAdStart(marker) {
|
|
8859
9175
|
return _async_to_generator(function() {
|
|
8860
|
-
var
|
|
9176
|
+
var baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, epoch, podPlayed;
|
|
8861
9177
|
return _ts_generator(this, function(_state) {
|
|
8862
9178
|
switch(_state.label){
|
|
8863
9179
|
case 0:
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
|
|
9180
|
+
if (this.slotState !== "IDLE") {
|
|
9181
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
9182
|
+
source: "scte35",
|
|
9183
|
+
state: this.slotState
|
|
9184
|
+
});
|
|
9185
|
+
return [
|
|
9186
|
+
2
|
|
9187
|
+
];
|
|
8867
9188
|
}
|
|
8868
|
-
|
|
8869
|
-
if (
|
|
8870
|
-
|
|
8871
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
8872
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
8873
|
-
} else {
|
|
9189
|
+
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
9190
|
+
if (!baseVastUrl) {
|
|
9191
|
+
console.warn("[AdBreak] SCTE-35 break started but no direct VAST tag is configured");
|
|
8874
9192
|
this.clearPendingAdBreak();
|
|
8875
9193
|
return [
|
|
8876
9194
|
2
|
|
8877
9195
|
];
|
|
8878
9196
|
}
|
|
8879
|
-
adBreakDurationMs =
|
|
9197
|
+
adBreakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : this.timing.expectedAdBreakDurationMs;
|
|
8880
9198
|
if (this.debug) {
|
|
8881
9199
|
mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
|
|
8882
9200
|
console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
@@ -8884,9 +9202,12 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8884
9202
|
this.timing.failedVastUrls.clear();
|
|
8885
9203
|
this.timing.temporaryFailureUrls.clear();
|
|
8886
9204
|
this.timing.consecutiveFailures = 0;
|
|
8887
|
-
this.continuousFetchingActive = true;
|
|
8888
9205
|
this.isShowingPlaceholder = false;
|
|
8889
9206
|
this.timing.totalAdRequestsInBreak = 0;
|
|
9207
|
+
this.breakSource = "scte35";
|
|
9208
|
+
this.followUpBaseVastUrl = baseVastUrl;
|
|
9209
|
+
this.unusableResponsesInBreak = 0;
|
|
9210
|
+
this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
|
|
8890
9211
|
if (this.adConfig.podAssignedByPrefetch) {
|
|
8891
9212
|
this.adConfig.podAssignedByPrefetch = false;
|
|
8892
9213
|
} else {
|
|
@@ -8905,29 +9226,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8905
9226
|
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
8906
9227
|
}
|
|
8907
9228
|
this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
|
|
9229
|
+
epoch = this.timing.adBreakEpoch;
|
|
8908
9230
|
return [
|
|
8909
9231
|
4,
|
|
8910
9232
|
this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
|
|
8911
9233
|
];
|
|
8912
9234
|
case 1:
|
|
8913
9235
|
podPlayed = _state.sent();
|
|
8914
|
-
if (
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
];
|
|
8918
|
-
if (this.debug) {
|
|
8919
|
-
console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
|
|
9236
|
+
if (!podPlayed && this.inAdBreak && epoch === this.timing.adBreakEpoch) {
|
|
9237
|
+
this.setSlotState("NEEDS_NEXT_AD", "initial_request_failed");
|
|
9238
|
+
this.requestNextAd("initial_request_failed");
|
|
8920
9239
|
}
|
|
8921
|
-
this.continuousFetchingActive = true;
|
|
8922
|
-
this.startContinuousFetching(baseVastUrl);
|
|
8923
|
-
return [
|
|
8924
|
-
4,
|
|
8925
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
8926
|
-
];
|
|
8927
|
-
case 2:
|
|
8928
|
-
_state.sent();
|
|
8929
|
-
_state.label = 3;
|
|
8930
|
-
case 3:
|
|
8931
9240
|
return [
|
|
8932
9241
|
2
|
|
8933
9242
|
];
|
|
@@ -8943,10 +9252,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8943
9252
|
// ───────────────────────────────────────────────────────────────
|
|
8944
9253
|
function startOptimizedPod(baseVastUrl, breakDurationMs) {
|
|
8945
9254
|
return _async_to_generator(function() {
|
|
8946
|
-
var podUrl, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
9255
|
+
var podUrl, prefetched, epoch, generation, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
8947
9256
|
return _ts_generator(this, function(_state) {
|
|
8948
9257
|
switch(_state.label){
|
|
8949
9258
|
case 0:
|
|
9259
|
+
prefetched = !!(this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0);
|
|
8950
9260
|
if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
|
|
8951
9261
|
podUrl = this.pendingAdBreak.vastUrls[0];
|
|
8952
9262
|
this.clearPendingAdBreak();
|
|
@@ -8959,12 +9269,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8959
9269
|
false
|
|
8960
9270
|
];
|
|
8961
9271
|
}
|
|
8962
|
-
this.
|
|
8963
|
-
this.
|
|
9272
|
+
this.noteVastUrlGenerated(podUrl, prefetched ? "prefetch" : "break_start");
|
|
9273
|
+
epoch = this.timing.adBreakEpoch;
|
|
9274
|
+
this.recreateAdController("new_request");
|
|
9275
|
+
generation = this.controllerGeneration;
|
|
8964
9276
|
adPlayer = this.host.getAdPlayer();
|
|
8965
9277
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8966
9278
|
this.timing.activeAdRequestToken = requestToken;
|
|
8967
9279
|
this.currentVastUrl = podUrl;
|
|
9280
|
+
this.setSlotState("REQUESTING", "initial_pod");
|
|
9281
|
+
this.beginFunnelRequest(adPlayer, requestToken, "initial_pod");
|
|
8968
9282
|
_state.label = 1;
|
|
8969
9283
|
case 1:
|
|
8970
9284
|
_state.trys.push([
|
|
@@ -8979,9 +9293,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8979
9293
|
];
|
|
8980
9294
|
case 2:
|
|
8981
9295
|
_state.sent();
|
|
9296
|
+
if (this.isStale(epoch, generation)) return [
|
|
9297
|
+
2,
|
|
9298
|
+
true
|
|
9299
|
+
];
|
|
8982
9300
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
8983
|
-
this.timing.noteAdRequestSent();
|
|
8984
|
-
this.beginFunnelRequest(adPlayer, requestToken);
|
|
8985
9301
|
return [
|
|
8986
9302
|
4,
|
|
8987
9303
|
this.callController(function() {
|
|
@@ -8991,7 +9307,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8991
9307
|
case 3:
|
|
8992
9308
|
_state.sent();
|
|
8993
9309
|
this.timing.clearAdRequestWatchdog();
|
|
8994
|
-
if (this.
|
|
9310
|
+
if (this.isStale(epoch, generation)) {
|
|
9311
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9312
|
+
requestId: requestToken
|
|
9313
|
+
});
|
|
8995
9314
|
return [
|
|
8996
9315
|
2,
|
|
8997
9316
|
true
|
|
@@ -8999,11 +9318,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8999
9318
|
}
|
|
9000
9319
|
podCount = (_ref = (_adPlayer_getPodAdCount = adPlayer.getPodAdCount) === null || _adPlayer_getPodAdCount === void 0 ? void 0 : _adPlayer_getPodAdCount.call(adPlayer)) !== null && _ref !== void 0 ? _ref : 1;
|
|
9001
9320
|
if (podCount < 1) {
|
|
9321
|
+
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9322
|
+
this.timing.activeAdRequestToken = null;
|
|
9323
|
+
}
|
|
9324
|
+
this.recordRequestFailure(new Error("No ads available"), podUrl);
|
|
9002
9325
|
return [
|
|
9003
9326
|
2,
|
|
9004
9327
|
false
|
|
9005
9328
|
];
|
|
9006
9329
|
}
|
|
9330
|
+
this.setSlotState("READY", "vast_ready");
|
|
9007
9331
|
if (this.debug) {
|
|
9008
9332
|
console.log(podCount === 1 ? "[POD] Response contained a single ad; playing it and enabling pod top-up" : "[POD] Optimized pod returned ".concat(podCount, " ads; playing pod in one controller"));
|
|
9009
9333
|
}
|
|
@@ -9021,12 +9345,14 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9021
9345
|
];
|
|
9022
9346
|
case 4:
|
|
9023
9347
|
_state.sent();
|
|
9348
|
+
if (this.isStale(epoch, generation)) return [
|
|
9349
|
+
2,
|
|
9350
|
+
true
|
|
9351
|
+
];
|
|
9024
9352
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
9025
9353
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
9026
9354
|
}
|
|
9027
9355
|
adPlayer.setAdVolume(getAdAudioVolume(adPlayer));
|
|
9028
|
-
this.continuousFetchingActive = true;
|
|
9029
|
-
this.startContinuousFetching(baseVastUrl);
|
|
9030
9356
|
return [
|
|
9031
9357
|
2,
|
|
9032
9358
|
true
|
|
@@ -9038,14 +9364,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9038
9364
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9039
9365
|
this.timing.activeAdRequestToken = null;
|
|
9040
9366
|
}
|
|
9367
|
+
if (this.isStale(epoch, generation)) {
|
|
9368
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9369
|
+
requestId: requestToken,
|
|
9370
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
9371
|
+
});
|
|
9372
|
+
return [
|
|
9373
|
+
2,
|
|
9374
|
+
true
|
|
9375
|
+
];
|
|
9376
|
+
}
|
|
9041
9377
|
if (this.debug) {
|
|
9042
9378
|
console.warn("[POD] Optimized pod request/play failed:", error);
|
|
9043
9379
|
}
|
|
9044
|
-
|
|
9045
|
-
this.timing.temporaryFailureUrls.set(podUrl, Date.now());
|
|
9046
|
-
}
|
|
9047
|
-
this.continuousFetchingActive = true;
|
|
9048
|
-
this.recreateAdController();
|
|
9380
|
+
this.recordRequestFailure(error, podUrl);
|
|
9049
9381
|
return [
|
|
9050
9382
|
2,
|
|
9051
9383
|
false
|
|
@@ -9061,168 +9393,204 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9061
9393
|
},
|
|
9062
9394
|
{
|
|
9063
9395
|
// ───────────────────────────────────────────────────────────────
|
|
9064
|
-
//
|
|
9396
|
+
// Next-ad scheduling (single flight)
|
|
9065
9397
|
// ───────────────────────────────────────────────────────────────
|
|
9066
|
-
key: "
|
|
9067
|
-
value: function
|
|
9068
|
-
if (
|
|
9398
|
+
key: "setSlotState",
|
|
9399
|
+
value: function setSlotState(next, reason) {
|
|
9400
|
+
if (this.slotState === next) return;
|
|
9401
|
+
var previous = this.slotState;
|
|
9402
|
+
this.slotState = next;
|
|
9403
|
+
if (this.debug) {
|
|
9404
|
+
console.log("[AdBreak][STATE] ".concat(previous, " -> ").concat(next), {
|
|
9405
|
+
reason: reason,
|
|
9406
|
+
breakId: this.timing.adBreakEpoch,
|
|
9407
|
+
requestId: this.currentRequestId,
|
|
9408
|
+
controllerId: this.controllerGeneration
|
|
9409
|
+
});
|
|
9410
|
+
}
|
|
9411
|
+
}
|
|
9412
|
+
},
|
|
9413
|
+
{
|
|
9414
|
+
key: "isStale",
|
|
9415
|
+
value: function isStale(epoch, generation) {
|
|
9416
|
+
return !this.inAdBreak || epoch !== this.timing.adBreakEpoch || generation !== this.controllerGeneration;
|
|
9417
|
+
}
|
|
9418
|
+
},
|
|
9419
|
+
{
|
|
9420
|
+
key: "getMinRemainingMsToRequestAd",
|
|
9421
|
+
value: function getMinRemainingMsToRequestAd() {
|
|
9422
|
+
var configured = this.host.config.minRemainingMsToRequestAd;
|
|
9423
|
+
var floor = this.timing.getMinRemainingMsToStartAd();
|
|
9424
|
+
if (typeof configured === "number" && configured >= 0) {
|
|
9425
|
+
return Math.max(configured, floor);
|
|
9426
|
+
}
|
|
9427
|
+
return Math.max(this.defaultMinRemainingMsToRequestAd, floor);
|
|
9428
|
+
}
|
|
9429
|
+
},
|
|
9430
|
+
{
|
|
9431
|
+
key: "getMaxNoFillsPerBreak",
|
|
9432
|
+
value: function getMaxNoFillsPerBreak() {
|
|
9433
|
+
var configured = this.host.config.maxNoFillsPerBreak;
|
|
9434
|
+
return typeof configured === "number" && configured > 0 ? configured : this.defaultMaxNoFillsPerBreak;
|
|
9435
|
+
}
|
|
9436
|
+
},
|
|
9437
|
+
{
|
|
9438
|
+
key: "isBreakTimeBounded",
|
|
9439
|
+
value: function isBreakTimeBounded() {
|
|
9440
|
+
return this.breakSource === "scte35" || this.timing.expectedAdBreakDurationMs != null;
|
|
9441
|
+
}
|
|
9442
|
+
},
|
|
9443
|
+
{
|
|
9444
|
+
key: "getStopRequestingReason",
|
|
9445
|
+
value: function getStopRequestingReason(remainingMs) {
|
|
9446
|
+
if (this.breakSource === "vmap") {
|
|
9447
|
+
if (this.adPodQueue.length === 0) return "vmap_queue_empty";
|
|
9448
|
+
} else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl) {
|
|
9449
|
+
return "no_follow_up_source";
|
|
9450
|
+
}
|
|
9451
|
+
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9452
|
+
return "max_consecutive_failures";
|
|
9453
|
+
}
|
|
9454
|
+
if (this.unusableResponsesInBreak >= this.getMaxNoFillsPerBreak()) {
|
|
9455
|
+
return "unusable_response_limit";
|
|
9456
|
+
}
|
|
9457
|
+
if (this.timing.totalAdRequestsInBreak >= this.timing.maxTotalAdRequestsPerBreak) {
|
|
9458
|
+
return "request_cap";
|
|
9459
|
+
}
|
|
9460
|
+
if (this.timing.isGamInCooldown()) {
|
|
9461
|
+
return "gam_cooldown";
|
|
9462
|
+
}
|
|
9463
|
+
if (this.isBreakTimeBounded() && remainingMs < this.getMinRemainingMsToRequestAd()) {
|
|
9464
|
+
return "insufficient_break_time";
|
|
9465
|
+
}
|
|
9466
|
+
return void 0;
|
|
9467
|
+
}
|
|
9468
|
+
},
|
|
9469
|
+
{
|
|
9470
|
+
key: "getNextRequestDelayMs",
|
|
9471
|
+
value: function getNextRequestDelayMs() {
|
|
9472
|
+
var failures = this.timing.consecutiveFailures;
|
|
9473
|
+
var backoff = failures > 0 ? Math.min(this.timing.backoffBaseMs * Math.pow(2, failures), this.timing.maxBackoffMs) : 0;
|
|
9474
|
+
var minInterval = this.timing.minAdRequestIntervalMs + backoff;
|
|
9475
|
+
var sinceLast = Date.now() - this.timing.lastAdRequestTime;
|
|
9476
|
+
return Math.max(0, minInterval - sinceLast);
|
|
9477
|
+
}
|
|
9478
|
+
},
|
|
9479
|
+
{
|
|
9480
|
+
key: "requestNextAd",
|
|
9481
|
+
value: function requestNextAd(trigger) {
|
|
9482
|
+
var _this = this;
|
|
9483
|
+
if (!this.inAdBreak) return;
|
|
9484
|
+
if (this.slotState !== "NEEDS_NEXT_AD") {
|
|
9485
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9486
|
+
trigger: trigger,
|
|
9487
|
+
state: this.slotState,
|
|
9488
|
+
why: "slot_busy"
|
|
9489
|
+
});
|
|
9069
9490
|
return;
|
|
9070
9491
|
}
|
|
9071
|
-
if (this.
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9492
|
+
if (this.nextAdTimerId != null) {
|
|
9493
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9494
|
+
trigger: trigger,
|
|
9495
|
+
state: this.slotState,
|
|
9496
|
+
why: "request_already_scheduled"
|
|
9497
|
+
});
|
|
9075
9498
|
return;
|
|
9076
9499
|
}
|
|
9077
|
-
|
|
9078
|
-
|
|
9500
|
+
var remainingMs = this.timing.getRemainingAdMs();
|
|
9501
|
+
var stopReason = this.getStopRequestingReason(remainingMs);
|
|
9502
|
+
if (stopReason) {
|
|
9503
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9504
|
+
trigger: trigger,
|
|
9505
|
+
decision: "end_break",
|
|
9506
|
+
reason: stopReason,
|
|
9507
|
+
remainingMs: remainingMs,
|
|
9508
|
+
requestsSent: this.timing.totalAdRequestsInBreak,
|
|
9509
|
+
unusableResponses: this.unusableResponsesInBreak,
|
|
9510
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
9511
|
+
});
|
|
9512
|
+
this.handleAdPodComplete(stopReason);
|
|
9513
|
+
return;
|
|
9079
9514
|
}
|
|
9080
|
-
|
|
9081
|
-
this.
|
|
9515
|
+
var waitMs = this.getNextRequestDelayMs();
|
|
9516
|
+
if (waitMs > 0 && this.isBreakTimeBounded() && remainingMs - waitMs < this.getMinRemainingMsToRequestAd()) {
|
|
9517
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9518
|
+
trigger: trigger,
|
|
9519
|
+
decision: "end_break",
|
|
9520
|
+
reason: "insufficient_break_time_after_backoff",
|
|
9521
|
+
remainingMs: remainingMs,
|
|
9522
|
+
waitMs: waitMs
|
|
9523
|
+
});
|
|
9524
|
+
this.handleAdPodComplete("insufficient_break_time_after_backoff");
|
|
9525
|
+
return;
|
|
9526
|
+
}
|
|
9527
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9528
|
+
trigger: trigger,
|
|
9529
|
+
decision: waitMs > 0 ? "request_after_delay" : "request_now",
|
|
9530
|
+
waitMs: waitMs,
|
|
9531
|
+
remainingMs: remainingMs,
|
|
9532
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
9533
|
+
});
|
|
9534
|
+
if (waitMs > 0) {
|
|
9535
|
+
if (!this.isShowingPlaceholder) {
|
|
9536
|
+
this.isShowingPlaceholder = true;
|
|
9537
|
+
this.host.getAdPlayer().showPlaceholder();
|
|
9538
|
+
}
|
|
9539
|
+
var epoch = this.timing.adBreakEpoch;
|
|
9540
|
+
this.nextAdTimerId = window.setTimeout(function() {
|
|
9541
|
+
_this.nextAdTimerId = void 0;
|
|
9542
|
+
if (!_this.inAdBreak || epoch !== _this.timing.adBreakEpoch) return;
|
|
9543
|
+
_this.requestNextAd("".concat(trigger, ":after_delay"));
|
|
9544
|
+
}, waitMs);
|
|
9545
|
+
return;
|
|
9546
|
+
}
|
|
9547
|
+
void this.requestFollowUpAd(trigger);
|
|
9082
9548
|
}
|
|
9083
9549
|
},
|
|
9084
9550
|
{
|
|
9085
|
-
key: "
|
|
9086
|
-
value: function
|
|
9551
|
+
key: "requestFollowUpAd",
|
|
9552
|
+
value: function requestFollowUpAd(trigger) {
|
|
9087
9553
|
return _async_to_generator(function() {
|
|
9088
|
-
var
|
|
9554
|
+
var url, epoch, unused;
|
|
9089
9555
|
return _ts_generator(this, function(_state) {
|
|
9090
9556
|
switch(_state.label){
|
|
9091
9557
|
case 0:
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
}
|
|
9102
|
-
return [
|
|
9103
|
-
2,
|
|
9104
|
-
"break"
|
|
9105
|
-
];
|
|
9106
|
-
}
|
|
9107
|
-
if (_this.timing.isGamInCooldown()) {
|
|
9108
|
-
if (_this.debug) {
|
|
9109
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping URL generation");
|
|
9110
|
-
}
|
|
9111
|
-
return [
|
|
9112
|
-
2,
|
|
9113
|
-
"break"
|
|
9114
|
-
];
|
|
9115
|
-
}
|
|
9116
|
-
if (_this.timing.consecutiveFailures >= _this.timing.maxConsecutiveFailures) {
|
|
9117
|
-
if (_this.debug) {
|
|
9118
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(_this.timing.consecutiveFailures, "), stopping URL generation"));
|
|
9119
|
-
}
|
|
9120
|
-
return [
|
|
9121
|
-
2,
|
|
9122
|
-
"break"
|
|
9123
|
-
];
|
|
9124
|
-
}
|
|
9125
|
-
if (_this.timing.totalAdRequestsInBreak >= _this.timing.maxTotalAdRequestsPerBreak) {
|
|
9126
|
-
if (_this.debug) {
|
|
9127
|
-
console.log("[CONTINUOUS-FETCH] Maximum ad requests reached (".concat(_this.timing.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
9128
|
-
}
|
|
9129
|
-
return [
|
|
9130
|
-
2,
|
|
9131
|
-
"break"
|
|
9132
|
-
];
|
|
9133
|
-
}
|
|
9134
|
-
maxQueueSize = 5;
|
|
9135
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
9136
|
-
3,
|
|
9137
|
-
2
|
|
9138
|
-
];
|
|
9139
|
-
if (_this.debug) {
|
|
9140
|
-
console.log("[CONTINUOUS-FETCH] URL queue full (".concat(_this.adRequestQueue.length, "), waiting..."));
|
|
9141
|
-
}
|
|
9142
|
-
return [
|
|
9143
|
-
4,
|
|
9144
|
-
new Promise(function(resolve) {
|
|
9145
|
-
return setTimeout(resolve, 1e3);
|
|
9146
|
-
})
|
|
9147
|
-
];
|
|
9148
|
-
case 1:
|
|
9149
|
-
_state.sent();
|
|
9150
|
-
return [
|
|
9151
|
-
2,
|
|
9152
|
-
"continue"
|
|
9153
|
-
];
|
|
9154
|
-
case 2:
|
|
9155
|
-
newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
|
|
9156
|
-
if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
|
|
9157
|
-
3,
|
|
9158
|
-
4
|
|
9159
|
-
];
|
|
9160
|
-
return [
|
|
9161
|
-
4,
|
|
9162
|
-
new Promise(function(resolve) {
|
|
9163
|
-
return setTimeout(resolve, 500);
|
|
9164
|
-
})
|
|
9165
|
-
];
|
|
9166
|
-
case 3:
|
|
9167
|
-
_state.sent();
|
|
9168
|
-
return [
|
|
9169
|
-
2,
|
|
9170
|
-
"continue"
|
|
9171
|
-
];
|
|
9172
|
-
case 4:
|
|
9173
|
-
if (_this.debug) {
|
|
9174
|
-
queuedUrlsPreview = _to_consumable_array(_this.adRequestQueue).concat([
|
|
9175
|
-
newAdUrl
|
|
9176
|
-
]);
|
|
9177
|
-
console.log("[CONTINUOUS-FETCH] Queued VAST URL (queue size: ".concat(queuedUrlsPreview.length, ")"), {
|
|
9178
|
-
queuedUrls: queuedUrlsPreview
|
|
9179
|
-
});
|
|
9180
|
-
}
|
|
9181
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
9182
|
-
generationDelay = _this.timing.consecutiveFailures > 0 ? Math.min(1e3 * Math.pow(2, _this.timing.consecutiveFailures), 5e3) : 500;
|
|
9183
|
-
return [
|
|
9184
|
-
4,
|
|
9185
|
-
new Promise(function(resolve) {
|
|
9186
|
-
return setTimeout(resolve, generationDelay);
|
|
9187
|
-
})
|
|
9188
|
-
];
|
|
9189
|
-
case 5:
|
|
9190
|
-
_state.sent();
|
|
9191
|
-
return [
|
|
9192
|
-
2
|
|
9193
|
-
];
|
|
9194
|
-
}
|
|
9195
|
-
});
|
|
9196
|
-
};
|
|
9558
|
+
if (this.breakSource === "vmap") {
|
|
9559
|
+
url = this.adPodQueue.shift();
|
|
9560
|
+
} else if (this.followUpBaseVastUrl) {
|
|
9561
|
+
url = this.nextAdRequestUrl(this.followUpBaseVastUrl);
|
|
9562
|
+
}
|
|
9563
|
+
if (!url) return [
|
|
9564
|
+
2
|
|
9565
|
+
];
|
|
9566
|
+
this.noteVastUrlGenerated(ensureVideoAdType(url), trigger);
|
|
9197
9567
|
epoch = this.timing.adBreakEpoch;
|
|
9198
9568
|
_state.label = 1;
|
|
9199
9569
|
case 1:
|
|
9200
|
-
|
|
9570
|
+
_state.trys.push([
|
|
9571
|
+
1,
|
|
9201
9572
|
3,
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
return [
|
|
9206
|
-
|
|
9207
|
-
|
|
9573
|
+
,
|
|
9574
|
+
4
|
|
9575
|
+
]);
|
|
9576
|
+
return [
|
|
9577
|
+
4,
|
|
9578
|
+
this.playSingleAd(url, trigger)
|
|
9208
9579
|
];
|
|
9209
9580
|
case 2:
|
|
9210
|
-
|
|
9211
|
-
|
|
9581
|
+
_state.sent();
|
|
9582
|
+
return [
|
|
9212
9583
|
3,
|
|
9213
|
-
|
|
9584
|
+
4
|
|
9214
9585
|
];
|
|
9586
|
+
case 3:
|
|
9587
|
+
unused = _state.sent();
|
|
9588
|
+
this.continueAfterRequestFailure(epoch);
|
|
9215
9589
|
return [
|
|
9216
9590
|
3,
|
|
9217
|
-
|
|
9591
|
+
4
|
|
9218
9592
|
];
|
|
9219
|
-
case
|
|
9220
|
-
this.continuousFetchLoopRunning = false;
|
|
9221
|
-
if (this.debug) {
|
|
9222
|
-
console.log("[CONTINUOUS-FETCH] URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"), this.adRequestQueue.length > 0 ? {
|
|
9223
|
-
queuedUrls: _to_consumable_array(this.adRequestQueue)
|
|
9224
|
-
} : {});
|
|
9225
|
-
}
|
|
9593
|
+
case 4:
|
|
9226
9594
|
return [
|
|
9227
9595
|
2
|
|
9228
9596
|
];
|
|
@@ -9232,242 +9600,158 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9232
9600
|
}
|
|
9233
9601
|
},
|
|
9234
9602
|
{
|
|
9235
|
-
key: "
|
|
9236
|
-
value: function
|
|
9237
|
-
|
|
9238
|
-
this.
|
|
9239
|
-
this.
|
|
9240
|
-
|
|
9241
|
-
|
|
9603
|
+
key: "continueAfterRequestFailure",
|
|
9604
|
+
value: function continueAfterRequestFailure() {
|
|
9605
|
+
var epoch = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.timing.adBreakEpoch;
|
|
9606
|
+
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) return;
|
|
9607
|
+
this.setSlotState("NEEDS_NEXT_AD", "request_failed");
|
|
9608
|
+
this.requestNextAd("after_failure");
|
|
9609
|
+
}
|
|
9610
|
+
},
|
|
9611
|
+
{
|
|
9612
|
+
key: "cancelScheduledRequest",
|
|
9613
|
+
value: function cancelScheduledRequest() {
|
|
9614
|
+
if (this.nextAdTimerId != null) {
|
|
9615
|
+
clearTimeout(this.nextAdTimerId);
|
|
9616
|
+
this.nextAdTimerId = void 0;
|
|
9242
9617
|
}
|
|
9243
9618
|
}
|
|
9244
9619
|
},
|
|
9245
9620
|
{
|
|
9246
|
-
key: "
|
|
9247
|
-
value:
|
|
9248
|
-
|
|
9621
|
+
key: "noteVastUrlGenerated",
|
|
9622
|
+
value: function noteVastUrlGenerated(url, source) {
|
|
9623
|
+
var _ref, _ref1, _ref2, _ref3, _ref4;
|
|
9624
|
+
var params;
|
|
9625
|
+
try {
|
|
9626
|
+
params = new URL(url).searchParams;
|
|
9627
|
+
} catch (unused) {}
|
|
9628
|
+
var adType = (_ref = params === null || params === void 0 ? void 0 : params.get("ad_type")) !== null && _ref !== void 0 ? _ref : void 0;
|
|
9629
|
+
this.logOrchestratorFunnel("vast_url_generated", {
|
|
9630
|
+
source: source,
|
|
9631
|
+
pod: (_ref1 = params === null || params === void 0 ? void 0 : params.get("pod")) !== null && _ref1 !== void 0 ? _ref1 : void 0,
|
|
9632
|
+
pmad: (_ref2 = params === null || params === void 0 ? void 0 : params.get("pmad")) !== null && _ref2 !== void 0 ? _ref2 : void 0,
|
|
9633
|
+
pmnd: (_ref3 = params === null || params === void 0 ? void 0 : params.get("pmnd")) !== null && _ref3 !== void 0 ? _ref3 : void 0,
|
|
9634
|
+
pmxd: (_ref4 = params === null || params === void 0 ? void 0 : params.get("pmxd")) !== null && _ref4 !== void 0 ? _ref4 : void 0,
|
|
9635
|
+
adType: adType
|
|
9636
|
+
});
|
|
9637
|
+
if (adType === "audio" || adType === "audio_video") {
|
|
9638
|
+
console.warn("[AdBreak] VAST tag requests ad_type=".concat(adType, "; GAM may return audio-only creatives, which this video player rejects"));
|
|
9639
|
+
this.countFunnelStage("tag_allows_audio");
|
|
9640
|
+
}
|
|
9641
|
+
}
|
|
9642
|
+
},
|
|
9643
|
+
{
|
|
9644
|
+
key: "recordRequestFailure",
|
|
9645
|
+
value: function recordRequestFailure(error, vastTagUrl) {
|
|
9646
|
+
var _diag_vastAdCount;
|
|
9647
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
9648
|
+
var message = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
9649
|
+
var outcome;
|
|
9650
|
+
if (message.includes("ad_duration_exceeds_budget")) {
|
|
9651
|
+
outcome = "discarded_budget";
|
|
9652
|
+
} else if (message.includes("VAST fill rejected")) {
|
|
9653
|
+
outcome = "fill_rejected";
|
|
9654
|
+
} else if (/no ads available|no fill|nofill/i.test(message)) {
|
|
9655
|
+
outcome = "no_fill";
|
|
9656
|
+
} else if (/timeout/i.test(message)) {
|
|
9657
|
+
outcome = "request_timeout";
|
|
9658
|
+
} else if (/destroyed|aborted/i.test(message)) {
|
|
9659
|
+
outcome = "request_aborted";
|
|
9660
|
+
} else if (diag && ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired) {
|
|
9661
|
+
outcome = "playback_failed";
|
|
9662
|
+
} else {
|
|
9663
|
+
outcome = "request_failed";
|
|
9664
|
+
}
|
|
9665
|
+
this.timing.consecutiveFailures++;
|
|
9666
|
+
if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
|
|
9667
|
+
this.unusableResponsesInBreak++;
|
|
9668
|
+
}
|
|
9669
|
+
if (outcome === "no_fill") {
|
|
9670
|
+
this.timing.recordGamNoFill();
|
|
9671
|
+
}
|
|
9672
|
+
if (diag && !diag.failureReason) {
|
|
9673
|
+
diag.failureReason = "".concat(outcome, ": ").concat(message);
|
|
9674
|
+
}
|
|
9675
|
+
if (this.timing.isTemporaryAdError(error)) {
|
|
9676
|
+
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9677
|
+
} else if (outcome !== "discarded_budget") {
|
|
9678
|
+
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9679
|
+
}
|
|
9680
|
+
this.countFunnelStage("request_outcome:".concat(outcome));
|
|
9681
|
+
this.logOrchestratorFunnel("request_outcome", {
|
|
9682
|
+
outcome: outcome,
|
|
9683
|
+
errorMessage: message,
|
|
9684
|
+
consecutiveFailures: this.timing.consecutiveFailures,
|
|
9685
|
+
unusableResponsesInBreak: this.unusableResponsesInBreak
|
|
9686
|
+
});
|
|
9687
|
+
}
|
|
9688
|
+
},
|
|
9689
|
+
{
|
|
9249
9690
|
// ───────────────────────────────────────────────────────────────
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
|
|
9259
|
-
|
|
9260
|
-
|
|
9261
|
-
|
|
9262
|
-
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
|
|
9267
|
-
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
backoffDelay = Math.min(this.timing.backoffBaseMs * backoffMultiplier, this.timing.maxBackoffMs);
|
|
9273
|
-
effectiveMinInterval = this.timing.minAdRequestIntervalMs + (this.timing.consecutiveFailures > 0 ? backoffDelay : 0);
|
|
9274
|
-
timeSinceLastRequest = Date.now() - this.timing.lastAdRequestTime;
|
|
9275
|
-
if (!(timeSinceLastRequest < effectiveMinInterval)) return [
|
|
9276
|
-
3,
|
|
9277
|
-
2
|
|
9278
|
-
];
|
|
9279
|
-
waitTime = effectiveMinInterval - timeSinceLastRequest;
|
|
9280
|
-
if (this.debug) {
|
|
9281
|
-
console.log("[CONTINUOUS-FETCH] Rate limiting: waiting ".concat(waitTime, "ms before next request (backoff: ").concat(this.timing.consecutiveFailures, " failures)"));
|
|
9282
|
-
}
|
|
9283
|
-
return [
|
|
9284
|
-
4,
|
|
9285
|
-
new Promise(function(resolve) {
|
|
9286
|
-
return setTimeout(resolve, waitTime);
|
|
9287
|
-
})
|
|
9288
|
-
];
|
|
9289
|
-
case 1:
|
|
9290
|
-
_state.sent();
|
|
9291
|
-
_state.label = 2;
|
|
9292
|
-
case 2:
|
|
9293
|
-
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) {
|
|
9294
|
-
return [
|
|
9295
|
-
2
|
|
9296
|
-
];
|
|
9297
|
-
}
|
|
9298
|
-
return [
|
|
9299
|
-
2,
|
|
9300
|
-
this.tryNextAvailableAd(0)
|
|
9301
|
-
];
|
|
9691
|
+
// Per-request diagnostics
|
|
9692
|
+
// ───────────────────────────────────────────────────────────────
|
|
9693
|
+
key: "recordRequestDiagnostic",
|
|
9694
|
+
value: function recordRequestDiagnostic(payload) {
|
|
9695
|
+
var requestId = payload.requestId;
|
|
9696
|
+
if (typeof requestId !== "number") return;
|
|
9697
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
9698
|
+
if (!diag) return;
|
|
9699
|
+
switch(payload.stage){
|
|
9700
|
+
case "gam_http_request_sent":
|
|
9701
|
+
diag.gamRequestSent++;
|
|
9702
|
+
break;
|
|
9703
|
+
case "gam_response_received":
|
|
9704
|
+
diag.vastHttpStatus = payload.httpStatus;
|
|
9705
|
+
break;
|
|
9706
|
+
case "vast_parsed":
|
|
9707
|
+
diag.vastAdCount = payload.adElementCount;
|
|
9708
|
+
break;
|
|
9709
|
+
case "wrapper_fetch":
|
|
9710
|
+
case "inline_resolved":
|
|
9711
|
+
if (typeof payload.depth === "number") {
|
|
9712
|
+
diag.wrapperDepth = Math.max(diag.wrapperDepth, payload.depth);
|
|
9302
9713
|
}
|
|
9303
|
-
|
|
9304
|
-
|
|
9714
|
+
if (payload.stage === "inline_resolved") diag.inlineResolved = true;
|
|
9715
|
+
break;
|
|
9716
|
+
case "mediafile_evaluated":
|
|
9717
|
+
diag.mediaCandidateCount++;
|
|
9718
|
+
if (payload.whyAccepted) diag.supportedMediaCount++;
|
|
9719
|
+
break;
|
|
9720
|
+
case "playing":
|
|
9721
|
+
diag.playStarted = true;
|
|
9722
|
+
break;
|
|
9723
|
+
case "impression_fired":
|
|
9724
|
+
diag.impressionFired = true;
|
|
9725
|
+
break;
|
|
9726
|
+
default:
|
|
9727
|
+
if (REQUEST_FAILURE_STAGES.has(payload.stage) && !diag.failureReason) {
|
|
9728
|
+
diag.failureReason = payload.reason ? "".concat(payload.stage, ":").concat(payload.reason) : payload.stage;
|
|
9729
|
+
}
|
|
9730
|
+
}
|
|
9305
9731
|
}
|
|
9306
9732
|
},
|
|
9307
9733
|
{
|
|
9308
|
-
key: "
|
|
9309
|
-
value: function
|
|
9310
|
-
var
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9320
|
-
|
|
9321
|
-
|
|
9322
|
-
|
|
9323
|
-
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
];
|
|
9330
|
-
}
|
|
9331
|
-
if (this.timing.isGamInCooldown()) {
|
|
9332
|
-
if (this.debug) {
|
|
9333
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, ending ad break gracefully");
|
|
9334
|
-
}
|
|
9335
|
-
this.handleAdPodComplete();
|
|
9336
|
-
return [
|
|
9337
|
-
2
|
|
9338
|
-
];
|
|
9339
|
-
}
|
|
9340
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9341
|
-
if (this.debug) {
|
|
9342
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(this.timing.consecutiveFailures, "), ending ad break"));
|
|
9343
|
-
}
|
|
9344
|
-
this.handleAdPodComplete();
|
|
9345
|
-
return [
|
|
9346
|
-
2
|
|
9347
|
-
];
|
|
9348
|
-
}
|
|
9349
|
-
this.timing.cleanupTemporaryFailures();
|
|
9350
|
-
_state.label = 1;
|
|
9351
|
-
case 1:
|
|
9352
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
9353
|
-
3,
|
|
9354
|
-
9
|
|
9355
|
-
];
|
|
9356
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
9357
|
-
if (!nextAdUrl) return [
|
|
9358
|
-
3,
|
|
9359
|
-
1
|
|
9360
|
-
];
|
|
9361
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) {
|
|
9362
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
|
|
9363
|
-
return [
|
|
9364
|
-
3,
|
|
9365
|
-
1
|
|
9366
|
-
];
|
|
9367
|
-
}
|
|
9368
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) {
|
|
9369
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
|
|
9370
|
-
return [
|
|
9371
|
-
3,
|
|
9372
|
-
1
|
|
9373
|
-
];
|
|
9374
|
-
}
|
|
9375
|
-
if (this.debug) {
|
|
9376
|
-
console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
|
|
9377
|
-
}
|
|
9378
|
-
_state.label = 2;
|
|
9379
|
-
case 2:
|
|
9380
|
-
_state.trys.push([
|
|
9381
|
-
2,
|
|
9382
|
-
4,
|
|
9383
|
-
,
|
|
9384
|
-
8
|
|
9385
|
-
]);
|
|
9386
|
-
return [
|
|
9387
|
-
4,
|
|
9388
|
-
this.playSingleAd(nextAdUrl)
|
|
9389
|
-
];
|
|
9390
|
-
case 3:
|
|
9391
|
-
_state.sent();
|
|
9392
|
-
return [
|
|
9393
|
-
3,
|
|
9394
|
-
8
|
|
9395
|
-
];
|
|
9396
|
-
case 4:
|
|
9397
|
-
error = _state.sent();
|
|
9398
|
-
errorMessage = error.message;
|
|
9399
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
|
|
9400
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
9401
|
-
3,
|
|
9402
|
-
6
|
|
9403
|
-
];
|
|
9404
|
-
this.timing.consecutiveFailures++;
|
|
9405
|
-
return [
|
|
9406
|
-
4,
|
|
9407
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9408
|
-
];
|
|
9409
|
-
case 5:
|
|
9410
|
-
_state.sent();
|
|
9411
|
-
return [
|
|
9412
|
-
2
|
|
9413
|
-
];
|
|
9414
|
-
case 6:
|
|
9415
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
9416
|
-
this.timing.consecutiveFailures++;
|
|
9417
|
-
}
|
|
9418
|
-
return [
|
|
9419
|
-
4,
|
|
9420
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9421
|
-
];
|
|
9422
|
-
case 7:
|
|
9423
|
-
_state.sent();
|
|
9424
|
-
return [
|
|
9425
|
-
3,
|
|
9426
|
-
8
|
|
9427
|
-
];
|
|
9428
|
-
case 8:
|
|
9429
|
-
return [
|
|
9430
|
-
2
|
|
9431
|
-
];
|
|
9432
|
-
case 9:
|
|
9433
|
-
maxRetries = 3;
|
|
9434
|
-
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
9435
|
-
3,
|
|
9436
|
-
12
|
|
9437
|
-
];
|
|
9438
|
-
if (this.debug) {
|
|
9439
|
-
console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
9440
|
-
}
|
|
9441
|
-
return [
|
|
9442
|
-
4,
|
|
9443
|
-
new Promise(function(resolve) {
|
|
9444
|
-
return setTimeout(resolve, 500);
|
|
9445
|
-
})
|
|
9446
|
-
];
|
|
9447
|
-
case 10:
|
|
9448
|
-
_state.sent();
|
|
9449
|
-
return [
|
|
9450
|
-
4,
|
|
9451
|
-
this.tryNextAvailableAd(retryCount + 1)
|
|
9452
|
-
];
|
|
9453
|
-
case 11:
|
|
9454
|
-
_state.sent();
|
|
9455
|
-
return [
|
|
9456
|
-
2
|
|
9457
|
-
];
|
|
9458
|
-
case 12:
|
|
9459
|
-
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
9460
|
-
this.showPlaceholderAndWaitForAds();
|
|
9461
|
-
} else {
|
|
9462
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] No more ads available, ending ad break");
|
|
9463
|
-
this.handleAdPodComplete();
|
|
9464
|
-
}
|
|
9465
|
-
return [
|
|
9466
|
-
2
|
|
9467
|
-
];
|
|
9468
|
-
}
|
|
9469
|
-
});
|
|
9470
|
-
}).call(this);
|
|
9734
|
+
key: "finalizeRequestDiagnostics",
|
|
9735
|
+
value: function finalizeRequestDiagnostics(requestId, endReason) {
|
|
9736
|
+
var _diag_vastAdCount;
|
|
9737
|
+
if (requestId == null) return;
|
|
9738
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
9739
|
+
if (!diag) return;
|
|
9740
|
+
this.requestDiagnostics.delete(requestId);
|
|
9741
|
+
if (!diag.impressionFired && !diag.failureReason && endReason) {
|
|
9742
|
+
diag.failureReason = endReason;
|
|
9743
|
+
}
|
|
9744
|
+
var gamReturnedAdWithoutImpression = ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired;
|
|
9745
|
+
if (gamReturnedAdWithoutImpression) {
|
|
9746
|
+
this.countFunnelStage("gam_ad_without_impression");
|
|
9747
|
+
}
|
|
9748
|
+
var startedAt = diag.startedAt, fields = _object_without_properties(diag, [
|
|
9749
|
+
"startedAt"
|
|
9750
|
+
]);
|
|
9751
|
+
console.log("[AdBreak][REQUEST] summary", _object_spread_props(_object_spread({}, fields), {
|
|
9752
|
+
durationMs: Date.now() - startedAt,
|
|
9753
|
+
gamReturnedAdWithoutImpression: gamReturnedAdWithoutImpression
|
|
9754
|
+
}));
|
|
9471
9755
|
}
|
|
9472
9756
|
},
|
|
9473
9757
|
{
|
|
@@ -9475,7 +9759,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9475
9759
|
// Single ad playback
|
|
9476
9760
|
// ───────────────────────────────────────────────────────────────
|
|
9477
9761
|
key: "withCurrentPodBudget",
|
|
9478
|
-
value: function withCurrentPodBudget(
|
|
9762
|
+
value: function withCurrentPodBudget(rawVastTagUrl) {
|
|
9763
|
+
var vastTagUrl = ensureVideoAdType(rawVastTagUrl);
|
|
9479
9764
|
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9480
9765
|
if (!(remaining > 0)) return vastTagUrl;
|
|
9481
9766
|
try {
|
|
@@ -9534,18 +9819,34 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9534
9819
|
},
|
|
9535
9820
|
{
|
|
9536
9821
|
key: "beginFunnelRequest",
|
|
9537
|
-
value: function beginFunnelRequest(adPlayer, requestToken) {
|
|
9822
|
+
value: function beginFunnelRequest(adPlayer, requestToken, trigger) {
|
|
9538
9823
|
var _adPlayer_setFunnelContext;
|
|
9539
9824
|
if (this.controllerCallInFlight) {
|
|
9540
9825
|
this.logOrchestratorFunnel("duplicate_request_detected", {
|
|
9541
9826
|
newRequestId: requestToken
|
|
9542
9827
|
});
|
|
9543
9828
|
}
|
|
9829
|
+
this.finalizeRequestDiagnostics(this.currentRequestId);
|
|
9544
9830
|
this.currentRequestId = requestToken;
|
|
9545
9831
|
this.requestStartedAt = Date.now();
|
|
9832
|
+
this.requestDiagnostics.set(requestToken, {
|
|
9833
|
+
breakId: this.timing.adBreakEpoch,
|
|
9834
|
+
requestId: requestToken,
|
|
9835
|
+
controllerId: this.controllerGeneration,
|
|
9836
|
+
trigger: trigger,
|
|
9837
|
+
gamRequestSent: 0,
|
|
9838
|
+
wrapperDepth: 0,
|
|
9839
|
+
inlineResolved: false,
|
|
9840
|
+
mediaCandidateCount: 0,
|
|
9841
|
+
supportedMediaCount: 0,
|
|
9842
|
+
playStarted: false,
|
|
9843
|
+
impressionFired: false,
|
|
9844
|
+
startedAt: Date.now()
|
|
9845
|
+
});
|
|
9546
9846
|
(_adPlayer_setFunnelContext = adPlayer.setFunnelContext) === null || _adPlayer_setFunnelContext === void 0 ? void 0 : _adPlayer_setFunnelContext.call(adPlayer, {
|
|
9547
9847
|
breakId: this.timing.adBreakEpoch,
|
|
9548
|
-
requestId: requestToken
|
|
9848
|
+
requestId: requestToken,
|
|
9849
|
+
controllerId: this.controllerGeneration
|
|
9549
9850
|
});
|
|
9550
9851
|
}
|
|
9551
9852
|
},
|
|
@@ -9576,7 +9877,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9576
9877
|
adPlayer.abortPendingRequest("VAST request aborted after request watchdog timeout");
|
|
9577
9878
|
return;
|
|
9578
9879
|
}
|
|
9579
|
-
this.handleAdFailure();
|
|
9880
|
+
this.handleAdFailure("request_watchdog_timeout");
|
|
9580
9881
|
}
|
|
9581
9882
|
},
|
|
9582
9883
|
{
|
|
@@ -9622,21 +9923,30 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9622
9923
|
{
|
|
9623
9924
|
key: "playSingleAd",
|
|
9624
9925
|
value: function playSingleAd(vastTagUrl) {
|
|
9926
|
+
var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
|
|
9625
9927
|
return _async_to_generator(function() {
|
|
9626
|
-
var
|
|
9928
|
+
var epoch, generation, requestToken, ap, requestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
|
|
9627
9929
|
return _ts_generator(this, function(_state) {
|
|
9628
9930
|
switch(_state.label){
|
|
9629
9931
|
case 0:
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9932
|
+
if (this.slotState === "REQUESTING" || this.slotState === "READY" || this.slotState === "PLAYING" || this.slotState === "ENDING") {
|
|
9933
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9934
|
+
trigger: trigger,
|
|
9935
|
+
state: this.slotState,
|
|
9936
|
+
why: "request_in_flight"
|
|
9937
|
+
});
|
|
9938
|
+
return [
|
|
9939
|
+
2
|
|
9940
|
+
];
|
|
9941
|
+
}
|
|
9634
9942
|
if (this.timing.failedVastUrls.has(vastTagUrl)) {
|
|
9635
9943
|
if (this.debug) console.warn("[AD-ERROR] Skipping permanently-failed VAST URL:", vastTagUrl);
|
|
9944
|
+
this.timing.consecutiveFailures++;
|
|
9636
9945
|
throw new Error("VAST URL permanently failed");
|
|
9637
9946
|
}
|
|
9638
9947
|
if (this.timing.isUrlInCooldown(vastTagUrl)) {
|
|
9639
9948
|
if (this.debug) console.warn("[AD-ERROR] Skipping URL in cooldown (recent no-fill):", vastTagUrl);
|
|
9949
|
+
this.timing.consecutiveFailures++;
|
|
9640
9950
|
throw new Error("VAST URL in cooldown after no-fill");
|
|
9641
9951
|
}
|
|
9642
9952
|
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
@@ -9647,16 +9957,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9647
9957
|
if (this.debug) console.warn("[CIRCUIT-BREAKER] GAM in cooldown, skipping ad request");
|
|
9648
9958
|
throw new Error("GAM in cooldown");
|
|
9649
9959
|
}
|
|
9650
|
-
this.
|
|
9960
|
+
epoch = this.timing.adBreakEpoch;
|
|
9961
|
+
this.recreateAdController("new_request");
|
|
9962
|
+
generation = this.controllerGeneration;
|
|
9651
9963
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
9652
9964
|
this.timing.activeAdRequestToken = requestToken;
|
|
9965
|
+
ap = this.host.getAdPlayer();
|
|
9966
|
+
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9967
|
+
this.currentVastUrl = requestUrl;
|
|
9968
|
+
this.setSlotState("REQUESTING", trigger);
|
|
9969
|
+
this.beginFunnelRequest(ap, requestToken, trigger);
|
|
9653
9970
|
_state.label = 1;
|
|
9654
9971
|
case 1:
|
|
9655
9972
|
_state.trys.push([
|
|
9656
9973
|
1,
|
|
9657
|
-
|
|
9974
|
+
5,
|
|
9658
9975
|
,
|
|
9659
|
-
|
|
9976
|
+
6
|
|
9660
9977
|
]);
|
|
9661
9978
|
return [
|
|
9662
9979
|
4,
|
|
@@ -9664,12 +9981,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9664
9981
|
];
|
|
9665
9982
|
case 2:
|
|
9666
9983
|
_state.sent();
|
|
9984
|
+
if (this.isStale(epoch, generation)) return [
|
|
9985
|
+
2
|
|
9986
|
+
];
|
|
9667
9987
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
9668
|
-
this.timing.noteAdRequestSent();
|
|
9669
|
-
ap = this.host.getAdPlayer();
|
|
9670
|
-
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9671
|
-
this.currentVastUrl = requestUrl;
|
|
9672
|
-
this.beginFunnelRequest(ap, requestToken);
|
|
9673
9988
|
return [
|
|
9674
9989
|
4,
|
|
9675
9990
|
this.callController(function() {
|
|
@@ -9678,36 +9993,31 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9678
9993
|
];
|
|
9679
9994
|
case 3:
|
|
9680
9995
|
_state.sent();
|
|
9996
|
+
this.timing.clearAdRequestWatchdog();
|
|
9997
|
+
if (this.isStale(epoch, generation)) {
|
|
9998
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9999
|
+
requestId: requestToken
|
|
10000
|
+
});
|
|
10001
|
+
return [
|
|
10002
|
+
2
|
|
10003
|
+
];
|
|
10004
|
+
}
|
|
9681
10005
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
9682
10006
|
source: "hls",
|
|
9683
10007
|
vastUrl: requestUrl,
|
|
9684
10008
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
9685
10009
|
}, this.analyticsContext).catch(function() {});
|
|
9686
|
-
this.timing.clearAdRequestWatchdog();
|
|
9687
|
-
if (this.timing.activeAdRequestToken !== requestToken) return [
|
|
9688
|
-
2
|
|
9689
|
-
];
|
|
9690
10010
|
if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
|
|
9691
10011
|
;
|
|
9692
10012
|
adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
|
|
9693
10013
|
remainingMs = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9694
10014
|
this.logOrchestratorFunnel("discarded_budget", {
|
|
9695
|
-
vastUrl: requestUrl,
|
|
9696
10015
|
adDurationMs: adDurationS != null ? adDurationS * 1e3 : void 0,
|
|
9697
10016
|
remainingMs: remainingMs
|
|
9698
10017
|
});
|
|
9699
|
-
this.timing.rejectLoadedAdForDuration(ap);
|
|
9700
|
-
this.recreateAdController();
|
|
9701
10018
|
throw new Error("ad_duration_exceeds_budget");
|
|
9702
10019
|
}
|
|
9703
|
-
|
|
9704
|
-
case 4:
|
|
9705
|
-
_state.trys.push([
|
|
9706
|
-
4,
|
|
9707
|
-
6,
|
|
9708
|
-
,
|
|
9709
|
-
7
|
|
9710
|
-
]);
|
|
10020
|
+
this.setSlotState("READY", "vast_ready");
|
|
9711
10021
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
9712
10022
|
return [
|
|
9713
10023
|
4,
|
|
@@ -9715,8 +10025,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9715
10025
|
return ap.play();
|
|
9716
10026
|
})
|
|
9717
10027
|
];
|
|
9718
|
-
case
|
|
10028
|
+
case 4:
|
|
9719
10029
|
_state.sent();
|
|
10030
|
+
if (this.isStale(epoch, generation)) return [
|
|
10031
|
+
2
|
|
10032
|
+
];
|
|
9720
10033
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
9721
10034
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
9722
10035
|
}
|
|
@@ -9724,216 +10037,31 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9724
10037
|
this.timing.temporaryFailureUrls.delete(vastTagUrl);
|
|
9725
10038
|
return [
|
|
9726
10039
|
3,
|
|
9727
|
-
|
|
9728
|
-
];
|
|
9729
|
-
case 6:
|
|
9730
|
-
playError = _state.sent();
|
|
9731
|
-
if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
|
|
9732
|
-
if (this.timing.isTemporaryAdError(playError)) {
|
|
9733
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9734
|
-
if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
|
|
9735
|
-
} else {
|
|
9736
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9737
|
-
if (this.debug) console.log("[AD-ERROR] Permanent play error - URL blacklisted");
|
|
9738
|
-
}
|
|
9739
|
-
this.timing.clearAdFailsafeTimer();
|
|
9740
|
-
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9741
|
-
this.timing.activeAdRequestToken = null;
|
|
9742
|
-
}
|
|
9743
|
-
throw playError;
|
|
9744
|
-
case 7:
|
|
9745
|
-
return [
|
|
9746
|
-
3,
|
|
9747
|
-
9
|
|
10040
|
+
6
|
|
9748
10041
|
];
|
|
9749
|
-
case
|
|
10042
|
+
case 5:
|
|
9750
10043
|
error = _state.sent();
|
|
9751
|
-
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
9752
|
-
if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
|
|
9753
|
-
if (this.timing.isTemporaryAdError(error)) {
|
|
9754
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9755
|
-
if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
|
|
9756
|
-
} else {
|
|
9757
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9758
|
-
if (this.debug) console.log("[AD-ERROR] Permanent error - URL blacklisted:", errorMessage);
|
|
9759
|
-
}
|
|
9760
10044
|
this.timing.clearAdRequestWatchdog();
|
|
9761
10045
|
this.timing.clearAdFailsafeTimer();
|
|
9762
10046
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9763
10047
|
this.timing.activeAdRequestToken = null;
|
|
9764
10048
|
}
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
}
|
|
9771
|
-
});
|
|
9772
|
-
}).call(this);
|
|
9773
|
-
}
|
|
9774
|
-
},
|
|
9775
|
-
{
|
|
9776
|
-
key: "showPlaceholderAndWaitForAds",
|
|
9777
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9778
|
-
// Placeholder wait
|
|
9779
|
-
// ───────────────────────────────────────────────────────────────
|
|
9780
|
-
function showPlaceholderAndWaitForAds() {
|
|
9781
|
-
return _async_to_generator(function() {
|
|
9782
|
-
var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
|
|
9783
|
-
return _ts_generator(this, function(_state) {
|
|
9784
|
-
switch(_state.label){
|
|
9785
|
-
case 0:
|
|
9786
|
-
remaining = this.timing.getRemainingAdMs();
|
|
9787
|
-
waitTime = Math.min(this.maxPlaceholderDurationMs, remaining);
|
|
9788
|
-
if (this.timing.isGamInCooldown()) {
|
|
9789
|
-
if (this.debug) console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping placeholder wait");
|
|
9790
|
-
this.handleAdPodComplete();
|
|
9791
|
-
return [
|
|
9792
|
-
2
|
|
9793
|
-
];
|
|
9794
|
-
}
|
|
9795
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9796
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping placeholder - too many consecutive failures");
|
|
9797
|
-
this.handleAdPodComplete();
|
|
9798
|
-
return [
|
|
9799
|
-
2
|
|
9800
|
-
];
|
|
9801
|
-
}
|
|
9802
|
-
if (waitTime < 1e3) {
|
|
9803
|
-
this.handleAdPodComplete();
|
|
10049
|
+
if (this.isStale(epoch, generation)) {
|
|
10050
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
10051
|
+
requestId: requestToken,
|
|
10052
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
10053
|
+
});
|
|
9804
10054
|
return [
|
|
9805
10055
|
2
|
|
9806
10056
|
];
|
|
9807
10057
|
}
|
|
9808
|
-
if (this.debug)
|
|
9809
|
-
|
|
10058
|
+
if (this.debug) console.error("[AD-ERROR] Ad request failed:", error === null || error === void 0 ? void 0 : error.message);
|
|
10059
|
+
this.recordRequestFailure(error, vastTagUrl);
|
|
10060
|
+
if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
|
|
10061
|
+
this.recreateAdController("discarded_budget");
|
|
9810
10062
|
}
|
|
9811
|
-
|
|
9812
|
-
this.host.getAdPlayer().showPlaceholder();
|
|
9813
|
-
checkInterval = 300;
|
|
9814
|
-
maxChecks = Math.floor(waitTime / checkInterval);
|
|
9815
|
-
i = 0;
|
|
9816
|
-
_state.label = 1;
|
|
9817
|
-
case 1:
|
|
9818
|
-
if (!(i < maxChecks)) return [
|
|
9819
|
-
3,
|
|
9820
|
-
12
|
|
9821
|
-
];
|
|
9822
|
-
return [
|
|
9823
|
-
4,
|
|
9824
|
-
new Promise(function(resolve) {
|
|
9825
|
-
return setTimeout(resolve, checkInterval);
|
|
9826
|
-
})
|
|
9827
|
-
];
|
|
9828
|
-
case 2:
|
|
9829
|
-
_state.sent();
|
|
9830
|
-
if (!this.inAdBreak) return [
|
|
9831
|
-
2
|
|
9832
|
-
];
|
|
9833
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9834
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Too many failures during placeholder wait");
|
|
9835
|
-
return [
|
|
9836
|
-
3,
|
|
9837
|
-
12
|
|
9838
|
-
];
|
|
9839
|
-
}
|
|
9840
|
-
if (!this.timing.hasTimeToStartAnotherAd()) {
|
|
9841
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Not enough time remaining during placeholder wait, ending ad break");
|
|
9842
|
-
return [
|
|
9843
|
-
3,
|
|
9844
|
-
12
|
|
9845
|
-
];
|
|
9846
|
-
}
|
|
9847
|
-
_state.label = 3;
|
|
9848
|
-
case 3:
|
|
9849
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
9850
|
-
3,
|
|
9851
|
-
11
|
|
9852
|
-
];
|
|
9853
|
-
if (!this.timing.hasTimeToStartAnotherAd()) return [
|
|
9854
|
-
3,
|
|
9855
|
-
11
|
|
9856
|
-
];
|
|
9857
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
9858
|
-
if (!nextAdUrl) return [
|
|
9859
|
-
3,
|
|
9860
|
-
3
|
|
9861
|
-
];
|
|
9862
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) return [
|
|
9863
|
-
3,
|
|
9864
|
-
3
|
|
9865
|
-
];
|
|
9866
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) return [
|
|
9867
|
-
3,
|
|
9868
|
-
3
|
|
9869
|
-
];
|
|
9870
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad URL available, requesting via HLS ad player");
|
|
9871
|
-
this.isShowingPlaceholder = false;
|
|
9872
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
9873
|
-
_state.label = 4;
|
|
9874
|
-
case 4:
|
|
9875
|
-
_state.trys.push([
|
|
9876
|
-
4,
|
|
9877
|
-
6,
|
|
9878
|
-
,
|
|
9879
|
-
10
|
|
9880
|
-
]);
|
|
9881
|
-
return [
|
|
9882
|
-
4,
|
|
9883
|
-
this.playSingleAd(nextAdUrl)
|
|
9884
|
-
];
|
|
9885
|
-
case 5:
|
|
9886
|
-
_state.sent();
|
|
9887
|
-
return [
|
|
9888
|
-
3,
|
|
9889
|
-
10
|
|
9890
|
-
];
|
|
10063
|
+
throw error;
|
|
9891
10064
|
case 6:
|
|
9892
|
-
error = _state.sent();
|
|
9893
|
-
errorMessage = error.message;
|
|
9894
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
9895
|
-
3,
|
|
9896
|
-
8
|
|
9897
|
-
];
|
|
9898
|
-
this.timing.consecutiveFailures++;
|
|
9899
|
-
return [
|
|
9900
|
-
4,
|
|
9901
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9902
|
-
];
|
|
9903
|
-
case 7:
|
|
9904
|
-
_state.sent();
|
|
9905
|
-
return [
|
|
9906
|
-
2
|
|
9907
|
-
];
|
|
9908
|
-
case 8:
|
|
9909
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
9910
|
-
this.timing.consecutiveFailures++;
|
|
9911
|
-
}
|
|
9912
|
-
return [
|
|
9913
|
-
4,
|
|
9914
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9915
|
-
];
|
|
9916
|
-
case 9:
|
|
9917
|
-
_state.sent();
|
|
9918
|
-
return [
|
|
9919
|
-
3,
|
|
9920
|
-
10
|
|
9921
|
-
];
|
|
9922
|
-
case 10:
|
|
9923
|
-
return [
|
|
9924
|
-
2
|
|
9925
|
-
];
|
|
9926
|
-
case 11:
|
|
9927
|
-
i++;
|
|
9928
|
-
return [
|
|
9929
|
-
3,
|
|
9930
|
-
1
|
|
9931
|
-
];
|
|
9932
|
-
case 12:
|
|
9933
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Placeholder timeout, ending ad break");
|
|
9934
|
-
this.isShowingPlaceholder = false;
|
|
9935
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
9936
|
-
this.handleAdPodComplete();
|
|
9937
10065
|
return [
|
|
9938
10066
|
2
|
|
9939
10067
|
];
|
|
@@ -9947,7 +10075,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9947
10075
|
// Ad break completion
|
|
9948
10076
|
// ───────────────────────────────────────────────────────────────
|
|
9949
10077
|
key: "logBreakFunnel",
|
|
9950
|
-
value: function logBreakFunnel() {
|
|
10078
|
+
value: function logBreakFunnel(endReason) {
|
|
9951
10079
|
var funnel = this.breakFunnel;
|
|
9952
10080
|
this.breakFunnel = {};
|
|
9953
10081
|
if (Object.keys(funnel).length === 0) return;
|
|
@@ -9955,26 +10083,49 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9955
10083
|
var _funnel_stage;
|
|
9956
10084
|
return (_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0;
|
|
9957
10085
|
};
|
|
10086
|
+
var countPrefix = function countPrefix(prefix) {
|
|
10087
|
+
return Object.keys(funnel).reduce(function(total, stage) {
|
|
10088
|
+
var _funnel_stage;
|
|
10089
|
+
return stage.indexOf(prefix) === 0 ? total + ((_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0) : total;
|
|
10090
|
+
}, 0);
|
|
10091
|
+
};
|
|
9958
10092
|
var breakId = this.opportunityEpoch;
|
|
9959
|
-
|
|
10093
|
+
var requestRetries = count("gam_http_request_retry");
|
|
10094
|
+
var requests = count("gam_http_request_sent") - requestRetries;
|
|
10095
|
+
if (requests > 0 && count("impression_fired") === 0) {
|
|
9960
10096
|
console.log("[AdBreak][FUNNEL] break_abandoned_before_start", {
|
|
9961
10097
|
breakId: breakId,
|
|
9962
|
-
requests:
|
|
10098
|
+
requests: requests,
|
|
10099
|
+
endReason: endReason
|
|
9963
10100
|
});
|
|
9964
10101
|
}
|
|
9965
10102
|
console.log("[AdBreak][FUNNEL] Break summary", {
|
|
9966
10103
|
breakId: breakId,
|
|
10104
|
+
endReason: endReason,
|
|
9967
10105
|
opportunities: count("opportunity_created"),
|
|
9968
|
-
|
|
10106
|
+
vastUrlsGenerated: count("vast_url_generated"),
|
|
10107
|
+
requests: requests,
|
|
10108
|
+
requestRetries: requestRetries,
|
|
10109
|
+
gamResponses: count("gam_response_received"),
|
|
10110
|
+
requestsSuppressed: count("request_suppressed"),
|
|
9969
10111
|
duplicates: count("duplicate_request_detected") + count("duplicate_break_start"),
|
|
9970
10112
|
filled: count("vast_received"),
|
|
9971
10113
|
noFill: count("no_fill"),
|
|
10114
|
+
fillRejected: count("vast_fill_rejected"),
|
|
10115
|
+
gamAdWithoutImpression: count("gam_ad_without_impression"),
|
|
10116
|
+
playbackFailedAfterFill: count("request_outcome:playback_failed"),
|
|
9972
10117
|
requestFailed: count("request_failed"),
|
|
9973
10118
|
requestAbortedTimeout: count("request_aborted_timeout"),
|
|
9974
10119
|
credentialsRetries: count("vast_credentials_retry"),
|
|
9975
10120
|
wrapperFailures: count("wrapper_fetch:failure"),
|
|
9976
10121
|
noSupportedMedia: count("vast_no_supported_media"),
|
|
9977
|
-
vpaidOnly: count("vast_no_supported_media:
|
|
10122
|
+
vpaidOnly: count("vast_no_supported_media:vpaid"),
|
|
10123
|
+
audioOnly: count("vast_no_supported_media:audio_only"),
|
|
10124
|
+
mediaFilesEvaluated: count("mediafile_evaluated"),
|
|
10125
|
+
mediaFilesAccepted: count("mediafile_evaluated:accepted"),
|
|
10126
|
+
controllerDestroys: countPrefix("controller_destroy:"),
|
|
10127
|
+
staleCallbacks: count("stale_callback_ignored") + count("stale_request_result_ignored"),
|
|
10128
|
+
tagAllowsAudio: count("tag_allows_audio"),
|
|
9978
10129
|
missingImpression: count("vast_missing_impression"),
|
|
9979
10130
|
discardedBudget: count("discarded_budget"),
|
|
9980
10131
|
mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
|
|
@@ -10009,25 +10160,50 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
10009
10160
|
{
|
|
10010
10161
|
key: "handleAdPodComplete",
|
|
10011
10162
|
value: function handleAdPodComplete() {
|
|
10163
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "unspecified";
|
|
10012
10164
|
if (this.debug) {
|
|
10013
|
-
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up"
|
|
10165
|
+
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up", {
|
|
10166
|
+
reason: reason
|
|
10167
|
+
});
|
|
10168
|
+
}
|
|
10169
|
+
var previousState = this.slotState;
|
|
10170
|
+
var alreadyEnded = previousState === "IDLE" && !this.inAdBreak;
|
|
10171
|
+
this.setSlotState("ENDING", reason);
|
|
10172
|
+
this.cancelScheduledRequest();
|
|
10173
|
+
var adPlayer = this.host.getAdPlayer();
|
|
10174
|
+
if (previousState === "REQUESTING") {
|
|
10175
|
+
var _adPlayer_abortPendingRequest;
|
|
10176
|
+
(_adPlayer_abortPendingRequest = adPlayer.abortPendingRequest) === null || _adPlayer_abortPendingRequest === void 0 ? void 0 : _adPlayer_abortPendingRequest.call(adPlayer, "VAST request aborted: ad break ended (".concat(reason, ")"));
|
|
10177
|
+
}
|
|
10178
|
+
if (!alreadyEnded) {
|
|
10179
|
+
console.log("[AD-CONTROLLER] stop", {
|
|
10180
|
+
controllerId: this.controllerGeneration,
|
|
10181
|
+
requestId: this.currentRequestId,
|
|
10182
|
+
state: previousState,
|
|
10183
|
+
reason: reason
|
|
10184
|
+
});
|
|
10014
10185
|
}
|
|
10186
|
+
this.finalizeRequestDiagnostics(this.currentRequestId, "break_ended:".concat(reason));
|
|
10187
|
+
this.currentRequestId = void 0;
|
|
10015
10188
|
this.timing.resetForBreakEnd();
|
|
10016
|
-
this.
|
|
10189
|
+
this.placeholder.hide();
|
|
10017
10190
|
this.clearPendingAdBreak();
|
|
10018
10191
|
if (this.isShowingPlaceholder) {
|
|
10019
|
-
|
|
10192
|
+
adPlayer.hidePlaceholder();
|
|
10020
10193
|
this.isShowingPlaceholder = false;
|
|
10021
10194
|
}
|
|
10022
|
-
this.adRequestQueue = [];
|
|
10023
10195
|
this.inAdBreak = false;
|
|
10024
10196
|
this.adDetectSentForCurrentBreak = false;
|
|
10025
10197
|
this.cueManager.activeScte35BreakKey = void 0;
|
|
10026
10198
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
10027
10199
|
this.adPodQueue = [];
|
|
10028
10200
|
this.showAds = false;
|
|
10029
|
-
this.
|
|
10030
|
-
this.
|
|
10201
|
+
this.breakSource = void 0;
|
|
10202
|
+
this.followUpBaseVastUrl = void 0;
|
|
10203
|
+
this.unusableResponsesInBreak = 0;
|
|
10204
|
+
adPlayer.stop().catch(function() {});
|
|
10205
|
+
if (!alreadyEnded) this.logBreakFunnel(reason);
|
|
10206
|
+
this.setSlotState("IDLE", "break_complete");
|
|
10031
10207
|
var restoredMuted = this.host.getAdPlayer().getOriginalMutedState();
|
|
10032
10208
|
var restoredVolume = this.host.getAdPlayer().getOriginalVolume();
|
|
10033
10209
|
if (this.host.video.muted !== restoredMuted) {
|
|
@@ -10321,25 +10497,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
10321
10497
|
{
|
|
10322
10498
|
key: "handleAdFailure",
|
|
10323
10499
|
value: function handleAdFailure() {
|
|
10324
|
-
|
|
10325
|
-
this.
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
}
|
|
10331
|
-
}
|
|
10332
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
10333
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Max consecutive failures reached (".concat(this.timing.consecutiveFailures, "), ending ad break gracefully"));
|
|
10334
|
-
this.handleAdPodComplete();
|
|
10500
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "ad_failure";
|
|
10501
|
+
if (!this.inAdBreak) return;
|
|
10502
|
+
if (this.slotState === "REQUESTING" || this.slotState === "ENDING") {
|
|
10503
|
+
this.logOrchestratorFunnel("failure_deferred_to_request", {
|
|
10504
|
+
reason: reason,
|
|
10505
|
+
state: this.slotState
|
|
10506
|
+
});
|
|
10335
10507
|
return;
|
|
10336
10508
|
}
|
|
10337
|
-
|
|
10338
|
-
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
this.
|
|
10509
|
+
this.timing.consecutiveFailures++;
|
|
10510
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
10511
|
+
if (diag && !diag.failureReason) diag.failureReason = reason;
|
|
10512
|
+
if (this.debug) {
|
|
10513
|
+
console.log("[AdBreak] Ad failure (".concat(reason, "): remaining=").concat(this.timing.getRemainingAdMs(), "ms, consecutiveFailures=").concat(this.timing.consecutiveFailures));
|
|
10342
10514
|
}
|
|
10515
|
+
this.setSlotState("NEEDS_NEXT_AD", reason);
|
|
10516
|
+
this.requestNextAd(reason);
|
|
10343
10517
|
}
|
|
10344
10518
|
}
|
|
10345
10519
|
]);
|
|
@@ -10382,7 +10556,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10382
10556
|
return _this.adBreak.handleRequestWatchdogTimeout();
|
|
10383
10557
|
},
|
|
10384
10558
|
onFailsafeTimeout: function onFailsafeTimeout() {
|
|
10385
|
-
return _this.adBreak.handleAdFailure();
|
|
10559
|
+
return _this.adBreak.handleAdFailure("failsafe_timeout");
|
|
10386
10560
|
},
|
|
10387
10561
|
getAdState: function getAdState() {
|
|
10388
10562
|
return {
|
|
@@ -10632,6 +10806,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10632
10806
|
adBehavior: adBehavior
|
|
10633
10807
|
});
|
|
10634
10808
|
}
|
|
10809
|
+
if (this.adBreak.isBreakActive()) {
|
|
10810
|
+
console.log("[AD-CONTROLLER] destroy skipped", {
|
|
10811
|
+
reason: "manifest_parsed_during_break",
|
|
10812
|
+
state: this.adBreak.getSlotState()
|
|
10813
|
+
});
|
|
10814
|
+
return [
|
|
10815
|
+
2
|
|
10816
|
+
];
|
|
10817
|
+
}
|
|
10818
|
+
if (this.debug) {
|
|
10819
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
10820
|
+
reason: "manifest_parsed",
|
|
10821
|
+
state: "IDLE"
|
|
10822
|
+
});
|
|
10823
|
+
}
|
|
10635
10824
|
this.adPlayer.destroy();
|
|
10636
10825
|
this.adPlayer = this.createAdPlayer(this.shouldContinueLiveStreamDuringAds());
|
|
10637
10826
|
this.adPlayer.initialize();
|
|
@@ -10813,9 +11002,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10813
11002
|
this.timing.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
10814
11003
|
}
|
|
10815
11004
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
10816
|
-
if (!this.adPlayer.isAdPlaying() && this.timing.activeAdRequestToken === null && this.adBreak.adRequestQueue.length > 0 && this.timing.hasTimeToStartAnotherAd()) {
|
|
10817
|
-
this.adBreak.tryNextAvailableAdWithRateLimit();
|
|
10818
|
-
}
|
|
10819
11005
|
return;
|
|
10820
11006
|
}
|
|
10821
11007
|
if (marker.type === "end") {
|
|
@@ -10827,12 +11013,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10827
11013
|
}
|
|
10828
11014
|
var remaining = this.timing.getRemainingAdMs();
|
|
10829
11015
|
var adPlaying = this.adPlayer.isAdPlaying();
|
|
10830
|
-
var hasQueuedAds = this.adBreak.adRequestQueue.length > 0;
|
|
10831
11016
|
if (this.debug) {
|
|
10832
11017
|
console.log("[StormcloudVideoPlayer] SCTE-35 end marker received:", {
|
|
10833
11018
|
remaining: remaining,
|
|
10834
11019
|
adPlaying: adPlaying,
|
|
10835
|
-
|
|
11020
|
+
adSlotState: this.adBreak.getSlotState(),
|
|
10836
11021
|
activeAdRequest: this.timing.activeAdRequestToken !== null
|
|
10837
11022
|
});
|
|
10838
11023
|
}
|
|
@@ -10843,7 +11028,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10843
11028
|
this.adBreak.noteStopBeforeStart("scte_end");
|
|
10844
11029
|
this.adPlayer.stop().catch(function() {});
|
|
10845
11030
|
}
|
|
10846
|
-
this.adBreak.handleAdPodComplete();
|
|
11031
|
+
this.adBreak.handleAdPodComplete("scte_end");
|
|
10847
11032
|
return;
|
|
10848
11033
|
}
|
|
10849
11034
|
}
|
|
@@ -10851,6 +11036,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10851
11036
|
{
|
|
10852
11037
|
key: "startScte35AdBreak",
|
|
10853
11038
|
value: function startScte35AdBreak(marker, cueKey, durationMs) {
|
|
11039
|
+
if (this.adBreak.isBreakActive()) {
|
|
11040
|
+
if (this.debug) {
|
|
11041
|
+
console.log("[StormcloudVideoPlayer] Ignoring SCTE-35 break start: a break is already active", {
|
|
11042
|
+
state: this.adBreak.getSlotState(),
|
|
11043
|
+
cueKey: cueKey
|
|
11044
|
+
});
|
|
11045
|
+
}
|
|
11046
|
+
return;
|
|
11047
|
+
}
|
|
10854
11048
|
this.adBreak.inAdBreak = true;
|
|
10855
11049
|
this.cueManager.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.cueManager.pendingScte35CueKey;
|
|
10856
11050
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
@@ -10883,7 +11077,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10883
11077
|
this.adBreak.noteStopBeforeStart("break_boundary");
|
|
10884
11078
|
this.adPlayer.stop().catch(function() {});
|
|
10885
11079
|
}
|
|
10886
|
-
this.adBreak.handleAdPodComplete();
|
|
11080
|
+
this.adBreak.handleAdPodComplete("break_boundary");
|
|
10887
11081
|
}
|
|
10888
11082
|
},
|
|
10889
11083
|
{
|
|
@@ -10893,14 +11087,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10893
11087
|
key: "startAdPrefetch",
|
|
10894
11088
|
value: function startAdPrefetch(marker, fragmentSn, cueKey) {
|
|
10895
11089
|
if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
|
|
10896
|
-
var
|
|
10897
|
-
|
|
10898
|
-
var baseVastUrl;
|
|
10899
|
-
if (tags && tags.length > 0 && tags[0]) {
|
|
10900
|
-
baseVastUrl = tags[0];
|
|
10901
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
10902
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
10903
|
-
} else {
|
|
11090
|
+
var baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
11091
|
+
if (!baseVastUrl) {
|
|
10904
11092
|
if (this.debug) console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
|
|
10905
11093
|
return;
|
|
10906
11094
|
}
|
|
@@ -10930,8 +11118,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10930
11118
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
10931
11119
|
}, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
|
|
10932
11120
|
if (this.debug) {
|
|
10933
|
-
console.log("[PREFETCH]
|
|
10934
|
-
console.log("[PREFETCH] Pre-generated pod request URL");
|
|
11121
|
+
console.log("[PREFETCH] Pre-generated pod request URL for upcoming ad break");
|
|
10935
11122
|
}
|
|
10936
11123
|
}
|
|
10937
11124
|
},
|
|
@@ -10942,7 +11129,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10942
11129
|
key: "onTimeUpdate",
|
|
10943
11130
|
value: function onTimeUpdate(currentTimeSec) {
|
|
10944
11131
|
var _this = this;
|
|
10945
|
-
if (
|
|
11132
|
+
if (this.adConfig.vmapBreaks.length === 0) return;
|
|
10946
11133
|
if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
|
|
10947
11134
|
var nowMs = currentTimeSec * 1e3;
|
|
10948
11135
|
var breakToPlay = this.adConfig.findBreakForTime(nowMs);
|
|
@@ -10959,7 +11146,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10959
11146
|
key: "onVideoEnded",
|
|
10960
11147
|
value: function onVideoEnded() {
|
|
10961
11148
|
var _this = this;
|
|
10962
|
-
if (
|
|
11149
|
+
if (this.adConfig.vmapBreaks.length === 0) return;
|
|
10963
11150
|
if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
|
|
10964
11151
|
var durationMs = Number.isFinite(this.video.duration) ? Math.floor(this.video.duration * 1e3) : 0;
|
|
10965
11152
|
var postroll = this.adConfig.vmapBreaks.find(function(b) {
|
|
@@ -11012,7 +11199,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
11012
11199
|
if (durationMs > 0) {
|
|
11013
11200
|
this.timing.setAdBreakDurationBoundary(durationMs);
|
|
11014
11201
|
}
|
|
11015
|
-
this.adBreak.
|
|
11202
|
+
this.adBreak.beginVmapBreak(key);
|
|
11016
11203
|
_state.label = 1;
|
|
11017
11204
|
case 1:
|
|
11018
11205
|
_state.trys.push([
|
|
@@ -11023,7 +11210,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
11023
11210
|
]);
|
|
11024
11211
|
return [
|
|
11025
11212
|
4,
|
|
11026
|
-
this.adBreak.playSingleAd(first)
|
|
11213
|
+
this.adBreak.playSingleAd(first, "vmap")
|
|
11027
11214
|
];
|
|
11028
11215
|
case 2:
|
|
11029
11216
|
_state.sent();
|
|
@@ -11036,7 +11223,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
11036
11223
|
if (this.debug) {
|
|
11037
11224
|
console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
|
|
11038
11225
|
}
|
|
11039
|
-
this.adBreak.
|
|
11226
|
+
this.adBreak.continueAfterRequestFailure();
|
|
11040
11227
|
return [
|
|
11041
11228
|
3,
|
|
11042
11229
|
4
|
|
@@ -11178,7 +11365,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
11178
11365
|
key: "destroy",
|
|
11179
11366
|
value: function destroy() {
|
|
11180
11367
|
var _this_adPlayer;
|
|
11181
|
-
this.adBreak.
|
|
11368
|
+
this.adBreak.cancelScheduledRequest();
|
|
11182
11369
|
this.timing.destroy();
|
|
11183
11370
|
this.adBreak.clearPendingAdBreak();
|
|
11184
11371
|
this.placeholder.destroy();
|
|
@@ -11202,7 +11389,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
11202
11389
|
this.palNonce.sendPlaybackEnd();
|
|
11203
11390
|
}
|
|
11204
11391
|
this.palNonce.reset();
|
|
11205
|
-
this.adBreak.adRequestQueue = [];
|
|
11206
11392
|
this.timing.consecutiveFailures = 0;
|
|
11207
11393
|
}
|
|
11208
11394
|
}
|