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