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
|
@@ -178,6 +178,42 @@ function _object_spread_props(target, source) {
|
|
|
178
178
|
}
|
|
179
179
|
return target;
|
|
180
180
|
}
|
|
181
|
+
function _object_without_properties(source, excluded) {
|
|
182
|
+
if (source == null) return {};
|
|
183
|
+
var target = {}, sourceKeys, key, i;
|
|
184
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
185
|
+
sourceKeys = Reflect.ownKeys(Object(source));
|
|
186
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
187
|
+
key = sourceKeys[i];
|
|
188
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
189
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
190
|
+
target[key] = source[key];
|
|
191
|
+
}
|
|
192
|
+
return target;
|
|
193
|
+
}
|
|
194
|
+
target = _object_without_properties_loose(source, excluded);
|
|
195
|
+
if (Object.getOwnPropertySymbols) {
|
|
196
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
197
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
198
|
+
key = sourceKeys[i];
|
|
199
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
200
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
201
|
+
target[key] = source[key];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return target;
|
|
205
|
+
}
|
|
206
|
+
function _object_without_properties_loose(source, excluded) {
|
|
207
|
+
if (source == null) return {};
|
|
208
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
209
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
210
|
+
key = sourceKeys[i];
|
|
211
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
212
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
213
|
+
target[key] = source[key];
|
|
214
|
+
}
|
|
215
|
+
return target;
|
|
216
|
+
}
|
|
181
217
|
function _possible_constructor_return(self, call) {
|
|
182
218
|
if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
|
|
183
219
|
return _assert_this_initialized(self);
|
|
@@ -294,26 +330,6 @@ function _ts_generator(thisArg, body) {
|
|
|
294
330
|
};
|
|
295
331
|
}
|
|
296
332
|
}
|
|
297
|
-
function _ts_values(o) {
|
|
298
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
299
|
-
if (m) {
|
|
300
|
-
return m.call(o);
|
|
301
|
-
}
|
|
302
|
-
if (o && typeof o.length === "number") {
|
|
303
|
-
return {
|
|
304
|
-
next: function() {
|
|
305
|
-
if (o && i >= o.length) {
|
|
306
|
-
o = void 0;
|
|
307
|
-
}
|
|
308
|
-
return {
|
|
309
|
-
value: o && o[i++],
|
|
310
|
-
done: !o
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
316
|
-
}
|
|
317
333
|
function _type_of(obj) {
|
|
318
334
|
"@swc/helpers - typeof";
|
|
319
335
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
@@ -805,6 +821,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
805
821
|
var pendingPlayPromise;
|
|
806
822
|
var currentVastTagUrl;
|
|
807
823
|
var funnelContext = {};
|
|
824
|
+
var mediaProbe;
|
|
825
|
+
var lastPodAdElementCount = 0;
|
|
808
826
|
var mediaCandidates = [];
|
|
809
827
|
var mediaCandidateIndex = 0;
|
|
810
828
|
var mediaStartTimerId;
|
|
@@ -922,6 +940,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
922
940
|
stage: stage,
|
|
923
941
|
breakId: funnelContext.breakId,
|
|
924
942
|
requestId: funnelContext.requestId,
|
|
943
|
+
controllerId: funnelContext.controllerId,
|
|
925
944
|
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0,
|
|
926
945
|
adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
|
|
927
946
|
podIndex: podIndex,
|
|
@@ -1111,7 +1130,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1111
1130
|
});
|
|
1112
1131
|
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1113
1132
|
reason: "accepted",
|
|
1114
|
-
// Mixed-content media is often auto-upgraded, so it is kept as a last resort.
|
|
1115
1133
|
why: insecure ? "insecure_http_deprioritized" : "playable",
|
|
1116
1134
|
score: score
|
|
1117
1135
|
}));
|
|
@@ -1139,6 +1157,145 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1139
1157
|
var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
|
|
1140
1158
|
return type.startsWith("audio/") || url.endsWith(".mp3") || url.endsWith(".aac") || url.endsWith(".m4a") || url.endsWith(".ogg") || url.endsWith(".oga") || url.endsWith(".opus") || url.endsWith(".wav") || url.endsWith(".weba");
|
|
1141
1159
|
}
|
|
1160
|
+
function getMediaProbe() {
|
|
1161
|
+
if (adVideoElement) return adVideoElement;
|
|
1162
|
+
if (!mediaProbe && typeof document !== "undefined") {
|
|
1163
|
+
mediaProbe = document.createElement("video");
|
|
1164
|
+
}
|
|
1165
|
+
return mediaProbe;
|
|
1166
|
+
}
|
|
1167
|
+
function evaluateMediaFile(mf) {
|
|
1168
|
+
var _mf_textContent;
|
|
1169
|
+
var type = mf.getAttribute("type") || "";
|
|
1170
|
+
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1171
|
+
var delivery = mf.getAttribute("delivery") || void 0;
|
|
1172
|
+
var codec = mf.getAttribute("codec") || void 0;
|
|
1173
|
+
if (!url) {
|
|
1174
|
+
return {
|
|
1175
|
+
category: "missing_media",
|
|
1176
|
+
whyRejected: "empty_url",
|
|
1177
|
+
canPlayType: ""
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
var apiFramework = (mf.getAttribute("apiFramework") || "").toUpperCase();
|
|
1181
|
+
if (apiFramework === "VPAID") {
|
|
1182
|
+
return {
|
|
1183
|
+
category: "vpaid",
|
|
1184
|
+
whyRejected: "vpaid_not_supported",
|
|
1185
|
+
canPlayType: ""
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
try {
|
|
1189
|
+
var protocol = new URL(url).protocol;
|
|
1190
|
+
if (protocol !== "https:" && protocol !== "http:") {
|
|
1191
|
+
return {
|
|
1192
|
+
category: "invalid_url",
|
|
1193
|
+
whyRejected: "protocol_".concat(protocol),
|
|
1194
|
+
canPlayType: ""
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
} catch (unused) {
|
|
1198
|
+
return {
|
|
1199
|
+
category: "invalid_url",
|
|
1200
|
+
whyRejected: "unparseable_url",
|
|
1201
|
+
canPlayType: ""
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1205
|
+
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1206
|
+
var file = {
|
|
1207
|
+
url: url,
|
|
1208
|
+
type: type,
|
|
1209
|
+
width: parseInt(mf.getAttribute("width") || "1920", 10),
|
|
1210
|
+
height: parseInt(mf.getAttribute("height") || "1080", 10),
|
|
1211
|
+
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0,
|
|
1212
|
+
delivery: delivery,
|
|
1213
|
+
codec: codec
|
|
1214
|
+
};
|
|
1215
|
+
if (isAudioMediaFile(file)) {
|
|
1216
|
+
return {
|
|
1217
|
+
category: "audio_only",
|
|
1218
|
+
whyRejected: type.toLowerCase().startsWith("audio/") ? "audio_mime" : "audio_extension",
|
|
1219
|
+
canPlayType: ""
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
var isHls = isHlsMediaFile(file);
|
|
1223
|
+
var hasExplicitDimensions = mf.getAttribute("width") != null && mf.getAttribute("height") != null;
|
|
1224
|
+
if (!isHls && hasExplicitDimensions && (file.width <= 1 || file.height <= 1)) {
|
|
1225
|
+
return {
|
|
1226
|
+
category: "audio_only",
|
|
1227
|
+
whyRejected: "zero_dimensions",
|
|
1228
|
+
canPlayType: ""
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
var probe = getMediaProbe();
|
|
1232
|
+
if (isHls) {
|
|
1233
|
+
var _ref;
|
|
1234
|
+
var nativeHls = (_ref = probe === null || probe === void 0 ? void 0 : probe.canPlayType("application/vnd.apple.mpegurl")) !== null && _ref !== void 0 ? _ref : "";
|
|
1235
|
+
if (import_hls.default.isSupported()) {
|
|
1236
|
+
return {
|
|
1237
|
+
file: file,
|
|
1238
|
+
whyAccepted: "hls_js",
|
|
1239
|
+
canPlayType: nativeHls
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
if (nativeHls !== "") {
|
|
1243
|
+
return {
|
|
1244
|
+
file: file,
|
|
1245
|
+
whyAccepted: "native_hls",
|
|
1246
|
+
canPlayType: nativeHls
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
return {
|
|
1250
|
+
category: "unsupported_hls",
|
|
1251
|
+
whyRejected: "no_hls_support",
|
|
1252
|
+
canPlayType: nativeHls
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1255
|
+
if (!isProgressiveMediaFile(file)) {
|
|
1256
|
+
return {
|
|
1257
|
+
category: "unsupported_mime",
|
|
1258
|
+
whyRejected: "not_a_video_mime",
|
|
1259
|
+
canPlayType: ""
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
if (!probe) {
|
|
1263
|
+
return {
|
|
1264
|
+
file: file,
|
|
1265
|
+
whyAccepted: "no_probe_available",
|
|
1266
|
+
canPlayType: ""
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
var baseType = type || "video/mp4";
|
|
1270
|
+
var canPlay2 = probe.canPlayType(baseType);
|
|
1271
|
+
if (canPlay2 === "") {
|
|
1272
|
+
return {
|
|
1273
|
+
category: "unsupported_mime",
|
|
1274
|
+
whyRejected: "canPlayType_empty",
|
|
1275
|
+
canPlayType: canPlay2
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
if (codec) {
|
|
1279
|
+
var withCodec = probe.canPlayType("".concat(baseType, '; codecs="').concat(codec, '"'));
|
|
1280
|
+
if (withCodec === "") {
|
|
1281
|
+
return {
|
|
1282
|
+
category: "unsupported_codec",
|
|
1283
|
+
whyRejected: "codec_canPlayType_empty",
|
|
1284
|
+
canPlayType: withCodec
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
return {
|
|
1288
|
+
file: file,
|
|
1289
|
+
whyAccepted: "canPlayType_".concat(withCodec),
|
|
1290
|
+
canPlayType: withCodec
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
return {
|
|
1294
|
+
file: file,
|
|
1295
|
+
whyAccepted: "canPlayType_".concat(canPlay2),
|
|
1296
|
+
canPlayType: canPlay2
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1142
1299
|
function collectVideoMediaFiles(linear, verbose, stats) {
|
|
1143
1300
|
var mediaFileElements = linear.querySelectorAll(":scope > MediaFiles > MediaFile");
|
|
1144
1301
|
var mediaFiles = [];
|
|
@@ -1148,57 +1305,33 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1148
1305
|
}
|
|
1149
1306
|
mediaFileElements.forEach(function(mf, index) {
|
|
1150
1307
|
var _mf_textContent;
|
|
1151
|
-
var
|
|
1308
|
+
var result = evaluateMediaFile(mf);
|
|
1152
1309
|
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1153
|
-
var
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
return;
|
|
1171
|
-
}
|
|
1172
|
-
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1173
|
-
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1174
|
-
var mediaFile = {
|
|
1175
|
-
url: url,
|
|
1176
|
-
type: type,
|
|
1177
|
-
width: parseInt(width || "1920", 10),
|
|
1178
|
-
height: parseInt(height || "1080", 10),
|
|
1179
|
-
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
1180
|
-
};
|
|
1181
|
-
if (isAudioMediaFile(mediaFile)) {
|
|
1182
|
-
if (stats) stats.audio++;
|
|
1183
|
-
console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
|
|
1310
|
+
var accepted = "file" in result;
|
|
1311
|
+
logFunnel("mediafile_evaluated", {
|
|
1312
|
+
reason: accepted ? "accepted" : result.category,
|
|
1313
|
+
index: index,
|
|
1314
|
+
type: mf.getAttribute("type") || "",
|
|
1315
|
+
delivery: mf.getAttribute("delivery") || void 0,
|
|
1316
|
+
codec: mf.getAttribute("codec") || void 0,
|
|
1317
|
+
apiFramework: mf.getAttribute("apiFramework") || void 0,
|
|
1318
|
+
width: mf.getAttribute("width"),
|
|
1319
|
+
height: mf.getAttribute("height"),
|
|
1320
|
+
fileUrl: redactUrl(url),
|
|
1321
|
+
canPlayType: result.canPlayType,
|
|
1322
|
+
whyAccepted: accepted ? result.whyAccepted : void 0,
|
|
1323
|
+
whyRejected: accepted ? void 0 : result.whyRejected
|
|
1324
|
+
});
|
|
1325
|
+
if ("file" in result) {
|
|
1326
|
+
mediaFiles.push(result.file);
|
|
1184
1327
|
return;
|
|
1185
1328
|
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
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'));
|
|
1190
|
-
return;
|
|
1329
|
+
if (stats) {
|
|
1330
|
+
var _stats_categories_result_category;
|
|
1331
|
+
stats.categories[result.category] = ((_stats_categories_result_category = stats.categories[result.category]) !== null && _stats_categories_result_category !== void 0 ? _stats_categories_result_category : 0) + 1;
|
|
1191
1332
|
}
|
|
1192
|
-
if (
|
|
1193
|
-
|
|
1194
|
-
if (verbose) {
|
|
1195
|
-
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
1196
|
-
}
|
|
1197
|
-
} else {
|
|
1198
|
-
if (stats) stats.unsupported++;
|
|
1199
|
-
if (verbose) {
|
|
1200
|
-
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
1201
|
-
}
|
|
1333
|
+
if (result.category === "audio_only") {
|
|
1334
|
+
console.warn("[HlsAdPlayer] MediaFile ".concat(index, " skipped (audio-only: ").concat(result.whyRejected, ', type="').concat(mf.getAttribute("type") || "", '") — audio-only ads are not played on video inventory'));
|
|
1202
1335
|
}
|
|
1203
1336
|
});
|
|
1204
1337
|
return mediaFiles;
|
|
@@ -1420,7 +1553,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1420
1553
|
if (adElement.getAttribute("conditionalAd") === "true") {
|
|
1421
1554
|
console.warn("[HlsAdPlayer] Skipping conditional <Ad> (VPAID-only)");
|
|
1422
1555
|
logFunnel("vast_no_supported_media", {
|
|
1423
|
-
reason: "
|
|
1556
|
+
reason: "vpaid",
|
|
1424
1557
|
conditionalAd: true
|
|
1425
1558
|
});
|
|
1426
1559
|
return {
|
|
@@ -1433,9 +1566,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1433
1566
|
var mediaFiles = [];
|
|
1434
1567
|
var rejectStats = {
|
|
1435
1568
|
total: 0,
|
|
1436
|
-
|
|
1437
|
-
audio: 0,
|
|
1438
|
-
unsupported: 0
|
|
1569
|
+
categories: {}
|
|
1439
1570
|
};
|
|
1440
1571
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1441
1572
|
try {
|
|
@@ -1464,10 +1595,39 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1464
1595
|
}
|
|
1465
1596
|
if (!linear) {
|
|
1466
1597
|
console.warn("[HlsAdPlayer] No supported linear media files in <Ad>");
|
|
1467
|
-
var reason =
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1598
|
+
var reason = "missing_media";
|
|
1599
|
+
var top = 0;
|
|
1600
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
1601
|
+
try {
|
|
1602
|
+
for(var _iterator1 = Object.keys(rejectStats.categories)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
1603
|
+
var category = _step1.value;
|
|
1604
|
+
var _rejectStats_categories_category;
|
|
1605
|
+
var count = (_rejectStats_categories_category = rejectStats.categories[category]) !== null && _rejectStats_categories_category !== void 0 ? _rejectStats_categories_category : 0;
|
|
1606
|
+
if (count > top) {
|
|
1607
|
+
top = count;
|
|
1608
|
+
reason = category;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
} catch (err) {
|
|
1612
|
+
_didIteratorError1 = true;
|
|
1613
|
+
_iteratorError1 = err;
|
|
1614
|
+
} finally{
|
|
1615
|
+
try {
|
|
1616
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1617
|
+
_iterator1.return();
|
|
1618
|
+
}
|
|
1619
|
+
} finally{
|
|
1620
|
+
if (_didIteratorError1) {
|
|
1621
|
+
throw _iteratorError1;
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
if (rejectStats.total > 0 && top === 0) reason = "other";
|
|
1626
|
+
logFunnel("vast_no_supported_media", {
|
|
1627
|
+
reason: reason,
|
|
1628
|
+
mediaFileCount: rejectStats.total,
|
|
1629
|
+
rejectedByCategory: rejectStats.categories
|
|
1630
|
+
});
|
|
1471
1631
|
return {
|
|
1472
1632
|
type: "empty",
|
|
1473
1633
|
errorUrls: errorUrls,
|
|
@@ -1497,9 +1657,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1497
1657
|
}
|
|
1498
1658
|
}
|
|
1499
1659
|
function fetchVastXml(vastTagUrl) {
|
|
1500
|
-
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
1660
|
+
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include", kind = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "gam";
|
|
1501
1661
|
return _async_to_generator(function() {
|
|
1502
|
-
var controller, timeoutId, requestVast, response, error, error1;
|
|
1662
|
+
var controller, timeoutId, startedAt, attempt, requestVast, response, error, error1;
|
|
1503
1663
|
return _ts_generator(this, function(_state) {
|
|
1504
1664
|
switch(_state.label){
|
|
1505
1665
|
case 0:
|
|
@@ -1511,17 +1671,51 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1511
1671
|
timeoutId = controller ? setTimeout(function() {
|
|
1512
1672
|
return controller.abort();
|
|
1513
1673
|
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
1674
|
+
startedAt = Date.now();
|
|
1675
|
+
attempt = 0;
|
|
1514
1676
|
requestVast = function requestVast(creds) {
|
|
1515
|
-
return
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1677
|
+
return _async_to_generator(function() {
|
|
1678
|
+
var response;
|
|
1679
|
+
return _ts_generator(this, function(_state) {
|
|
1680
|
+
switch(_state.label){
|
|
1681
|
+
case 0:
|
|
1682
|
+
attempt++;
|
|
1683
|
+
if (kind === "gam") {
|
|
1684
|
+
logFunnel("gam_http_request_sent", {
|
|
1685
|
+
attempt: attempt,
|
|
1686
|
+
credentials: creds
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
return [
|
|
1690
|
+
4,
|
|
1691
|
+
fetch(vastTagUrl, _object_spread({
|
|
1692
|
+
mode: "cors",
|
|
1693
|
+
credentials: creds,
|
|
1694
|
+
headers: {
|
|
1695
|
+
"Accept": "application/xml, text/xml, */*"
|
|
1696
|
+
},
|
|
1697
|
+
referrerPolicy: "no-referrer-when-downgrade"
|
|
1698
|
+
}, controller ? {
|
|
1699
|
+
signal: controller.signal
|
|
1700
|
+
} : {}))
|
|
1701
|
+
];
|
|
1702
|
+
case 1:
|
|
1703
|
+
response = _state.sent();
|
|
1704
|
+
if (kind === "gam") {
|
|
1705
|
+
logFunnel("gam_response_received", {
|
|
1706
|
+
attempt: attempt,
|
|
1707
|
+
httpStatus: response.status,
|
|
1708
|
+
ok: response.ok,
|
|
1709
|
+
elapsedMs: Date.now() - startedAt
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
return [
|
|
1713
|
+
2,
|
|
1714
|
+
response
|
|
1715
|
+
];
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
})();
|
|
1525
1719
|
};
|
|
1526
1720
|
_state.label = 1;
|
|
1527
1721
|
case 1:
|
|
@@ -1578,7 +1772,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1578
1772
|
];
|
|
1579
1773
|
case 8:
|
|
1580
1774
|
if (!response.ok) {
|
|
1581
|
-
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
1775
|
+
throw new Error("Failed to fetch VAST: HTTP ".concat(response.status, " ").concat(response.statusText));
|
|
1582
1776
|
}
|
|
1583
1777
|
return [
|
|
1584
1778
|
4,
|
|
@@ -1593,7 +1787,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1593
1787
|
error1 = _state.sent();
|
|
1594
1788
|
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1595
1789
|
if (pendingRequestAbortReason) {
|
|
1596
|
-
throw new Error("".concat(pendingRequestAbortReason, "
|
|
1790
|
+
throw new Error("".concat(pendingRequestAbortReason, ": ").concat(vastTagUrl));
|
|
1597
1791
|
}
|
|
1598
1792
|
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1599
1793
|
}
|
|
@@ -1637,7 +1831,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1637
1831
|
]);
|
|
1638
1832
|
return [
|
|
1639
1833
|
4,
|
|
1640
|
-
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit")
|
|
1834
|
+
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit", depth === 0 ? "gam" : "wrapper")
|
|
1641
1835
|
];
|
|
1642
1836
|
case 2:
|
|
1643
1837
|
vastXml = _state.sent();
|
|
@@ -1722,10 +1916,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1722
1916
|
}
|
|
1723
1917
|
function fetchAndParsePod(vastTagUrl) {
|
|
1724
1918
|
return _async_to_generator(function() {
|
|
1725
|
-
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements,
|
|
1919
|
+
var _root_getAttribute, _root_getAttribute1, vastXml, trimmedXml, xmlDoc, root, adElements, _root_getAttribute2, _empty_errorUrls, empty, _empty_errorCode, resolveAd, podElements, buffet, resolveAll, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, ad, err, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, ad1, err;
|
|
1726
1920
|
return _ts_generator(this, function(_state) {
|
|
1727
1921
|
switch(_state.label){
|
|
1728
1922
|
case 0:
|
|
1923
|
+
lastPodAdElementCount = 0;
|
|
1729
1924
|
return [
|
|
1730
1925
|
4,
|
|
1731
1926
|
fetchVastXml(vastTagUrl)
|
|
@@ -1740,6 +1935,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1740
1935
|
trimmedXml = vastXml.trim();
|
|
1741
1936
|
if (trimmedXml.length === 0) {
|
|
1742
1937
|
console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
|
|
1938
|
+
logFunnel("vast_parsed", {
|
|
1939
|
+
adElementCount: 0,
|
|
1940
|
+
reason: "empty_body"
|
|
1941
|
+
});
|
|
1743
1942
|
return [
|
|
1744
1943
|
2,
|
|
1745
1944
|
[]
|
|
@@ -1748,6 +1947,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1748
1947
|
xmlDoc = parseXml(vastXml);
|
|
1749
1948
|
if (!xmlDoc) {
|
|
1750
1949
|
console.error("[HlsAdPlayer] Pod VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1950
|
+
logFunnel("vast_parsed", {
|
|
1951
|
+
adElementCount: 0,
|
|
1952
|
+
reason: "xml_parse_error"
|
|
1953
|
+
});
|
|
1751
1954
|
return [
|
|
1752
1955
|
2,
|
|
1753
1956
|
[]
|
|
@@ -1755,10 +1958,21 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1755
1958
|
}
|
|
1756
1959
|
root = xmlDoc.documentElement;
|
|
1757
1960
|
adElements = Array.from(root.querySelectorAll(":scope > Ad"));
|
|
1961
|
+
logFunnel("vast_parsed", {
|
|
1962
|
+
reason: adElements.length > 0 ? "has_ads" : "no_ads",
|
|
1963
|
+
vastVersion: (_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : void 0,
|
|
1964
|
+
adElementCount: adElements.length,
|
|
1965
|
+
inlineCount: adElements.filter(function(el) {
|
|
1966
|
+
return el.querySelector(":scope > InLine");
|
|
1967
|
+
}).length,
|
|
1968
|
+
wrapperCount: adElements.filter(function(el) {
|
|
1969
|
+
return el.querySelector(":scope > Wrapper");
|
|
1970
|
+
}).length
|
|
1971
|
+
});
|
|
1758
1972
|
if (adElements.length === 0) {
|
|
1759
1973
|
;
|
|
1760
1974
|
;
|
|
1761
|
-
console.warn("[HlsAdPlayer] No <Ad> elements in VAST ".concat((
|
|
1975
|
+
console.warn("[HlsAdPlayer] No <Ad> elements in VAST ".concat((_root_getAttribute2 = root.getAttribute("version")) !== null && _root_getAttribute2 !== void 0 ? _root_getAttribute2 : "", " pod response (no fill)"));
|
|
1762
1976
|
empty = emptyVastResult(root);
|
|
1763
1977
|
if (empty.type === "empty" && ((_empty_errorUrls = empty.errorUrls) === null || _empty_errorUrls === void 0 ? void 0 : _empty_errorUrls.length)) {
|
|
1764
1978
|
;
|
|
@@ -1776,10 +1990,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1776
1990
|
var _parsed_errorUrls, parsed, _parsed_errorCode;
|
|
1777
1991
|
return _ts_generator(this, function(_state) {
|
|
1778
1992
|
parsed = parseAdElement(adElement);
|
|
1779
|
-
if (parsed.type === "inline")
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1993
|
+
if (parsed.type === "inline") {
|
|
1994
|
+
logFunnel("inline_resolved", {
|
|
1995
|
+
depth: 0
|
|
1996
|
+
});
|
|
1997
|
+
return [
|
|
1998
|
+
2,
|
|
1999
|
+
parsed.ad
|
|
2000
|
+
];
|
|
2001
|
+
}
|
|
1783
2002
|
if (parsed.type === "wrapper") {
|
|
1784
2003
|
return [
|
|
1785
2004
|
2,
|
|
@@ -1957,7 +2176,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1957
2176
|
7
|
|
1958
2177
|
];
|
|
1959
2178
|
case 21:
|
|
1960
|
-
console.log("[HlsAdPlayer] Parsed ".concat(ads.length, " ad(s) from VAST ").concat((
|
|
2179
|
+
console.log("[HlsAdPlayer] Parsed ".concat(ads.length, " ad(s) from VAST ").concat((_root_getAttribute1 = root.getAttribute("version")) !== null && _root_getAttribute1 !== void 0 ? _root_getAttribute1 : "", " pod response"));
|
|
2180
|
+
lastPodAdElementCount = adElements.length;
|
|
1961
2181
|
return [
|
|
1962
2182
|
2,
|
|
1963
2183
|
ads
|
|
@@ -3027,6 +3247,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
3027
3247
|
if (!ads.length && pendingRequestAbortReason) {
|
|
3028
3248
|
throw new Error(pendingRequestAbortReason);
|
|
3029
3249
|
}
|
|
3250
|
+
if (!ads.length && lastPodAdElementCount > 0) {
|
|
3251
|
+
console.warn("[HlsAdPlayer] VAST response had ads but none were playable");
|
|
3252
|
+
logFunnel("vast_fill_rejected", {
|
|
3253
|
+
adElementCount: lastPodAdElementCount
|
|
3254
|
+
});
|
|
3255
|
+
emit("ad_error");
|
|
3256
|
+
return [
|
|
3257
|
+
2,
|
|
3258
|
+
Promise.reject(new Error("VAST fill rejected: no playable ad in response"))
|
|
3259
|
+
];
|
|
3260
|
+
}
|
|
3030
3261
|
if (!ads.length) {
|
|
3031
3262
|
console.warn("[HlsAdPlayer] No ads available from VAST response");
|
|
3032
3263
|
logFunnel("no_fill");
|
|
@@ -5460,6 +5691,21 @@ function normalizeVastTagUrl(raw) {
|
|
|
5460
5691
|
return raw;
|
|
5461
5692
|
}
|
|
5462
5693
|
}
|
|
5694
|
+
var GAM_AD_HOSTS = /* @__PURE__ */ new Set([
|
|
5695
|
+
"pubads.g.doubleclick.net",
|
|
5696
|
+
"securepubads.g.doubleclick.net"
|
|
5697
|
+
]);
|
|
5698
|
+
function ensureVideoAdType(rawUrl) {
|
|
5699
|
+
try {
|
|
5700
|
+
var url = new URL(rawUrl);
|
|
5701
|
+
if (!GAM_AD_HOSTS.has(url.hostname)) return rawUrl;
|
|
5702
|
+
if (url.searchParams.has("ad_type")) return rawUrl;
|
|
5703
|
+
url.searchParams.set("ad_type", "video");
|
|
5704
|
+
return url.toString();
|
|
5705
|
+
} catch (unused) {
|
|
5706
|
+
return rawUrl;
|
|
5707
|
+
}
|
|
5708
|
+
}
|
|
5463
5709
|
function applyVastMacros(baseUrl, ctx) {
|
|
5464
5710
|
var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
|
|
5465
5711
|
var url;
|
|
@@ -7170,7 +7416,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
7170
7416
|
} : {}), {
|
|
7171
7417
|
consent: this.consentSignals
|
|
7172
7418
|
}));
|
|
7173
|
-
var finalUrl = palNonce.injectNonce(urlWithMacros);
|
|
7419
|
+
var finalUrl = palNonce.injectNonce(ensureVideoAdType(urlWithMacros));
|
|
7174
7420
|
console.log("[StormcloudVideoPlayer] Resolved optimized-pod request URL (pod=".concat(this.podCounter, ", pmad=").concat(podParams.maxAds, ", pmnd=").concat(podParams.minDurationMs, ", pmxd=").concat((_podParams_maxDurationMs = podParams.maxDurationMs) !== null && _podParams_maxDurationMs !== void 0 ? _podParams_maxDurationMs : "?", "):"), finalUrl);
|
|
7175
7421
|
return finalUrl;
|
|
7176
7422
|
}
|
|
@@ -8659,6 +8905,18 @@ function resizePlayer(video, adPlayer, debug) {
|
|
|
8659
8905
|
}
|
|
8660
8906
|
}
|
|
8661
8907
|
// src/player/AdBreakOrchestrator.ts
|
|
8908
|
+
var REQUEST_FAILURE_STAGES = /* @__PURE__ */ new Set([
|
|
8909
|
+
"no_fill",
|
|
8910
|
+
"vast_fill_rejected",
|
|
8911
|
+
"request_failed",
|
|
8912
|
+
"media_unsupported",
|
|
8913
|
+
"play_failed",
|
|
8914
|
+
"play_resolved_but_never_started",
|
|
8915
|
+
"hls_fatal",
|
|
8916
|
+
"media_error",
|
|
8917
|
+
"stall",
|
|
8918
|
+
"decode_failure"
|
|
8919
|
+
]);
|
|
8662
8920
|
var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
8663
8921
|
function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
|
|
8664
8922
|
_class_call_check(this, AdBreakOrchestrator);
|
|
@@ -8666,15 +8924,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8666
8924
|
this.showAds = false;
|
|
8667
8925
|
this.isShowingPlaceholder = false;
|
|
8668
8926
|
this.adDetectSentForCurrentBreak = false;
|
|
8669
|
-
this.
|
|
8670
|
-
this.
|
|
8927
|
+
this.slotState = "IDLE";
|
|
8928
|
+
this.unusableResponsesInBreak = 0;
|
|
8929
|
+
this.controllerGeneration = 0;
|
|
8930
|
+
this.requestDiagnostics = /* @__PURE__ */ new Map();
|
|
8671
8931
|
this.breakFunnel = {};
|
|
8672
8932
|
this.controllerCallInFlight = false;
|
|
8673
8933
|
this.playbackStartedForCurrentRequest = false;
|
|
8674
8934
|
this.opportunityEpoch = -1;
|
|
8675
|
-
this.adRequestQueue = [];
|
|
8676
8935
|
this.adPodQueue = [];
|
|
8677
|
-
this.
|
|
8936
|
+
this.defaultMinRemainingMsToRequestAd = 1e4;
|
|
8937
|
+
this.defaultMaxNoFillsPerBreak = 2;
|
|
8678
8938
|
this.pendingAdBreak = null;
|
|
8679
8939
|
this.host = host;
|
|
8680
8940
|
this.timing = timing;
|
|
@@ -8710,7 +8970,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8710
8970
|
key: "attachImaEventListeners",
|
|
8711
8971
|
value: function attachImaEventListeners() {
|
|
8712
8972
|
var _this = this;
|
|
8713
|
-
var
|
|
8973
|
+
var controller = this.host.getAdPlayer();
|
|
8974
|
+
var generation = this.controllerGeneration;
|
|
8975
|
+
var adPlayer = {
|
|
8976
|
+
on: function on(event, handler) {
|
|
8977
|
+
controller.on(event, function(payload) {
|
|
8978
|
+
if (generation !== _this.controllerGeneration) {
|
|
8979
|
+
_this.logOrchestratorFunnel("stale_callback_ignored", {
|
|
8980
|
+
event: event,
|
|
8981
|
+
staleControllerId: generation,
|
|
8982
|
+
currentControllerId: _this.controllerGeneration
|
|
8983
|
+
});
|
|
8984
|
+
return;
|
|
8985
|
+
}
|
|
8986
|
+
handler(payload);
|
|
8987
|
+
});
|
|
8988
|
+
}
|
|
8989
|
+
};
|
|
8714
8990
|
adPlayer.on("pod_ad_started", function(payload) {
|
|
8715
8991
|
_this.timing.notePodAdStarted();
|
|
8716
8992
|
if (_this.debug) {
|
|
@@ -8726,19 +9002,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8726
9002
|
});
|
|
8727
9003
|
adPlayer.on("ad_funnel", function(payload) {
|
|
8728
9004
|
if (!(payload === null || payload === void 0 ? void 0 : payload.stage)) return;
|
|
8729
|
-
|
|
9005
|
+
var stage = payload.stage;
|
|
9006
|
+
_this.countFunnelStage(stage);
|
|
8730
9007
|
if (payload.reason) {
|
|
8731
|
-
_this.countFunnelStage("".concat(
|
|
9008
|
+
_this.countFunnelStage("".concat(stage, ":").concat(payload.reason));
|
|
8732
9009
|
}
|
|
8733
|
-
if (
|
|
9010
|
+
if (stage === "impression_fired" && payload.pixelCount != null) {
|
|
8734
9011
|
_this.countFunnelStage("impression_urls", payload.pixelCount);
|
|
8735
9012
|
}
|
|
8736
9013
|
if (payload.visibilityState === "hidden") {
|
|
8737
9014
|
_this.countFunnelStage("while_hidden");
|
|
8738
9015
|
}
|
|
9016
|
+
if (stage === "gam_http_request_sent") {
|
|
9017
|
+
if (payload.attempt === 1) {
|
|
9018
|
+
_this.timing.noteAdRequestSent();
|
|
9019
|
+
} else {
|
|
9020
|
+
_this.countFunnelStage("gam_http_request_retry");
|
|
9021
|
+
}
|
|
9022
|
+
}
|
|
9023
|
+
_this.recordRequestDiagnostic(payload);
|
|
8739
9024
|
});
|
|
8740
9025
|
adPlayer.on("ad_impression", function() {
|
|
8741
9026
|
_this.timing.consecutiveFailures = 0;
|
|
9027
|
+
_this.setSlotState("PLAYING", "impression");
|
|
8742
9028
|
if (!_this.playbackStartedForCurrentRequest) {
|
|
8743
9029
|
_this.playbackStartedForCurrentRequest = true;
|
|
8744
9030
|
_this.timing.markAdStarted();
|
|
@@ -8757,16 +9043,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8757
9043
|
var remaining = _this.timing.getRemainingAdMs();
|
|
8758
9044
|
_this.timing.consecutiveFailures = 0;
|
|
8759
9045
|
if (_this.debug) {
|
|
8760
|
-
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms
|
|
8761
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
8762
|
-
} : {});
|
|
9046
|
+
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms"));
|
|
8763
9047
|
}
|
|
8764
9048
|
if (_this.inAdBreak) {
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
} else {
|
|
8768
|
-
_this.handleAdPodComplete();
|
|
8769
|
-
}
|
|
9049
|
+
_this.setSlotState("NEEDS_NEXT_AD", "all_ads_completed");
|
|
9050
|
+
_this.requestNextAd("all_ads_completed");
|
|
8770
9051
|
}
|
|
8771
9052
|
});
|
|
8772
9053
|
adPlayer.on("ad_error", function(errorPayload) {
|
|
@@ -8787,10 +9068,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8787
9068
|
}
|
|
8788
9069
|
console.error("[AD-ERROR]", errorMessage, errorPayload || "");
|
|
8789
9070
|
if (_this.controllerCallInFlight) {
|
|
8790
|
-
_this.timing.recordGamNoFill();
|
|
8791
9071
|
return;
|
|
8792
9072
|
}
|
|
8793
|
-
_this.handleAdFailure();
|
|
9073
|
+
_this.handleAdFailure("ad_error");
|
|
8794
9074
|
});
|
|
8795
9075
|
adPlayer.on("content_pause", function() {
|
|
8796
9076
|
_this.timing.clearAdFailsafeTimer();
|
|
@@ -8829,26 +9109,32 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8829
9109
|
}
|
|
8830
9110
|
_this.timing.consecutiveFailures = 0;
|
|
8831
9111
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
8832
|
-
var remaining = _this.timing.getRemainingAdMs();
|
|
8833
9112
|
if (_this.debug) {
|
|
8834
|
-
console.log("[
|
|
8835
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
8836
|
-
} : {});
|
|
8837
|
-
}
|
|
8838
|
-
if (_this.timing.hasTimeToStartAnotherAd()) {
|
|
8839
|
-
_this.tryNextAvailableAdWithRateLimit();
|
|
8840
|
-
} else {
|
|
8841
|
-
_this.handleAdPodComplete();
|
|
9113
|
+
console.log("[AdBreak] content_resume: remaining=".concat(_this.timing.getRemainingAdMs(), "ms"));
|
|
8842
9114
|
}
|
|
9115
|
+
_this.setSlotState("NEEDS_NEXT_AD", "ad_complete");
|
|
9116
|
+
_this.requestNextAd("ad_complete");
|
|
8843
9117
|
});
|
|
8844
9118
|
}
|
|
8845
9119
|
},
|
|
8846
9120
|
{
|
|
8847
9121
|
key: "recreateAdController",
|
|
8848
|
-
value: function recreateAdController() {
|
|
8849
|
-
if (this.
|
|
8850
|
-
console.
|
|
9122
|
+
value: function recreateAdController(reason) {
|
|
9123
|
+
if (reason === "new_request" && (this.slotState === "REQUESTING" || this.slotState === "READY")) {
|
|
9124
|
+
console.warn("[AD-CONTROLLER] destroy during active request", {
|
|
9125
|
+
controllerId: this.controllerGeneration,
|
|
9126
|
+
requestId: this.currentRequestId,
|
|
9127
|
+
state: this.slotState,
|
|
9128
|
+
reason: reason
|
|
9129
|
+
});
|
|
8851
9130
|
}
|
|
9131
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
9132
|
+
controllerId: this.controllerGeneration,
|
|
9133
|
+
requestId: this.currentRequestId,
|
|
9134
|
+
state: this.slotState,
|
|
9135
|
+
reason: reason
|
|
9136
|
+
});
|
|
9137
|
+
this.countFunnelStage("controller_destroy:".concat(reason));
|
|
8852
9138
|
var shouldShowPlaceholder = this.inAdBreak && this.showAds;
|
|
8853
9139
|
var adPlayer = this.host.getAdPlayer();
|
|
8854
9140
|
if (shouldShowPlaceholder && adPlayer) {
|
|
@@ -8875,9 +9161,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8875
9161
|
var continueLiveStreamDuringAds = this.host.shouldContinueLiveStreamDuringAds();
|
|
8876
9162
|
var newAdPlayer = this.host.createAdPlayer(continueLiveStreamDuringAds);
|
|
8877
9163
|
this.host.setAdPlayer(newAdPlayer);
|
|
9164
|
+
this.controllerGeneration++;
|
|
8878
9165
|
newAdPlayer.initialize();
|
|
8879
9166
|
newAdPlayer.updateOriginalMutedState(preservedMutedState, preservedVolumeState);
|
|
8880
9167
|
this.attachImaEventListeners();
|
|
9168
|
+
if (this.debug) {
|
|
9169
|
+
console.log("[AD-CONTROLLER] create", {
|
|
9170
|
+
controllerId: this.controllerGeneration,
|
|
9171
|
+
reason: reason
|
|
9172
|
+
});
|
|
9173
|
+
}
|
|
8881
9174
|
if (shouldShowPlaceholder) {
|
|
8882
9175
|
this.placeholder.show();
|
|
8883
9176
|
newAdPlayer.showPlaceholder();
|
|
@@ -8898,32 +9191,57 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8898
9191
|
}
|
|
8899
9192
|
},
|
|
8900
9193
|
{
|
|
8901
|
-
|
|
8902
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9194
|
+
// ───────────────────────────────────────────────────────────────
|
|
8903
9195
|
// Ad break start
|
|
8904
9196
|
// ───────────────────────────────────────────────────────────────
|
|
8905
|
-
|
|
9197
|
+
key: "isBreakActive",
|
|
9198
|
+
value: function isBreakActive() {
|
|
9199
|
+
return this.slotState !== "IDLE";
|
|
9200
|
+
}
|
|
9201
|
+
},
|
|
9202
|
+
{
|
|
9203
|
+
key: "getSlotState",
|
|
9204
|
+
value: function getSlotState() {
|
|
9205
|
+
return this.slotState;
|
|
9206
|
+
}
|
|
9207
|
+
},
|
|
9208
|
+
{
|
|
9209
|
+
key: "beginVmapBreak",
|
|
9210
|
+
value: function beginVmapBreak(breakKey) {
|
|
9211
|
+
this.breakSource = "vmap";
|
|
9212
|
+
this.followUpBaseVastUrl = void 0;
|
|
9213
|
+
this.unusableResponsesInBreak = 0;
|
|
9214
|
+
this.timing.totalAdRequestsInBreak = 0;
|
|
9215
|
+
this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
|
|
9216
|
+
this.noteOpportunity("vmap", breakKey);
|
|
9217
|
+
}
|
|
9218
|
+
},
|
|
9219
|
+
{
|
|
9220
|
+
key: "handleAdStart",
|
|
9221
|
+
value: function handleAdStart(marker) {
|
|
8906
9222
|
return _async_to_generator(function() {
|
|
8907
|
-
var
|
|
9223
|
+
var baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, epoch, podPlayed;
|
|
8908
9224
|
return _ts_generator(this, function(_state) {
|
|
8909
9225
|
switch(_state.label){
|
|
8910
9226
|
case 0:
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
9227
|
+
if (this.slotState !== "IDLE") {
|
|
9228
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
9229
|
+
source: "scte35",
|
|
9230
|
+
state: this.slotState
|
|
9231
|
+
});
|
|
9232
|
+
return [
|
|
9233
|
+
2
|
|
9234
|
+
];
|
|
8914
9235
|
}
|
|
8915
|
-
|
|
8916
|
-
if (
|
|
8917
|
-
|
|
8918
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
8919
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
8920
|
-
} else {
|
|
9236
|
+
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
9237
|
+
if (!baseVastUrl) {
|
|
9238
|
+
console.warn("[AdBreak] SCTE-35 break started but no direct VAST tag is configured");
|
|
8921
9239
|
this.clearPendingAdBreak();
|
|
8922
9240
|
return [
|
|
8923
9241
|
2
|
|
8924
9242
|
];
|
|
8925
9243
|
}
|
|
8926
|
-
adBreakDurationMs =
|
|
9244
|
+
adBreakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : this.timing.expectedAdBreakDurationMs;
|
|
8927
9245
|
if (this.debug) {
|
|
8928
9246
|
mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
|
|
8929
9247
|
console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
@@ -8931,9 +9249,12 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8931
9249
|
this.timing.failedVastUrls.clear();
|
|
8932
9250
|
this.timing.temporaryFailureUrls.clear();
|
|
8933
9251
|
this.timing.consecutiveFailures = 0;
|
|
8934
|
-
this.continuousFetchingActive = true;
|
|
8935
9252
|
this.isShowingPlaceholder = false;
|
|
8936
9253
|
this.timing.totalAdRequestsInBreak = 0;
|
|
9254
|
+
this.breakSource = "scte35";
|
|
9255
|
+
this.followUpBaseVastUrl = baseVastUrl;
|
|
9256
|
+
this.unusableResponsesInBreak = 0;
|
|
9257
|
+
this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
|
|
8937
9258
|
if (this.adConfig.podAssignedByPrefetch) {
|
|
8938
9259
|
this.adConfig.podAssignedByPrefetch = false;
|
|
8939
9260
|
} else {
|
|
@@ -8952,29 +9273,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8952
9273
|
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
8953
9274
|
}
|
|
8954
9275
|
this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
|
|
9276
|
+
epoch = this.timing.adBreakEpoch;
|
|
8955
9277
|
return [
|
|
8956
9278
|
4,
|
|
8957
9279
|
this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
|
|
8958
9280
|
];
|
|
8959
9281
|
case 1:
|
|
8960
9282
|
podPlayed = _state.sent();
|
|
8961
|
-
if (
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
];
|
|
8965
|
-
if (this.debug) {
|
|
8966
|
-
console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
|
|
9283
|
+
if (!podPlayed && this.inAdBreak && epoch === this.timing.adBreakEpoch) {
|
|
9284
|
+
this.setSlotState("NEEDS_NEXT_AD", "initial_request_failed");
|
|
9285
|
+
this.requestNextAd("initial_request_failed");
|
|
8967
9286
|
}
|
|
8968
|
-
this.continuousFetchingActive = true;
|
|
8969
|
-
this.startContinuousFetching(baseVastUrl);
|
|
8970
|
-
return [
|
|
8971
|
-
4,
|
|
8972
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
8973
|
-
];
|
|
8974
|
-
case 2:
|
|
8975
|
-
_state.sent();
|
|
8976
|
-
_state.label = 3;
|
|
8977
|
-
case 3:
|
|
8978
9287
|
return [
|
|
8979
9288
|
2
|
|
8980
9289
|
];
|
|
@@ -8990,10 +9299,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8990
9299
|
// ───────────────────────────────────────────────────────────────
|
|
8991
9300
|
function startOptimizedPod(baseVastUrl, breakDurationMs) {
|
|
8992
9301
|
return _async_to_generator(function() {
|
|
8993
|
-
var podUrl, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
9302
|
+
var podUrl, prefetched, epoch, generation, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
8994
9303
|
return _ts_generator(this, function(_state) {
|
|
8995
9304
|
switch(_state.label){
|
|
8996
9305
|
case 0:
|
|
9306
|
+
prefetched = !!(this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0);
|
|
8997
9307
|
if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
|
|
8998
9308
|
podUrl = this.pendingAdBreak.vastUrls[0];
|
|
8999
9309
|
this.clearPendingAdBreak();
|
|
@@ -9006,12 +9316,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9006
9316
|
false
|
|
9007
9317
|
];
|
|
9008
9318
|
}
|
|
9009
|
-
this.
|
|
9010
|
-
this.
|
|
9319
|
+
this.noteVastUrlGenerated(podUrl, prefetched ? "prefetch" : "break_start");
|
|
9320
|
+
epoch = this.timing.adBreakEpoch;
|
|
9321
|
+
this.recreateAdController("new_request");
|
|
9322
|
+
generation = this.controllerGeneration;
|
|
9011
9323
|
adPlayer = this.host.getAdPlayer();
|
|
9012
9324
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
9013
9325
|
this.timing.activeAdRequestToken = requestToken;
|
|
9014
9326
|
this.currentVastUrl = podUrl;
|
|
9327
|
+
this.setSlotState("REQUESTING", "initial_pod");
|
|
9328
|
+
this.beginFunnelRequest(adPlayer, requestToken, "initial_pod");
|
|
9015
9329
|
_state.label = 1;
|
|
9016
9330
|
case 1:
|
|
9017
9331
|
_state.trys.push([
|
|
@@ -9026,9 +9340,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9026
9340
|
];
|
|
9027
9341
|
case 2:
|
|
9028
9342
|
_state.sent();
|
|
9343
|
+
if (this.isStale(epoch, generation)) return [
|
|
9344
|
+
2,
|
|
9345
|
+
true
|
|
9346
|
+
];
|
|
9029
9347
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
9030
|
-
this.timing.noteAdRequestSent();
|
|
9031
|
-
this.beginFunnelRequest(adPlayer, requestToken);
|
|
9032
9348
|
return [
|
|
9033
9349
|
4,
|
|
9034
9350
|
this.callController(function() {
|
|
@@ -9038,7 +9354,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9038
9354
|
case 3:
|
|
9039
9355
|
_state.sent();
|
|
9040
9356
|
this.timing.clearAdRequestWatchdog();
|
|
9041
|
-
if (this.
|
|
9357
|
+
if (this.isStale(epoch, generation)) {
|
|
9358
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9359
|
+
requestId: requestToken
|
|
9360
|
+
});
|
|
9042
9361
|
return [
|
|
9043
9362
|
2,
|
|
9044
9363
|
true
|
|
@@ -9046,11 +9365,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9046
9365
|
}
|
|
9047
9366
|
podCount = (_ref = (_adPlayer_getPodAdCount = adPlayer.getPodAdCount) === null || _adPlayer_getPodAdCount === void 0 ? void 0 : _adPlayer_getPodAdCount.call(adPlayer)) !== null && _ref !== void 0 ? _ref : 1;
|
|
9048
9367
|
if (podCount < 1) {
|
|
9368
|
+
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9369
|
+
this.timing.activeAdRequestToken = null;
|
|
9370
|
+
}
|
|
9371
|
+
this.recordRequestFailure(new Error("No ads available"), podUrl);
|
|
9049
9372
|
return [
|
|
9050
9373
|
2,
|
|
9051
9374
|
false
|
|
9052
9375
|
];
|
|
9053
9376
|
}
|
|
9377
|
+
this.setSlotState("READY", "vast_ready");
|
|
9054
9378
|
if (this.debug) {
|
|
9055
9379
|
console.log(podCount === 1 ? "[POD] Response contained a single ad; playing it and enabling pod top-up" : "[POD] Optimized pod returned ".concat(podCount, " ads; playing pod in one controller"));
|
|
9056
9380
|
}
|
|
@@ -9068,12 +9392,14 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9068
9392
|
];
|
|
9069
9393
|
case 4:
|
|
9070
9394
|
_state.sent();
|
|
9395
|
+
if (this.isStale(epoch, generation)) return [
|
|
9396
|
+
2,
|
|
9397
|
+
true
|
|
9398
|
+
];
|
|
9071
9399
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
9072
9400
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
9073
9401
|
}
|
|
9074
9402
|
adPlayer.setAdVolume(getAdAudioVolume(adPlayer));
|
|
9075
|
-
this.continuousFetchingActive = true;
|
|
9076
|
-
this.startContinuousFetching(baseVastUrl);
|
|
9077
9403
|
return [
|
|
9078
9404
|
2,
|
|
9079
9405
|
true
|
|
@@ -9085,14 +9411,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9085
9411
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9086
9412
|
this.timing.activeAdRequestToken = null;
|
|
9087
9413
|
}
|
|
9414
|
+
if (this.isStale(epoch, generation)) {
|
|
9415
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9416
|
+
requestId: requestToken,
|
|
9417
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
9418
|
+
});
|
|
9419
|
+
return [
|
|
9420
|
+
2,
|
|
9421
|
+
true
|
|
9422
|
+
];
|
|
9423
|
+
}
|
|
9088
9424
|
if (this.debug) {
|
|
9089
9425
|
console.warn("[POD] Optimized pod request/play failed:", error);
|
|
9090
9426
|
}
|
|
9091
|
-
|
|
9092
|
-
this.timing.temporaryFailureUrls.set(podUrl, Date.now());
|
|
9093
|
-
}
|
|
9094
|
-
this.continuousFetchingActive = true;
|
|
9095
|
-
this.recreateAdController();
|
|
9427
|
+
this.recordRequestFailure(error, podUrl);
|
|
9096
9428
|
return [
|
|
9097
9429
|
2,
|
|
9098
9430
|
false
|
|
@@ -9108,168 +9440,204 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9108
9440
|
},
|
|
9109
9441
|
{
|
|
9110
9442
|
// ───────────────────────────────────────────────────────────────
|
|
9111
|
-
//
|
|
9443
|
+
// Next-ad scheduling (single flight)
|
|
9112
9444
|
// ───────────────────────────────────────────────────────────────
|
|
9113
|
-
key: "
|
|
9114
|
-
value: function
|
|
9115
|
-
if (
|
|
9445
|
+
key: "setSlotState",
|
|
9446
|
+
value: function setSlotState(next, reason) {
|
|
9447
|
+
if (this.slotState === next) return;
|
|
9448
|
+
var previous = this.slotState;
|
|
9449
|
+
this.slotState = next;
|
|
9450
|
+
if (this.debug) {
|
|
9451
|
+
console.log("[AdBreak][STATE] ".concat(previous, " -> ").concat(next), {
|
|
9452
|
+
reason: reason,
|
|
9453
|
+
breakId: this.timing.adBreakEpoch,
|
|
9454
|
+
requestId: this.currentRequestId,
|
|
9455
|
+
controllerId: this.controllerGeneration
|
|
9456
|
+
});
|
|
9457
|
+
}
|
|
9458
|
+
}
|
|
9459
|
+
},
|
|
9460
|
+
{
|
|
9461
|
+
key: "isStale",
|
|
9462
|
+
value: function isStale(epoch, generation) {
|
|
9463
|
+
return !this.inAdBreak || epoch !== this.timing.adBreakEpoch || generation !== this.controllerGeneration;
|
|
9464
|
+
}
|
|
9465
|
+
},
|
|
9466
|
+
{
|
|
9467
|
+
key: "getMinRemainingMsToRequestAd",
|
|
9468
|
+
value: function getMinRemainingMsToRequestAd() {
|
|
9469
|
+
var configured = this.host.config.minRemainingMsToRequestAd;
|
|
9470
|
+
var floor = this.timing.getMinRemainingMsToStartAd();
|
|
9471
|
+
if (typeof configured === "number" && configured >= 0) {
|
|
9472
|
+
return Math.max(configured, floor);
|
|
9473
|
+
}
|
|
9474
|
+
return Math.max(this.defaultMinRemainingMsToRequestAd, floor);
|
|
9475
|
+
}
|
|
9476
|
+
},
|
|
9477
|
+
{
|
|
9478
|
+
key: "getMaxNoFillsPerBreak",
|
|
9479
|
+
value: function getMaxNoFillsPerBreak() {
|
|
9480
|
+
var configured = this.host.config.maxNoFillsPerBreak;
|
|
9481
|
+
return typeof configured === "number" && configured > 0 ? configured : this.defaultMaxNoFillsPerBreak;
|
|
9482
|
+
}
|
|
9483
|
+
},
|
|
9484
|
+
{
|
|
9485
|
+
key: "isBreakTimeBounded",
|
|
9486
|
+
value: function isBreakTimeBounded() {
|
|
9487
|
+
return this.breakSource === "scte35" || this.timing.expectedAdBreakDurationMs != null;
|
|
9488
|
+
}
|
|
9489
|
+
},
|
|
9490
|
+
{
|
|
9491
|
+
key: "getStopRequestingReason",
|
|
9492
|
+
value: function getStopRequestingReason(remainingMs) {
|
|
9493
|
+
if (this.breakSource === "vmap") {
|
|
9494
|
+
if (this.adPodQueue.length === 0) return "vmap_queue_empty";
|
|
9495
|
+
} else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl) {
|
|
9496
|
+
return "no_follow_up_source";
|
|
9497
|
+
}
|
|
9498
|
+
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9499
|
+
return "max_consecutive_failures";
|
|
9500
|
+
}
|
|
9501
|
+
if (this.unusableResponsesInBreak >= this.getMaxNoFillsPerBreak()) {
|
|
9502
|
+
return "unusable_response_limit";
|
|
9503
|
+
}
|
|
9504
|
+
if (this.timing.totalAdRequestsInBreak >= this.timing.maxTotalAdRequestsPerBreak) {
|
|
9505
|
+
return "request_cap";
|
|
9506
|
+
}
|
|
9507
|
+
if (this.timing.isGamInCooldown()) {
|
|
9508
|
+
return "gam_cooldown";
|
|
9509
|
+
}
|
|
9510
|
+
if (this.isBreakTimeBounded() && remainingMs < this.getMinRemainingMsToRequestAd()) {
|
|
9511
|
+
return "insufficient_break_time";
|
|
9512
|
+
}
|
|
9513
|
+
return void 0;
|
|
9514
|
+
}
|
|
9515
|
+
},
|
|
9516
|
+
{
|
|
9517
|
+
key: "getNextRequestDelayMs",
|
|
9518
|
+
value: function getNextRequestDelayMs() {
|
|
9519
|
+
var failures = this.timing.consecutiveFailures;
|
|
9520
|
+
var backoff = failures > 0 ? Math.min(this.timing.backoffBaseMs * Math.pow(2, failures), this.timing.maxBackoffMs) : 0;
|
|
9521
|
+
var minInterval = this.timing.minAdRequestIntervalMs + backoff;
|
|
9522
|
+
var sinceLast = Date.now() - this.timing.lastAdRequestTime;
|
|
9523
|
+
return Math.max(0, minInterval - sinceLast);
|
|
9524
|
+
}
|
|
9525
|
+
},
|
|
9526
|
+
{
|
|
9527
|
+
key: "requestNextAd",
|
|
9528
|
+
value: function requestNextAd(trigger) {
|
|
9529
|
+
var _this = this;
|
|
9530
|
+
if (!this.inAdBreak) return;
|
|
9531
|
+
if (this.slotState !== "NEEDS_NEXT_AD") {
|
|
9532
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9533
|
+
trigger: trigger,
|
|
9534
|
+
state: this.slotState,
|
|
9535
|
+
why: "slot_busy"
|
|
9536
|
+
});
|
|
9116
9537
|
return;
|
|
9117
9538
|
}
|
|
9118
|
-
if (this.
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9539
|
+
if (this.nextAdTimerId != null) {
|
|
9540
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9541
|
+
trigger: trigger,
|
|
9542
|
+
state: this.slotState,
|
|
9543
|
+
why: "request_already_scheduled"
|
|
9544
|
+
});
|
|
9122
9545
|
return;
|
|
9123
9546
|
}
|
|
9124
|
-
|
|
9125
|
-
|
|
9547
|
+
var remainingMs = this.timing.getRemainingAdMs();
|
|
9548
|
+
var stopReason = this.getStopRequestingReason(remainingMs);
|
|
9549
|
+
if (stopReason) {
|
|
9550
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9551
|
+
trigger: trigger,
|
|
9552
|
+
decision: "end_break",
|
|
9553
|
+
reason: stopReason,
|
|
9554
|
+
remainingMs: remainingMs,
|
|
9555
|
+
requestsSent: this.timing.totalAdRequestsInBreak,
|
|
9556
|
+
unusableResponses: this.unusableResponsesInBreak,
|
|
9557
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
9558
|
+
});
|
|
9559
|
+
this.handleAdPodComplete(stopReason);
|
|
9560
|
+
return;
|
|
9126
9561
|
}
|
|
9127
|
-
|
|
9128
|
-
this.
|
|
9562
|
+
var waitMs = this.getNextRequestDelayMs();
|
|
9563
|
+
if (waitMs > 0 && this.isBreakTimeBounded() && remainingMs - waitMs < this.getMinRemainingMsToRequestAd()) {
|
|
9564
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9565
|
+
trigger: trigger,
|
|
9566
|
+
decision: "end_break",
|
|
9567
|
+
reason: "insufficient_break_time_after_backoff",
|
|
9568
|
+
remainingMs: remainingMs,
|
|
9569
|
+
waitMs: waitMs
|
|
9570
|
+
});
|
|
9571
|
+
this.handleAdPodComplete("insufficient_break_time_after_backoff");
|
|
9572
|
+
return;
|
|
9573
|
+
}
|
|
9574
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9575
|
+
trigger: trigger,
|
|
9576
|
+
decision: waitMs > 0 ? "request_after_delay" : "request_now",
|
|
9577
|
+
waitMs: waitMs,
|
|
9578
|
+
remainingMs: remainingMs,
|
|
9579
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
9580
|
+
});
|
|
9581
|
+
if (waitMs > 0) {
|
|
9582
|
+
if (!this.isShowingPlaceholder) {
|
|
9583
|
+
this.isShowingPlaceholder = true;
|
|
9584
|
+
this.host.getAdPlayer().showPlaceholder();
|
|
9585
|
+
}
|
|
9586
|
+
var epoch = this.timing.adBreakEpoch;
|
|
9587
|
+
this.nextAdTimerId = window.setTimeout(function() {
|
|
9588
|
+
_this.nextAdTimerId = void 0;
|
|
9589
|
+
if (!_this.inAdBreak || epoch !== _this.timing.adBreakEpoch) return;
|
|
9590
|
+
_this.requestNextAd("".concat(trigger, ":after_delay"));
|
|
9591
|
+
}, waitMs);
|
|
9592
|
+
return;
|
|
9593
|
+
}
|
|
9594
|
+
void this.requestFollowUpAd(trigger);
|
|
9129
9595
|
}
|
|
9130
9596
|
},
|
|
9131
9597
|
{
|
|
9132
|
-
key: "
|
|
9133
|
-
value: function
|
|
9598
|
+
key: "requestFollowUpAd",
|
|
9599
|
+
value: function requestFollowUpAd(trigger) {
|
|
9134
9600
|
return _async_to_generator(function() {
|
|
9135
|
-
var
|
|
9601
|
+
var url, epoch, unused;
|
|
9136
9602
|
return _ts_generator(this, function(_state) {
|
|
9137
9603
|
switch(_state.label){
|
|
9138
9604
|
case 0:
|
|
9139
|
-
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
|
|
9145
|
-
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
}
|
|
9149
|
-
return [
|
|
9150
|
-
2,
|
|
9151
|
-
"break"
|
|
9152
|
-
];
|
|
9153
|
-
}
|
|
9154
|
-
if (_this.timing.isGamInCooldown()) {
|
|
9155
|
-
if (_this.debug) {
|
|
9156
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping URL generation");
|
|
9157
|
-
}
|
|
9158
|
-
return [
|
|
9159
|
-
2,
|
|
9160
|
-
"break"
|
|
9161
|
-
];
|
|
9162
|
-
}
|
|
9163
|
-
if (_this.timing.consecutiveFailures >= _this.timing.maxConsecutiveFailures) {
|
|
9164
|
-
if (_this.debug) {
|
|
9165
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(_this.timing.consecutiveFailures, "), stopping URL generation"));
|
|
9166
|
-
}
|
|
9167
|
-
return [
|
|
9168
|
-
2,
|
|
9169
|
-
"break"
|
|
9170
|
-
];
|
|
9171
|
-
}
|
|
9172
|
-
if (_this.timing.totalAdRequestsInBreak >= _this.timing.maxTotalAdRequestsPerBreak) {
|
|
9173
|
-
if (_this.debug) {
|
|
9174
|
-
console.log("[CONTINUOUS-FETCH] Maximum ad requests reached (".concat(_this.timing.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
9175
|
-
}
|
|
9176
|
-
return [
|
|
9177
|
-
2,
|
|
9178
|
-
"break"
|
|
9179
|
-
];
|
|
9180
|
-
}
|
|
9181
|
-
maxQueueSize = 5;
|
|
9182
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
9183
|
-
3,
|
|
9184
|
-
2
|
|
9185
|
-
];
|
|
9186
|
-
if (_this.debug) {
|
|
9187
|
-
console.log("[CONTINUOUS-FETCH] URL queue full (".concat(_this.adRequestQueue.length, "), waiting..."));
|
|
9188
|
-
}
|
|
9189
|
-
return [
|
|
9190
|
-
4,
|
|
9191
|
-
new Promise(function(resolve) {
|
|
9192
|
-
return setTimeout(resolve, 1e3);
|
|
9193
|
-
})
|
|
9194
|
-
];
|
|
9195
|
-
case 1:
|
|
9196
|
-
_state.sent();
|
|
9197
|
-
return [
|
|
9198
|
-
2,
|
|
9199
|
-
"continue"
|
|
9200
|
-
];
|
|
9201
|
-
case 2:
|
|
9202
|
-
newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
|
|
9203
|
-
if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
|
|
9204
|
-
3,
|
|
9205
|
-
4
|
|
9206
|
-
];
|
|
9207
|
-
return [
|
|
9208
|
-
4,
|
|
9209
|
-
new Promise(function(resolve) {
|
|
9210
|
-
return setTimeout(resolve, 500);
|
|
9211
|
-
})
|
|
9212
|
-
];
|
|
9213
|
-
case 3:
|
|
9214
|
-
_state.sent();
|
|
9215
|
-
return [
|
|
9216
|
-
2,
|
|
9217
|
-
"continue"
|
|
9218
|
-
];
|
|
9219
|
-
case 4:
|
|
9220
|
-
if (_this.debug) {
|
|
9221
|
-
queuedUrlsPreview = _to_consumable_array(_this.adRequestQueue).concat([
|
|
9222
|
-
newAdUrl
|
|
9223
|
-
]);
|
|
9224
|
-
console.log("[CONTINUOUS-FETCH] Queued VAST URL (queue size: ".concat(queuedUrlsPreview.length, ")"), {
|
|
9225
|
-
queuedUrls: queuedUrlsPreview
|
|
9226
|
-
});
|
|
9227
|
-
}
|
|
9228
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
9229
|
-
generationDelay = _this.timing.consecutiveFailures > 0 ? Math.min(1e3 * Math.pow(2, _this.timing.consecutiveFailures), 5e3) : 500;
|
|
9230
|
-
return [
|
|
9231
|
-
4,
|
|
9232
|
-
new Promise(function(resolve) {
|
|
9233
|
-
return setTimeout(resolve, generationDelay);
|
|
9234
|
-
})
|
|
9235
|
-
];
|
|
9236
|
-
case 5:
|
|
9237
|
-
_state.sent();
|
|
9238
|
-
return [
|
|
9239
|
-
2
|
|
9240
|
-
];
|
|
9241
|
-
}
|
|
9242
|
-
});
|
|
9243
|
-
};
|
|
9605
|
+
if (this.breakSource === "vmap") {
|
|
9606
|
+
url = this.adPodQueue.shift();
|
|
9607
|
+
} else if (this.followUpBaseVastUrl) {
|
|
9608
|
+
url = this.nextAdRequestUrl(this.followUpBaseVastUrl);
|
|
9609
|
+
}
|
|
9610
|
+
if (!url) return [
|
|
9611
|
+
2
|
|
9612
|
+
];
|
|
9613
|
+
this.noteVastUrlGenerated(ensureVideoAdType(url), trigger);
|
|
9244
9614
|
epoch = this.timing.adBreakEpoch;
|
|
9245
9615
|
_state.label = 1;
|
|
9246
9616
|
case 1:
|
|
9247
|
-
|
|
9617
|
+
_state.trys.push([
|
|
9618
|
+
1,
|
|
9248
9619
|
3,
|
|
9249
|
-
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
return [
|
|
9253
|
-
|
|
9254
|
-
|
|
9620
|
+
,
|
|
9621
|
+
4
|
|
9622
|
+
]);
|
|
9623
|
+
return [
|
|
9624
|
+
4,
|
|
9625
|
+
this.playSingleAd(url, trigger)
|
|
9255
9626
|
];
|
|
9256
9627
|
case 2:
|
|
9257
|
-
|
|
9258
|
-
|
|
9628
|
+
_state.sent();
|
|
9629
|
+
return [
|
|
9259
9630
|
3,
|
|
9260
|
-
|
|
9631
|
+
4
|
|
9261
9632
|
];
|
|
9633
|
+
case 3:
|
|
9634
|
+
unused = _state.sent();
|
|
9635
|
+
this.continueAfterRequestFailure(epoch);
|
|
9262
9636
|
return [
|
|
9263
9637
|
3,
|
|
9264
|
-
|
|
9638
|
+
4
|
|
9265
9639
|
];
|
|
9266
|
-
case
|
|
9267
|
-
this.continuousFetchLoopRunning = false;
|
|
9268
|
-
if (this.debug) {
|
|
9269
|
-
console.log("[CONTINUOUS-FETCH] URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"), this.adRequestQueue.length > 0 ? {
|
|
9270
|
-
queuedUrls: _to_consumable_array(this.adRequestQueue)
|
|
9271
|
-
} : {});
|
|
9272
|
-
}
|
|
9640
|
+
case 4:
|
|
9273
9641
|
return [
|
|
9274
9642
|
2
|
|
9275
9643
|
];
|
|
@@ -9279,242 +9647,158 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9279
9647
|
}
|
|
9280
9648
|
},
|
|
9281
9649
|
{
|
|
9282
|
-
key: "
|
|
9283
|
-
value: function
|
|
9284
|
-
|
|
9285
|
-
this.
|
|
9286
|
-
this.
|
|
9287
|
-
|
|
9288
|
-
|
|
9650
|
+
key: "continueAfterRequestFailure",
|
|
9651
|
+
value: function continueAfterRequestFailure() {
|
|
9652
|
+
var epoch = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.timing.adBreakEpoch;
|
|
9653
|
+
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) return;
|
|
9654
|
+
this.setSlotState("NEEDS_NEXT_AD", "request_failed");
|
|
9655
|
+
this.requestNextAd("after_failure");
|
|
9656
|
+
}
|
|
9657
|
+
},
|
|
9658
|
+
{
|
|
9659
|
+
key: "cancelScheduledRequest",
|
|
9660
|
+
value: function cancelScheduledRequest() {
|
|
9661
|
+
if (this.nextAdTimerId != null) {
|
|
9662
|
+
clearTimeout(this.nextAdTimerId);
|
|
9663
|
+
this.nextAdTimerId = void 0;
|
|
9289
9664
|
}
|
|
9290
9665
|
}
|
|
9291
9666
|
},
|
|
9292
9667
|
{
|
|
9293
|
-
key: "
|
|
9294
|
-
value:
|
|
9295
|
-
|
|
9668
|
+
key: "noteVastUrlGenerated",
|
|
9669
|
+
value: function noteVastUrlGenerated(url, source) {
|
|
9670
|
+
var _ref, _ref1, _ref2, _ref3, _ref4;
|
|
9671
|
+
var params;
|
|
9672
|
+
try {
|
|
9673
|
+
params = new URL(url).searchParams;
|
|
9674
|
+
} catch (unused) {}
|
|
9675
|
+
var adType = (_ref = params === null || params === void 0 ? void 0 : params.get("ad_type")) !== null && _ref !== void 0 ? _ref : void 0;
|
|
9676
|
+
this.logOrchestratorFunnel("vast_url_generated", {
|
|
9677
|
+
source: source,
|
|
9678
|
+
pod: (_ref1 = params === null || params === void 0 ? void 0 : params.get("pod")) !== null && _ref1 !== void 0 ? _ref1 : void 0,
|
|
9679
|
+
pmad: (_ref2 = params === null || params === void 0 ? void 0 : params.get("pmad")) !== null && _ref2 !== void 0 ? _ref2 : void 0,
|
|
9680
|
+
pmnd: (_ref3 = params === null || params === void 0 ? void 0 : params.get("pmnd")) !== null && _ref3 !== void 0 ? _ref3 : void 0,
|
|
9681
|
+
pmxd: (_ref4 = params === null || params === void 0 ? void 0 : params.get("pmxd")) !== null && _ref4 !== void 0 ? _ref4 : void 0,
|
|
9682
|
+
adType: adType
|
|
9683
|
+
});
|
|
9684
|
+
if (adType === "audio" || adType === "audio_video") {
|
|
9685
|
+
console.warn("[AdBreak] VAST tag requests ad_type=".concat(adType, "; GAM may return audio-only creatives, which this video player rejects"));
|
|
9686
|
+
this.countFunnelStage("tag_allows_audio");
|
|
9687
|
+
}
|
|
9688
|
+
}
|
|
9689
|
+
},
|
|
9690
|
+
{
|
|
9691
|
+
key: "recordRequestFailure",
|
|
9692
|
+
value: function recordRequestFailure(error, vastTagUrl) {
|
|
9693
|
+
var _diag_vastAdCount;
|
|
9694
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
9695
|
+
var message = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
9696
|
+
var outcome;
|
|
9697
|
+
if (message.includes("ad_duration_exceeds_budget")) {
|
|
9698
|
+
outcome = "discarded_budget";
|
|
9699
|
+
} else if (message.includes("VAST fill rejected")) {
|
|
9700
|
+
outcome = "fill_rejected";
|
|
9701
|
+
} else if (/no ads available|no fill|nofill/i.test(message)) {
|
|
9702
|
+
outcome = "no_fill";
|
|
9703
|
+
} else if (/timeout/i.test(message)) {
|
|
9704
|
+
outcome = "request_timeout";
|
|
9705
|
+
} else if (/destroyed|aborted/i.test(message)) {
|
|
9706
|
+
outcome = "request_aborted";
|
|
9707
|
+
} else if (diag && ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired) {
|
|
9708
|
+
outcome = "playback_failed";
|
|
9709
|
+
} else {
|
|
9710
|
+
outcome = "request_failed";
|
|
9711
|
+
}
|
|
9712
|
+
this.timing.consecutiveFailures++;
|
|
9713
|
+
if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
|
|
9714
|
+
this.unusableResponsesInBreak++;
|
|
9715
|
+
}
|
|
9716
|
+
if (outcome === "no_fill") {
|
|
9717
|
+
this.timing.recordGamNoFill();
|
|
9718
|
+
}
|
|
9719
|
+
if (diag && !diag.failureReason) {
|
|
9720
|
+
diag.failureReason = "".concat(outcome, ": ").concat(message);
|
|
9721
|
+
}
|
|
9722
|
+
if (this.timing.isTemporaryAdError(error)) {
|
|
9723
|
+
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9724
|
+
} else if (outcome !== "discarded_budget") {
|
|
9725
|
+
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9726
|
+
}
|
|
9727
|
+
this.countFunnelStage("request_outcome:".concat(outcome));
|
|
9728
|
+
this.logOrchestratorFunnel("request_outcome", {
|
|
9729
|
+
outcome: outcome,
|
|
9730
|
+
errorMessage: message,
|
|
9731
|
+
consecutiveFailures: this.timing.consecutiveFailures,
|
|
9732
|
+
unusableResponsesInBreak: this.unusableResponsesInBreak
|
|
9733
|
+
});
|
|
9734
|
+
}
|
|
9735
|
+
},
|
|
9736
|
+
{
|
|
9296
9737
|
// ───────────────────────────────────────────────────────────────
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
backoffDelay = Math.min(this.timing.backoffBaseMs * backoffMultiplier, this.timing.maxBackoffMs);
|
|
9320
|
-
effectiveMinInterval = this.timing.minAdRequestIntervalMs + (this.timing.consecutiveFailures > 0 ? backoffDelay : 0);
|
|
9321
|
-
timeSinceLastRequest = Date.now() - this.timing.lastAdRequestTime;
|
|
9322
|
-
if (!(timeSinceLastRequest < effectiveMinInterval)) return [
|
|
9323
|
-
3,
|
|
9324
|
-
2
|
|
9325
|
-
];
|
|
9326
|
-
waitTime = effectiveMinInterval - timeSinceLastRequest;
|
|
9327
|
-
if (this.debug) {
|
|
9328
|
-
console.log("[CONTINUOUS-FETCH] Rate limiting: waiting ".concat(waitTime, "ms before next request (backoff: ").concat(this.timing.consecutiveFailures, " failures)"));
|
|
9329
|
-
}
|
|
9330
|
-
return [
|
|
9331
|
-
4,
|
|
9332
|
-
new Promise(function(resolve) {
|
|
9333
|
-
return setTimeout(resolve, waitTime);
|
|
9334
|
-
})
|
|
9335
|
-
];
|
|
9336
|
-
case 1:
|
|
9337
|
-
_state.sent();
|
|
9338
|
-
_state.label = 2;
|
|
9339
|
-
case 2:
|
|
9340
|
-
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) {
|
|
9341
|
-
return [
|
|
9342
|
-
2
|
|
9343
|
-
];
|
|
9344
|
-
}
|
|
9345
|
-
return [
|
|
9346
|
-
2,
|
|
9347
|
-
this.tryNextAvailableAd(0)
|
|
9348
|
-
];
|
|
9738
|
+
// Per-request diagnostics
|
|
9739
|
+
// ───────────────────────────────────────────────────────────────
|
|
9740
|
+
key: "recordRequestDiagnostic",
|
|
9741
|
+
value: function recordRequestDiagnostic(payload) {
|
|
9742
|
+
var requestId = payload.requestId;
|
|
9743
|
+
if (typeof requestId !== "number") return;
|
|
9744
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
9745
|
+
if (!diag) return;
|
|
9746
|
+
switch(payload.stage){
|
|
9747
|
+
case "gam_http_request_sent":
|
|
9748
|
+
diag.gamRequestSent++;
|
|
9749
|
+
break;
|
|
9750
|
+
case "gam_response_received":
|
|
9751
|
+
diag.vastHttpStatus = payload.httpStatus;
|
|
9752
|
+
break;
|
|
9753
|
+
case "vast_parsed":
|
|
9754
|
+
diag.vastAdCount = payload.adElementCount;
|
|
9755
|
+
break;
|
|
9756
|
+
case "wrapper_fetch":
|
|
9757
|
+
case "inline_resolved":
|
|
9758
|
+
if (typeof payload.depth === "number") {
|
|
9759
|
+
diag.wrapperDepth = Math.max(diag.wrapperDepth, payload.depth);
|
|
9349
9760
|
}
|
|
9350
|
-
|
|
9351
|
-
|
|
9761
|
+
if (payload.stage === "inline_resolved") diag.inlineResolved = true;
|
|
9762
|
+
break;
|
|
9763
|
+
case "mediafile_evaluated":
|
|
9764
|
+
diag.mediaCandidateCount++;
|
|
9765
|
+
if (payload.whyAccepted) diag.supportedMediaCount++;
|
|
9766
|
+
break;
|
|
9767
|
+
case "playing":
|
|
9768
|
+
diag.playStarted = true;
|
|
9769
|
+
break;
|
|
9770
|
+
case "impression_fired":
|
|
9771
|
+
diag.impressionFired = true;
|
|
9772
|
+
break;
|
|
9773
|
+
default:
|
|
9774
|
+
if (REQUEST_FAILURE_STAGES.has(payload.stage) && !diag.failureReason) {
|
|
9775
|
+
diag.failureReason = payload.reason ? "".concat(payload.stage, ":").concat(payload.reason) : payload.stage;
|
|
9776
|
+
}
|
|
9777
|
+
}
|
|
9352
9778
|
}
|
|
9353
9779
|
},
|
|
9354
9780
|
{
|
|
9355
|
-
key: "
|
|
9356
|
-
value: function
|
|
9357
|
-
var
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
];
|
|
9377
|
-
}
|
|
9378
|
-
if (this.timing.isGamInCooldown()) {
|
|
9379
|
-
if (this.debug) {
|
|
9380
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, ending ad break gracefully");
|
|
9381
|
-
}
|
|
9382
|
-
this.handleAdPodComplete();
|
|
9383
|
-
return [
|
|
9384
|
-
2
|
|
9385
|
-
];
|
|
9386
|
-
}
|
|
9387
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9388
|
-
if (this.debug) {
|
|
9389
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(this.timing.consecutiveFailures, "), ending ad break"));
|
|
9390
|
-
}
|
|
9391
|
-
this.handleAdPodComplete();
|
|
9392
|
-
return [
|
|
9393
|
-
2
|
|
9394
|
-
];
|
|
9395
|
-
}
|
|
9396
|
-
this.timing.cleanupTemporaryFailures();
|
|
9397
|
-
_state.label = 1;
|
|
9398
|
-
case 1:
|
|
9399
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
9400
|
-
3,
|
|
9401
|
-
9
|
|
9402
|
-
];
|
|
9403
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
9404
|
-
if (!nextAdUrl) return [
|
|
9405
|
-
3,
|
|
9406
|
-
1
|
|
9407
|
-
];
|
|
9408
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) {
|
|
9409
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
|
|
9410
|
-
return [
|
|
9411
|
-
3,
|
|
9412
|
-
1
|
|
9413
|
-
];
|
|
9414
|
-
}
|
|
9415
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) {
|
|
9416
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
|
|
9417
|
-
return [
|
|
9418
|
-
3,
|
|
9419
|
-
1
|
|
9420
|
-
];
|
|
9421
|
-
}
|
|
9422
|
-
if (this.debug) {
|
|
9423
|
-
console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
|
|
9424
|
-
}
|
|
9425
|
-
_state.label = 2;
|
|
9426
|
-
case 2:
|
|
9427
|
-
_state.trys.push([
|
|
9428
|
-
2,
|
|
9429
|
-
4,
|
|
9430
|
-
,
|
|
9431
|
-
8
|
|
9432
|
-
]);
|
|
9433
|
-
return [
|
|
9434
|
-
4,
|
|
9435
|
-
this.playSingleAd(nextAdUrl)
|
|
9436
|
-
];
|
|
9437
|
-
case 3:
|
|
9438
|
-
_state.sent();
|
|
9439
|
-
return [
|
|
9440
|
-
3,
|
|
9441
|
-
8
|
|
9442
|
-
];
|
|
9443
|
-
case 4:
|
|
9444
|
-
error = _state.sent();
|
|
9445
|
-
errorMessage = error.message;
|
|
9446
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
|
|
9447
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
9448
|
-
3,
|
|
9449
|
-
6
|
|
9450
|
-
];
|
|
9451
|
-
this.timing.consecutiveFailures++;
|
|
9452
|
-
return [
|
|
9453
|
-
4,
|
|
9454
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9455
|
-
];
|
|
9456
|
-
case 5:
|
|
9457
|
-
_state.sent();
|
|
9458
|
-
return [
|
|
9459
|
-
2
|
|
9460
|
-
];
|
|
9461
|
-
case 6:
|
|
9462
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
9463
|
-
this.timing.consecutiveFailures++;
|
|
9464
|
-
}
|
|
9465
|
-
return [
|
|
9466
|
-
4,
|
|
9467
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9468
|
-
];
|
|
9469
|
-
case 7:
|
|
9470
|
-
_state.sent();
|
|
9471
|
-
return [
|
|
9472
|
-
3,
|
|
9473
|
-
8
|
|
9474
|
-
];
|
|
9475
|
-
case 8:
|
|
9476
|
-
return [
|
|
9477
|
-
2
|
|
9478
|
-
];
|
|
9479
|
-
case 9:
|
|
9480
|
-
maxRetries = 3;
|
|
9481
|
-
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
9482
|
-
3,
|
|
9483
|
-
12
|
|
9484
|
-
];
|
|
9485
|
-
if (this.debug) {
|
|
9486
|
-
console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
9487
|
-
}
|
|
9488
|
-
return [
|
|
9489
|
-
4,
|
|
9490
|
-
new Promise(function(resolve) {
|
|
9491
|
-
return setTimeout(resolve, 500);
|
|
9492
|
-
})
|
|
9493
|
-
];
|
|
9494
|
-
case 10:
|
|
9495
|
-
_state.sent();
|
|
9496
|
-
return [
|
|
9497
|
-
4,
|
|
9498
|
-
this.tryNextAvailableAd(retryCount + 1)
|
|
9499
|
-
];
|
|
9500
|
-
case 11:
|
|
9501
|
-
_state.sent();
|
|
9502
|
-
return [
|
|
9503
|
-
2
|
|
9504
|
-
];
|
|
9505
|
-
case 12:
|
|
9506
|
-
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
9507
|
-
this.showPlaceholderAndWaitForAds();
|
|
9508
|
-
} else {
|
|
9509
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] No more ads available, ending ad break");
|
|
9510
|
-
this.handleAdPodComplete();
|
|
9511
|
-
}
|
|
9512
|
-
return [
|
|
9513
|
-
2
|
|
9514
|
-
];
|
|
9515
|
-
}
|
|
9516
|
-
});
|
|
9517
|
-
}).call(this);
|
|
9781
|
+
key: "finalizeRequestDiagnostics",
|
|
9782
|
+
value: function finalizeRequestDiagnostics(requestId, endReason) {
|
|
9783
|
+
var _diag_vastAdCount;
|
|
9784
|
+
if (requestId == null) return;
|
|
9785
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
9786
|
+
if (!diag) return;
|
|
9787
|
+
this.requestDiagnostics.delete(requestId);
|
|
9788
|
+
if (!diag.impressionFired && !diag.failureReason && endReason) {
|
|
9789
|
+
diag.failureReason = endReason;
|
|
9790
|
+
}
|
|
9791
|
+
var gamReturnedAdWithoutImpression = ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired;
|
|
9792
|
+
if (gamReturnedAdWithoutImpression) {
|
|
9793
|
+
this.countFunnelStage("gam_ad_without_impression");
|
|
9794
|
+
}
|
|
9795
|
+
var startedAt = diag.startedAt, fields = _object_without_properties(diag, [
|
|
9796
|
+
"startedAt"
|
|
9797
|
+
]);
|
|
9798
|
+
console.log("[AdBreak][REQUEST] summary", _object_spread_props(_object_spread({}, fields), {
|
|
9799
|
+
durationMs: Date.now() - startedAt,
|
|
9800
|
+
gamReturnedAdWithoutImpression: gamReturnedAdWithoutImpression
|
|
9801
|
+
}));
|
|
9518
9802
|
}
|
|
9519
9803
|
},
|
|
9520
9804
|
{
|
|
@@ -9522,7 +9806,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9522
9806
|
// Single ad playback
|
|
9523
9807
|
// ───────────────────────────────────────────────────────────────
|
|
9524
9808
|
key: "withCurrentPodBudget",
|
|
9525
|
-
value: function withCurrentPodBudget(
|
|
9809
|
+
value: function withCurrentPodBudget(rawVastTagUrl) {
|
|
9810
|
+
var vastTagUrl = ensureVideoAdType(rawVastTagUrl);
|
|
9526
9811
|
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9527
9812
|
if (!(remaining > 0)) return vastTagUrl;
|
|
9528
9813
|
try {
|
|
@@ -9581,18 +9866,34 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9581
9866
|
},
|
|
9582
9867
|
{
|
|
9583
9868
|
key: "beginFunnelRequest",
|
|
9584
|
-
value: function beginFunnelRequest(adPlayer, requestToken) {
|
|
9869
|
+
value: function beginFunnelRequest(adPlayer, requestToken, trigger) {
|
|
9585
9870
|
var _adPlayer_setFunnelContext;
|
|
9586
9871
|
if (this.controllerCallInFlight) {
|
|
9587
9872
|
this.logOrchestratorFunnel("duplicate_request_detected", {
|
|
9588
9873
|
newRequestId: requestToken
|
|
9589
9874
|
});
|
|
9590
9875
|
}
|
|
9876
|
+
this.finalizeRequestDiagnostics(this.currentRequestId);
|
|
9591
9877
|
this.currentRequestId = requestToken;
|
|
9592
9878
|
this.requestStartedAt = Date.now();
|
|
9879
|
+
this.requestDiagnostics.set(requestToken, {
|
|
9880
|
+
breakId: this.timing.adBreakEpoch,
|
|
9881
|
+
requestId: requestToken,
|
|
9882
|
+
controllerId: this.controllerGeneration,
|
|
9883
|
+
trigger: trigger,
|
|
9884
|
+
gamRequestSent: 0,
|
|
9885
|
+
wrapperDepth: 0,
|
|
9886
|
+
inlineResolved: false,
|
|
9887
|
+
mediaCandidateCount: 0,
|
|
9888
|
+
supportedMediaCount: 0,
|
|
9889
|
+
playStarted: false,
|
|
9890
|
+
impressionFired: false,
|
|
9891
|
+
startedAt: Date.now()
|
|
9892
|
+
});
|
|
9593
9893
|
(_adPlayer_setFunnelContext = adPlayer.setFunnelContext) === null || _adPlayer_setFunnelContext === void 0 ? void 0 : _adPlayer_setFunnelContext.call(adPlayer, {
|
|
9594
9894
|
breakId: this.timing.adBreakEpoch,
|
|
9595
|
-
requestId: requestToken
|
|
9895
|
+
requestId: requestToken,
|
|
9896
|
+
controllerId: this.controllerGeneration
|
|
9596
9897
|
});
|
|
9597
9898
|
}
|
|
9598
9899
|
},
|
|
@@ -9623,7 +9924,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9623
9924
|
adPlayer.abortPendingRequest("VAST request aborted after request watchdog timeout");
|
|
9624
9925
|
return;
|
|
9625
9926
|
}
|
|
9626
|
-
this.handleAdFailure();
|
|
9927
|
+
this.handleAdFailure("request_watchdog_timeout");
|
|
9627
9928
|
}
|
|
9628
9929
|
},
|
|
9629
9930
|
{
|
|
@@ -9669,21 +9970,30 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9669
9970
|
{
|
|
9670
9971
|
key: "playSingleAd",
|
|
9671
9972
|
value: function playSingleAd(vastTagUrl) {
|
|
9973
|
+
var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
|
|
9672
9974
|
return _async_to_generator(function() {
|
|
9673
|
-
var
|
|
9975
|
+
var epoch, generation, requestToken, ap, requestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
|
|
9674
9976
|
return _ts_generator(this, function(_state) {
|
|
9675
9977
|
switch(_state.label){
|
|
9676
9978
|
case 0:
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
|
|
9680
|
-
|
|
9979
|
+
if (this.slotState === "REQUESTING" || this.slotState === "READY" || this.slotState === "PLAYING" || this.slotState === "ENDING") {
|
|
9980
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9981
|
+
trigger: trigger,
|
|
9982
|
+
state: this.slotState,
|
|
9983
|
+
why: "request_in_flight"
|
|
9984
|
+
});
|
|
9985
|
+
return [
|
|
9986
|
+
2
|
|
9987
|
+
];
|
|
9988
|
+
}
|
|
9681
9989
|
if (this.timing.failedVastUrls.has(vastTagUrl)) {
|
|
9682
9990
|
if (this.debug) console.warn("[AD-ERROR] Skipping permanently-failed VAST URL:", vastTagUrl);
|
|
9991
|
+
this.timing.consecutiveFailures++;
|
|
9683
9992
|
throw new Error("VAST URL permanently failed");
|
|
9684
9993
|
}
|
|
9685
9994
|
if (this.timing.isUrlInCooldown(vastTagUrl)) {
|
|
9686
9995
|
if (this.debug) console.warn("[AD-ERROR] Skipping URL in cooldown (recent no-fill):", vastTagUrl);
|
|
9996
|
+
this.timing.consecutiveFailures++;
|
|
9687
9997
|
throw new Error("VAST URL in cooldown after no-fill");
|
|
9688
9998
|
}
|
|
9689
9999
|
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
@@ -9694,16 +10004,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9694
10004
|
if (this.debug) console.warn("[CIRCUIT-BREAKER] GAM in cooldown, skipping ad request");
|
|
9695
10005
|
throw new Error("GAM in cooldown");
|
|
9696
10006
|
}
|
|
9697
|
-
this.
|
|
10007
|
+
epoch = this.timing.adBreakEpoch;
|
|
10008
|
+
this.recreateAdController("new_request");
|
|
10009
|
+
generation = this.controllerGeneration;
|
|
9698
10010
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
9699
10011
|
this.timing.activeAdRequestToken = requestToken;
|
|
10012
|
+
ap = this.host.getAdPlayer();
|
|
10013
|
+
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
10014
|
+
this.currentVastUrl = requestUrl;
|
|
10015
|
+
this.setSlotState("REQUESTING", trigger);
|
|
10016
|
+
this.beginFunnelRequest(ap, requestToken, trigger);
|
|
9700
10017
|
_state.label = 1;
|
|
9701
10018
|
case 1:
|
|
9702
10019
|
_state.trys.push([
|
|
9703
10020
|
1,
|
|
9704
|
-
|
|
10021
|
+
5,
|
|
9705
10022
|
,
|
|
9706
|
-
|
|
10023
|
+
6
|
|
9707
10024
|
]);
|
|
9708
10025
|
return [
|
|
9709
10026
|
4,
|
|
@@ -9711,12 +10028,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9711
10028
|
];
|
|
9712
10029
|
case 2:
|
|
9713
10030
|
_state.sent();
|
|
10031
|
+
if (this.isStale(epoch, generation)) return [
|
|
10032
|
+
2
|
|
10033
|
+
];
|
|
9714
10034
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
9715
|
-
this.timing.noteAdRequestSent();
|
|
9716
|
-
ap = this.host.getAdPlayer();
|
|
9717
|
-
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9718
|
-
this.currentVastUrl = requestUrl;
|
|
9719
|
-
this.beginFunnelRequest(ap, requestToken);
|
|
9720
10035
|
return [
|
|
9721
10036
|
4,
|
|
9722
10037
|
this.callController(function() {
|
|
@@ -9725,36 +10040,31 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9725
10040
|
];
|
|
9726
10041
|
case 3:
|
|
9727
10042
|
_state.sent();
|
|
10043
|
+
this.timing.clearAdRequestWatchdog();
|
|
10044
|
+
if (this.isStale(epoch, generation)) {
|
|
10045
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
10046
|
+
requestId: requestToken
|
|
10047
|
+
});
|
|
10048
|
+
return [
|
|
10049
|
+
2
|
|
10050
|
+
];
|
|
10051
|
+
}
|
|
9728
10052
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
9729
10053
|
source: "hls",
|
|
9730
10054
|
vastUrl: requestUrl,
|
|
9731
10055
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
9732
10056
|
}, this.analyticsContext).catch(function() {});
|
|
9733
|
-
this.timing.clearAdRequestWatchdog();
|
|
9734
|
-
if (this.timing.activeAdRequestToken !== requestToken) return [
|
|
9735
|
-
2
|
|
9736
|
-
];
|
|
9737
10057
|
if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
|
|
9738
10058
|
;
|
|
9739
10059
|
adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
|
|
9740
10060
|
remainingMs = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9741
10061
|
this.logOrchestratorFunnel("discarded_budget", {
|
|
9742
|
-
vastUrl: requestUrl,
|
|
9743
10062
|
adDurationMs: adDurationS != null ? adDurationS * 1e3 : void 0,
|
|
9744
10063
|
remainingMs: remainingMs
|
|
9745
10064
|
});
|
|
9746
|
-
this.timing.rejectLoadedAdForDuration(ap);
|
|
9747
|
-
this.recreateAdController();
|
|
9748
10065
|
throw new Error("ad_duration_exceeds_budget");
|
|
9749
10066
|
}
|
|
9750
|
-
|
|
9751
|
-
case 4:
|
|
9752
|
-
_state.trys.push([
|
|
9753
|
-
4,
|
|
9754
|
-
6,
|
|
9755
|
-
,
|
|
9756
|
-
7
|
|
9757
|
-
]);
|
|
10067
|
+
this.setSlotState("READY", "vast_ready");
|
|
9758
10068
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
9759
10069
|
return [
|
|
9760
10070
|
4,
|
|
@@ -9762,8 +10072,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9762
10072
|
return ap.play();
|
|
9763
10073
|
})
|
|
9764
10074
|
];
|
|
9765
|
-
case
|
|
10075
|
+
case 4:
|
|
9766
10076
|
_state.sent();
|
|
10077
|
+
if (this.isStale(epoch, generation)) return [
|
|
10078
|
+
2
|
|
10079
|
+
];
|
|
9767
10080
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
9768
10081
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
9769
10082
|
}
|
|
@@ -9771,216 +10084,31 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9771
10084
|
this.timing.temporaryFailureUrls.delete(vastTagUrl);
|
|
9772
10085
|
return [
|
|
9773
10086
|
3,
|
|
9774
|
-
|
|
9775
|
-
];
|
|
9776
|
-
case 6:
|
|
9777
|
-
playError = _state.sent();
|
|
9778
|
-
if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
|
|
9779
|
-
if (this.timing.isTemporaryAdError(playError)) {
|
|
9780
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9781
|
-
if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
|
|
9782
|
-
} else {
|
|
9783
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9784
|
-
if (this.debug) console.log("[AD-ERROR] Permanent play error - URL blacklisted");
|
|
9785
|
-
}
|
|
9786
|
-
this.timing.clearAdFailsafeTimer();
|
|
9787
|
-
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9788
|
-
this.timing.activeAdRequestToken = null;
|
|
9789
|
-
}
|
|
9790
|
-
throw playError;
|
|
9791
|
-
case 7:
|
|
9792
|
-
return [
|
|
9793
|
-
3,
|
|
9794
|
-
9
|
|
10087
|
+
6
|
|
9795
10088
|
];
|
|
9796
|
-
case
|
|
10089
|
+
case 5:
|
|
9797
10090
|
error = _state.sent();
|
|
9798
|
-
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
9799
|
-
if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
|
|
9800
|
-
if (this.timing.isTemporaryAdError(error)) {
|
|
9801
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9802
|
-
if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
|
|
9803
|
-
} else {
|
|
9804
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9805
|
-
if (this.debug) console.log("[AD-ERROR] Permanent error - URL blacklisted:", errorMessage);
|
|
9806
|
-
}
|
|
9807
10091
|
this.timing.clearAdRequestWatchdog();
|
|
9808
10092
|
this.timing.clearAdFailsafeTimer();
|
|
9809
10093
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9810
10094
|
this.timing.activeAdRequestToken = null;
|
|
9811
10095
|
}
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
|
|
9816
|
-
|
|
9817
|
-
}
|
|
9818
|
-
});
|
|
9819
|
-
}).call(this);
|
|
9820
|
-
}
|
|
9821
|
-
},
|
|
9822
|
-
{
|
|
9823
|
-
key: "showPlaceholderAndWaitForAds",
|
|
9824
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9825
|
-
// Placeholder wait
|
|
9826
|
-
// ───────────────────────────────────────────────────────────────
|
|
9827
|
-
function showPlaceholderAndWaitForAds() {
|
|
9828
|
-
return _async_to_generator(function() {
|
|
9829
|
-
var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
|
|
9830
|
-
return _ts_generator(this, function(_state) {
|
|
9831
|
-
switch(_state.label){
|
|
9832
|
-
case 0:
|
|
9833
|
-
remaining = this.timing.getRemainingAdMs();
|
|
9834
|
-
waitTime = Math.min(this.maxPlaceholderDurationMs, remaining);
|
|
9835
|
-
if (this.timing.isGamInCooldown()) {
|
|
9836
|
-
if (this.debug) console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping placeholder wait");
|
|
9837
|
-
this.handleAdPodComplete();
|
|
9838
|
-
return [
|
|
9839
|
-
2
|
|
9840
|
-
];
|
|
9841
|
-
}
|
|
9842
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9843
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping placeholder - too many consecutive failures");
|
|
9844
|
-
this.handleAdPodComplete();
|
|
9845
|
-
return [
|
|
9846
|
-
2
|
|
9847
|
-
];
|
|
9848
|
-
}
|
|
9849
|
-
if (waitTime < 1e3) {
|
|
9850
|
-
this.handleAdPodComplete();
|
|
10096
|
+
if (this.isStale(epoch, generation)) {
|
|
10097
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
10098
|
+
requestId: requestToken,
|
|
10099
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
10100
|
+
});
|
|
9851
10101
|
return [
|
|
9852
10102
|
2
|
|
9853
10103
|
];
|
|
9854
10104
|
}
|
|
9855
|
-
if (this.debug)
|
|
9856
|
-
|
|
10105
|
+
if (this.debug) console.error("[AD-ERROR] Ad request failed:", error === null || error === void 0 ? void 0 : error.message);
|
|
10106
|
+
this.recordRequestFailure(error, vastTagUrl);
|
|
10107
|
+
if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
|
|
10108
|
+
this.recreateAdController("discarded_budget");
|
|
9857
10109
|
}
|
|
9858
|
-
|
|
9859
|
-
this.host.getAdPlayer().showPlaceholder();
|
|
9860
|
-
checkInterval = 300;
|
|
9861
|
-
maxChecks = Math.floor(waitTime / checkInterval);
|
|
9862
|
-
i = 0;
|
|
9863
|
-
_state.label = 1;
|
|
9864
|
-
case 1:
|
|
9865
|
-
if (!(i < maxChecks)) return [
|
|
9866
|
-
3,
|
|
9867
|
-
12
|
|
9868
|
-
];
|
|
9869
|
-
return [
|
|
9870
|
-
4,
|
|
9871
|
-
new Promise(function(resolve) {
|
|
9872
|
-
return setTimeout(resolve, checkInterval);
|
|
9873
|
-
})
|
|
9874
|
-
];
|
|
9875
|
-
case 2:
|
|
9876
|
-
_state.sent();
|
|
9877
|
-
if (!this.inAdBreak) return [
|
|
9878
|
-
2
|
|
9879
|
-
];
|
|
9880
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9881
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Too many failures during placeholder wait");
|
|
9882
|
-
return [
|
|
9883
|
-
3,
|
|
9884
|
-
12
|
|
9885
|
-
];
|
|
9886
|
-
}
|
|
9887
|
-
if (!this.timing.hasTimeToStartAnotherAd()) {
|
|
9888
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Not enough time remaining during placeholder wait, ending ad break");
|
|
9889
|
-
return [
|
|
9890
|
-
3,
|
|
9891
|
-
12
|
|
9892
|
-
];
|
|
9893
|
-
}
|
|
9894
|
-
_state.label = 3;
|
|
9895
|
-
case 3:
|
|
9896
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
9897
|
-
3,
|
|
9898
|
-
11
|
|
9899
|
-
];
|
|
9900
|
-
if (!this.timing.hasTimeToStartAnotherAd()) return [
|
|
9901
|
-
3,
|
|
9902
|
-
11
|
|
9903
|
-
];
|
|
9904
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
9905
|
-
if (!nextAdUrl) return [
|
|
9906
|
-
3,
|
|
9907
|
-
3
|
|
9908
|
-
];
|
|
9909
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) return [
|
|
9910
|
-
3,
|
|
9911
|
-
3
|
|
9912
|
-
];
|
|
9913
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) return [
|
|
9914
|
-
3,
|
|
9915
|
-
3
|
|
9916
|
-
];
|
|
9917
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad URL available, requesting via HLS ad player");
|
|
9918
|
-
this.isShowingPlaceholder = false;
|
|
9919
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
9920
|
-
_state.label = 4;
|
|
9921
|
-
case 4:
|
|
9922
|
-
_state.trys.push([
|
|
9923
|
-
4,
|
|
9924
|
-
6,
|
|
9925
|
-
,
|
|
9926
|
-
10
|
|
9927
|
-
]);
|
|
9928
|
-
return [
|
|
9929
|
-
4,
|
|
9930
|
-
this.playSingleAd(nextAdUrl)
|
|
9931
|
-
];
|
|
9932
|
-
case 5:
|
|
9933
|
-
_state.sent();
|
|
9934
|
-
return [
|
|
9935
|
-
3,
|
|
9936
|
-
10
|
|
9937
|
-
];
|
|
10110
|
+
throw error;
|
|
9938
10111
|
case 6:
|
|
9939
|
-
error = _state.sent();
|
|
9940
|
-
errorMessage = error.message;
|
|
9941
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
9942
|
-
3,
|
|
9943
|
-
8
|
|
9944
|
-
];
|
|
9945
|
-
this.timing.consecutiveFailures++;
|
|
9946
|
-
return [
|
|
9947
|
-
4,
|
|
9948
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9949
|
-
];
|
|
9950
|
-
case 7:
|
|
9951
|
-
_state.sent();
|
|
9952
|
-
return [
|
|
9953
|
-
2
|
|
9954
|
-
];
|
|
9955
|
-
case 8:
|
|
9956
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
9957
|
-
this.timing.consecutiveFailures++;
|
|
9958
|
-
}
|
|
9959
|
-
return [
|
|
9960
|
-
4,
|
|
9961
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9962
|
-
];
|
|
9963
|
-
case 9:
|
|
9964
|
-
_state.sent();
|
|
9965
|
-
return [
|
|
9966
|
-
3,
|
|
9967
|
-
10
|
|
9968
|
-
];
|
|
9969
|
-
case 10:
|
|
9970
|
-
return [
|
|
9971
|
-
2
|
|
9972
|
-
];
|
|
9973
|
-
case 11:
|
|
9974
|
-
i++;
|
|
9975
|
-
return [
|
|
9976
|
-
3,
|
|
9977
|
-
1
|
|
9978
|
-
];
|
|
9979
|
-
case 12:
|
|
9980
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Placeholder timeout, ending ad break");
|
|
9981
|
-
this.isShowingPlaceholder = false;
|
|
9982
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
9983
|
-
this.handleAdPodComplete();
|
|
9984
10112
|
return [
|
|
9985
10113
|
2
|
|
9986
10114
|
];
|
|
@@ -9994,7 +10122,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9994
10122
|
// Ad break completion
|
|
9995
10123
|
// ───────────────────────────────────────────────────────────────
|
|
9996
10124
|
key: "logBreakFunnel",
|
|
9997
|
-
value: function logBreakFunnel() {
|
|
10125
|
+
value: function logBreakFunnel(endReason) {
|
|
9998
10126
|
var funnel = this.breakFunnel;
|
|
9999
10127
|
this.breakFunnel = {};
|
|
10000
10128
|
if (Object.keys(funnel).length === 0) return;
|
|
@@ -10002,26 +10130,49 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
10002
10130
|
var _funnel_stage;
|
|
10003
10131
|
return (_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0;
|
|
10004
10132
|
};
|
|
10133
|
+
var countPrefix = function countPrefix(prefix) {
|
|
10134
|
+
return Object.keys(funnel).reduce(function(total, stage) {
|
|
10135
|
+
var _funnel_stage;
|
|
10136
|
+
return stage.indexOf(prefix) === 0 ? total + ((_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0) : total;
|
|
10137
|
+
}, 0);
|
|
10138
|
+
};
|
|
10005
10139
|
var breakId = this.opportunityEpoch;
|
|
10006
|
-
|
|
10140
|
+
var requestRetries = count("gam_http_request_retry");
|
|
10141
|
+
var requests = count("gam_http_request_sent") - requestRetries;
|
|
10142
|
+
if (requests > 0 && count("impression_fired") === 0) {
|
|
10007
10143
|
console.log("[AdBreak][FUNNEL] break_abandoned_before_start", {
|
|
10008
10144
|
breakId: breakId,
|
|
10009
|
-
requests:
|
|
10145
|
+
requests: requests,
|
|
10146
|
+
endReason: endReason
|
|
10010
10147
|
});
|
|
10011
10148
|
}
|
|
10012
10149
|
console.log("[AdBreak][FUNNEL] Break summary", {
|
|
10013
10150
|
breakId: breakId,
|
|
10151
|
+
endReason: endReason,
|
|
10014
10152
|
opportunities: count("opportunity_created"),
|
|
10015
|
-
|
|
10153
|
+
vastUrlsGenerated: count("vast_url_generated"),
|
|
10154
|
+
requests: requests,
|
|
10155
|
+
requestRetries: requestRetries,
|
|
10156
|
+
gamResponses: count("gam_response_received"),
|
|
10157
|
+
requestsSuppressed: count("request_suppressed"),
|
|
10016
10158
|
duplicates: count("duplicate_request_detected") + count("duplicate_break_start"),
|
|
10017
10159
|
filled: count("vast_received"),
|
|
10018
10160
|
noFill: count("no_fill"),
|
|
10161
|
+
fillRejected: count("vast_fill_rejected"),
|
|
10162
|
+
gamAdWithoutImpression: count("gam_ad_without_impression"),
|
|
10163
|
+
playbackFailedAfterFill: count("request_outcome:playback_failed"),
|
|
10019
10164
|
requestFailed: count("request_failed"),
|
|
10020
10165
|
requestAbortedTimeout: count("request_aborted_timeout"),
|
|
10021
10166
|
credentialsRetries: count("vast_credentials_retry"),
|
|
10022
10167
|
wrapperFailures: count("wrapper_fetch:failure"),
|
|
10023
10168
|
noSupportedMedia: count("vast_no_supported_media"),
|
|
10024
|
-
vpaidOnly: count("vast_no_supported_media:
|
|
10169
|
+
vpaidOnly: count("vast_no_supported_media:vpaid"),
|
|
10170
|
+
audioOnly: count("vast_no_supported_media:audio_only"),
|
|
10171
|
+
mediaFilesEvaluated: count("mediafile_evaluated"),
|
|
10172
|
+
mediaFilesAccepted: count("mediafile_evaluated:accepted"),
|
|
10173
|
+
controllerDestroys: countPrefix("controller_destroy:"),
|
|
10174
|
+
staleCallbacks: count("stale_callback_ignored") + count("stale_request_result_ignored"),
|
|
10175
|
+
tagAllowsAudio: count("tag_allows_audio"),
|
|
10025
10176
|
missingImpression: count("vast_missing_impression"),
|
|
10026
10177
|
discardedBudget: count("discarded_budget"),
|
|
10027
10178
|
mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
|
|
@@ -10056,25 +10207,50 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
10056
10207
|
{
|
|
10057
10208
|
key: "handleAdPodComplete",
|
|
10058
10209
|
value: function handleAdPodComplete() {
|
|
10210
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "unspecified";
|
|
10059
10211
|
if (this.debug) {
|
|
10060
|
-
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up"
|
|
10212
|
+
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up", {
|
|
10213
|
+
reason: reason
|
|
10214
|
+
});
|
|
10215
|
+
}
|
|
10216
|
+
var previousState = this.slotState;
|
|
10217
|
+
var alreadyEnded = previousState === "IDLE" && !this.inAdBreak;
|
|
10218
|
+
this.setSlotState("ENDING", reason);
|
|
10219
|
+
this.cancelScheduledRequest();
|
|
10220
|
+
var adPlayer = this.host.getAdPlayer();
|
|
10221
|
+
if (previousState === "REQUESTING") {
|
|
10222
|
+
var _adPlayer_abortPendingRequest;
|
|
10223
|
+
(_adPlayer_abortPendingRequest = adPlayer.abortPendingRequest) === null || _adPlayer_abortPendingRequest === void 0 ? void 0 : _adPlayer_abortPendingRequest.call(adPlayer, "VAST request aborted: ad break ended (".concat(reason, ")"));
|
|
10224
|
+
}
|
|
10225
|
+
if (!alreadyEnded) {
|
|
10226
|
+
console.log("[AD-CONTROLLER] stop", {
|
|
10227
|
+
controllerId: this.controllerGeneration,
|
|
10228
|
+
requestId: this.currentRequestId,
|
|
10229
|
+
state: previousState,
|
|
10230
|
+
reason: reason
|
|
10231
|
+
});
|
|
10061
10232
|
}
|
|
10233
|
+
this.finalizeRequestDiagnostics(this.currentRequestId, "break_ended:".concat(reason));
|
|
10234
|
+
this.currentRequestId = void 0;
|
|
10062
10235
|
this.timing.resetForBreakEnd();
|
|
10063
|
-
this.
|
|
10236
|
+
this.placeholder.hide();
|
|
10064
10237
|
this.clearPendingAdBreak();
|
|
10065
10238
|
if (this.isShowingPlaceholder) {
|
|
10066
|
-
|
|
10239
|
+
adPlayer.hidePlaceholder();
|
|
10067
10240
|
this.isShowingPlaceholder = false;
|
|
10068
10241
|
}
|
|
10069
|
-
this.adRequestQueue = [];
|
|
10070
10242
|
this.inAdBreak = false;
|
|
10071
10243
|
this.adDetectSentForCurrentBreak = false;
|
|
10072
10244
|
this.cueManager.activeScte35BreakKey = void 0;
|
|
10073
10245
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
10074
10246
|
this.adPodQueue = [];
|
|
10075
10247
|
this.showAds = false;
|
|
10076
|
-
this.
|
|
10077
|
-
this.
|
|
10248
|
+
this.breakSource = void 0;
|
|
10249
|
+
this.followUpBaseVastUrl = void 0;
|
|
10250
|
+
this.unusableResponsesInBreak = 0;
|
|
10251
|
+
adPlayer.stop().catch(function() {});
|
|
10252
|
+
if (!alreadyEnded) this.logBreakFunnel(reason);
|
|
10253
|
+
this.setSlotState("IDLE", "break_complete");
|
|
10078
10254
|
var restoredMuted = this.host.getAdPlayer().getOriginalMutedState();
|
|
10079
10255
|
var restoredVolume = this.host.getAdPlayer().getOriginalVolume();
|
|
10080
10256
|
if (this.host.video.muted !== restoredMuted) {
|
|
@@ -10368,25 +10544,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
10368
10544
|
{
|
|
10369
10545
|
key: "handleAdFailure",
|
|
10370
10546
|
value: function handleAdFailure() {
|
|
10371
|
-
|
|
10372
|
-
this.
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
}
|
|
10378
|
-
}
|
|
10379
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
10380
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Max consecutive failures reached (".concat(this.timing.consecutiveFailures, "), ending ad break gracefully"));
|
|
10381
|
-
this.handleAdPodComplete();
|
|
10547
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "ad_failure";
|
|
10548
|
+
if (!this.inAdBreak) return;
|
|
10549
|
+
if (this.slotState === "REQUESTING" || this.slotState === "ENDING") {
|
|
10550
|
+
this.logOrchestratorFunnel("failure_deferred_to_request", {
|
|
10551
|
+
reason: reason,
|
|
10552
|
+
state: this.slotState
|
|
10553
|
+
});
|
|
10382
10554
|
return;
|
|
10383
10555
|
}
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
this.
|
|
10556
|
+
this.timing.consecutiveFailures++;
|
|
10557
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
10558
|
+
if (diag && !diag.failureReason) diag.failureReason = reason;
|
|
10559
|
+
if (this.debug) {
|
|
10560
|
+
console.log("[AdBreak] Ad failure (".concat(reason, "): remaining=").concat(this.timing.getRemainingAdMs(), "ms, consecutiveFailures=").concat(this.timing.consecutiveFailures));
|
|
10389
10561
|
}
|
|
10562
|
+
this.setSlotState("NEEDS_NEXT_AD", reason);
|
|
10563
|
+
this.requestNextAd(reason);
|
|
10390
10564
|
}
|
|
10391
10565
|
}
|
|
10392
10566
|
]);
|
|
@@ -10429,7 +10603,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10429
10603
|
return _this.adBreak.handleRequestWatchdogTimeout();
|
|
10430
10604
|
},
|
|
10431
10605
|
onFailsafeTimeout: function onFailsafeTimeout() {
|
|
10432
|
-
return _this.adBreak.handleAdFailure();
|
|
10606
|
+
return _this.adBreak.handleAdFailure("failsafe_timeout");
|
|
10433
10607
|
},
|
|
10434
10608
|
getAdState: function getAdState() {
|
|
10435
10609
|
return {
|
|
@@ -10679,6 +10853,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10679
10853
|
adBehavior: adBehavior
|
|
10680
10854
|
});
|
|
10681
10855
|
}
|
|
10856
|
+
if (this.adBreak.isBreakActive()) {
|
|
10857
|
+
console.log("[AD-CONTROLLER] destroy skipped", {
|
|
10858
|
+
reason: "manifest_parsed_during_break",
|
|
10859
|
+
state: this.adBreak.getSlotState()
|
|
10860
|
+
});
|
|
10861
|
+
return [
|
|
10862
|
+
2
|
|
10863
|
+
];
|
|
10864
|
+
}
|
|
10865
|
+
if (this.debug) {
|
|
10866
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
10867
|
+
reason: "manifest_parsed",
|
|
10868
|
+
state: "IDLE"
|
|
10869
|
+
});
|
|
10870
|
+
}
|
|
10682
10871
|
this.adPlayer.destroy();
|
|
10683
10872
|
this.adPlayer = this.createAdPlayer(this.shouldContinueLiveStreamDuringAds());
|
|
10684
10873
|
this.adPlayer.initialize();
|
|
@@ -10860,9 +11049,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10860
11049
|
this.timing.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
10861
11050
|
}
|
|
10862
11051
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
10863
|
-
if (!this.adPlayer.isAdPlaying() && this.timing.activeAdRequestToken === null && this.adBreak.adRequestQueue.length > 0 && this.timing.hasTimeToStartAnotherAd()) {
|
|
10864
|
-
this.adBreak.tryNextAvailableAdWithRateLimit();
|
|
10865
|
-
}
|
|
10866
11052
|
return;
|
|
10867
11053
|
}
|
|
10868
11054
|
if (marker.type === "end") {
|
|
@@ -10874,12 +11060,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10874
11060
|
}
|
|
10875
11061
|
var remaining = this.timing.getRemainingAdMs();
|
|
10876
11062
|
var adPlaying = this.adPlayer.isAdPlaying();
|
|
10877
|
-
var hasQueuedAds = this.adBreak.adRequestQueue.length > 0;
|
|
10878
11063
|
if (this.debug) {
|
|
10879
11064
|
console.log("[StormcloudVideoPlayer] SCTE-35 end marker received:", {
|
|
10880
11065
|
remaining: remaining,
|
|
10881
11066
|
adPlaying: adPlaying,
|
|
10882
|
-
|
|
11067
|
+
adSlotState: this.adBreak.getSlotState(),
|
|
10883
11068
|
activeAdRequest: this.timing.activeAdRequestToken !== null
|
|
10884
11069
|
});
|
|
10885
11070
|
}
|
|
@@ -10890,7 +11075,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10890
11075
|
this.adBreak.noteStopBeforeStart("scte_end");
|
|
10891
11076
|
this.adPlayer.stop().catch(function() {});
|
|
10892
11077
|
}
|
|
10893
|
-
this.adBreak.handleAdPodComplete();
|
|
11078
|
+
this.adBreak.handleAdPodComplete("scte_end");
|
|
10894
11079
|
return;
|
|
10895
11080
|
}
|
|
10896
11081
|
}
|
|
@@ -10898,6 +11083,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10898
11083
|
{
|
|
10899
11084
|
key: "startScte35AdBreak",
|
|
10900
11085
|
value: function startScte35AdBreak(marker, cueKey, durationMs) {
|
|
11086
|
+
if (this.adBreak.isBreakActive()) {
|
|
11087
|
+
if (this.debug) {
|
|
11088
|
+
console.log("[StormcloudVideoPlayer] Ignoring SCTE-35 break start: a break is already active", {
|
|
11089
|
+
state: this.adBreak.getSlotState(),
|
|
11090
|
+
cueKey: cueKey
|
|
11091
|
+
});
|
|
11092
|
+
}
|
|
11093
|
+
return;
|
|
11094
|
+
}
|
|
10901
11095
|
this.adBreak.inAdBreak = true;
|
|
10902
11096
|
this.cueManager.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.cueManager.pendingScte35CueKey;
|
|
10903
11097
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
@@ -10930,7 +11124,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10930
11124
|
this.adBreak.noteStopBeforeStart("break_boundary");
|
|
10931
11125
|
this.adPlayer.stop().catch(function() {});
|
|
10932
11126
|
}
|
|
10933
|
-
this.adBreak.handleAdPodComplete();
|
|
11127
|
+
this.adBreak.handleAdPodComplete("break_boundary");
|
|
10934
11128
|
}
|
|
10935
11129
|
},
|
|
10936
11130
|
{
|
|
@@ -10940,14 +11134,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10940
11134
|
key: "startAdPrefetch",
|
|
10941
11135
|
value: function startAdPrefetch(marker, fragmentSn, cueKey) {
|
|
10942
11136
|
if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
|
|
10943
|
-
var
|
|
10944
|
-
|
|
10945
|
-
var baseVastUrl;
|
|
10946
|
-
if (tags && tags.length > 0 && tags[0]) {
|
|
10947
|
-
baseVastUrl = tags[0];
|
|
10948
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
10949
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
10950
|
-
} else {
|
|
11137
|
+
var baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
11138
|
+
if (!baseVastUrl) {
|
|
10951
11139
|
if (this.debug) console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
|
|
10952
11140
|
return;
|
|
10953
11141
|
}
|
|
@@ -10977,8 +11165,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10977
11165
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
10978
11166
|
}, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
|
|
10979
11167
|
if (this.debug) {
|
|
10980
|
-
console.log("[PREFETCH]
|
|
10981
|
-
console.log("[PREFETCH] Pre-generated pod request URL");
|
|
11168
|
+
console.log("[PREFETCH] Pre-generated pod request URL for upcoming ad break");
|
|
10982
11169
|
}
|
|
10983
11170
|
}
|
|
10984
11171
|
},
|
|
@@ -10989,7 +11176,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10989
11176
|
key: "onTimeUpdate",
|
|
10990
11177
|
value: function onTimeUpdate(currentTimeSec) {
|
|
10991
11178
|
var _this = this;
|
|
10992
|
-
if (
|
|
11179
|
+
if (this.adConfig.vmapBreaks.length === 0) return;
|
|
10993
11180
|
if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
|
|
10994
11181
|
var nowMs = currentTimeSec * 1e3;
|
|
10995
11182
|
var breakToPlay = this.adConfig.findBreakForTime(nowMs);
|
|
@@ -11006,7 +11193,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
11006
11193
|
key: "onVideoEnded",
|
|
11007
11194
|
value: function onVideoEnded() {
|
|
11008
11195
|
var _this = this;
|
|
11009
|
-
if (
|
|
11196
|
+
if (this.adConfig.vmapBreaks.length === 0) return;
|
|
11010
11197
|
if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
|
|
11011
11198
|
var durationMs = Number.isFinite(this.video.duration) ? Math.floor(this.video.duration * 1e3) : 0;
|
|
11012
11199
|
var postroll = this.adConfig.vmapBreaks.find(function(b) {
|
|
@@ -11059,7 +11246,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
11059
11246
|
if (durationMs > 0) {
|
|
11060
11247
|
this.timing.setAdBreakDurationBoundary(durationMs);
|
|
11061
11248
|
}
|
|
11062
|
-
this.adBreak.
|
|
11249
|
+
this.adBreak.beginVmapBreak(key);
|
|
11063
11250
|
_state.label = 1;
|
|
11064
11251
|
case 1:
|
|
11065
11252
|
_state.trys.push([
|
|
@@ -11070,7 +11257,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
11070
11257
|
]);
|
|
11071
11258
|
return [
|
|
11072
11259
|
4,
|
|
11073
|
-
this.adBreak.playSingleAd(first)
|
|
11260
|
+
this.adBreak.playSingleAd(first, "vmap")
|
|
11074
11261
|
];
|
|
11075
11262
|
case 2:
|
|
11076
11263
|
_state.sent();
|
|
@@ -11083,7 +11270,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
11083
11270
|
if (this.debug) {
|
|
11084
11271
|
console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
|
|
11085
11272
|
}
|
|
11086
|
-
this.adBreak.
|
|
11273
|
+
this.adBreak.continueAfterRequestFailure();
|
|
11087
11274
|
return [
|
|
11088
11275
|
3,
|
|
11089
11276
|
4
|
|
@@ -11225,7 +11412,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
11225
11412
|
key: "destroy",
|
|
11226
11413
|
value: function destroy() {
|
|
11227
11414
|
var _this_adPlayer;
|
|
11228
|
-
this.adBreak.
|
|
11415
|
+
this.adBreak.cancelScheduledRequest();
|
|
11229
11416
|
this.timing.destroy();
|
|
11230
11417
|
this.adBreak.clearPendingAdBreak();
|
|
11231
11418
|
this.placeholder.destroy();
|
|
@@ -11249,7 +11436,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
11249
11436
|
this.palNonce.sendPlaybackEnd();
|
|
11250
11437
|
}
|
|
11251
11438
|
this.palNonce.reset();
|
|
11252
|
-
this.adBreak.adRequestQueue = [];
|
|
11253
11439
|
this.timing.consecutiveFailures = 0;
|
|
11254
11440
|
}
|
|
11255
11441
|
}
|