stormcloud-video-player 0.8.64 → 0.8.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/stormcloud-vp.min.js +2 -2
- package/lib/StormcloudPlayer.cjs +1897 -917
- package/lib/StormcloudPlayer.cjs.map +1 -1
- package/lib/index.cjs +1853 -909
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +10 -0
- package/lib/index.js +1853 -909
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +899 -736
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +50 -16
- package/lib/player/AdConfigManager.cjs +16 -1
- package/lib/player/AdConfigManager.cjs.map +1 -1
- package/lib/player/AdTimingService.cjs +9 -1
- package/lib/player/AdTimingService.cjs.map +1 -1
- package/lib/player/AdTimingService.d.cts +1 -0
- package/lib/player/StormcloudVideoPlayer.cjs +1890 -910
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +1890 -910
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +1890 -910
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +975 -175
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -0
- package/lib/types.d.cts +9 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +1854 -910
- 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/players/index.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;
|
|
@@ -807,7 +823,7 @@ function toVastMediaErrorCode(error) {
|
|
|
807
823
|
}
|
|
808
824
|
}
|
|
809
825
|
function createHlsAdPlayer(contentVideo, options) {
|
|
810
|
-
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
|
|
826
|
+
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP, _ref;
|
|
811
827
|
var adPlaying = false;
|
|
812
828
|
var originalMutedState = false;
|
|
813
829
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
@@ -839,6 +855,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
839
855
|
var sawDecodedVideoFrame = false;
|
|
840
856
|
var videoFrameCallbackHandle;
|
|
841
857
|
var pendingPlayPromise;
|
|
858
|
+
var currentVastTagUrl;
|
|
859
|
+
var funnelContext = {};
|
|
860
|
+
var mediaProbe;
|
|
861
|
+
var lastPodAdElementCount = 0;
|
|
862
|
+
var mediaCandidates = [];
|
|
863
|
+
var mediaCandidateIndex = 0;
|
|
864
|
+
var mediaStartTimerId;
|
|
865
|
+
var MEDIA_START_TIMEOUT_MS = (_ref = options === null || options === void 0 ? void 0 : options.mediaStartTimeoutMs) !== null && _ref !== void 0 ? _ref : 8e3;
|
|
866
|
+
var VAST_ERROR_MEDIA_TIMEOUT = 402;
|
|
867
|
+
var pendingVastRequests = /* @__PURE__ */ new Set();
|
|
868
|
+
var pendingRequestAbortReason;
|
|
869
|
+
var forcedMuteByAutoplay = false;
|
|
842
870
|
function createTrackingState() {
|
|
843
871
|
return {
|
|
844
872
|
impression: false,
|
|
@@ -889,6 +917,78 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
889
917
|
}
|
|
890
918
|
}
|
|
891
919
|
}
|
|
920
|
+
var SENSITIVE_URL_PARAMS = /* @__PURE__ */ new Set([
|
|
921
|
+
"ppid",
|
|
922
|
+
"rdid",
|
|
923
|
+
"idtype",
|
|
924
|
+
"is_lat",
|
|
925
|
+
"ifa",
|
|
926
|
+
"idfa",
|
|
927
|
+
"aaid",
|
|
928
|
+
"uid",
|
|
929
|
+
"user_id",
|
|
930
|
+
"userid",
|
|
931
|
+
"device_id",
|
|
932
|
+
"deviceid",
|
|
933
|
+
"ip",
|
|
934
|
+
"ua",
|
|
935
|
+
"gdpr_consent",
|
|
936
|
+
"us_privacy",
|
|
937
|
+
"gpp",
|
|
938
|
+
"addtl_consent",
|
|
939
|
+
"cust_params",
|
|
940
|
+
"email"
|
|
941
|
+
]);
|
|
942
|
+
function redactUrl(url) {
|
|
943
|
+
if (!url) return url;
|
|
944
|
+
try {
|
|
945
|
+
var parsed = new URL(url);
|
|
946
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
947
|
+
try {
|
|
948
|
+
for(var _iterator = Array.from(parsed.searchParams.keys())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
949
|
+
var key = _step.value;
|
|
950
|
+
if (SENSITIVE_URL_PARAMS.has(key.toLowerCase())) {
|
|
951
|
+
parsed.searchParams.set(key, "REDACTED");
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
} catch (err) {
|
|
955
|
+
_didIteratorError = true;
|
|
956
|
+
_iteratorError = err;
|
|
957
|
+
} finally{
|
|
958
|
+
try {
|
|
959
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
960
|
+
_iterator.return();
|
|
961
|
+
}
|
|
962
|
+
} finally{
|
|
963
|
+
if (_didIteratorError) {
|
|
964
|
+
throw _iteratorError;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
return parsed.toString();
|
|
969
|
+
} catch (unused) {
|
|
970
|
+
return url.split("?")[0];
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
function logFunnel(stage) {
|
|
974
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
975
|
+
var payload = _object_spread({
|
|
976
|
+
stage: stage,
|
|
977
|
+
breakId: funnelContext.breakId,
|
|
978
|
+
requestId: funnelContext.requestId,
|
|
979
|
+
controllerId: funnelContext.controllerId,
|
|
980
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0,
|
|
981
|
+
adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
|
|
982
|
+
podIndex: podIndex,
|
|
983
|
+
podSize: podAds.length,
|
|
984
|
+
vastUrl: redactUrl(currentVastTagUrl),
|
|
985
|
+
mediaUrl: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url,
|
|
986
|
+
mediaType: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.type,
|
|
987
|
+
muted: adVideoElement ? adVideoElement.muted : void 0
|
|
988
|
+
}, extra);
|
|
989
|
+
console.log("[HlsAdPlayer][FUNNEL] ".concat(stage), payload);
|
|
990
|
+
emit("ad_funnel", payload);
|
|
991
|
+
}
|
|
892
992
|
function buildTrackingMacroContext() {
|
|
893
993
|
var options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
894
994
|
var _options2_ad;
|
|
@@ -928,20 +1028,53 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
928
1028
|
urls.forEach(function(url) {
|
|
929
1029
|
try {
|
|
930
1030
|
var trackingUrl = substituteVastTrackingMacros(url, macroContext);
|
|
1031
|
+
var trackingHost;
|
|
1032
|
+
try {
|
|
1033
|
+
trackingHost = new URL(trackingUrl).host;
|
|
1034
|
+
} catch (unused) {
|
|
1035
|
+
logFunnel("tracking_url_invalid", {
|
|
1036
|
+
trackingUrl: redactUrl(trackingUrl)
|
|
1037
|
+
});
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
1040
|
+
var unexpanded = trackingUrl.match(/\[[A-Z_]+\]/g);
|
|
1041
|
+
if (unexpanded) {
|
|
1042
|
+
logFunnel("tracking_url_unexpanded_macro", {
|
|
1043
|
+
trackingHost: trackingHost,
|
|
1044
|
+
macros: Array.from(new Set(unexpanded))
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
931
1047
|
var img = new Image(1, 1);
|
|
932
1048
|
inFlightBeacons.add(img);
|
|
933
1049
|
var timeoutId;
|
|
934
|
-
var release = function release() {
|
|
1050
|
+
var release = function release(outcome) {
|
|
935
1051
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
936
1052
|
img.onload = null;
|
|
937
1053
|
img.onerror = null;
|
|
938
1054
|
inFlightBeacons.delete(img);
|
|
1055
|
+
console.log("[HlsAdPlayer] Tracking pixel settled (".concat(outcome, "): ").concat(trackingUrl));
|
|
1056
|
+
if (outcome !== "load") {
|
|
1057
|
+
logFunnel("tracking_request_settled", {
|
|
1058
|
+
reason: outcome,
|
|
1059
|
+
trackingHost: trackingHost
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
img.onload = function() {
|
|
1064
|
+
return release("load");
|
|
1065
|
+
};
|
|
1066
|
+
img.onerror = function() {
|
|
1067
|
+
return release("error");
|
|
939
1068
|
};
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
1069
|
+
timeoutId = setTimeout(function() {
|
|
1070
|
+
return release("timeout");
|
|
1071
|
+
}, BEACON_TIMEOUT_MS);
|
|
943
1072
|
img.src = trackingUrl;
|
|
944
1073
|
console.log("[HlsAdPlayer] Fired tracking pixel: ".concat(trackingUrl));
|
|
1074
|
+
logFunnel("tracking_request_created", {
|
|
1075
|
+
trackingHost: trackingHost,
|
|
1076
|
+
errorCode: options2 === null || options2 === void 0 ? void 0 : options2.errorCode
|
|
1077
|
+
});
|
|
945
1078
|
} catch (error) {
|
|
946
1079
|
console.warn("[HlsAdPlayer] Error firing tracking pixel:", error);
|
|
947
1080
|
}
|
|
@@ -971,54 +1104,79 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
971
1104
|
bitrate: level.bitrate || 5e6
|
|
972
1105
|
};
|
|
973
1106
|
}
|
|
974
|
-
function
|
|
975
|
-
if (mediaFiles.length === 0) {
|
|
976
|
-
throw new Error("No media files available");
|
|
977
|
-
}
|
|
978
|
-
var firstFile = mediaFiles[0];
|
|
979
|
-
if (!firstFile) {
|
|
980
|
-
throw new Error("No media files available");
|
|
981
|
-
}
|
|
982
|
-
if (mediaFiles.length === 1) {
|
|
983
|
-
return firstFile;
|
|
984
|
-
}
|
|
1107
|
+
function getMediaTargetQuality() {
|
|
985
1108
|
var mainQuality = getMainStreamQuality();
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1109
|
+
var dpr = typeof window !== "undefined" && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1;
|
|
1110
|
+
var containerWidth = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientWidth) || contentVideo.clientWidth) * dpr;
|
|
1111
|
+
var containerHeight = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientHeight) || contentVideo.clientHeight) * dpr;
|
|
1112
|
+
if (!mainQuality && !(containerWidth > 0 && containerHeight > 0)) {
|
|
1113
|
+
return null;
|
|
1114
|
+
}
|
|
1115
|
+
var base = mainQuality !== null && mainQuality !== void 0 ? mainQuality : {
|
|
1116
|
+
width: containerWidth,
|
|
1117
|
+
height: containerHeight,
|
|
1118
|
+
bitrate: 5e6
|
|
1119
|
+
};
|
|
1120
|
+
var width = containerWidth > 0 ? Math.min(base.width, containerWidth) : base.width;
|
|
1121
|
+
var height = containerHeight > 0 ? Math.min(base.height, containerHeight) : base.height;
|
|
1122
|
+
return {
|
|
1123
|
+
width: width,
|
|
1124
|
+
height: height,
|
|
1125
|
+
bitrate: base.bitrate
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
function rankMediaCandidates(mediaFiles) {
|
|
1129
|
+
var probe = adVideoElement !== null && adVideoElement !== void 0 ? adVideoElement : document.createElement("video");
|
|
1130
|
+
var pageIsHttps = typeof location !== "undefined" && location.protocol === "https:";
|
|
1131
|
+
var target = getMediaTargetQuality();
|
|
1132
|
+
var accepted = [];
|
|
1133
|
+
mediaFiles.forEach(function(file, index) {
|
|
1134
|
+
var isHls = isHlsMediaFile(file);
|
|
1135
|
+
var mimeForProbe = isHls ? "application/vnd.apple.mpegurl" : file.type || "video/mp4";
|
|
1136
|
+
var canPlay2 = probe.canPlayType(mimeForProbe);
|
|
1137
|
+
var playable = isHls ? import_hls.default.isSupported() || canPlay2 !== "" : canPlay2 !== "";
|
|
1138
|
+
var insecure = pageIsHttps && /^http:/i.test(file.url);
|
|
1139
|
+
var details = {
|
|
1140
|
+
index: index,
|
|
1141
|
+
candidateUrl: file.url,
|
|
1142
|
+
candidateType: file.type,
|
|
1143
|
+
width: file.width,
|
|
1144
|
+
height: file.height,
|
|
1145
|
+
bitrate: file.bitrate,
|
|
1146
|
+
canPlayType: canPlay2,
|
|
1147
|
+
hlsJs: isHls ? import_hls.default.isSupported() : void 0
|
|
1148
|
+
};
|
|
1149
|
+
if (!playable) {
|
|
1150
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1151
|
+
reason: "rejected",
|
|
1152
|
+
why: "cannot_play_type"
|
|
1153
|
+
}));
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
var score = 0;
|
|
1157
|
+
if (target) {
|
|
1158
|
+
var resolutionDiff = Math.abs(file.width - target.width) + Math.abs(file.height - target.height);
|
|
1159
|
+
var bitrateDiff = Math.abs((file.bitrate || 5e3) * 1e3 - target.bitrate);
|
|
1160
|
+
score = resolutionDiff * 2 + bitrateDiff / 1e3;
|
|
1161
|
+
}
|
|
1162
|
+
accepted.push({
|
|
999
1163
|
file: file,
|
|
1000
1164
|
score: score,
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
}
|
|
1165
|
+
insecure: insecure
|
|
1166
|
+
});
|
|
1167
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1168
|
+
reason: "accepted",
|
|
1169
|
+
why: insecure ? "insecure_http_deprioritized" : "playable",
|
|
1170
|
+
score: score
|
|
1171
|
+
}));
|
|
1004
1172
|
});
|
|
1005
|
-
|
|
1173
|
+
accepted.sort(function(a, b) {
|
|
1174
|
+
if (a.insecure !== b.insecure) return a.insecure ? 1 : -1;
|
|
1006
1175
|
return a.score - b.score;
|
|
1007
1176
|
});
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
console.log("[HlsAdPlayer] No best match found, using first media file");
|
|
1011
|
-
return firstFile;
|
|
1012
|
-
}
|
|
1013
|
-
console.log("[HlsAdPlayer] Selected media file:", {
|
|
1014
|
-
url: bestMatch.file.url,
|
|
1015
|
-
resolution: "".concat(bestMatch.file.width, "x").concat(bestMatch.file.height),
|
|
1016
|
-
bitrate: bestMatch.file.bitrate,
|
|
1017
|
-
score: bestMatch.score,
|
|
1018
|
-
resolutionDiff: bestMatch.resolutionDiff,
|
|
1019
|
-
bitrateDiff: bestMatch.bitrateDiff
|
|
1177
|
+
return accepted.map(function(entry) {
|
|
1178
|
+
return entry.file;
|
|
1020
1179
|
});
|
|
1021
|
-
return bestMatch.file;
|
|
1022
1180
|
}
|
|
1023
1181
|
function isHlsMediaFile(mediaFile) {
|
|
1024
1182
|
var type = mediaFile.type.toLowerCase();
|
|
@@ -1035,59 +1193,181 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1035
1193
|
var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
|
|
1036
1194
|
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");
|
|
1037
1195
|
}
|
|
1038
|
-
function
|
|
1196
|
+
function getMediaProbe() {
|
|
1197
|
+
if (adVideoElement) return adVideoElement;
|
|
1198
|
+
if (!mediaProbe && typeof document !== "undefined") {
|
|
1199
|
+
mediaProbe = document.createElement("video");
|
|
1200
|
+
}
|
|
1201
|
+
return mediaProbe;
|
|
1202
|
+
}
|
|
1203
|
+
function evaluateMediaFile(mf) {
|
|
1204
|
+
var _mf_textContent;
|
|
1205
|
+
var type = mf.getAttribute("type") || "";
|
|
1206
|
+
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1207
|
+
var delivery = mf.getAttribute("delivery") || void 0;
|
|
1208
|
+
var codec = mf.getAttribute("codec") || void 0;
|
|
1209
|
+
if (!url) {
|
|
1210
|
+
return {
|
|
1211
|
+
category: "missing_media",
|
|
1212
|
+
whyRejected: "empty_url",
|
|
1213
|
+
canPlayType: ""
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
var apiFramework = (mf.getAttribute("apiFramework") || "").toUpperCase();
|
|
1217
|
+
if (apiFramework === "VPAID") {
|
|
1218
|
+
return {
|
|
1219
|
+
category: "vpaid",
|
|
1220
|
+
whyRejected: "vpaid_not_supported",
|
|
1221
|
+
canPlayType: ""
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
try {
|
|
1225
|
+
var protocol = new URL(url).protocol;
|
|
1226
|
+
if (protocol !== "https:" && protocol !== "http:") {
|
|
1227
|
+
return {
|
|
1228
|
+
category: "invalid_url",
|
|
1229
|
+
whyRejected: "protocol_".concat(protocol),
|
|
1230
|
+
canPlayType: ""
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
} catch (unused) {
|
|
1234
|
+
return {
|
|
1235
|
+
category: "invalid_url",
|
|
1236
|
+
whyRejected: "unparseable_url",
|
|
1237
|
+
canPlayType: ""
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1241
|
+
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1242
|
+
var file = {
|
|
1243
|
+
url: url,
|
|
1244
|
+
type: type,
|
|
1245
|
+
width: parseInt(mf.getAttribute("width") || "1920", 10),
|
|
1246
|
+
height: parseInt(mf.getAttribute("height") || "1080", 10),
|
|
1247
|
+
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0,
|
|
1248
|
+
delivery: delivery,
|
|
1249
|
+
codec: codec
|
|
1250
|
+
};
|
|
1251
|
+
if (isAudioMediaFile(file)) {
|
|
1252
|
+
return {
|
|
1253
|
+
category: "audio_only",
|
|
1254
|
+
whyRejected: type.toLowerCase().startsWith("audio/") ? "audio_mime" : "audio_extension",
|
|
1255
|
+
canPlayType: ""
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
var isHls = isHlsMediaFile(file);
|
|
1259
|
+
var hasExplicitDimensions = mf.getAttribute("width") != null && mf.getAttribute("height") != null;
|
|
1260
|
+
if (!isHls && hasExplicitDimensions && (file.width <= 1 || file.height <= 1)) {
|
|
1261
|
+
return {
|
|
1262
|
+
category: "audio_only",
|
|
1263
|
+
whyRejected: "zero_dimensions",
|
|
1264
|
+
canPlayType: ""
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
var probe = getMediaProbe();
|
|
1268
|
+
if (isHls) {
|
|
1269
|
+
var _ref;
|
|
1270
|
+
var nativeHls = (_ref = probe === null || probe === void 0 ? void 0 : probe.canPlayType("application/vnd.apple.mpegurl")) !== null && _ref !== void 0 ? _ref : "";
|
|
1271
|
+
if (import_hls.default.isSupported()) {
|
|
1272
|
+
return {
|
|
1273
|
+
file: file,
|
|
1274
|
+
whyAccepted: "hls_js",
|
|
1275
|
+
canPlayType: nativeHls
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
if (nativeHls !== "") {
|
|
1279
|
+
return {
|
|
1280
|
+
file: file,
|
|
1281
|
+
whyAccepted: "native_hls",
|
|
1282
|
+
canPlayType: nativeHls
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
return {
|
|
1286
|
+
category: "unsupported_hls",
|
|
1287
|
+
whyRejected: "no_hls_support",
|
|
1288
|
+
canPlayType: nativeHls
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
if (!isProgressiveMediaFile(file)) {
|
|
1292
|
+
return {
|
|
1293
|
+
category: "unsupported_mime",
|
|
1294
|
+
whyRejected: "not_a_video_mime",
|
|
1295
|
+
canPlayType: ""
|
|
1296
|
+
};
|
|
1297
|
+
}
|
|
1298
|
+
if (!probe) {
|
|
1299
|
+
return {
|
|
1300
|
+
file: file,
|
|
1301
|
+
whyAccepted: "no_probe_available",
|
|
1302
|
+
canPlayType: ""
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
var baseType = type || "video/mp4";
|
|
1306
|
+
var canPlay2 = probe.canPlayType(baseType);
|
|
1307
|
+
if (canPlay2 === "") {
|
|
1308
|
+
return {
|
|
1309
|
+
category: "unsupported_mime",
|
|
1310
|
+
whyRejected: "canPlayType_empty",
|
|
1311
|
+
canPlayType: canPlay2
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
if (codec) {
|
|
1315
|
+
var withCodec = probe.canPlayType("".concat(baseType, '; codecs="').concat(codec, '"'));
|
|
1316
|
+
if (withCodec === "") {
|
|
1317
|
+
return {
|
|
1318
|
+
category: "unsupported_codec",
|
|
1319
|
+
whyRejected: "codec_canPlayType_empty",
|
|
1320
|
+
canPlayType: withCodec
|
|
1321
|
+
};
|
|
1322
|
+
}
|
|
1323
|
+
return {
|
|
1324
|
+
file: file,
|
|
1325
|
+
whyAccepted: "canPlayType_".concat(withCodec),
|
|
1326
|
+
canPlayType: withCodec
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
return {
|
|
1330
|
+
file: file,
|
|
1331
|
+
whyAccepted: "canPlayType_".concat(canPlay2),
|
|
1332
|
+
canPlayType: canPlay2
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
function collectVideoMediaFiles(linear, verbose, stats) {
|
|
1039
1336
|
var mediaFileElements = linear.querySelectorAll(":scope > MediaFiles > MediaFile");
|
|
1040
1337
|
var mediaFiles = [];
|
|
1338
|
+
if (stats) stats.total += mediaFileElements.length;
|
|
1041
1339
|
if (verbose) {
|
|
1042
1340
|
console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
|
|
1043
1341
|
}
|
|
1044
1342
|
mediaFileElements.forEach(function(mf, index) {
|
|
1045
1343
|
var _mf_textContent;
|
|
1046
|
-
var
|
|
1344
|
+
var result = evaluateMediaFile(mf);
|
|
1047
1345
|
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1048
|
-
var
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
}
|
|
1066
|
-
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1067
|
-
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1068
|
-
var mediaFile = {
|
|
1069
|
-
url: url,
|
|
1070
|
-
type: type,
|
|
1071
|
-
width: parseInt(width || "1920", 10),
|
|
1072
|
-
height: parseInt(height || "1080", 10),
|
|
1073
|
-
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
1074
|
-
};
|
|
1075
|
-
if (isAudioMediaFile(mediaFile)) {
|
|
1076
|
-
console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
|
|
1346
|
+
var accepted = "file" in result;
|
|
1347
|
+
logFunnel("mediafile_evaluated", {
|
|
1348
|
+
reason: accepted ? "accepted" : result.category,
|
|
1349
|
+
index: index,
|
|
1350
|
+
type: mf.getAttribute("type") || "",
|
|
1351
|
+
delivery: mf.getAttribute("delivery") || void 0,
|
|
1352
|
+
codec: mf.getAttribute("codec") || void 0,
|
|
1353
|
+
apiFramework: mf.getAttribute("apiFramework") || void 0,
|
|
1354
|
+
width: mf.getAttribute("width"),
|
|
1355
|
+
height: mf.getAttribute("height"),
|
|
1356
|
+
fileUrl: redactUrl(url),
|
|
1357
|
+
canPlayType: result.canPlayType,
|
|
1358
|
+
whyAccepted: accepted ? result.whyAccepted : void 0,
|
|
1359
|
+
whyRejected: accepted ? void 0 : result.whyRejected
|
|
1360
|
+
});
|
|
1361
|
+
if ("file" in result) {
|
|
1362
|
+
mediaFiles.push(result.file);
|
|
1077
1363
|
return;
|
|
1078
1364
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
return;
|
|
1365
|
+
if (stats) {
|
|
1366
|
+
var _stats_categories_result_category;
|
|
1367
|
+
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;
|
|
1083
1368
|
}
|
|
1084
|
-
if (
|
|
1085
|
-
|
|
1086
|
-
if (verbose) {
|
|
1087
|
-
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
1088
|
-
}
|
|
1089
|
-
} else if (verbose) {
|
|
1090
|
-
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
1369
|
+
if (result.category === "audio_only") {
|
|
1370
|
+
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'));
|
|
1091
1371
|
}
|
|
1092
1372
|
});
|
|
1093
1373
|
return mediaFiles;
|
|
@@ -1211,26 +1491,58 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1211
1491
|
}
|
|
1212
1492
|
function parseVastXml(xmlString) {
|
|
1213
1493
|
try {
|
|
1214
|
-
var _adElements_find;
|
|
1215
1494
|
var xmlDoc = parseXml(xmlString);
|
|
1216
1495
|
if (!xmlDoc) return {
|
|
1217
1496
|
type: "empty"
|
|
1218
1497
|
};
|
|
1219
1498
|
var root = xmlDoc.documentElement;
|
|
1220
1499
|
var adElements = Array.from(root.querySelectorAll(":scope > Ad"));
|
|
1221
|
-
|
|
1222
|
-
return getAdSequence(el) === void 0;
|
|
1223
|
-
})) !== null && _adElements_find !== void 0 ? _adElements_find : adElements[0];
|
|
1224
|
-
if (!adElement) {
|
|
1500
|
+
if (adElements.length === 0) {
|
|
1225
1501
|
var _root_getAttribute;
|
|
1226
1502
|
console.warn("[HlsAdPlayer] No Ad element found in VAST ".concat((_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : "", " response"));
|
|
1227
1503
|
return emptyVastResult(root);
|
|
1228
1504
|
}
|
|
1229
|
-
var
|
|
1230
|
-
|
|
1231
|
-
|
|
1505
|
+
var ordered = _to_consumable_array(adElements.filter(function(el) {
|
|
1506
|
+
return getAdSequence(el) === void 0;
|
|
1507
|
+
})).concat(_to_consumable_array(adElements.filter(function(el) {
|
|
1508
|
+
return getAdSequence(el) !== void 0;
|
|
1509
|
+
})));
|
|
1510
|
+
var firstEmpty;
|
|
1511
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1512
|
+
try {
|
|
1513
|
+
for(var _iterator = ordered.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1514
|
+
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], adElement = _step_value[1];
|
|
1515
|
+
var parsed = parseAdElement(adElement, true);
|
|
1516
|
+
if (parsed.type === "empty") {
|
|
1517
|
+
firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : firstEmpty = parsed;
|
|
1518
|
+
continue;
|
|
1519
|
+
}
|
|
1520
|
+
if (index > 0) {
|
|
1521
|
+
logFunnel("vast_ad_fallback", {
|
|
1522
|
+
usedAdIndex: index,
|
|
1523
|
+
adCount: ordered.length
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
if (parsed.type === "wrapper") {
|
|
1527
|
+
console.log("[HlsAdPlayer] VAST wrapper detected, following VASTAdTagURI: ".concat(parsed.vastAdTagUri));
|
|
1528
|
+
}
|
|
1529
|
+
return parsed;
|
|
1530
|
+
}
|
|
1531
|
+
} catch (err) {
|
|
1532
|
+
_didIteratorError = true;
|
|
1533
|
+
_iteratorError = err;
|
|
1534
|
+
} finally{
|
|
1535
|
+
try {
|
|
1536
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1537
|
+
_iterator.return();
|
|
1538
|
+
}
|
|
1539
|
+
} finally{
|
|
1540
|
+
if (_didIteratorError) {
|
|
1541
|
+
throw _iteratorError;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1232
1544
|
}
|
|
1233
|
-
return
|
|
1545
|
+
return firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : emptyVastResult(root);
|
|
1234
1546
|
} catch (error) {
|
|
1235
1547
|
console.error("[HlsAdPlayer] Error parsing VAST XML:", error);
|
|
1236
1548
|
return {
|
|
@@ -1276,6 +1588,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1276
1588
|
pushUrls(errorUrls, inLine.querySelectorAll(":scope > Error"));
|
|
1277
1589
|
if (adElement.getAttribute("conditionalAd") === "true") {
|
|
1278
1590
|
console.warn("[HlsAdPlayer] Skipping conditional <Ad> (VPAID-only)");
|
|
1591
|
+
logFunnel("vast_no_supported_media", {
|
|
1592
|
+
reason: "vpaid",
|
|
1593
|
+
conditionalAd: true
|
|
1594
|
+
});
|
|
1279
1595
|
return {
|
|
1280
1596
|
type: "empty",
|
|
1281
1597
|
errorUrls: errorUrls,
|
|
@@ -1284,11 +1600,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1284
1600
|
}
|
|
1285
1601
|
var linear;
|
|
1286
1602
|
var mediaFiles = [];
|
|
1603
|
+
var rejectStats = {
|
|
1604
|
+
total: 0,
|
|
1605
|
+
categories: {}
|
|
1606
|
+
};
|
|
1287
1607
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1288
1608
|
try {
|
|
1289
1609
|
for(var _iterator = Array.from(inLine.querySelectorAll(":scope > Creatives > Creative > Linear"))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1290
1610
|
var candidate = _step.value;
|
|
1291
|
-
var files = collectVideoMediaFiles(candidate, verbose);
|
|
1611
|
+
var files = collectVideoMediaFiles(candidate, verbose, rejectStats);
|
|
1292
1612
|
if (files.length > 0) {
|
|
1293
1613
|
linear = candidate;
|
|
1294
1614
|
mediaFiles = files;
|
|
@@ -1311,6 +1631,39 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1311
1631
|
}
|
|
1312
1632
|
if (!linear) {
|
|
1313
1633
|
console.warn("[HlsAdPlayer] No supported linear media files in <Ad>");
|
|
1634
|
+
var reason = "missing_media";
|
|
1635
|
+
var top = 0;
|
|
1636
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
1637
|
+
try {
|
|
1638
|
+
for(var _iterator1 = Object.keys(rejectStats.categories)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
1639
|
+
var category = _step1.value;
|
|
1640
|
+
var _rejectStats_categories_category;
|
|
1641
|
+
var count = (_rejectStats_categories_category = rejectStats.categories[category]) !== null && _rejectStats_categories_category !== void 0 ? _rejectStats_categories_category : 0;
|
|
1642
|
+
if (count > top) {
|
|
1643
|
+
top = count;
|
|
1644
|
+
reason = category;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
} catch (err) {
|
|
1648
|
+
_didIteratorError1 = true;
|
|
1649
|
+
_iteratorError1 = err;
|
|
1650
|
+
} finally{
|
|
1651
|
+
try {
|
|
1652
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1653
|
+
_iterator1.return();
|
|
1654
|
+
}
|
|
1655
|
+
} finally{
|
|
1656
|
+
if (_didIteratorError1) {
|
|
1657
|
+
throw _iteratorError1;
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
if (rejectStats.total > 0 && top === 0) reason = "other";
|
|
1662
|
+
logFunnel("vast_no_supported_media", {
|
|
1663
|
+
reason: reason,
|
|
1664
|
+
mediaFileCount: rejectStats.total,
|
|
1665
|
+
rejectedByCategory: rejectStats.categories
|
|
1666
|
+
});
|
|
1314
1667
|
return {
|
|
1315
1668
|
type: "empty",
|
|
1316
1669
|
errorUrls: errorUrls,
|
|
@@ -1340,27 +1693,65 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1340
1693
|
}
|
|
1341
1694
|
}
|
|
1342
1695
|
function fetchVastXml(vastTagUrl) {
|
|
1343
|
-
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
1696
|
+
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include", kind = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "gam";
|
|
1344
1697
|
return _async_to_generator(function() {
|
|
1345
|
-
var controller, timeoutId, requestVast, response, error, error1;
|
|
1698
|
+
var controller, timeoutId, startedAt, attempt, requestVast, response, error, error1;
|
|
1346
1699
|
return _ts_generator(this, function(_state) {
|
|
1347
1700
|
switch(_state.label){
|
|
1348
1701
|
case 0:
|
|
1702
|
+
if (destroyed) {
|
|
1703
|
+
throw new Error("VAST request skipped: ad player destroyed");
|
|
1704
|
+
}
|
|
1349
1705
|
controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1706
|
+
if (controller) pendingVastRequests.add(controller);
|
|
1350
1707
|
timeoutId = controller ? setTimeout(function() {
|
|
1351
1708
|
return controller.abort();
|
|
1352
1709
|
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
1710
|
+
startedAt = Date.now();
|
|
1711
|
+
attempt = 0;
|
|
1353
1712
|
requestVast = function requestVast(creds) {
|
|
1354
|
-
return
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1713
|
+
return _async_to_generator(function() {
|
|
1714
|
+
var response;
|
|
1715
|
+
return _ts_generator(this, function(_state) {
|
|
1716
|
+
switch(_state.label){
|
|
1717
|
+
case 0:
|
|
1718
|
+
attempt++;
|
|
1719
|
+
if (kind === "gam") {
|
|
1720
|
+
logFunnel("gam_http_request_sent", {
|
|
1721
|
+
attempt: attempt,
|
|
1722
|
+
credentials: creds
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
return [
|
|
1726
|
+
4,
|
|
1727
|
+
fetch(vastTagUrl, _object_spread({
|
|
1728
|
+
mode: "cors",
|
|
1729
|
+
credentials: creds,
|
|
1730
|
+
headers: {
|
|
1731
|
+
"Accept": "application/xml, text/xml, */*"
|
|
1732
|
+
},
|
|
1733
|
+
referrerPolicy: "no-referrer-when-downgrade"
|
|
1734
|
+
}, controller ? {
|
|
1735
|
+
signal: controller.signal
|
|
1736
|
+
} : {}))
|
|
1737
|
+
];
|
|
1738
|
+
case 1:
|
|
1739
|
+
response = _state.sent();
|
|
1740
|
+
if (kind === "gam") {
|
|
1741
|
+
logFunnel("gam_response_received", {
|
|
1742
|
+
attempt: attempt,
|
|
1743
|
+
httpStatus: response.status,
|
|
1744
|
+
ok: response.ok,
|
|
1745
|
+
elapsedMs: Date.now() - startedAt
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
return [
|
|
1749
|
+
2,
|
|
1750
|
+
response
|
|
1751
|
+
];
|
|
1752
|
+
}
|
|
1753
|
+
});
|
|
1754
|
+
})();
|
|
1364
1755
|
};
|
|
1365
1756
|
_state.label = 1;
|
|
1366
1757
|
case 1:
|
|
@@ -1395,6 +1786,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1395
1786
|
6
|
|
1396
1787
|
];
|
|
1397
1788
|
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
1789
|
+
logFunnel("vast_credentials_retry", {
|
|
1790
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1791
|
+
});
|
|
1398
1792
|
return [
|
|
1399
1793
|
4,
|
|
1400
1794
|
requestVast("omit")
|
|
@@ -1414,7 +1808,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1414
1808
|
];
|
|
1415
1809
|
case 8:
|
|
1416
1810
|
if (!response.ok) {
|
|
1417
|
-
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
1811
|
+
throw new Error("Failed to fetch VAST: HTTP ".concat(response.status, " ").concat(response.statusText));
|
|
1418
1812
|
}
|
|
1419
1813
|
return [
|
|
1420
1814
|
4,
|
|
@@ -1428,11 +1822,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1428
1822
|
case 10:
|
|
1429
1823
|
error1 = _state.sent();
|
|
1430
1824
|
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1825
|
+
if (pendingRequestAbortReason) {
|
|
1826
|
+
throw new Error("".concat(pendingRequestAbortReason, ": ").concat(vastTagUrl));
|
|
1827
|
+
}
|
|
1431
1828
|
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1432
1829
|
}
|
|
1433
1830
|
throw error1;
|
|
1434
1831
|
case 11:
|
|
1435
1832
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1833
|
+
if (controller) pendingVastRequests.delete(controller);
|
|
1436
1834
|
return [
|
|
1437
1835
|
7
|
|
1438
1836
|
];
|
|
@@ -1446,7 +1844,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1446
1844
|
}
|
|
1447
1845
|
function fetchAndParseVastAd(_0) {
|
|
1448
1846
|
return _async_to_generator(function(vastTagUrl) {
|
|
1449
|
-
var depth, accumulatedTracking, rules, vastXml, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1847
|
+
var depth, accumulatedTracking, rules, vastXml, fetchStartedAt, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1450
1848
|
var _arguments = arguments;
|
|
1451
1849
|
return _ts_generator(this, function(_state) {
|
|
1452
1850
|
switch(_state.label){
|
|
@@ -1454,6 +1852,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1454
1852
|
depth = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : 0, accumulatedTracking = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : createEmptyTrackingUrls(), rules = _arguments.length > 3 && _arguments[3] !== void 0 ? _arguments[3] : {
|
|
1455
1853
|
followAdditionalWrappers: true
|
|
1456
1854
|
};
|
|
1855
|
+
if (destroyed) return [
|
|
1856
|
+
2,
|
|
1857
|
+
null
|
|
1858
|
+
];
|
|
1859
|
+
fetchStartedAt = Date.now();
|
|
1457
1860
|
_state.label = 1;
|
|
1458
1861
|
case 1:
|
|
1459
1862
|
_state.trys.push([
|
|
@@ -1464,7 +1867,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1464
1867
|
]);
|
|
1465
1868
|
return [
|
|
1466
1869
|
4,
|
|
1467
|
-
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit")
|
|
1870
|
+
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit", depth === 0 ? "gam" : "wrapper")
|
|
1468
1871
|
];
|
|
1469
1872
|
case 2:
|
|
1470
1873
|
vastXml = _state.sent();
|
|
@@ -1476,14 +1879,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1476
1879
|
error = _state.sent();
|
|
1477
1880
|
if (depth === 0) throw error;
|
|
1478
1881
|
console.warn("[HlsAdPlayer] Wrapped VAST request failed:", error);
|
|
1479
|
-
|
|
1480
|
-
|
|
1882
|
+
logFunnel("wrapper_fetch", {
|
|
1883
|
+
reason: "failure",
|
|
1884
|
+
depth: depth,
|
|
1885
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
1886
|
+
elapsedMs: Date.now() - fetchStartedAt,
|
|
1887
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1481
1888
|
});
|
|
1889
|
+
if (!destroyed) {
|
|
1890
|
+
fireTrackingPixels(accumulatedTracking.error, {
|
|
1891
|
+
errorCode: VAST_ERROR_WRAPPER_TIMEOUT
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1482
1894
|
return [
|
|
1483
1895
|
2,
|
|
1484
1896
|
null
|
|
1485
1897
|
];
|
|
1486
1898
|
case 4:
|
|
1899
|
+
if (destroyed) return [
|
|
1900
|
+
2,
|
|
1901
|
+
null
|
|
1902
|
+
];
|
|
1903
|
+
if (depth > 0) {
|
|
1904
|
+
logFunnel("wrapper_fetch", {
|
|
1905
|
+
reason: "success",
|
|
1906
|
+
depth: depth,
|
|
1907
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
1908
|
+
elapsedMs: Date.now() - fetchStartedAt
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1487
1911
|
console.log("[HlsAdPlayer] VAST XML received");
|
|
1488
1912
|
console.log("[HlsAdPlayer] VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1489
1913
|
parsed = parseVastXml(vastXml);
|
|
@@ -1515,6 +1939,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1515
1939
|
];
|
|
1516
1940
|
}
|
|
1517
1941
|
mergeTrackingUrls(parsed.ad.trackingUrls, accumulatedTracking);
|
|
1942
|
+
logFunnel("inline_resolved", {
|
|
1943
|
+
depth: depth
|
|
1944
|
+
});
|
|
1518
1945
|
return [
|
|
1519
1946
|
2,
|
|
1520
1947
|
parsed.ad
|
|
@@ -1525,20 +1952,29 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1525
1952
|
}
|
|
1526
1953
|
function fetchAndParsePod(vastTagUrl) {
|
|
1527
1954
|
return _async_to_generator(function() {
|
|
1528
|
-
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements,
|
|
1955
|
+
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;
|
|
1529
1956
|
return _ts_generator(this, function(_state) {
|
|
1530
1957
|
switch(_state.label){
|
|
1531
1958
|
case 0:
|
|
1959
|
+
lastPodAdElementCount = 0;
|
|
1532
1960
|
return [
|
|
1533
1961
|
4,
|
|
1534
1962
|
fetchVastXml(vastTagUrl)
|
|
1535
1963
|
];
|
|
1536
1964
|
case 1:
|
|
1537
1965
|
vastXml = _state.sent();
|
|
1966
|
+
if (destroyed) return [
|
|
1967
|
+
2,
|
|
1968
|
+
[]
|
|
1969
|
+
];
|
|
1538
1970
|
console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
|
|
1539
1971
|
trimmedXml = vastXml.trim();
|
|
1540
1972
|
if (trimmedXml.length === 0) {
|
|
1541
1973
|
console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
|
|
1974
|
+
logFunnel("vast_parsed", {
|
|
1975
|
+
adElementCount: 0,
|
|
1976
|
+
reason: "empty_body"
|
|
1977
|
+
});
|
|
1542
1978
|
return [
|
|
1543
1979
|
2,
|
|
1544
1980
|
[]
|
|
@@ -1547,6 +1983,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1547
1983
|
xmlDoc = parseXml(vastXml);
|
|
1548
1984
|
if (!xmlDoc) {
|
|
1549
1985
|
console.error("[HlsAdPlayer] Pod VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1986
|
+
logFunnel("vast_parsed", {
|
|
1987
|
+
adElementCount: 0,
|
|
1988
|
+
reason: "xml_parse_error"
|
|
1989
|
+
});
|
|
1550
1990
|
return [
|
|
1551
1991
|
2,
|
|
1552
1992
|
[]
|
|
@@ -1554,10 +1994,21 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1554
1994
|
}
|
|
1555
1995
|
root = xmlDoc.documentElement;
|
|
1556
1996
|
adElements = Array.from(root.querySelectorAll(":scope > Ad"));
|
|
1997
|
+
logFunnel("vast_parsed", {
|
|
1998
|
+
reason: adElements.length > 0 ? "has_ads" : "no_ads",
|
|
1999
|
+
vastVersion: (_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : void 0,
|
|
2000
|
+
adElementCount: adElements.length,
|
|
2001
|
+
inlineCount: adElements.filter(function(el) {
|
|
2002
|
+
return el.querySelector(":scope > InLine");
|
|
2003
|
+
}).length,
|
|
2004
|
+
wrapperCount: adElements.filter(function(el) {
|
|
2005
|
+
return el.querySelector(":scope > Wrapper");
|
|
2006
|
+
}).length
|
|
2007
|
+
});
|
|
1557
2008
|
if (adElements.length === 0) {
|
|
1558
2009
|
;
|
|
1559
2010
|
;
|
|
1560
|
-
console.warn("[HlsAdPlayer] No <Ad> elements in VAST ".concat((
|
|
2011
|
+
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)"));
|
|
1561
2012
|
empty = emptyVastResult(root);
|
|
1562
2013
|
if (empty.type === "empty" && ((_empty_errorUrls = empty.errorUrls) === null || _empty_errorUrls === void 0 ? void 0 : _empty_errorUrls.length)) {
|
|
1563
2014
|
;
|
|
@@ -1575,10 +2026,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1575
2026
|
var _parsed_errorUrls, parsed, _parsed_errorCode;
|
|
1576
2027
|
return _ts_generator(this, function(_state) {
|
|
1577
2028
|
parsed = parseAdElement(adElement);
|
|
1578
|
-
if (parsed.type === "inline")
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
2029
|
+
if (parsed.type === "inline") {
|
|
2030
|
+
logFunnel("inline_resolved", {
|
|
2031
|
+
depth: 0
|
|
2032
|
+
});
|
|
2033
|
+
return [
|
|
2034
|
+
2,
|
|
2035
|
+
parsed.ad
|
|
2036
|
+
];
|
|
2037
|
+
}
|
|
1582
2038
|
if (parsed.type === "wrapper") {
|
|
1583
2039
|
return [
|
|
1584
2040
|
2,
|
|
@@ -1756,7 +2212,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1756
2212
|
7
|
|
1757
2213
|
];
|
|
1758
2214
|
case 21:
|
|
1759
|
-
console.log("[HlsAdPlayer] Parsed ".concat(ads.length, " ad(s) from VAST ").concat((
|
|
2215
|
+
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"));
|
|
2216
|
+
lastPodAdElementCount = adElements.length;
|
|
1760
2217
|
return [
|
|
1761
2218
|
2,
|
|
1762
2219
|
ads
|
|
@@ -1822,14 +2279,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1822
2279
|
var progress = currentTime / currentAd.duration;
|
|
1823
2280
|
if (progress >= 0.25 && !trackingFired.firstQuartile) {
|
|
1824
2281
|
trackingFired.firstQuartile = true;
|
|
2282
|
+
logFunnel("first_quartile");
|
|
1825
2283
|
fireTrackingPixels(currentAd.trackingUrls.firstQuartile);
|
|
1826
2284
|
}
|
|
1827
2285
|
if (progress >= 0.5 && !trackingFired.midpoint) {
|
|
1828
2286
|
trackingFired.midpoint = true;
|
|
2287
|
+
logFunnel("midpoint");
|
|
1829
2288
|
fireTrackingPixels(currentAd.trackingUrls.midpoint);
|
|
1830
2289
|
}
|
|
1831
2290
|
if (progress >= 0.75 && !trackingFired.thirdQuartile) {
|
|
1832
2291
|
trackingFired.thirdQuartile = true;
|
|
2292
|
+
logFunnel("third_quartile");
|
|
1833
2293
|
fireTrackingPixels(currentAd.trackingUrls.thirdQuartile);
|
|
1834
2294
|
}
|
|
1835
2295
|
};
|
|
@@ -1852,6 +2312,16 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1852
2312
|
if (!trackingFired.impression) {
|
|
1853
2313
|
trackingFired.impression = true;
|
|
1854
2314
|
resolvedAds.add(currentAd);
|
|
2315
|
+
logFunnel("playing", {
|
|
2316
|
+
mutedByAutoplay: forcedMuteByAutoplay,
|
|
2317
|
+
candidateIndex: mediaCandidateIndex
|
|
2318
|
+
});
|
|
2319
|
+
logFunnel("impression_fired", {
|
|
2320
|
+
pixelCount: currentAd.trackingUrls.impression.length
|
|
2321
|
+
});
|
|
2322
|
+
if (currentAd.trackingUrls.impression.length === 0) {
|
|
2323
|
+
console.warn("[HlsAdPlayer] Ad started but VAST contained no <Impression> URLs - GAM will not count it");
|
|
2324
|
+
}
|
|
1855
2325
|
fireTrackingPixels(currentAd.trackingUrls.impression);
|
|
1856
2326
|
fireTrackingPixels(currentAd.trackingUrls.creativeView);
|
|
1857
2327
|
fireTrackingPixels(currentAd.trackingUrls.verificationNotExecuted, {
|
|
@@ -1874,6 +2344,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1874
2344
|
sampleViewability();
|
|
1875
2345
|
settleViewability();
|
|
1876
2346
|
trackingFired.complete = true;
|
|
2347
|
+
logFunnel("complete");
|
|
1877
2348
|
fireTrackingPixels(currentAd.trackingUrls.complete);
|
|
1878
2349
|
console.log("[HlsAdPlayer] Ad completed");
|
|
1879
2350
|
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
|
|
@@ -1882,16 +2353,41 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1882
2353
|
handleAdComplete();
|
|
1883
2354
|
};
|
|
1884
2355
|
var onError = function onError(e) {
|
|
2356
|
+
var _adVideoElement_error, _adVideoElement_error1;
|
|
1885
2357
|
if (!adPlaying) return;
|
|
1886
2358
|
console.error("[HlsAdPlayer] Ad video error:", e);
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
2359
|
+
var vastErrorCode = toVastMediaErrorCode(adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.error);
|
|
2360
|
+
logFunnel("media_error", {
|
|
2361
|
+
mediaErrorCode: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error = adVideoElement.error) === null || _adVideoElement_error === void 0 ? void 0 : _adVideoElement_error.code,
|
|
2362
|
+
errorMessage: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error1 = adVideoElement.error) === null || _adVideoElement_error1 === void 0 ? void 0 : _adVideoElement_error1.message,
|
|
2363
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2364
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2365
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2366
|
+
vastErrorCode: vastErrorCode
|
|
2367
|
+
});
|
|
2368
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2369
|
+
};
|
|
2370
|
+
var onMediaDiagnostic = function onMediaDiagnostic(event) {
|
|
2371
|
+
if (!adPlaying || !adVideoElement || trackingFired.impression) return;
|
|
2372
|
+
if (!adVideoElement.currentSrc) return;
|
|
2373
|
+
logFunnel("media_event", {
|
|
2374
|
+
reason: event.type,
|
|
2375
|
+
readyState: adVideoElement.readyState,
|
|
2376
|
+
networkState: adVideoElement.networkState,
|
|
2377
|
+
currentSrc: adVideoElement.currentSrc
|
|
2378
|
+
});
|
|
1892
2379
|
};
|
|
1893
2380
|
var onVolumeChange = function onVolumeChange() {
|
|
1894
2381
|
if (!currentAd || !adVideoElement) return;
|
|
2382
|
+
if (forcedMuteByAutoplay && !adVideoElement.muted) {
|
|
2383
|
+
var userActivation = navigator.userActivation;
|
|
2384
|
+
if (userActivation && !userActivation.isActive) {
|
|
2385
|
+
logFunnel("unexpected_unmute", {
|
|
2386
|
+
paused: adVideoElement.paused
|
|
2387
|
+
});
|
|
2388
|
+
}
|
|
2389
|
+
forcedMuteByAutoplay = false;
|
|
2390
|
+
}
|
|
1895
2391
|
var muted = adVideoElement.muted || adVideoElement.volume === 0;
|
|
1896
2392
|
if (!trackingFired.start) {
|
|
1897
2393
|
trackingFired.lastMuted = muted;
|
|
@@ -1951,6 +2447,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1951
2447
|
{
|
|
1952
2448
|
type: "play",
|
|
1953
2449
|
handler: onPlay
|
|
2450
|
+
},
|
|
2451
|
+
{
|
|
2452
|
+
type: "stalled",
|
|
2453
|
+
handler: onMediaDiagnostic
|
|
2454
|
+
},
|
|
2455
|
+
{
|
|
2456
|
+
type: "suspend",
|
|
2457
|
+
handler: onMediaDiagnostic
|
|
2458
|
+
},
|
|
2459
|
+
{
|
|
2460
|
+
type: "abort",
|
|
2461
|
+
handler: onMediaDiagnostic
|
|
2462
|
+
},
|
|
2463
|
+
{
|
|
2464
|
+
type: "emptied",
|
|
2465
|
+
handler: onMediaDiagnostic
|
|
1954
2466
|
}
|
|
1955
2467
|
];
|
|
1956
2468
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -2240,16 +2752,51 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2240
2752
|
function settlePendingPlay() {
|
|
2241
2753
|
pendingPlayPromise = void 0;
|
|
2242
2754
|
}
|
|
2755
|
+
function toVastPlayErrorCode(error) {
|
|
2756
|
+
return (error === null || error === void 0 ? void 0 : error.name) === "NotSupportedError" ? VAST_ERROR_NO_SUPPORTED_MEDIA : VAST_ERROR_MEDIA_DISPLAY;
|
|
2757
|
+
}
|
|
2758
|
+
function failAdPlayback(context, error) {
|
|
2759
|
+
var vastErrorCode = toVastPlayErrorCode(error);
|
|
2760
|
+
console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
|
|
2761
|
+
logFunnel("play_failed", {
|
|
2762
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2763
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message,
|
|
2764
|
+
vastErrorCode: vastErrorCode
|
|
2765
|
+
});
|
|
2766
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2767
|
+
}
|
|
2243
2768
|
function startAdPlayback(context) {
|
|
2769
|
+
var isMutedRetry = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
2244
2770
|
if (!adVideoElement) return;
|
|
2771
|
+
var computed = typeof getComputedStyle === "function" && adContainerEl ? getComputedStyle(adContainerEl) : void 0;
|
|
2772
|
+
logFunnel(isMutedRetry ? "muted_retry" : "play_called", {
|
|
2773
|
+
context: context,
|
|
2774
|
+
isConnected: adVideoElement.isConnected,
|
|
2775
|
+
clientWidth: adVideoElement.clientWidth,
|
|
2776
|
+
clientHeight: adVideoElement.clientHeight,
|
|
2777
|
+
containerDisplay: computed === null || computed === void 0 ? void 0 : computed.display,
|
|
2778
|
+
containerVisibility: computed === null || computed === void 0 ? void 0 : computed.visibility
|
|
2779
|
+
});
|
|
2245
2780
|
var playPromise = adVideoElement.play();
|
|
2246
2781
|
pendingPlayPromise = playPromise;
|
|
2247
2782
|
playPromise.catch(function(error) {
|
|
2248
2783
|
if (pendingPlayPromise !== playPromise) {
|
|
2249
2784
|
return;
|
|
2250
2785
|
}
|
|
2251
|
-
|
|
2252
|
-
|
|
2786
|
+
logFunnel("play_rejected", {
|
|
2787
|
+
context: context,
|
|
2788
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2789
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
2790
|
+
});
|
|
2791
|
+
if (!isMutedRetry && (error === null || error === void 0 ? void 0 : error.name) === "NotAllowedError" && adVideoElement && !adVideoElement.muted) {
|
|
2792
|
+
console.warn("[HlsAdPlayer] Unmuted ".concat(context, " blocked by autoplay policy - retrying muted"));
|
|
2793
|
+
originalMutedState = true;
|
|
2794
|
+
forcedMuteByAutoplay = true;
|
|
2795
|
+
adVideoElement.muted = true;
|
|
2796
|
+
startAdPlayback(context, true);
|
|
2797
|
+
return;
|
|
2798
|
+
}
|
|
2799
|
+
failAdPlayback(context, error);
|
|
2253
2800
|
}).finally(function() {
|
|
2254
2801
|
if (pendingPlayPromise === playPromise) {
|
|
2255
2802
|
pendingPlayPromise = void 0;
|
|
@@ -2288,17 +2835,109 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2288
2835
|
adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
|
|
2289
2836
|
adVideoElement.muted = originalMutedState;
|
|
2290
2837
|
}
|
|
2838
|
+
function clearMediaStartTimer() {
|
|
2839
|
+
if (mediaStartTimerId !== void 0) {
|
|
2840
|
+
clearTimeout(mediaStartTimerId);
|
|
2841
|
+
mediaStartTimerId = void 0;
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
function startMediaStartTimer() {
|
|
2845
|
+
clearMediaStartTimer();
|
|
2846
|
+
if (!(MEDIA_START_TIMEOUT_MS > 0)) return;
|
|
2847
|
+
var startedAt = Date.now();
|
|
2848
|
+
mediaStartTimerId = setTimeout(function() {
|
|
2849
|
+
mediaStartTimerId = void 0;
|
|
2850
|
+
if (!adPlaying || trackingFired.impression) return;
|
|
2851
|
+
console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(MEDIA_START_TIMEOUT_MS, "ms"));
|
|
2852
|
+
logFunnel("play_resolved_but_never_started", {
|
|
2853
|
+
timeoutMs: MEDIA_START_TIMEOUT_MS,
|
|
2854
|
+
elapsedMs: Date.now() - startedAt,
|
|
2855
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2856
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2857
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2858
|
+
paused: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.paused,
|
|
2859
|
+
vastErrorCode: VAST_ERROR_MEDIA_TIMEOUT
|
|
2860
|
+
});
|
|
2861
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_TIMEOUT);
|
|
2862
|
+
}, MEDIA_START_TIMEOUT_MS);
|
|
2863
|
+
}
|
|
2864
|
+
function resetVideoElementForNextSource() {
|
|
2865
|
+
clearStallWatchdog();
|
|
2866
|
+
if (requiresMediaPipelineResetAfterAds()) {
|
|
2867
|
+
recreateAdVideoElement();
|
|
2868
|
+
setupAdEventListeners();
|
|
2869
|
+
} else {
|
|
2870
|
+
prepareVideoElementForNewSource();
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
function tryNextMediaCandidate() {
|
|
2874
|
+
if (!currentAd || trackingFired.impression) return false;
|
|
2875
|
+
if (mediaCandidateIndex >= mediaCandidates.length - 1) return false;
|
|
2876
|
+
var failedUrl = currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url;
|
|
2877
|
+
mediaCandidateIndex++;
|
|
2878
|
+
var next = mediaCandidates[mediaCandidateIndex];
|
|
2879
|
+
if (!next) return false;
|
|
2880
|
+
logFunnel("media_fallback", {
|
|
2881
|
+
failedUrl: failedUrl,
|
|
2882
|
+
nextUrl: next.url,
|
|
2883
|
+
nextType: next.type,
|
|
2884
|
+
candidateIndex: mediaCandidateIndex,
|
|
2885
|
+
candidateCount: mediaCandidates.length
|
|
2886
|
+
});
|
|
2887
|
+
resetVideoElementForNextSource();
|
|
2888
|
+
try {
|
|
2889
|
+
loadMediaCandidate(next);
|
|
2890
|
+
return true;
|
|
2891
|
+
} catch (error) {
|
|
2892
|
+
console.error("[HlsAdPlayer] Failed to load fallback media file:", error);
|
|
2893
|
+
return tryNextMediaCandidate();
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
function recoverFromAdFailure(vastErrorCode) {
|
|
2897
|
+
clearMediaStartTimer();
|
|
2898
|
+
if (tryNextMediaCandidate()) return;
|
|
2899
|
+
reportCurrentAdError(vastErrorCode);
|
|
2900
|
+
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) return;
|
|
2901
|
+
handleAdError();
|
|
2902
|
+
}
|
|
2291
2903
|
function loadCurrentAdMedia() {
|
|
2292
2904
|
if (!adVideoElement || !currentAd) {
|
|
2293
2905
|
throw new Error("No ad video element or ad to load");
|
|
2294
2906
|
}
|
|
2295
|
-
|
|
2907
|
+
mediaCandidates = rankMediaCandidates(currentAd.mediaFiles);
|
|
2908
|
+
mediaCandidateIndex = 0;
|
|
2909
|
+
var mediaFile = mediaCandidates[0];
|
|
2296
2910
|
if (!mediaFile) {
|
|
2297
|
-
|
|
2911
|
+
logFunnel("media_unsupported", {
|
|
2912
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA,
|
|
2913
|
+
candidates: currentAd.mediaFiles.length
|
|
2914
|
+
});
|
|
2915
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
2916
|
+
throw new Error("No media file this browser can play");
|
|
2917
|
+
}
|
|
2918
|
+
try {
|
|
2919
|
+
loadMediaCandidate(mediaFile);
|
|
2920
|
+
} catch (error) {
|
|
2921
|
+
if (tryNextMediaCandidate()) return;
|
|
2922
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
2923
|
+
throw error;
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
function loadMediaCandidate(mediaFile) {
|
|
2927
|
+
if (!adVideoElement || !currentAd) {
|
|
2928
|
+
throw new Error("No ad video element or ad to load");
|
|
2298
2929
|
}
|
|
2299
2930
|
currentAdMediaFile = mediaFile;
|
|
2300
2931
|
var isHlsAd = isHlsMediaFile(mediaFile);
|
|
2932
|
+
logFunnel("media_selected", {
|
|
2933
|
+
width: mediaFile.width,
|
|
2934
|
+
height: mediaFile.height,
|
|
2935
|
+
bitrate: mediaFile.bitrate,
|
|
2936
|
+
candidateIndex: mediaCandidateIndex,
|
|
2937
|
+
candidates: mediaCandidates.length
|
|
2938
|
+
});
|
|
2301
2939
|
console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad (pod ").concat(podIndex + 1, "/").concat(podAds.length || 1, ") from: ").concat(mediaFile.url));
|
|
2940
|
+
startMediaStartTimer();
|
|
2302
2941
|
if (isHlsAd && import_hls.default.isSupported()) {
|
|
2303
2942
|
if (adHls) {
|
|
2304
2943
|
adHls.destroy();
|
|
@@ -2307,6 +2946,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2307
2946
|
enableWorker: true,
|
|
2308
2947
|
lowLatencyMode: false
|
|
2309
2948
|
});
|
|
2949
|
+
logFunnel("media_load", {
|
|
2950
|
+
pipeline: "hls.js"
|
|
2951
|
+
});
|
|
2310
2952
|
adHls.loadSource(mediaFile.url);
|
|
2311
2953
|
adHls.attachMedia(adVideoElement);
|
|
2312
2954
|
adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
|
|
@@ -2316,10 +2958,24 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2316
2958
|
adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
|
|
2317
2959
|
console.error("[HlsAdPlayer] HLS error:", data);
|
|
2318
2960
|
if (data.fatal) {
|
|
2319
|
-
|
|
2961
|
+
var _data_response, _data_response1, _data_frag;
|
|
2962
|
+
var vastErrorCode = data.type === import_hls.default.ErrorTypes.NETWORK_ERROR ? 401 : VAST_ERROR_MEDIA_DISPLAY;
|
|
2963
|
+
logFunnel("hls_fatal", {
|
|
2964
|
+
reason: data.details,
|
|
2965
|
+
errorName: data.type,
|
|
2966
|
+
errorMessage: data.details,
|
|
2967
|
+
responseCode: (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.code,
|
|
2968
|
+
responseText: (_data_response1 = data.response) === null || _data_response1 === void 0 ? void 0 : _data_response1.text,
|
|
2969
|
+
fragUrl: (_data_frag = data.frag) === null || _data_frag === void 0 ? void 0 : _data_frag.url,
|
|
2970
|
+
vastErrorCode: vastErrorCode
|
|
2971
|
+
});
|
|
2972
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2320
2973
|
}
|
|
2321
2974
|
});
|
|
2322
2975
|
} else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
|
|
2976
|
+
logFunnel("media_load", {
|
|
2977
|
+
pipeline: "native-hls"
|
|
2978
|
+
});
|
|
2323
2979
|
adVideoElement.src = mediaFile.url;
|
|
2324
2980
|
startAdPlayback("native HLS ad playback");
|
|
2325
2981
|
} else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
|
|
@@ -2327,45 +2983,47 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2327
2983
|
adHls.destroy();
|
|
2328
2984
|
adHls = void 0;
|
|
2329
2985
|
}
|
|
2986
|
+
logFunnel("media_load", {
|
|
2987
|
+
pipeline: "progressive"
|
|
2988
|
+
});
|
|
2330
2989
|
adVideoElement.src = mediaFile.url;
|
|
2331
2990
|
adVideoElement.load();
|
|
2332
2991
|
startAdPlayback("progressive ad playback");
|
|
2333
2992
|
} else {
|
|
2993
|
+
clearMediaStartTimer();
|
|
2994
|
+
logFunnel("media_unsupported", {
|
|
2995
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA
|
|
2996
|
+
});
|
|
2334
2997
|
throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
|
|
2335
2998
|
}
|
|
2336
2999
|
}
|
|
2337
3000
|
function advanceToNextPodAd() {
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
index: podIndex,
|
|
2360
|
-
total: podAds.length
|
|
2361
|
-
});
|
|
2362
|
-
return true;
|
|
2363
|
-
} catch (error) {
|
|
2364
|
-
console.error("[HlsAdPlayer] Failed to load next pod ad:", error);
|
|
2365
|
-
return false;
|
|
3001
|
+
clearMediaStartTimer();
|
|
3002
|
+
while(podIndex < podAds.length - 1){
|
|
3003
|
+
settleViewability();
|
|
3004
|
+
podIndex++;
|
|
3005
|
+
currentAd = podAds[podIndex];
|
|
3006
|
+
currentAdMediaFile = void 0;
|
|
3007
|
+
resetAdTracking();
|
|
3008
|
+
if (currentAd) {
|
|
3009
|
+
console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
|
|
3010
|
+
}
|
|
3011
|
+
resetVideoElementForNextSource();
|
|
3012
|
+
try {
|
|
3013
|
+
loadCurrentAdMedia();
|
|
3014
|
+
emit("pod_ad_started", {
|
|
3015
|
+
index: podIndex,
|
|
3016
|
+
total: podAds.length
|
|
3017
|
+
});
|
|
3018
|
+
return true;
|
|
3019
|
+
} catch (error) {
|
|
3020
|
+
console.error("[HlsAdPlayer] Failed to load next pod ad:", error);
|
|
3021
|
+
}
|
|
2366
3022
|
}
|
|
3023
|
+
return false;
|
|
2367
3024
|
}
|
|
2368
3025
|
function clearStallWatchdog() {
|
|
3026
|
+
clearMediaStartTimer();
|
|
2369
3027
|
if (stallWatchdogId != null) {
|
|
2370
3028
|
clearInterval(stallWatchdogId);
|
|
2371
3029
|
stallWatchdogId = void 0;
|
|
@@ -2381,11 +3039,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2381
3039
|
function handleAdStall() {
|
|
2382
3040
|
console.warn("[HlsAdPlayer] Ad playback stalled (no progress) - recovering to avoid a blank frame");
|
|
2383
3041
|
clearStallWatchdog();
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
handleAdError();
|
|
3042
|
+
logFunnel("stall", {
|
|
3043
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
3044
|
+
});
|
|
3045
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2389
3046
|
}
|
|
2390
3047
|
function getDecodedVideoFrameCount(video) {
|
|
2391
3048
|
try {
|
|
@@ -2447,11 +3104,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2447
3104
|
function handleVideoDecodeFailure() {
|
|
2448
3105
|
console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
|
|
2449
3106
|
clearStallWatchdog();
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
handleAdError();
|
|
3107
|
+
logFunnel("decode_failure", {
|
|
3108
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
3109
|
+
});
|
|
3110
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2455
3111
|
}
|
|
2456
3112
|
function startStallWatchdog() {
|
|
2457
3113
|
clearStallWatchdog();
|
|
@@ -2575,6 +3231,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2575
3231
|
Promise.reject(new Error("Ad already playing"))
|
|
2576
3232
|
];
|
|
2577
3233
|
}
|
|
3234
|
+
if (destroyed) {
|
|
3235
|
+
return [
|
|
3236
|
+
2,
|
|
3237
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
3238
|
+
];
|
|
3239
|
+
}
|
|
3240
|
+
currentVastTagUrl = vastTagUrl;
|
|
3241
|
+
pendingRequestAbortReason = void 0;
|
|
3242
|
+
logFunnel("request_sent");
|
|
2578
3243
|
_state.label = 1;
|
|
2579
3244
|
case 1:
|
|
2580
3245
|
_state.trys.push([
|
|
@@ -2609,8 +3274,29 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2609
3274
|
ads = _state.sent();
|
|
2610
3275
|
_state.label = 4;
|
|
2611
3276
|
case 4:
|
|
3277
|
+
if (destroyed) {
|
|
3278
|
+
return [
|
|
3279
|
+
2,
|
|
3280
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
3281
|
+
];
|
|
3282
|
+
}
|
|
3283
|
+
if (!ads.length && pendingRequestAbortReason) {
|
|
3284
|
+
throw new Error(pendingRequestAbortReason);
|
|
3285
|
+
}
|
|
3286
|
+
if (!ads.length && lastPodAdElementCount > 0) {
|
|
3287
|
+
console.warn("[HlsAdPlayer] VAST response had ads but none were playable");
|
|
3288
|
+
logFunnel("vast_fill_rejected", {
|
|
3289
|
+
adElementCount: lastPodAdElementCount
|
|
3290
|
+
});
|
|
3291
|
+
emit("ad_error");
|
|
3292
|
+
return [
|
|
3293
|
+
2,
|
|
3294
|
+
Promise.reject(new Error("VAST fill rejected: no playable ad in response"))
|
|
3295
|
+
];
|
|
3296
|
+
}
|
|
2612
3297
|
if (!ads.length) {
|
|
2613
3298
|
console.warn("[HlsAdPlayer] No ads available from VAST response");
|
|
3299
|
+
logFunnel("no_fill");
|
|
2614
3300
|
emit("ad_error");
|
|
2615
3301
|
return [
|
|
2616
3302
|
2,
|
|
@@ -2621,6 +3307,23 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2621
3307
|
podIndex = 0;
|
|
2622
3308
|
currentAd = ads[0];
|
|
2623
3309
|
currentAdMediaFile = void 0;
|
|
3310
|
+
logFunnel("vast_received", {
|
|
3311
|
+
adCount: ads.length,
|
|
3312
|
+
durations: ads.map(function(ad) {
|
|
3313
|
+
return ad.duration;
|
|
3314
|
+
}),
|
|
3315
|
+
impressionUrls: ads.map(function(ad) {
|
|
3316
|
+
return ad.trackingUrls.impression.length;
|
|
3317
|
+
})
|
|
3318
|
+
});
|
|
3319
|
+
ads.forEach(function(ad, index) {
|
|
3320
|
+
if (ad.trackingUrls.impression.length === 0) {
|
|
3321
|
+
logFunnel("vast_missing_impression", {
|
|
3322
|
+
adIndex: index,
|
|
3323
|
+
missingAdId: ad.id
|
|
3324
|
+
});
|
|
3325
|
+
}
|
|
3326
|
+
});
|
|
2624
3327
|
console.log("[HlsAdPlayer] Pod parsed: ".concat(ads.length, ' ad(s), first="').concat(currentAd === null || currentAd === void 0 ? void 0 : currentAd.title, '", duration=').concat(currentAd === null || currentAd === void 0 ? void 0 : currentAd.duration, "s"));
|
|
2625
3328
|
return [
|
|
2626
3329
|
2,
|
|
@@ -2629,6 +3332,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2629
3332
|
case 5:
|
|
2630
3333
|
error = _state.sent();
|
|
2631
3334
|
console.error("[HlsAdPlayer] Error requesting ads:", error);
|
|
3335
|
+
logFunnel("request_failed", {
|
|
3336
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3337
|
+
});
|
|
2632
3338
|
emit("ad_error");
|
|
2633
3339
|
return [
|
|
2634
3340
|
2,
|
|
@@ -2684,13 +3390,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2684
3390
|
adContainerEl.style.pointerEvents = "auto";
|
|
2685
3391
|
}
|
|
2686
3392
|
emit("content_pause");
|
|
2687
|
-
|
|
3393
|
+
try {
|
|
3394
|
+
loadCurrentAdMedia();
|
|
3395
|
+
} catch (loadError) {
|
|
3396
|
+
if (!(podIndex < podAds.length - 1 && advanceToNextPodAd())) {
|
|
3397
|
+
throw loadError;
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
2688
3400
|
return [
|
|
2689
3401
|
2,
|
|
2690
3402
|
Promise.resolve()
|
|
2691
3403
|
];
|
|
2692
3404
|
} catch (error) {
|
|
2693
3405
|
console.error("[HlsAdPlayer] Error playing ad:", error);
|
|
3406
|
+
logFunnel("play_failed", {
|
|
3407
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3408
|
+
});
|
|
2694
3409
|
handleAdError();
|
|
2695
3410
|
return [
|
|
2696
3411
|
2,
|
|
@@ -2732,6 +3447,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2732
3447
|
var previousMutedState;
|
|
2733
3448
|
return _ts_generator(this, function(_state) {
|
|
2734
3449
|
console.log("[HlsAdPlayer] Stopping ad");
|
|
3450
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3451
|
+
logFunnel("stopped_before_start");
|
|
3452
|
+
}
|
|
2735
3453
|
settleViewability();
|
|
2736
3454
|
fireNotUsedForUnplayedAds();
|
|
2737
3455
|
clearStallWatchdog();
|
|
@@ -2764,15 +3482,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2764
3482
|
},
|
|
2765
3483
|
destroy: function destroy() {
|
|
2766
3484
|
console.log("[HlsAdPlayer] Destroying");
|
|
3485
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3486
|
+
logFunnel("stopped_before_start");
|
|
3487
|
+
}
|
|
2767
3488
|
settleViewability();
|
|
2768
3489
|
fireNotUsedForUnplayedAds();
|
|
2769
3490
|
destroyed = true;
|
|
2770
|
-
|
|
3491
|
+
pendingRequestAbortReason = "Ad player destroyed";
|
|
2771
3492
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2772
3493
|
try {
|
|
2773
|
-
for(var _iterator =
|
|
2774
|
-
var
|
|
2775
|
-
|
|
3494
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3495
|
+
var controller = _step.value;
|
|
3496
|
+
controller.abort();
|
|
2776
3497
|
}
|
|
2777
3498
|
} catch (err) {
|
|
2778
3499
|
_didIteratorError = true;
|
|
@@ -2788,6 +3509,28 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2788
3509
|
}
|
|
2789
3510
|
}
|
|
2790
3511
|
}
|
|
3512
|
+
pendingVastRequests.clear();
|
|
3513
|
+
clearStallWatchdog();
|
|
3514
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3515
|
+
try {
|
|
3516
|
+
for(var _iterator1 = pendingTimeouts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3517
|
+
var timeoutId = _step1.value;
|
|
3518
|
+
clearTimeout(timeoutId);
|
|
3519
|
+
}
|
|
3520
|
+
} catch (err) {
|
|
3521
|
+
_didIteratorError1 = true;
|
|
3522
|
+
_iteratorError1 = err;
|
|
3523
|
+
} finally{
|
|
3524
|
+
try {
|
|
3525
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
3526
|
+
_iterator1.return();
|
|
3527
|
+
}
|
|
3528
|
+
} finally{
|
|
3529
|
+
if (_didIteratorError1) {
|
|
3530
|
+
throw _iteratorError1;
|
|
3531
|
+
}
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
2791
3534
|
pendingTimeouts = [];
|
|
2792
3535
|
adPlaying = false;
|
|
2793
3536
|
setAdPlayingFlag(false);
|
|
@@ -2807,6 +3550,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2807
3550
|
isAdPlaying: function isAdPlaying() {
|
|
2808
3551
|
return adPlaying;
|
|
2809
3552
|
},
|
|
3553
|
+
setFunnelContext: function setFunnelContext(context) {
|
|
3554
|
+
funnelContext = _object_spread({}, context);
|
|
3555
|
+
},
|
|
3556
|
+
abortPendingRequest: function abortPendingRequest() {
|
|
3557
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "VAST request aborted (timeout)";
|
|
3558
|
+
if (pendingVastRequests.size === 0) return;
|
|
3559
|
+
pendingRequestAbortReason = reason;
|
|
3560
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3561
|
+
try {
|
|
3562
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3563
|
+
var controller = _step.value;
|
|
3564
|
+
controller.abort();
|
|
3565
|
+
}
|
|
3566
|
+
} catch (err) {
|
|
3567
|
+
_didIteratorError = true;
|
|
3568
|
+
_iteratorError = err;
|
|
3569
|
+
} finally{
|
|
3570
|
+
try {
|
|
3571
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3572
|
+
_iterator.return();
|
|
3573
|
+
}
|
|
3574
|
+
} finally{
|
|
3575
|
+
if (_didIteratorError) {
|
|
3576
|
+
throw _iteratorError;
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
pendingVastRequests.clear();
|
|
3581
|
+
},
|
|
2810
3582
|
resize: function resize(width, height) {
|
|
2811
3583
|
console.log("[HlsAdPlayer] Resizing to ".concat(width, "x").concat(height));
|
|
2812
3584
|
if (adContainerEl) {
|
|
@@ -2842,6 +3614,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2842
3614
|
if (adVideoElement && adPlaying) {
|
|
2843
3615
|
var clamped = Math.max(0, Math.min(1, volume));
|
|
2844
3616
|
adVideoElement.volume = clamped;
|
|
3617
|
+
var userActivation = navigator.userActivation;
|
|
3618
|
+
if (clamped > 0 && forcedMuteByAutoplay && userActivation && !userActivation.isActive) {
|
|
3619
|
+
logFunnel("unmute_blocked_without_gesture", {
|
|
3620
|
+
requestedVolume: clamped
|
|
3621
|
+
});
|
|
3622
|
+
return;
|
|
3623
|
+
}
|
|
2845
3624
|
adVideoElement.muted = clamped === 0;
|
|
2846
3625
|
}
|
|
2847
3626
|
},
|
|
@@ -4948,6 +5727,21 @@ function normalizeVastTagUrl(raw) {
|
|
|
4948
5727
|
return raw;
|
|
4949
5728
|
}
|
|
4950
5729
|
}
|
|
5730
|
+
var GAM_AD_HOSTS = /* @__PURE__ */ new Set([
|
|
5731
|
+
"pubads.g.doubleclick.net",
|
|
5732
|
+
"securepubads.g.doubleclick.net"
|
|
5733
|
+
]);
|
|
5734
|
+
function ensureVideoAdType(rawUrl) {
|
|
5735
|
+
try {
|
|
5736
|
+
var url = new URL(rawUrl);
|
|
5737
|
+
if (!GAM_AD_HOSTS.has(url.hostname)) return rawUrl;
|
|
5738
|
+
if (url.searchParams.has("ad_type")) return rawUrl;
|
|
5739
|
+
url.searchParams.set("ad_type", "video");
|
|
5740
|
+
return url.toString();
|
|
5741
|
+
} catch (unused) {
|
|
5742
|
+
return rawUrl;
|
|
5743
|
+
}
|
|
5744
|
+
}
|
|
4951
5745
|
function applyVastMacros(baseUrl, ctx) {
|
|
4952
5746
|
var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
|
|
4953
5747
|
var url;
|
|
@@ -6658,7 +7452,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
6658
7452
|
} : {}), {
|
|
6659
7453
|
consent: this.consentSignals
|
|
6660
7454
|
}));
|
|
6661
|
-
var finalUrl = palNonce.injectNonce(urlWithMacros);
|
|
7455
|
+
var finalUrl = palNonce.injectNonce(ensureVideoAdType(urlWithMacros));
|
|
6662
7456
|
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);
|
|
6663
7457
|
return finalUrl;
|
|
6664
7458
|
}
|
|
@@ -6905,7 +7699,7 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6905
7699
|
{
|
|
6906
7700
|
key: "adFitsRemainingBudget",
|
|
6907
7701
|
value: function adFitsRemainingBudget(durationMs) {
|
|
6908
|
-
if (durationMs <= 0) {
|
|
7702
|
+
if (durationMs <= 0 || this.expectedAdBreakDurationMs == null) {
|
|
6909
7703
|
return true;
|
|
6910
7704
|
}
|
|
6911
7705
|
return durationMs <= this.getDurationBudgetRemainingMs();
|
|
@@ -6964,6 +7758,11 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6964
7758
|
value: function markAdStarted() {
|
|
6965
7759
|
this.currentAdIndex++;
|
|
6966
7760
|
this.totalAdsInBreak = this.currentAdIndex;
|
|
7761
|
+
}
|
|
7762
|
+
},
|
|
7763
|
+
{
|
|
7764
|
+
key: "noteAdRequestSent",
|
|
7765
|
+
value: function noteAdRequestSent() {
|
|
6967
7766
|
this.totalAdRequestsInBreak++;
|
|
6968
7767
|
this.lastAdRequestTime = Date.now();
|
|
6969
7768
|
}
|
|
@@ -7015,6 +7814,9 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
7015
7814
|
if (message.includes("timeout")) {
|
|
7016
7815
|
return true;
|
|
7017
7816
|
}
|
|
7817
|
+
if (message.includes("ad player destroyed") || message.includes("aborted")) {
|
|
7818
|
+
return true;
|
|
7819
|
+
}
|
|
7018
7820
|
if (message.includes("rate limit") || message.includes("too many requests")) {
|
|
7019
7821
|
return true;
|
|
7020
7822
|
}
|
|
@@ -8139,6 +8941,18 @@ function resizePlayer(video, adPlayer, debug) {
|
|
|
8139
8941
|
}
|
|
8140
8942
|
}
|
|
8141
8943
|
// src/player/AdBreakOrchestrator.ts
|
|
8944
|
+
var REQUEST_FAILURE_STAGES = /* @__PURE__ */ new Set([
|
|
8945
|
+
"no_fill",
|
|
8946
|
+
"vast_fill_rejected",
|
|
8947
|
+
"request_failed",
|
|
8948
|
+
"media_unsupported",
|
|
8949
|
+
"play_failed",
|
|
8950
|
+
"play_resolved_but_never_started",
|
|
8951
|
+
"hls_fatal",
|
|
8952
|
+
"media_error",
|
|
8953
|
+
"stall",
|
|
8954
|
+
"decode_failure"
|
|
8955
|
+
]);
|
|
8142
8956
|
var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
8143
8957
|
function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
|
|
8144
8958
|
_class_call_check(this, AdBreakOrchestrator);
|
|
@@ -8146,11 +8960,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8146
8960
|
this.showAds = false;
|
|
8147
8961
|
this.isShowingPlaceholder = false;
|
|
8148
8962
|
this.adDetectSentForCurrentBreak = false;
|
|
8149
|
-
this.
|
|
8150
|
-
this.
|
|
8151
|
-
this.
|
|
8963
|
+
this.slotState = "IDLE";
|
|
8964
|
+
this.unusableResponsesInBreak = 0;
|
|
8965
|
+
this.controllerGeneration = 0;
|
|
8966
|
+
this.requestDiagnostics = /* @__PURE__ */ new Map();
|
|
8967
|
+
this.breakFunnel = {};
|
|
8968
|
+
this.controllerCallInFlight = false;
|
|
8969
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8970
|
+
this.opportunityEpoch = -1;
|
|
8152
8971
|
this.adPodQueue = [];
|
|
8153
|
-
this.
|
|
8972
|
+
this.defaultMinRemainingMsToRequestAd = 1e4;
|
|
8973
|
+
this.defaultMaxNoFillsPerBreak = 2;
|
|
8154
8974
|
this.pendingAdBreak = null;
|
|
8155
8975
|
this.host = host;
|
|
8156
8976
|
this.timing = timing;
|
|
@@ -8186,7 +9006,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8186
9006
|
key: "attachImaEventListeners",
|
|
8187
9007
|
value: function attachImaEventListeners() {
|
|
8188
9008
|
var _this = this;
|
|
8189
|
-
var
|
|
9009
|
+
var controller = this.host.getAdPlayer();
|
|
9010
|
+
var generation = this.controllerGeneration;
|
|
9011
|
+
var adPlayer = {
|
|
9012
|
+
on: function on(event, handler) {
|
|
9013
|
+
controller.on(event, function(payload) {
|
|
9014
|
+
if (generation !== _this.controllerGeneration) {
|
|
9015
|
+
_this.logOrchestratorFunnel("stale_callback_ignored", {
|
|
9016
|
+
event: event,
|
|
9017
|
+
staleControllerId: generation,
|
|
9018
|
+
currentControllerId: _this.controllerGeneration
|
|
9019
|
+
});
|
|
9020
|
+
return;
|
|
9021
|
+
}
|
|
9022
|
+
handler(payload);
|
|
9023
|
+
});
|
|
9024
|
+
}
|
|
9025
|
+
};
|
|
8190
9026
|
adPlayer.on("pod_ad_started", function(payload) {
|
|
8191
9027
|
_this.timing.notePodAdStarted();
|
|
8192
9028
|
if (_this.debug) {
|
|
@@ -8200,7 +9036,35 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8200
9036
|
adPlayer.on("ad_interaction", function(event) {
|
|
8201
9037
|
if (event) _this.host.onAdInteraction(event);
|
|
8202
9038
|
});
|
|
9039
|
+
adPlayer.on("ad_funnel", function(payload) {
|
|
9040
|
+
if (!(payload === null || payload === void 0 ? void 0 : payload.stage)) return;
|
|
9041
|
+
var stage = payload.stage;
|
|
9042
|
+
_this.countFunnelStage(stage);
|
|
9043
|
+
if (payload.reason) {
|
|
9044
|
+
_this.countFunnelStage("".concat(stage, ":").concat(payload.reason));
|
|
9045
|
+
}
|
|
9046
|
+
if (stage === "impression_fired" && payload.pixelCount != null) {
|
|
9047
|
+
_this.countFunnelStage("impression_urls", payload.pixelCount);
|
|
9048
|
+
}
|
|
9049
|
+
if (payload.visibilityState === "hidden") {
|
|
9050
|
+
_this.countFunnelStage("while_hidden");
|
|
9051
|
+
}
|
|
9052
|
+
if (stage === "gam_http_request_sent") {
|
|
9053
|
+
if (payload.attempt === 1) {
|
|
9054
|
+
_this.timing.noteAdRequestSent();
|
|
9055
|
+
} else {
|
|
9056
|
+
_this.countFunnelStage("gam_http_request_retry");
|
|
9057
|
+
}
|
|
9058
|
+
}
|
|
9059
|
+
_this.recordRequestDiagnostic(payload);
|
|
9060
|
+
});
|
|
8203
9061
|
adPlayer.on("ad_impression", function() {
|
|
9062
|
+
_this.timing.consecutiveFailures = 0;
|
|
9063
|
+
_this.setSlotState("PLAYING", "impression");
|
|
9064
|
+
if (!_this.playbackStartedForCurrentRequest) {
|
|
9065
|
+
_this.playbackStartedForCurrentRequest = true;
|
|
9066
|
+
_this.timing.markAdStarted();
|
|
9067
|
+
}
|
|
8204
9068
|
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
8205
9069
|
source: "hls",
|
|
8206
9070
|
adIndex: _this.timing.currentAdIndex
|
|
@@ -8215,16 +9079,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8215
9079
|
var remaining = _this.timing.getRemainingAdMs();
|
|
8216
9080
|
_this.timing.consecutiveFailures = 0;
|
|
8217
9081
|
if (_this.debug) {
|
|
8218
|
-
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms
|
|
8219
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
8220
|
-
} : {});
|
|
9082
|
+
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms"));
|
|
8221
9083
|
}
|
|
8222
9084
|
if (_this.inAdBreak) {
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
} else {
|
|
8226
|
-
_this.handleAdPodComplete();
|
|
8227
|
-
}
|
|
9085
|
+
_this.setSlotState("NEEDS_NEXT_AD", "all_ads_completed");
|
|
9086
|
+
_this.requestNextAd("all_ads_completed");
|
|
8228
9087
|
}
|
|
8229
9088
|
});
|
|
8230
9089
|
adPlayer.on("ad_error", function(errorPayload) {
|
|
@@ -8244,7 +9103,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8244
9103
|
}
|
|
8245
9104
|
}
|
|
8246
9105
|
console.error("[AD-ERROR]", errorMessage, errorPayload || "");
|
|
8247
|
-
_this.
|
|
9106
|
+
if (_this.controllerCallInFlight) {
|
|
9107
|
+
return;
|
|
9108
|
+
}
|
|
9109
|
+
_this.handleAdFailure("ad_error");
|
|
8248
9110
|
});
|
|
8249
9111
|
adPlayer.on("content_pause", function() {
|
|
8250
9112
|
_this.timing.clearAdFailsafeTimer();
|
|
@@ -8283,26 +9145,32 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8283
9145
|
}
|
|
8284
9146
|
_this.timing.consecutiveFailures = 0;
|
|
8285
9147
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
8286
|
-
var remaining = _this.timing.getRemainingAdMs();
|
|
8287
9148
|
if (_this.debug) {
|
|
8288
|
-
console.log("[
|
|
8289
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
8290
|
-
} : {});
|
|
8291
|
-
}
|
|
8292
|
-
if (_this.timing.hasTimeToStartAnotherAd()) {
|
|
8293
|
-
_this.tryNextAvailableAdWithRateLimit();
|
|
8294
|
-
} else {
|
|
8295
|
-
_this.handleAdPodComplete();
|
|
9149
|
+
console.log("[AdBreak] content_resume: remaining=".concat(_this.timing.getRemainingAdMs(), "ms"));
|
|
8296
9150
|
}
|
|
9151
|
+
_this.setSlotState("NEEDS_NEXT_AD", "ad_complete");
|
|
9152
|
+
_this.requestNextAd("ad_complete");
|
|
8297
9153
|
});
|
|
8298
9154
|
}
|
|
8299
9155
|
},
|
|
8300
9156
|
{
|
|
8301
9157
|
key: "recreateAdController",
|
|
8302
|
-
value: function recreateAdController() {
|
|
8303
|
-
if (this.
|
|
8304
|
-
console.
|
|
9158
|
+
value: function recreateAdController(reason) {
|
|
9159
|
+
if (reason === "new_request" && (this.slotState === "REQUESTING" || this.slotState === "READY")) {
|
|
9160
|
+
console.warn("[AD-CONTROLLER] destroy during active request", {
|
|
9161
|
+
controllerId: this.controllerGeneration,
|
|
9162
|
+
requestId: this.currentRequestId,
|
|
9163
|
+
state: this.slotState,
|
|
9164
|
+
reason: reason
|
|
9165
|
+
});
|
|
8305
9166
|
}
|
|
9167
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
9168
|
+
controllerId: this.controllerGeneration,
|
|
9169
|
+
requestId: this.currentRequestId,
|
|
9170
|
+
state: this.slotState,
|
|
9171
|
+
reason: reason
|
|
9172
|
+
});
|
|
9173
|
+
this.countFunnelStage("controller_destroy:".concat(reason));
|
|
8306
9174
|
var shouldShowPlaceholder = this.inAdBreak && this.showAds;
|
|
8307
9175
|
var adPlayer = this.host.getAdPlayer();
|
|
8308
9176
|
if (shouldShowPlaceholder && adPlayer) {
|
|
@@ -8315,6 +9183,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8315
9183
|
}
|
|
8316
9184
|
var preservedMutedState = adPlayer.getOriginalMutedState();
|
|
8317
9185
|
var preservedVolumeState = adPlayer.getOriginalVolume();
|
|
9186
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8318
9187
|
if (adPlayer) {
|
|
8319
9188
|
try {
|
|
8320
9189
|
adPlayer.destroy();
|
|
@@ -8328,9 +9197,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8328
9197
|
var continueLiveStreamDuringAds = this.host.shouldContinueLiveStreamDuringAds();
|
|
8329
9198
|
var newAdPlayer = this.host.createAdPlayer(continueLiveStreamDuringAds);
|
|
8330
9199
|
this.host.setAdPlayer(newAdPlayer);
|
|
9200
|
+
this.controllerGeneration++;
|
|
8331
9201
|
newAdPlayer.initialize();
|
|
8332
9202
|
newAdPlayer.updateOriginalMutedState(preservedMutedState, preservedVolumeState);
|
|
8333
9203
|
this.attachImaEventListeners();
|
|
9204
|
+
if (this.debug) {
|
|
9205
|
+
console.log("[AD-CONTROLLER] create", {
|
|
9206
|
+
controllerId: this.controllerGeneration,
|
|
9207
|
+
reason: reason
|
|
9208
|
+
});
|
|
9209
|
+
}
|
|
8334
9210
|
if (shouldShowPlaceholder) {
|
|
8335
9211
|
this.placeholder.show();
|
|
8336
9212
|
newAdPlayer.showPlaceholder();
|
|
@@ -8351,32 +9227,57 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8351
9227
|
}
|
|
8352
9228
|
},
|
|
8353
9229
|
{
|
|
8354
|
-
|
|
8355
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9230
|
+
// ───────────────────────────────────────────────────────────────
|
|
8356
9231
|
// Ad break start
|
|
8357
9232
|
// ───────────────────────────────────────────────────────────────
|
|
8358
|
-
|
|
9233
|
+
key: "isBreakActive",
|
|
9234
|
+
value: function isBreakActive() {
|
|
9235
|
+
return this.slotState !== "IDLE";
|
|
9236
|
+
}
|
|
9237
|
+
},
|
|
9238
|
+
{
|
|
9239
|
+
key: "getSlotState",
|
|
9240
|
+
value: function getSlotState() {
|
|
9241
|
+
return this.slotState;
|
|
9242
|
+
}
|
|
9243
|
+
},
|
|
9244
|
+
{
|
|
9245
|
+
key: "beginVmapBreak",
|
|
9246
|
+
value: function beginVmapBreak(breakKey) {
|
|
9247
|
+
this.breakSource = "vmap";
|
|
9248
|
+
this.followUpBaseVastUrl = void 0;
|
|
9249
|
+
this.unusableResponsesInBreak = 0;
|
|
9250
|
+
this.timing.totalAdRequestsInBreak = 0;
|
|
9251
|
+
this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
|
|
9252
|
+
this.noteOpportunity("vmap", breakKey);
|
|
9253
|
+
}
|
|
9254
|
+
},
|
|
9255
|
+
{
|
|
9256
|
+
key: "handleAdStart",
|
|
9257
|
+
value: function handleAdStart(marker) {
|
|
8359
9258
|
return _async_to_generator(function() {
|
|
8360
|
-
var
|
|
9259
|
+
var baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, epoch, podPlayed;
|
|
8361
9260
|
return _ts_generator(this, function(_state) {
|
|
8362
9261
|
switch(_state.label){
|
|
8363
9262
|
case 0:
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
9263
|
+
if (this.slotState !== "IDLE") {
|
|
9264
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
9265
|
+
source: "scte35",
|
|
9266
|
+
state: this.slotState
|
|
9267
|
+
});
|
|
9268
|
+
return [
|
|
9269
|
+
2
|
|
9270
|
+
];
|
|
8367
9271
|
}
|
|
8368
|
-
|
|
8369
|
-
if (
|
|
8370
|
-
|
|
8371
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
8372
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
8373
|
-
} else {
|
|
9272
|
+
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
9273
|
+
if (!baseVastUrl) {
|
|
9274
|
+
console.warn("[AdBreak] SCTE-35 break started but no direct VAST tag is configured");
|
|
8374
9275
|
this.clearPendingAdBreak();
|
|
8375
9276
|
return [
|
|
8376
9277
|
2
|
|
8377
9278
|
];
|
|
8378
9279
|
}
|
|
8379
|
-
adBreakDurationMs =
|
|
9280
|
+
adBreakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : this.timing.expectedAdBreakDurationMs;
|
|
8380
9281
|
if (this.debug) {
|
|
8381
9282
|
mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
|
|
8382
9283
|
console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
@@ -8384,9 +9285,12 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8384
9285
|
this.timing.failedVastUrls.clear();
|
|
8385
9286
|
this.timing.temporaryFailureUrls.clear();
|
|
8386
9287
|
this.timing.consecutiveFailures = 0;
|
|
8387
|
-
this.continuousFetchingActive = true;
|
|
8388
9288
|
this.isShowingPlaceholder = false;
|
|
8389
9289
|
this.timing.totalAdRequestsInBreak = 0;
|
|
9290
|
+
this.breakSource = "scte35";
|
|
9291
|
+
this.followUpBaseVastUrl = baseVastUrl;
|
|
9292
|
+
this.unusableResponsesInBreak = 0;
|
|
9293
|
+
this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
|
|
8390
9294
|
if (this.adConfig.podAssignedByPrefetch) {
|
|
8391
9295
|
this.adConfig.podAssignedByPrefetch = false;
|
|
8392
9296
|
} else {
|
|
@@ -8404,29 +9308,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8404
9308
|
if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
8405
9309
|
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
8406
9310
|
}
|
|
9311
|
+
this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
|
|
9312
|
+
epoch = this.timing.adBreakEpoch;
|
|
8407
9313
|
return [
|
|
8408
9314
|
4,
|
|
8409
|
-
this.startOptimizedPod(baseVastUrl, adBreakDurationMs
|
|
9315
|
+
this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
|
|
8410
9316
|
];
|
|
8411
9317
|
case 1:
|
|
8412
9318
|
podPlayed = _state.sent();
|
|
8413
|
-
if (
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
];
|
|
8417
|
-
if (this.debug) {
|
|
8418
|
-
console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
|
|
9319
|
+
if (!podPlayed && this.inAdBreak && epoch === this.timing.adBreakEpoch) {
|
|
9320
|
+
this.setSlotState("NEEDS_NEXT_AD", "initial_request_failed");
|
|
9321
|
+
this.requestNextAd("initial_request_failed");
|
|
8419
9322
|
}
|
|
8420
|
-
this.continuousFetchingActive = true;
|
|
8421
|
-
this.startContinuousFetching(baseVastUrl);
|
|
8422
|
-
return [
|
|
8423
|
-
4,
|
|
8424
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
8425
|
-
];
|
|
8426
|
-
case 2:
|
|
8427
|
-
_state.sent();
|
|
8428
|
-
_state.label = 3;
|
|
8429
|
-
case 3:
|
|
8430
9323
|
return [
|
|
8431
9324
|
2
|
|
8432
9325
|
];
|
|
@@ -8440,12 +9333,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8440
9333
|
value: // ───────────────────────────────────────────────────────────────
|
|
8441
9334
|
// Optimized pod (single multi-ad request)
|
|
8442
9335
|
// ───────────────────────────────────────────────────────────────
|
|
8443
|
-
function startOptimizedPod(baseVastUrl, breakDurationMs
|
|
9336
|
+
function startOptimizedPod(baseVastUrl, breakDurationMs) {
|
|
8444
9337
|
return _async_to_generator(function() {
|
|
8445
|
-
var podUrl, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
9338
|
+
var podUrl, prefetched, epoch, generation, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
8446
9339
|
return _ts_generator(this, function(_state) {
|
|
8447
9340
|
switch(_state.label){
|
|
8448
9341
|
case 0:
|
|
9342
|
+
prefetched = !!(this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0);
|
|
8449
9343
|
if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
|
|
8450
9344
|
podUrl = this.pendingAdBreak.vastUrls[0];
|
|
8451
9345
|
this.clearPendingAdBreak();
|
|
@@ -8458,12 +9352,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8458
9352
|
false
|
|
8459
9353
|
];
|
|
8460
9354
|
}
|
|
8461
|
-
this.
|
|
8462
|
-
this.
|
|
9355
|
+
this.noteVastUrlGenerated(podUrl, prefetched ? "prefetch" : "break_start");
|
|
9356
|
+
epoch = this.timing.adBreakEpoch;
|
|
9357
|
+
this.recreateAdController("new_request");
|
|
9358
|
+
generation = this.controllerGeneration;
|
|
8463
9359
|
adPlayer = this.host.getAdPlayer();
|
|
8464
9360
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8465
9361
|
this.timing.activeAdRequestToken = requestToken;
|
|
8466
9362
|
this.currentVastUrl = podUrl;
|
|
9363
|
+
this.setSlotState("REQUESTING", "initial_pod");
|
|
9364
|
+
this.beginFunnelRequest(adPlayer, requestToken, "initial_pod");
|
|
8467
9365
|
_state.label = 1;
|
|
8468
9366
|
case 1:
|
|
8469
9367
|
_state.trys.push([
|
|
@@ -8478,16 +9376,24 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8478
9376
|
];
|
|
8479
9377
|
case 2:
|
|
8480
9378
|
_state.sent();
|
|
9379
|
+
if (this.isStale(epoch, generation)) return [
|
|
9380
|
+
2,
|
|
9381
|
+
true
|
|
9382
|
+
];
|
|
8481
9383
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
8482
|
-
this.timing.lastAdRequestTime = Date.now();
|
|
8483
9384
|
return [
|
|
8484
9385
|
4,
|
|
8485
|
-
|
|
9386
|
+
this.callController(function() {
|
|
9387
|
+
return adPlayer.requestAds(podUrl);
|
|
9388
|
+
})
|
|
8486
9389
|
];
|
|
8487
9390
|
case 3:
|
|
8488
9391
|
_state.sent();
|
|
8489
9392
|
this.timing.clearAdRequestWatchdog();
|
|
8490
|
-
if (this.
|
|
9393
|
+
if (this.isStale(epoch, generation)) {
|
|
9394
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9395
|
+
requestId: requestToken
|
|
9396
|
+
});
|
|
8491
9397
|
return [
|
|
8492
9398
|
2,
|
|
8493
9399
|
true
|
|
@@ -8495,11 +9401,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8495
9401
|
}
|
|
8496
9402
|
podCount = (_ref = (_adPlayer_getPodAdCount = adPlayer.getPodAdCount) === null || _adPlayer_getPodAdCount === void 0 ? void 0 : _adPlayer_getPodAdCount.call(adPlayer)) !== null && _ref !== void 0 ? _ref : 1;
|
|
8497
9403
|
if (podCount < 1) {
|
|
9404
|
+
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9405
|
+
this.timing.activeAdRequestToken = null;
|
|
9406
|
+
}
|
|
9407
|
+
this.recordRequestFailure(new Error("No ads available"), podUrl);
|
|
8498
9408
|
return [
|
|
8499
9409
|
2,
|
|
8500
9410
|
false
|
|
8501
9411
|
];
|
|
8502
9412
|
}
|
|
9413
|
+
this.setSlotState("READY", "vast_ready");
|
|
8503
9414
|
if (this.debug) {
|
|
8504
9415
|
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"));
|
|
8505
9416
|
}
|
|
@@ -8511,18 +9422,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8511
9422
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
8512
9423
|
return [
|
|
8513
9424
|
4,
|
|
8514
|
-
|
|
9425
|
+
this.callController(function() {
|
|
9426
|
+
return adPlayer.play();
|
|
9427
|
+
})
|
|
8515
9428
|
];
|
|
8516
9429
|
case 4:
|
|
8517
9430
|
_state.sent();
|
|
8518
|
-
this.
|
|
9431
|
+
if (this.isStale(epoch, generation)) return [
|
|
9432
|
+
2,
|
|
9433
|
+
true
|
|
9434
|
+
];
|
|
8519
9435
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
8520
9436
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
8521
9437
|
}
|
|
8522
|
-
adPlayer.setAdVolume(
|
|
8523
|
-
this.timing.consecutiveFailures = 0;
|
|
8524
|
-
this.continuousFetchingActive = true;
|
|
8525
|
-
this.startContinuousFetching(baseVastUrl);
|
|
9438
|
+
adPlayer.setAdVolume(getAdAudioVolume(adPlayer));
|
|
8526
9439
|
return [
|
|
8527
9440
|
2,
|
|
8528
9441
|
true
|
|
@@ -8534,14 +9447,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8534
9447
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
8535
9448
|
this.timing.activeAdRequestToken = null;
|
|
8536
9449
|
}
|
|
9450
|
+
if (this.isStale(epoch, generation)) {
|
|
9451
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9452
|
+
requestId: requestToken,
|
|
9453
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
9454
|
+
});
|
|
9455
|
+
return [
|
|
9456
|
+
2,
|
|
9457
|
+
true
|
|
9458
|
+
];
|
|
9459
|
+
}
|
|
8537
9460
|
if (this.debug) {
|
|
8538
9461
|
console.warn("[POD] Optimized pod request/play failed:", error);
|
|
8539
9462
|
}
|
|
8540
|
-
|
|
8541
|
-
this.timing.temporaryFailureUrls.set(podUrl, Date.now());
|
|
8542
|
-
}
|
|
8543
|
-
this.continuousFetchingActive = true;
|
|
8544
|
-
this.recreateAdController();
|
|
9463
|
+
this.recordRequestFailure(error, podUrl);
|
|
8545
9464
|
return [
|
|
8546
9465
|
2,
|
|
8547
9466
|
false
|
|
@@ -8557,168 +9476,204 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8557
9476
|
},
|
|
8558
9477
|
{
|
|
8559
9478
|
// ───────────────────────────────────────────────────────────────
|
|
8560
|
-
//
|
|
9479
|
+
// Next-ad scheduling (single flight)
|
|
8561
9480
|
// ───────────────────────────────────────────────────────────────
|
|
8562
|
-
key: "
|
|
8563
|
-
value: function
|
|
8564
|
-
if (
|
|
9481
|
+
key: "setSlotState",
|
|
9482
|
+
value: function setSlotState(next, reason) {
|
|
9483
|
+
if (this.slotState === next) return;
|
|
9484
|
+
var previous = this.slotState;
|
|
9485
|
+
this.slotState = next;
|
|
9486
|
+
if (this.debug) {
|
|
9487
|
+
console.log("[AdBreak][STATE] ".concat(previous, " -> ").concat(next), {
|
|
9488
|
+
reason: reason,
|
|
9489
|
+
breakId: this.timing.adBreakEpoch,
|
|
9490
|
+
requestId: this.currentRequestId,
|
|
9491
|
+
controllerId: this.controllerGeneration
|
|
9492
|
+
});
|
|
9493
|
+
}
|
|
9494
|
+
}
|
|
9495
|
+
},
|
|
9496
|
+
{
|
|
9497
|
+
key: "isStale",
|
|
9498
|
+
value: function isStale(epoch, generation) {
|
|
9499
|
+
return !this.inAdBreak || epoch !== this.timing.adBreakEpoch || generation !== this.controllerGeneration;
|
|
9500
|
+
}
|
|
9501
|
+
},
|
|
9502
|
+
{
|
|
9503
|
+
key: "getMinRemainingMsToRequestAd",
|
|
9504
|
+
value: function getMinRemainingMsToRequestAd() {
|
|
9505
|
+
var configured = this.host.config.minRemainingMsToRequestAd;
|
|
9506
|
+
var floor = this.timing.getMinRemainingMsToStartAd();
|
|
9507
|
+
if (typeof configured === "number" && configured >= 0) {
|
|
9508
|
+
return Math.max(configured, floor);
|
|
9509
|
+
}
|
|
9510
|
+
return Math.max(this.defaultMinRemainingMsToRequestAd, floor);
|
|
9511
|
+
}
|
|
9512
|
+
},
|
|
9513
|
+
{
|
|
9514
|
+
key: "getMaxNoFillsPerBreak",
|
|
9515
|
+
value: function getMaxNoFillsPerBreak() {
|
|
9516
|
+
var configured = this.host.config.maxNoFillsPerBreak;
|
|
9517
|
+
return typeof configured === "number" && configured > 0 ? configured : this.defaultMaxNoFillsPerBreak;
|
|
9518
|
+
}
|
|
9519
|
+
},
|
|
9520
|
+
{
|
|
9521
|
+
key: "isBreakTimeBounded",
|
|
9522
|
+
value: function isBreakTimeBounded() {
|
|
9523
|
+
return this.breakSource === "scte35" || this.timing.expectedAdBreakDurationMs != null;
|
|
9524
|
+
}
|
|
9525
|
+
},
|
|
9526
|
+
{
|
|
9527
|
+
key: "getStopRequestingReason",
|
|
9528
|
+
value: function getStopRequestingReason(remainingMs) {
|
|
9529
|
+
if (this.breakSource === "vmap") {
|
|
9530
|
+
if (this.adPodQueue.length === 0) return "vmap_queue_empty";
|
|
9531
|
+
} else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl) {
|
|
9532
|
+
return "no_follow_up_source";
|
|
9533
|
+
}
|
|
9534
|
+
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9535
|
+
return "max_consecutive_failures";
|
|
9536
|
+
}
|
|
9537
|
+
if (this.unusableResponsesInBreak >= this.getMaxNoFillsPerBreak()) {
|
|
9538
|
+
return "unusable_response_limit";
|
|
9539
|
+
}
|
|
9540
|
+
if (this.timing.totalAdRequestsInBreak >= this.timing.maxTotalAdRequestsPerBreak) {
|
|
9541
|
+
return "request_cap";
|
|
9542
|
+
}
|
|
9543
|
+
if (this.timing.isGamInCooldown()) {
|
|
9544
|
+
return "gam_cooldown";
|
|
9545
|
+
}
|
|
9546
|
+
if (this.isBreakTimeBounded() && remainingMs < this.getMinRemainingMsToRequestAd()) {
|
|
9547
|
+
return "insufficient_break_time";
|
|
9548
|
+
}
|
|
9549
|
+
return void 0;
|
|
9550
|
+
}
|
|
9551
|
+
},
|
|
9552
|
+
{
|
|
9553
|
+
key: "getNextRequestDelayMs",
|
|
9554
|
+
value: function getNextRequestDelayMs() {
|
|
9555
|
+
var failures = this.timing.consecutiveFailures;
|
|
9556
|
+
var backoff = failures > 0 ? Math.min(this.timing.backoffBaseMs * Math.pow(2, failures), this.timing.maxBackoffMs) : 0;
|
|
9557
|
+
var minInterval = this.timing.minAdRequestIntervalMs + backoff;
|
|
9558
|
+
var sinceLast = Date.now() - this.timing.lastAdRequestTime;
|
|
9559
|
+
return Math.max(0, minInterval - sinceLast);
|
|
9560
|
+
}
|
|
9561
|
+
},
|
|
9562
|
+
{
|
|
9563
|
+
key: "requestNextAd",
|
|
9564
|
+
value: function requestNextAd(trigger) {
|
|
9565
|
+
var _this = this;
|
|
9566
|
+
if (!this.inAdBreak) return;
|
|
9567
|
+
if (this.slotState !== "NEEDS_NEXT_AD") {
|
|
9568
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9569
|
+
trigger: trigger,
|
|
9570
|
+
state: this.slotState,
|
|
9571
|
+
why: "slot_busy"
|
|
9572
|
+
});
|
|
8565
9573
|
return;
|
|
8566
9574
|
}
|
|
8567
|
-
if (this.
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
9575
|
+
if (this.nextAdTimerId != null) {
|
|
9576
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9577
|
+
trigger: trigger,
|
|
9578
|
+
state: this.slotState,
|
|
9579
|
+
why: "request_already_scheduled"
|
|
9580
|
+
});
|
|
8571
9581
|
return;
|
|
8572
9582
|
}
|
|
8573
|
-
|
|
8574
|
-
|
|
9583
|
+
var remainingMs = this.timing.getRemainingAdMs();
|
|
9584
|
+
var stopReason = this.getStopRequestingReason(remainingMs);
|
|
9585
|
+
if (stopReason) {
|
|
9586
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9587
|
+
trigger: trigger,
|
|
9588
|
+
decision: "end_break",
|
|
9589
|
+
reason: stopReason,
|
|
9590
|
+
remainingMs: remainingMs,
|
|
9591
|
+
requestsSent: this.timing.totalAdRequestsInBreak,
|
|
9592
|
+
unusableResponses: this.unusableResponsesInBreak,
|
|
9593
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
9594
|
+
});
|
|
9595
|
+
this.handleAdPodComplete(stopReason);
|
|
9596
|
+
return;
|
|
9597
|
+
}
|
|
9598
|
+
var waitMs = this.getNextRequestDelayMs();
|
|
9599
|
+
if (waitMs > 0 && this.isBreakTimeBounded() && remainingMs - waitMs < this.getMinRemainingMsToRequestAd()) {
|
|
9600
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9601
|
+
trigger: trigger,
|
|
9602
|
+
decision: "end_break",
|
|
9603
|
+
reason: "insufficient_break_time_after_backoff",
|
|
9604
|
+
remainingMs: remainingMs,
|
|
9605
|
+
waitMs: waitMs
|
|
9606
|
+
});
|
|
9607
|
+
this.handleAdPodComplete("insufficient_break_time_after_backoff");
|
|
9608
|
+
return;
|
|
9609
|
+
}
|
|
9610
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9611
|
+
trigger: trigger,
|
|
9612
|
+
decision: waitMs > 0 ? "request_after_delay" : "request_now",
|
|
9613
|
+
waitMs: waitMs,
|
|
9614
|
+
remainingMs: remainingMs,
|
|
9615
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
9616
|
+
});
|
|
9617
|
+
if (waitMs > 0) {
|
|
9618
|
+
if (!this.isShowingPlaceholder) {
|
|
9619
|
+
this.isShowingPlaceholder = true;
|
|
9620
|
+
this.host.getAdPlayer().showPlaceholder();
|
|
9621
|
+
}
|
|
9622
|
+
var epoch = this.timing.adBreakEpoch;
|
|
9623
|
+
this.nextAdTimerId = window.setTimeout(function() {
|
|
9624
|
+
_this.nextAdTimerId = void 0;
|
|
9625
|
+
if (!_this.inAdBreak || epoch !== _this.timing.adBreakEpoch) return;
|
|
9626
|
+
_this.requestNextAd("".concat(trigger, ":after_delay"));
|
|
9627
|
+
}, waitMs);
|
|
9628
|
+
return;
|
|
8575
9629
|
}
|
|
8576
|
-
this.
|
|
8577
|
-
this.continuousFetchLoop(baseVastUrl);
|
|
9630
|
+
void this.requestFollowUpAd(trigger);
|
|
8578
9631
|
}
|
|
8579
9632
|
},
|
|
8580
9633
|
{
|
|
8581
|
-
key: "
|
|
8582
|
-
value: function
|
|
9634
|
+
key: "requestFollowUpAd",
|
|
9635
|
+
value: function requestFollowUpAd(trigger) {
|
|
8583
9636
|
return _async_to_generator(function() {
|
|
8584
|
-
var
|
|
9637
|
+
var url, epoch, unused;
|
|
8585
9638
|
return _ts_generator(this, function(_state) {
|
|
8586
9639
|
switch(_state.label){
|
|
8587
9640
|
case 0:
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
}
|
|
8598
|
-
return [
|
|
8599
|
-
2,
|
|
8600
|
-
"break"
|
|
8601
|
-
];
|
|
8602
|
-
}
|
|
8603
|
-
if (_this.timing.isGamInCooldown()) {
|
|
8604
|
-
if (_this.debug) {
|
|
8605
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping URL generation");
|
|
8606
|
-
}
|
|
8607
|
-
return [
|
|
8608
|
-
2,
|
|
8609
|
-
"break"
|
|
8610
|
-
];
|
|
8611
|
-
}
|
|
8612
|
-
if (_this.timing.consecutiveFailures >= _this.timing.maxConsecutiveFailures) {
|
|
8613
|
-
if (_this.debug) {
|
|
8614
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(_this.timing.consecutiveFailures, "), stopping URL generation"));
|
|
8615
|
-
}
|
|
8616
|
-
return [
|
|
8617
|
-
2,
|
|
8618
|
-
"break"
|
|
8619
|
-
];
|
|
8620
|
-
}
|
|
8621
|
-
if (_this.timing.totalAdRequestsInBreak >= _this.timing.maxTotalAdRequestsPerBreak) {
|
|
8622
|
-
if (_this.debug) {
|
|
8623
|
-
console.log("[CONTINUOUS-FETCH] Maximum ad requests reached (".concat(_this.timing.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
8624
|
-
}
|
|
8625
|
-
return [
|
|
8626
|
-
2,
|
|
8627
|
-
"break"
|
|
8628
|
-
];
|
|
8629
|
-
}
|
|
8630
|
-
maxQueueSize = 5;
|
|
8631
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
8632
|
-
3,
|
|
8633
|
-
2
|
|
8634
|
-
];
|
|
8635
|
-
if (_this.debug) {
|
|
8636
|
-
console.log("[CONTINUOUS-FETCH] URL queue full (".concat(_this.adRequestQueue.length, "), waiting..."));
|
|
8637
|
-
}
|
|
8638
|
-
return [
|
|
8639
|
-
4,
|
|
8640
|
-
new Promise(function(resolve) {
|
|
8641
|
-
return setTimeout(resolve, 1e3);
|
|
8642
|
-
})
|
|
8643
|
-
];
|
|
8644
|
-
case 1:
|
|
8645
|
-
_state.sent();
|
|
8646
|
-
return [
|
|
8647
|
-
2,
|
|
8648
|
-
"continue"
|
|
8649
|
-
];
|
|
8650
|
-
case 2:
|
|
8651
|
-
newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
|
|
8652
|
-
if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
|
|
8653
|
-
3,
|
|
8654
|
-
4
|
|
8655
|
-
];
|
|
8656
|
-
return [
|
|
8657
|
-
4,
|
|
8658
|
-
new Promise(function(resolve) {
|
|
8659
|
-
return setTimeout(resolve, 500);
|
|
8660
|
-
})
|
|
8661
|
-
];
|
|
8662
|
-
case 3:
|
|
8663
|
-
_state.sent();
|
|
8664
|
-
return [
|
|
8665
|
-
2,
|
|
8666
|
-
"continue"
|
|
8667
|
-
];
|
|
8668
|
-
case 4:
|
|
8669
|
-
if (_this.debug) {
|
|
8670
|
-
queuedUrlsPreview = _to_consumable_array(_this.adRequestQueue).concat([
|
|
8671
|
-
newAdUrl
|
|
8672
|
-
]);
|
|
8673
|
-
console.log("[CONTINUOUS-FETCH] Queued VAST URL (queue size: ".concat(queuedUrlsPreview.length, ")"), {
|
|
8674
|
-
queuedUrls: queuedUrlsPreview
|
|
8675
|
-
});
|
|
8676
|
-
}
|
|
8677
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
8678
|
-
generationDelay = _this.timing.consecutiveFailures > 0 ? Math.min(1e3 * Math.pow(2, _this.timing.consecutiveFailures), 5e3) : 500;
|
|
8679
|
-
return [
|
|
8680
|
-
4,
|
|
8681
|
-
new Promise(function(resolve) {
|
|
8682
|
-
return setTimeout(resolve, generationDelay);
|
|
8683
|
-
})
|
|
8684
|
-
];
|
|
8685
|
-
case 5:
|
|
8686
|
-
_state.sent();
|
|
8687
|
-
return [
|
|
8688
|
-
2
|
|
8689
|
-
];
|
|
8690
|
-
}
|
|
8691
|
-
});
|
|
8692
|
-
};
|
|
9641
|
+
if (this.breakSource === "vmap") {
|
|
9642
|
+
url = this.adPodQueue.shift();
|
|
9643
|
+
} else if (this.followUpBaseVastUrl) {
|
|
9644
|
+
url = this.nextAdRequestUrl(this.followUpBaseVastUrl);
|
|
9645
|
+
}
|
|
9646
|
+
if (!url) return [
|
|
9647
|
+
2
|
|
9648
|
+
];
|
|
9649
|
+
this.noteVastUrlGenerated(ensureVideoAdType(url), trigger);
|
|
8693
9650
|
epoch = this.timing.adBreakEpoch;
|
|
8694
9651
|
_state.label = 1;
|
|
8695
9652
|
case 1:
|
|
8696
|
-
|
|
9653
|
+
_state.trys.push([
|
|
9654
|
+
1,
|
|
8697
9655
|
3,
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
return [
|
|
8702
|
-
|
|
8703
|
-
|
|
9656
|
+
,
|
|
9657
|
+
4
|
|
9658
|
+
]);
|
|
9659
|
+
return [
|
|
9660
|
+
4,
|
|
9661
|
+
this.playSingleAd(url, trigger)
|
|
8704
9662
|
];
|
|
8705
9663
|
case 2:
|
|
8706
|
-
|
|
8707
|
-
|
|
9664
|
+
_state.sent();
|
|
9665
|
+
return [
|
|
8708
9666
|
3,
|
|
8709
|
-
|
|
9667
|
+
4
|
|
8710
9668
|
];
|
|
9669
|
+
case 3:
|
|
9670
|
+
unused = _state.sent();
|
|
9671
|
+
this.continueAfterRequestFailure(epoch);
|
|
8711
9672
|
return [
|
|
8712
9673
|
3,
|
|
8713
|
-
|
|
9674
|
+
4
|
|
8714
9675
|
];
|
|
8715
|
-
case
|
|
8716
|
-
this.continuousFetchLoopRunning = false;
|
|
8717
|
-
if (this.debug) {
|
|
8718
|
-
console.log("[CONTINUOUS-FETCH] URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"), this.adRequestQueue.length > 0 ? {
|
|
8719
|
-
queuedUrls: _to_consumable_array(this.adRequestQueue)
|
|
8720
|
-
} : {});
|
|
8721
|
-
}
|
|
9676
|
+
case 4:
|
|
8722
9677
|
return [
|
|
8723
9678
|
2
|
|
8724
9679
|
];
|
|
@@ -8728,236 +9683,318 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8728
9683
|
}
|
|
8729
9684
|
},
|
|
8730
9685
|
{
|
|
8731
|
-
key: "
|
|
8732
|
-
value: function
|
|
8733
|
-
|
|
8734
|
-
this.
|
|
8735
|
-
this.
|
|
8736
|
-
|
|
8737
|
-
|
|
9686
|
+
key: "continueAfterRequestFailure",
|
|
9687
|
+
value: function continueAfterRequestFailure() {
|
|
9688
|
+
var epoch = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.timing.adBreakEpoch;
|
|
9689
|
+
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) return;
|
|
9690
|
+
this.setSlotState("NEEDS_NEXT_AD", "request_failed");
|
|
9691
|
+
this.requestNextAd("after_failure");
|
|
9692
|
+
}
|
|
9693
|
+
},
|
|
9694
|
+
{
|
|
9695
|
+
key: "cancelScheduledRequest",
|
|
9696
|
+
value: function cancelScheduledRequest() {
|
|
9697
|
+
if (this.nextAdTimerId != null) {
|
|
9698
|
+
clearTimeout(this.nextAdTimerId);
|
|
9699
|
+
this.nextAdTimerId = void 0;
|
|
8738
9700
|
}
|
|
8739
9701
|
}
|
|
8740
9702
|
},
|
|
8741
9703
|
{
|
|
8742
|
-
key: "
|
|
8743
|
-
value:
|
|
8744
|
-
|
|
9704
|
+
key: "noteVastUrlGenerated",
|
|
9705
|
+
value: function noteVastUrlGenerated(url, source) {
|
|
9706
|
+
var _ref, _ref1, _ref2, _ref3, _ref4;
|
|
9707
|
+
var params;
|
|
9708
|
+
try {
|
|
9709
|
+
params = new URL(url).searchParams;
|
|
9710
|
+
} catch (unused) {}
|
|
9711
|
+
var adType = (_ref = params === null || params === void 0 ? void 0 : params.get("ad_type")) !== null && _ref !== void 0 ? _ref : void 0;
|
|
9712
|
+
this.logOrchestratorFunnel("vast_url_generated", {
|
|
9713
|
+
source: source,
|
|
9714
|
+
pod: (_ref1 = params === null || params === void 0 ? void 0 : params.get("pod")) !== null && _ref1 !== void 0 ? _ref1 : void 0,
|
|
9715
|
+
pmad: (_ref2 = params === null || params === void 0 ? void 0 : params.get("pmad")) !== null && _ref2 !== void 0 ? _ref2 : void 0,
|
|
9716
|
+
pmnd: (_ref3 = params === null || params === void 0 ? void 0 : params.get("pmnd")) !== null && _ref3 !== void 0 ? _ref3 : void 0,
|
|
9717
|
+
pmxd: (_ref4 = params === null || params === void 0 ? void 0 : params.get("pmxd")) !== null && _ref4 !== void 0 ? _ref4 : void 0,
|
|
9718
|
+
adType: adType
|
|
9719
|
+
});
|
|
9720
|
+
if (adType === "audio" || adType === "audio_video") {
|
|
9721
|
+
console.warn("[AdBreak] VAST tag requests ad_type=".concat(adType, "; GAM may return audio-only creatives, which this video player rejects"));
|
|
9722
|
+
this.countFunnelStage("tag_allows_audio");
|
|
9723
|
+
}
|
|
9724
|
+
}
|
|
9725
|
+
},
|
|
9726
|
+
{
|
|
9727
|
+
key: "recordRequestFailure",
|
|
9728
|
+
value: function recordRequestFailure(error, vastTagUrl) {
|
|
9729
|
+
var _diag_vastAdCount;
|
|
9730
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
9731
|
+
var message = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
9732
|
+
var outcome;
|
|
9733
|
+
if (message.includes("ad_duration_exceeds_budget")) {
|
|
9734
|
+
outcome = "discarded_budget";
|
|
9735
|
+
} else if (message.includes("VAST fill rejected")) {
|
|
9736
|
+
outcome = "fill_rejected";
|
|
9737
|
+
} else if (/no ads available|no fill|nofill/i.test(message)) {
|
|
9738
|
+
outcome = "no_fill";
|
|
9739
|
+
} else if (/timeout/i.test(message)) {
|
|
9740
|
+
outcome = "request_timeout";
|
|
9741
|
+
} else if (/destroyed|aborted/i.test(message)) {
|
|
9742
|
+
outcome = "request_aborted";
|
|
9743
|
+
} else if (diag && ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired) {
|
|
9744
|
+
outcome = "playback_failed";
|
|
9745
|
+
} else {
|
|
9746
|
+
outcome = "request_failed";
|
|
9747
|
+
}
|
|
9748
|
+
this.timing.consecutiveFailures++;
|
|
9749
|
+
if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
|
|
9750
|
+
this.unusableResponsesInBreak++;
|
|
9751
|
+
}
|
|
9752
|
+
if (outcome === "no_fill") {
|
|
9753
|
+
this.timing.recordGamNoFill();
|
|
9754
|
+
}
|
|
9755
|
+
if (diag && !diag.failureReason) {
|
|
9756
|
+
diag.failureReason = "".concat(outcome, ": ").concat(message);
|
|
9757
|
+
}
|
|
9758
|
+
if (this.timing.isTemporaryAdError(error)) {
|
|
9759
|
+
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9760
|
+
} else if (outcome !== "discarded_budget") {
|
|
9761
|
+
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9762
|
+
}
|
|
9763
|
+
this.countFunnelStage("request_outcome:".concat(outcome));
|
|
9764
|
+
this.logOrchestratorFunnel("request_outcome", {
|
|
9765
|
+
outcome: outcome,
|
|
9766
|
+
errorMessage: message,
|
|
9767
|
+
consecutiveFailures: this.timing.consecutiveFailures,
|
|
9768
|
+
unusableResponsesInBreak: this.unusableResponsesInBreak
|
|
9769
|
+
});
|
|
9770
|
+
}
|
|
9771
|
+
},
|
|
9772
|
+
{
|
|
8745
9773
|
// ───────────────────────────────────────────────────────────────
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
backoffDelay = Math.min(this.timing.backoffBaseMs * backoffMultiplier, this.timing.maxBackoffMs);
|
|
8769
|
-
effectiveMinInterval = this.timing.minAdRequestIntervalMs + (this.timing.consecutiveFailures > 0 ? backoffDelay : 0);
|
|
8770
|
-
timeSinceLastRequest = Date.now() - this.timing.lastAdRequestTime;
|
|
8771
|
-
if (!(timeSinceLastRequest < effectiveMinInterval)) return [
|
|
8772
|
-
3,
|
|
8773
|
-
2
|
|
8774
|
-
];
|
|
8775
|
-
waitTime = effectiveMinInterval - timeSinceLastRequest;
|
|
8776
|
-
if (this.debug) {
|
|
8777
|
-
console.log("[CONTINUOUS-FETCH] Rate limiting: waiting ".concat(waitTime, "ms before next request (backoff: ").concat(this.timing.consecutiveFailures, " failures)"));
|
|
8778
|
-
}
|
|
8779
|
-
return [
|
|
8780
|
-
4,
|
|
8781
|
-
new Promise(function(resolve) {
|
|
8782
|
-
return setTimeout(resolve, waitTime);
|
|
8783
|
-
})
|
|
8784
|
-
];
|
|
8785
|
-
case 1:
|
|
8786
|
-
_state.sent();
|
|
8787
|
-
_state.label = 2;
|
|
8788
|
-
case 2:
|
|
8789
|
-
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) {
|
|
8790
|
-
return [
|
|
8791
|
-
2
|
|
8792
|
-
];
|
|
8793
|
-
}
|
|
8794
|
-
return [
|
|
8795
|
-
2,
|
|
8796
|
-
this.tryNextAvailableAd(0)
|
|
8797
|
-
];
|
|
9774
|
+
// Per-request diagnostics
|
|
9775
|
+
// ───────────────────────────────────────────────────────────────
|
|
9776
|
+
key: "recordRequestDiagnostic",
|
|
9777
|
+
value: function recordRequestDiagnostic(payload) {
|
|
9778
|
+
var requestId = payload.requestId;
|
|
9779
|
+
if (typeof requestId !== "number") return;
|
|
9780
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
9781
|
+
if (!diag) return;
|
|
9782
|
+
switch(payload.stage){
|
|
9783
|
+
case "gam_http_request_sent":
|
|
9784
|
+
diag.gamRequestSent++;
|
|
9785
|
+
break;
|
|
9786
|
+
case "gam_response_received":
|
|
9787
|
+
diag.vastHttpStatus = payload.httpStatus;
|
|
9788
|
+
break;
|
|
9789
|
+
case "vast_parsed":
|
|
9790
|
+
diag.vastAdCount = payload.adElementCount;
|
|
9791
|
+
break;
|
|
9792
|
+
case "wrapper_fetch":
|
|
9793
|
+
case "inline_resolved":
|
|
9794
|
+
if (typeof payload.depth === "number") {
|
|
9795
|
+
diag.wrapperDepth = Math.max(diag.wrapperDepth, payload.depth);
|
|
8798
9796
|
}
|
|
9797
|
+
if (payload.stage === "inline_resolved") diag.inlineResolved = true;
|
|
9798
|
+
break;
|
|
9799
|
+
case "mediafile_evaluated":
|
|
9800
|
+
diag.mediaCandidateCount++;
|
|
9801
|
+
if (payload.whyAccepted) diag.supportedMediaCount++;
|
|
9802
|
+
break;
|
|
9803
|
+
case "playing":
|
|
9804
|
+
diag.playStarted = true;
|
|
9805
|
+
break;
|
|
9806
|
+
case "impression_fired":
|
|
9807
|
+
diag.impressionFired = true;
|
|
9808
|
+
break;
|
|
9809
|
+
default:
|
|
9810
|
+
if (REQUEST_FAILURE_STAGES.has(payload.stage) && !diag.failureReason) {
|
|
9811
|
+
diag.failureReason = payload.reason ? "".concat(payload.stage, ":").concat(payload.reason) : payload.stage;
|
|
9812
|
+
}
|
|
9813
|
+
}
|
|
9814
|
+
}
|
|
9815
|
+
},
|
|
9816
|
+
{
|
|
9817
|
+
key: "finalizeRequestDiagnostics",
|
|
9818
|
+
value: function finalizeRequestDiagnostics(requestId, endReason) {
|
|
9819
|
+
var _diag_vastAdCount;
|
|
9820
|
+
if (requestId == null) return;
|
|
9821
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
9822
|
+
if (!diag) return;
|
|
9823
|
+
this.requestDiagnostics.delete(requestId);
|
|
9824
|
+
if (!diag.impressionFired && !diag.failureReason && endReason) {
|
|
9825
|
+
diag.failureReason = endReason;
|
|
9826
|
+
}
|
|
9827
|
+
var gamReturnedAdWithoutImpression = ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired;
|
|
9828
|
+
if (gamReturnedAdWithoutImpression) {
|
|
9829
|
+
this.countFunnelStage("gam_ad_without_impression");
|
|
9830
|
+
}
|
|
9831
|
+
var startedAt = diag.startedAt, fields = _object_without_properties(diag, [
|
|
9832
|
+
"startedAt"
|
|
9833
|
+
]);
|
|
9834
|
+
console.log("[AdBreak][REQUEST] summary", _object_spread_props(_object_spread({}, fields), {
|
|
9835
|
+
durationMs: Date.now() - startedAt,
|
|
9836
|
+
gamReturnedAdWithoutImpression: gamReturnedAdWithoutImpression
|
|
9837
|
+
}));
|
|
9838
|
+
}
|
|
9839
|
+
},
|
|
9840
|
+
{
|
|
9841
|
+
// ───────────────────────────────────────────────────────────────
|
|
9842
|
+
// Single ad playback
|
|
9843
|
+
// ───────────────────────────────────────────────────────────────
|
|
9844
|
+
key: "withCurrentPodBudget",
|
|
9845
|
+
value: function withCurrentPodBudget(rawVastTagUrl) {
|
|
9846
|
+
var vastTagUrl = ensureVideoAdType(rawVastTagUrl);
|
|
9847
|
+
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9848
|
+
if (!(remaining > 0)) return vastTagUrl;
|
|
9849
|
+
try {
|
|
9850
|
+
var url = new URL(vastTagUrl);
|
|
9851
|
+
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
9852
|
+
var maxMs = Math.round(remaining);
|
|
9853
|
+
url.searchParams.set("pmxd", String(maxMs));
|
|
9854
|
+
var minMs = Number(url.searchParams.get("pmnd"));
|
|
9855
|
+
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
9856
|
+
url.searchParams.set("pmnd", String(maxMs));
|
|
9857
|
+
}
|
|
9858
|
+
return url.toString();
|
|
9859
|
+
} catch (unused) {
|
|
9860
|
+
return vastTagUrl;
|
|
9861
|
+
}
|
|
9862
|
+
}
|
|
9863
|
+
},
|
|
9864
|
+
{
|
|
9865
|
+
key: "countFunnelStage",
|
|
9866
|
+
value: function countFunnelStage(stage) {
|
|
9867
|
+
var amount = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
|
|
9868
|
+
var _this_breakFunnel_stage;
|
|
9869
|
+
this.breakFunnel[stage] = ((_this_breakFunnel_stage = this.breakFunnel[stage]) !== null && _this_breakFunnel_stage !== void 0 ? _this_breakFunnel_stage : 0) + amount;
|
|
9870
|
+
}
|
|
9871
|
+
},
|
|
9872
|
+
{
|
|
9873
|
+
key: "logOrchestratorFunnel",
|
|
9874
|
+
value: function logOrchestratorFunnel(stage) {
|
|
9875
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
9876
|
+
this.countFunnelStage(stage);
|
|
9877
|
+
console.log("[AdBreak][FUNNEL] ".concat(stage), _object_spread({
|
|
9878
|
+
breakId: this.timing.adBreakEpoch,
|
|
9879
|
+
requestId: this.currentRequestId,
|
|
9880
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0
|
|
9881
|
+
}, extra));
|
|
9882
|
+
}
|
|
9883
|
+
},
|
|
9884
|
+
{
|
|
9885
|
+
key: "noteOpportunity",
|
|
9886
|
+
value: function noteOpportunity(source, breakKey) {
|
|
9887
|
+
if (breakKey && breakKey === this.opportunityBreakKey && this.opportunityEpoch === this.timing.adBreakEpoch) {
|
|
9888
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
9889
|
+
source: source,
|
|
9890
|
+
breakKey: breakKey
|
|
8799
9891
|
});
|
|
8800
|
-
|
|
9892
|
+
return;
|
|
9893
|
+
}
|
|
9894
|
+
this.opportunityBreakKey = breakKey;
|
|
9895
|
+
this.opportunityEpoch = this.timing.adBreakEpoch;
|
|
9896
|
+
this.logOrchestratorFunnel("opportunity_created", {
|
|
9897
|
+
source: source,
|
|
9898
|
+
breakKey: breakKey,
|
|
9899
|
+
expectedDurationMs: this.timing.expectedAdBreakDurationMs
|
|
9900
|
+
});
|
|
9901
|
+
}
|
|
9902
|
+
},
|
|
9903
|
+
{
|
|
9904
|
+
key: "beginFunnelRequest",
|
|
9905
|
+
value: function beginFunnelRequest(adPlayer, requestToken, trigger) {
|
|
9906
|
+
var _adPlayer_setFunnelContext;
|
|
9907
|
+
if (this.controllerCallInFlight) {
|
|
9908
|
+
this.logOrchestratorFunnel("duplicate_request_detected", {
|
|
9909
|
+
newRequestId: requestToken
|
|
9910
|
+
});
|
|
9911
|
+
}
|
|
9912
|
+
this.finalizeRequestDiagnostics(this.currentRequestId);
|
|
9913
|
+
this.currentRequestId = requestToken;
|
|
9914
|
+
this.requestStartedAt = Date.now();
|
|
9915
|
+
this.requestDiagnostics.set(requestToken, {
|
|
9916
|
+
breakId: this.timing.adBreakEpoch,
|
|
9917
|
+
requestId: requestToken,
|
|
9918
|
+
controllerId: this.controllerGeneration,
|
|
9919
|
+
trigger: trigger,
|
|
9920
|
+
gamRequestSent: 0,
|
|
9921
|
+
wrapperDepth: 0,
|
|
9922
|
+
inlineResolved: false,
|
|
9923
|
+
mediaCandidateCount: 0,
|
|
9924
|
+
supportedMediaCount: 0,
|
|
9925
|
+
playStarted: false,
|
|
9926
|
+
impressionFired: false,
|
|
9927
|
+
startedAt: Date.now()
|
|
9928
|
+
});
|
|
9929
|
+
(_adPlayer_setFunnelContext = adPlayer.setFunnelContext) === null || _adPlayer_setFunnelContext === void 0 ? void 0 : _adPlayer_setFunnelContext.call(adPlayer, {
|
|
9930
|
+
breakId: this.timing.adBreakEpoch,
|
|
9931
|
+
requestId: requestToken,
|
|
9932
|
+
controllerId: this.controllerGeneration
|
|
9933
|
+
});
|
|
9934
|
+
}
|
|
9935
|
+
},
|
|
9936
|
+
{
|
|
9937
|
+
key: "isAdLoadingWithoutPlayback",
|
|
9938
|
+
value: function isAdLoadingWithoutPlayback() {
|
|
9939
|
+
return this.host.getAdPlayer().isAdPlaying() && !this.playbackStartedForCurrentRequest;
|
|
9940
|
+
}
|
|
9941
|
+
},
|
|
9942
|
+
{
|
|
9943
|
+
key: "noteStopBeforeStart",
|
|
9944
|
+
value: function noteStopBeforeStart(reason) {
|
|
9945
|
+
if (!this.isAdLoadingWithoutPlayback()) return;
|
|
9946
|
+
this.logOrchestratorFunnel("ad_stopped_before_start", {
|
|
9947
|
+
reason: reason,
|
|
9948
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
9949
|
+
});
|
|
9950
|
+
}
|
|
9951
|
+
},
|
|
9952
|
+
{
|
|
9953
|
+
key: "handleRequestWatchdogTimeout",
|
|
9954
|
+
value: function handleRequestWatchdogTimeout() {
|
|
9955
|
+
var adPlayer = this.host.getAdPlayer();
|
|
9956
|
+
if (this.controllerCallInFlight && adPlayer.abortPendingRequest) {
|
|
9957
|
+
this.logOrchestratorFunnel("request_aborted_timeout", {
|
|
9958
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
9959
|
+
});
|
|
9960
|
+
adPlayer.abortPendingRequest("VAST request aborted after request watchdog timeout");
|
|
9961
|
+
return;
|
|
9962
|
+
}
|
|
9963
|
+
this.handleAdFailure("request_watchdog_timeout");
|
|
8801
9964
|
}
|
|
8802
9965
|
},
|
|
8803
9966
|
{
|
|
8804
|
-
key: "
|
|
8805
|
-
value: function
|
|
8806
|
-
var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
|
9967
|
+
key: "callController",
|
|
9968
|
+
value: function callController(call) {
|
|
8807
9969
|
return _async_to_generator(function() {
|
|
8808
|
-
var remaining, nextAdUrl, error, errorMessage, maxRetries;
|
|
8809
9970
|
return _ts_generator(this, function(_state) {
|
|
8810
9971
|
switch(_state.label){
|
|
8811
9972
|
case 0:
|
|
8812
|
-
|
|
8813
|
-
return [
|
|
8814
|
-
2
|
|
8815
|
-
];
|
|
8816
|
-
}
|
|
8817
|
-
remaining = this.timing.getRemainingAdMs();
|
|
8818
|
-
if (!this.timing.hasTimeToStartAnotherAd()) {
|
|
8819
|
-
if (this.debug) {
|
|
8820
|
-
console.log("[CONTINUOUS-FETCH] Not enough time remaining (".concat(remaining, "ms) to start another ad, ending ad break"));
|
|
8821
|
-
}
|
|
8822
|
-
this.handleAdPodComplete();
|
|
8823
|
-
return [
|
|
8824
|
-
2
|
|
8825
|
-
];
|
|
8826
|
-
}
|
|
8827
|
-
if (this.timing.isGamInCooldown()) {
|
|
8828
|
-
if (this.debug) {
|
|
8829
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, ending ad break gracefully");
|
|
8830
|
-
}
|
|
8831
|
-
this.handleAdPodComplete();
|
|
8832
|
-
return [
|
|
8833
|
-
2
|
|
8834
|
-
];
|
|
8835
|
-
}
|
|
8836
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
8837
|
-
if (this.debug) {
|
|
8838
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(this.timing.consecutiveFailures, "), ending ad break"));
|
|
8839
|
-
}
|
|
8840
|
-
this.handleAdPodComplete();
|
|
8841
|
-
return [
|
|
8842
|
-
2
|
|
8843
|
-
];
|
|
8844
|
-
}
|
|
8845
|
-
this.timing.cleanupTemporaryFailures();
|
|
9973
|
+
this.controllerCallInFlight = true;
|
|
8846
9974
|
_state.label = 1;
|
|
8847
9975
|
case 1:
|
|
8848
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
8849
|
-
3,
|
|
8850
|
-
9
|
|
8851
|
-
];
|
|
8852
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
8853
|
-
if (!nextAdUrl) return [
|
|
8854
|
-
3,
|
|
8855
|
-
1
|
|
8856
|
-
];
|
|
8857
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) {
|
|
8858
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
|
|
8859
|
-
return [
|
|
8860
|
-
3,
|
|
8861
|
-
1
|
|
8862
|
-
];
|
|
8863
|
-
}
|
|
8864
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) {
|
|
8865
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
|
|
8866
|
-
return [
|
|
8867
|
-
3,
|
|
8868
|
-
1
|
|
8869
|
-
];
|
|
8870
|
-
}
|
|
8871
|
-
if (this.debug) {
|
|
8872
|
-
console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
|
|
8873
|
-
}
|
|
8874
|
-
_state.label = 2;
|
|
8875
|
-
case 2:
|
|
8876
9976
|
_state.trys.push([
|
|
8877
|
-
|
|
8878
|
-
4,
|
|
9977
|
+
1,
|
|
8879
9978
|
,
|
|
8880
|
-
8
|
|
8881
|
-
]);
|
|
8882
|
-
return [
|
|
8883
|
-
4,
|
|
8884
|
-
this.playSingleAd(nextAdUrl)
|
|
8885
|
-
];
|
|
8886
|
-
case 3:
|
|
8887
|
-
_state.sent();
|
|
8888
|
-
this.timing.consecutiveFailures = 0;
|
|
8889
|
-
return [
|
|
8890
9979
|
3,
|
|
8891
|
-
|
|
8892
|
-
];
|
|
8893
|
-
case 4:
|
|
8894
|
-
error = _state.sent();
|
|
8895
|
-
errorMessage = error.message;
|
|
8896
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
|
|
8897
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
8898
|
-
3,
|
|
8899
|
-
6
|
|
8900
|
-
];
|
|
8901
|
-
return [
|
|
8902
|
-
4,
|
|
8903
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
8904
|
-
];
|
|
8905
|
-
case 5:
|
|
8906
|
-
_state.sent();
|
|
8907
|
-
return [
|
|
8908
|
-
2
|
|
8909
|
-
];
|
|
8910
|
-
case 6:
|
|
8911
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
8912
|
-
this.timing.consecutiveFailures++;
|
|
8913
|
-
}
|
|
9980
|
+
4
|
|
9981
|
+
]);
|
|
8914
9982
|
return [
|
|
8915
9983
|
4,
|
|
8916
|
-
|
|
9984
|
+
call()
|
|
8917
9985
|
];
|
|
8918
|
-
case
|
|
9986
|
+
case 2:
|
|
8919
9987
|
_state.sent();
|
|
8920
9988
|
return [
|
|
8921
9989
|
3,
|
|
8922
|
-
|
|
8923
|
-
];
|
|
8924
|
-
case 8:
|
|
8925
|
-
return [
|
|
8926
|
-
2
|
|
8927
|
-
];
|
|
8928
|
-
case 9:
|
|
8929
|
-
maxRetries = 3;
|
|
8930
|
-
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
8931
|
-
3,
|
|
8932
|
-
12
|
|
8933
|
-
];
|
|
8934
|
-
if (this.debug) {
|
|
8935
|
-
console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
8936
|
-
}
|
|
8937
|
-
return [
|
|
8938
|
-
4,
|
|
8939
|
-
new Promise(function(resolve) {
|
|
8940
|
-
return setTimeout(resolve, 500);
|
|
8941
|
-
})
|
|
8942
|
-
];
|
|
8943
|
-
case 10:
|
|
8944
|
-
_state.sent();
|
|
8945
|
-
return [
|
|
8946
|
-
4,
|
|
8947
|
-
this.tryNextAvailableAd(retryCount + 1)
|
|
9990
|
+
4
|
|
8948
9991
|
];
|
|
8949
|
-
case
|
|
8950
|
-
|
|
9992
|
+
case 3:
|
|
9993
|
+
this.controllerCallInFlight = false;
|
|
8951
9994
|
return [
|
|
8952
|
-
|
|
9995
|
+
7
|
|
8953
9996
|
];
|
|
8954
|
-
case
|
|
8955
|
-
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
8956
|
-
this.showPlaceholderAndWaitForAds();
|
|
8957
|
-
} else {
|
|
8958
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] No more ads available, ending ad break");
|
|
8959
|
-
this.handleAdPodComplete();
|
|
8960
|
-
}
|
|
9997
|
+
case 4:
|
|
8961
9998
|
return [
|
|
8962
9999
|
2
|
|
8963
10000
|
];
|
|
@@ -8966,47 +10003,33 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8966
10003
|
}).call(this);
|
|
8967
10004
|
}
|
|
8968
10005
|
},
|
|
8969
|
-
{
|
|
8970
|
-
// ───────────────────────────────────────────────────────────────
|
|
8971
|
-
// Single ad playback
|
|
8972
|
-
// ───────────────────────────────────────────────────────────────
|
|
8973
|
-
key: "withCurrentPodBudget",
|
|
8974
|
-
value: function withCurrentPodBudget(vastTagUrl) {
|
|
8975
|
-
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
8976
|
-
if (!(remaining > 0)) return vastTagUrl;
|
|
8977
|
-
try {
|
|
8978
|
-
var url = new URL(vastTagUrl);
|
|
8979
|
-
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
8980
|
-
var maxMs = Math.round(remaining);
|
|
8981
|
-
url.searchParams.set("pmxd", String(maxMs));
|
|
8982
|
-
var minMs = Number(url.searchParams.get("pmnd"));
|
|
8983
|
-
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
8984
|
-
url.searchParams.set("pmnd", String(maxMs));
|
|
8985
|
-
}
|
|
8986
|
-
return url.toString();
|
|
8987
|
-
} catch (unused) {
|
|
8988
|
-
return vastTagUrl;
|
|
8989
|
-
}
|
|
8990
|
-
}
|
|
8991
|
-
},
|
|
8992
10006
|
{
|
|
8993
10007
|
key: "playSingleAd",
|
|
8994
10008
|
value: function playSingleAd(vastTagUrl) {
|
|
10009
|
+
var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
|
|
8995
10010
|
return _async_to_generator(function() {
|
|
8996
|
-
var
|
|
10011
|
+
var epoch, generation, requestToken, ap, requestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
|
|
8997
10012
|
return _ts_generator(this, function(_state) {
|
|
8998
10013
|
switch(_state.label){
|
|
8999
10014
|
case 0:
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
10015
|
+
if (this.slotState === "REQUESTING" || this.slotState === "READY" || this.slotState === "PLAYING" || this.slotState === "ENDING") {
|
|
10016
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
10017
|
+
trigger: trigger,
|
|
10018
|
+
state: this.slotState,
|
|
10019
|
+
why: "request_in_flight"
|
|
10020
|
+
});
|
|
10021
|
+
return [
|
|
10022
|
+
2
|
|
10023
|
+
];
|
|
10024
|
+
}
|
|
9004
10025
|
if (this.timing.failedVastUrls.has(vastTagUrl)) {
|
|
9005
10026
|
if (this.debug) console.warn("[AD-ERROR] Skipping permanently-failed VAST URL:", vastTagUrl);
|
|
10027
|
+
this.timing.consecutiveFailures++;
|
|
9006
10028
|
throw new Error("VAST URL permanently failed");
|
|
9007
10029
|
}
|
|
9008
10030
|
if (this.timing.isUrlInCooldown(vastTagUrl)) {
|
|
9009
10031
|
if (this.debug) console.warn("[AD-ERROR] Skipping URL in cooldown (recent no-fill):", vastTagUrl);
|
|
10032
|
+
this.timing.consecutiveFailures++;
|
|
9010
10033
|
throw new Error("VAST URL in cooldown after no-fill");
|
|
9011
10034
|
}
|
|
9012
10035
|
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
@@ -9017,16 +10040,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9017
10040
|
if (this.debug) console.warn("[CIRCUIT-BREAKER] GAM in cooldown, skipping ad request");
|
|
9018
10041
|
throw new Error("GAM in cooldown");
|
|
9019
10042
|
}
|
|
9020
|
-
this.
|
|
10043
|
+
epoch = this.timing.adBreakEpoch;
|
|
10044
|
+
this.recreateAdController("new_request");
|
|
10045
|
+
generation = this.controllerGeneration;
|
|
9021
10046
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
9022
10047
|
this.timing.activeAdRequestToken = requestToken;
|
|
10048
|
+
ap = this.host.getAdPlayer();
|
|
10049
|
+
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
10050
|
+
this.currentVastUrl = requestUrl;
|
|
10051
|
+
this.setSlotState("REQUESTING", trigger);
|
|
10052
|
+
this.beginFunnelRequest(ap, requestToken, trigger);
|
|
9023
10053
|
_state.label = 1;
|
|
9024
10054
|
case 1:
|
|
9025
10055
|
_state.trys.push([
|
|
9026
10056
|
1,
|
|
9027
|
-
|
|
10057
|
+
5,
|
|
9028
10058
|
,
|
|
9029
|
-
|
|
10059
|
+
6
|
|
9030
10060
|
]);
|
|
9031
10061
|
return [
|
|
9032
10062
|
4,
|
|
@@ -9034,265 +10064,87 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9034
10064
|
];
|
|
9035
10065
|
case 2:
|
|
9036
10066
|
_state.sent();
|
|
10067
|
+
if (this.isStale(epoch, generation)) return [
|
|
10068
|
+
2
|
|
10069
|
+
];
|
|
9037
10070
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
9038
|
-
this.timing.lastAdRequestTime = Date.now();
|
|
9039
|
-
ap = this.host.getAdPlayer();
|
|
9040
|
-
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9041
|
-
this.currentVastUrl = requestUrl;
|
|
9042
10071
|
return [
|
|
9043
10072
|
4,
|
|
9044
|
-
|
|
10073
|
+
this.callController(function() {
|
|
10074
|
+
return ap.requestAds(requestUrl);
|
|
10075
|
+
})
|
|
9045
10076
|
];
|
|
9046
10077
|
case 3:
|
|
9047
10078
|
_state.sent();
|
|
10079
|
+
this.timing.clearAdRequestWatchdog();
|
|
10080
|
+
if (this.isStale(epoch, generation)) {
|
|
10081
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
10082
|
+
requestId: requestToken
|
|
10083
|
+
});
|
|
10084
|
+
return [
|
|
10085
|
+
2
|
|
10086
|
+
];
|
|
10087
|
+
}
|
|
9048
10088
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
9049
10089
|
source: "hls",
|
|
9050
10090
|
vastUrl: requestUrl,
|
|
9051
10091
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
9052
10092
|
}, this.analyticsContext).catch(function() {});
|
|
9053
|
-
this.timing.clearAdRequestWatchdog();
|
|
9054
|
-
if (this.timing.activeAdRequestToken !== requestToken) return [
|
|
9055
|
-
2
|
|
9056
|
-
];
|
|
9057
10093
|
if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
|
|
9058
|
-
|
|
9059
|
-
|
|
10094
|
+
;
|
|
10095
|
+
adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
|
|
10096
|
+
remainingMs = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
10097
|
+
this.logOrchestratorFunnel("discarded_budget", {
|
|
10098
|
+
adDurationMs: adDurationS != null ? adDurationS * 1e3 : void 0,
|
|
10099
|
+
remainingMs: remainingMs
|
|
10100
|
+
});
|
|
9060
10101
|
throw new Error("ad_duration_exceeds_budget");
|
|
9061
10102
|
}
|
|
9062
|
-
|
|
9063
|
-
case 4:
|
|
9064
|
-
_state.trys.push([
|
|
9065
|
-
4,
|
|
9066
|
-
6,
|
|
9067
|
-
,
|
|
9068
|
-
7
|
|
9069
|
-
]);
|
|
10103
|
+
this.setSlotState("READY", "vast_ready");
|
|
9070
10104
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
9071
10105
|
return [
|
|
9072
10106
|
4,
|
|
9073
|
-
|
|
10107
|
+
this.callController(function() {
|
|
10108
|
+
return ap.play();
|
|
10109
|
+
})
|
|
9074
10110
|
];
|
|
9075
|
-
case
|
|
10111
|
+
case 4:
|
|
9076
10112
|
_state.sent();
|
|
9077
|
-
this.
|
|
10113
|
+
if (this.isStale(epoch, generation)) return [
|
|
10114
|
+
2
|
|
10115
|
+
];
|
|
9078
10116
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
9079
10117
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
9080
10118
|
}
|
|
9081
10119
|
ap.setAdVolume(getAdAudioVolume(ap));
|
|
9082
|
-
this.timing.consecutiveFailures = 0;
|
|
9083
10120
|
this.timing.temporaryFailureUrls.delete(vastTagUrl);
|
|
9084
10121
|
return [
|
|
9085
10122
|
3,
|
|
9086
|
-
|
|
9087
|
-
];
|
|
9088
|
-
case 6:
|
|
9089
|
-
playError = _state.sent();
|
|
9090
|
-
if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
|
|
9091
|
-
if (this.timing.isTemporaryAdError(playError)) {
|
|
9092
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9093
|
-
if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
|
|
9094
|
-
} else {
|
|
9095
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9096
|
-
if (this.debug) console.log("[AD-ERROR] Permanent play error - URL blacklisted");
|
|
9097
|
-
}
|
|
9098
|
-
this.timing.clearAdFailsafeTimer();
|
|
9099
|
-
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9100
|
-
this.timing.activeAdRequestToken = null;
|
|
9101
|
-
}
|
|
9102
|
-
throw playError;
|
|
9103
|
-
case 7:
|
|
9104
|
-
return [
|
|
9105
|
-
3,
|
|
9106
|
-
9
|
|
10123
|
+
6
|
|
9107
10124
|
];
|
|
9108
|
-
case
|
|
10125
|
+
case 5:
|
|
9109
10126
|
error = _state.sent();
|
|
9110
|
-
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
9111
|
-
if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
|
|
9112
|
-
if (this.timing.isTemporaryAdError(error)) {
|
|
9113
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9114
|
-
if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
|
|
9115
|
-
} else {
|
|
9116
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9117
|
-
if (this.debug) console.log("[AD-ERROR] Permanent error - URL blacklisted:", errorMessage);
|
|
9118
|
-
}
|
|
9119
10127
|
this.timing.clearAdRequestWatchdog();
|
|
9120
10128
|
this.timing.clearAdFailsafeTimer();
|
|
9121
10129
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9122
10130
|
this.timing.activeAdRequestToken = null;
|
|
9123
10131
|
}
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
}
|
|
9130
|
-
});
|
|
9131
|
-
}).call(this);
|
|
9132
|
-
}
|
|
9133
|
-
},
|
|
9134
|
-
{
|
|
9135
|
-
key: "showPlaceholderAndWaitForAds",
|
|
9136
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9137
|
-
// Placeholder wait
|
|
9138
|
-
// ───────────────────────────────────────────────────────────────
|
|
9139
|
-
function showPlaceholderAndWaitForAds() {
|
|
9140
|
-
return _async_to_generator(function() {
|
|
9141
|
-
var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
|
|
9142
|
-
return _ts_generator(this, function(_state) {
|
|
9143
|
-
switch(_state.label){
|
|
9144
|
-
case 0:
|
|
9145
|
-
remaining = this.timing.getRemainingAdMs();
|
|
9146
|
-
waitTime = Math.min(this.maxPlaceholderDurationMs, remaining);
|
|
9147
|
-
if (this.timing.isGamInCooldown()) {
|
|
9148
|
-
if (this.debug) console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping placeholder wait");
|
|
9149
|
-
this.handleAdPodComplete();
|
|
9150
|
-
return [
|
|
9151
|
-
2
|
|
9152
|
-
];
|
|
9153
|
-
}
|
|
9154
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9155
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping placeholder - too many consecutive failures");
|
|
9156
|
-
this.handleAdPodComplete();
|
|
9157
|
-
return [
|
|
9158
|
-
2
|
|
9159
|
-
];
|
|
9160
|
-
}
|
|
9161
|
-
if (waitTime < 1e3) {
|
|
9162
|
-
this.handleAdPodComplete();
|
|
10132
|
+
if (this.isStale(epoch, generation)) {
|
|
10133
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
10134
|
+
requestId: requestToken,
|
|
10135
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
10136
|
+
});
|
|
9163
10137
|
return [
|
|
9164
10138
|
2
|
|
9165
10139
|
];
|
|
9166
10140
|
}
|
|
9167
|
-
if (this.debug)
|
|
9168
|
-
|
|
10141
|
+
if (this.debug) console.error("[AD-ERROR] Ad request failed:", error === null || error === void 0 ? void 0 : error.message);
|
|
10142
|
+
this.recordRequestFailure(error, vastTagUrl);
|
|
10143
|
+
if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
|
|
10144
|
+
this.recreateAdController("discarded_budget");
|
|
9169
10145
|
}
|
|
9170
|
-
|
|
9171
|
-
this.host.getAdPlayer().showPlaceholder();
|
|
9172
|
-
checkInterval = 300;
|
|
9173
|
-
maxChecks = Math.floor(waitTime / checkInterval);
|
|
9174
|
-
i = 0;
|
|
9175
|
-
_state.label = 1;
|
|
9176
|
-
case 1:
|
|
9177
|
-
if (!(i < maxChecks)) return [
|
|
9178
|
-
3,
|
|
9179
|
-
12
|
|
9180
|
-
];
|
|
9181
|
-
return [
|
|
9182
|
-
4,
|
|
9183
|
-
new Promise(function(resolve) {
|
|
9184
|
-
return setTimeout(resolve, checkInterval);
|
|
9185
|
-
})
|
|
9186
|
-
];
|
|
9187
|
-
case 2:
|
|
9188
|
-
_state.sent();
|
|
9189
|
-
if (!this.inAdBreak) return [
|
|
9190
|
-
2
|
|
9191
|
-
];
|
|
9192
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9193
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Too many failures during placeholder wait");
|
|
9194
|
-
return [
|
|
9195
|
-
3,
|
|
9196
|
-
12
|
|
9197
|
-
];
|
|
9198
|
-
}
|
|
9199
|
-
if (!this.timing.hasTimeToStartAnotherAd()) {
|
|
9200
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Not enough time remaining during placeholder wait, ending ad break");
|
|
9201
|
-
return [
|
|
9202
|
-
3,
|
|
9203
|
-
12
|
|
9204
|
-
];
|
|
9205
|
-
}
|
|
9206
|
-
_state.label = 3;
|
|
9207
|
-
case 3:
|
|
9208
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
9209
|
-
3,
|
|
9210
|
-
11
|
|
9211
|
-
];
|
|
9212
|
-
if (!this.timing.hasTimeToStartAnotherAd()) return [
|
|
9213
|
-
3,
|
|
9214
|
-
11
|
|
9215
|
-
];
|
|
9216
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
9217
|
-
if (!nextAdUrl) return [
|
|
9218
|
-
3,
|
|
9219
|
-
3
|
|
9220
|
-
];
|
|
9221
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) return [
|
|
9222
|
-
3,
|
|
9223
|
-
3
|
|
9224
|
-
];
|
|
9225
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) return [
|
|
9226
|
-
3,
|
|
9227
|
-
3
|
|
9228
|
-
];
|
|
9229
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad URL available, requesting via HLS ad player");
|
|
9230
|
-
this.isShowingPlaceholder = false;
|
|
9231
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
9232
|
-
_state.label = 4;
|
|
9233
|
-
case 4:
|
|
9234
|
-
_state.trys.push([
|
|
9235
|
-
4,
|
|
9236
|
-
6,
|
|
9237
|
-
,
|
|
9238
|
-
10
|
|
9239
|
-
]);
|
|
9240
|
-
return [
|
|
9241
|
-
4,
|
|
9242
|
-
this.playSingleAd(nextAdUrl)
|
|
9243
|
-
];
|
|
9244
|
-
case 5:
|
|
9245
|
-
_state.sent();
|
|
9246
|
-
this.timing.consecutiveFailures = 0;
|
|
9247
|
-
return [
|
|
9248
|
-
3,
|
|
9249
|
-
10
|
|
9250
|
-
];
|
|
10146
|
+
throw error;
|
|
9251
10147
|
case 6:
|
|
9252
|
-
error = _state.sent();
|
|
9253
|
-
errorMessage = error.message;
|
|
9254
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
9255
|
-
3,
|
|
9256
|
-
8
|
|
9257
|
-
];
|
|
9258
|
-
return [
|
|
9259
|
-
4,
|
|
9260
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9261
|
-
];
|
|
9262
|
-
case 7:
|
|
9263
|
-
_state.sent();
|
|
9264
|
-
return [
|
|
9265
|
-
2
|
|
9266
|
-
];
|
|
9267
|
-
case 8:
|
|
9268
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
9269
|
-
this.timing.consecutiveFailures++;
|
|
9270
|
-
}
|
|
9271
|
-
return [
|
|
9272
|
-
4,
|
|
9273
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9274
|
-
];
|
|
9275
|
-
case 9:
|
|
9276
|
-
_state.sent();
|
|
9277
|
-
return [
|
|
9278
|
-
3,
|
|
9279
|
-
10
|
|
9280
|
-
];
|
|
9281
|
-
case 10:
|
|
9282
|
-
return [
|
|
9283
|
-
2
|
|
9284
|
-
];
|
|
9285
|
-
case 11:
|
|
9286
|
-
i++;
|
|
9287
|
-
return [
|
|
9288
|
-
3,
|
|
9289
|
-
1
|
|
9290
|
-
];
|
|
9291
|
-
case 12:
|
|
9292
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Placeholder timeout, ending ad break");
|
|
9293
|
-
this.isShowingPlaceholder = false;
|
|
9294
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
9295
|
-
this.handleAdPodComplete();
|
|
9296
10148
|
return [
|
|
9297
10149
|
2
|
|
9298
10150
|
];
|
|
@@ -9305,26 +10157,136 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9305
10157
|
// ───────────────────────────────────────────────────────────────
|
|
9306
10158
|
// Ad break completion
|
|
9307
10159
|
// ───────────────────────────────────────────────────────────────
|
|
10160
|
+
key: "logBreakFunnel",
|
|
10161
|
+
value: function logBreakFunnel(endReason) {
|
|
10162
|
+
var funnel = this.breakFunnel;
|
|
10163
|
+
this.breakFunnel = {};
|
|
10164
|
+
if (Object.keys(funnel).length === 0) return;
|
|
10165
|
+
var count = function count(stage) {
|
|
10166
|
+
var _funnel_stage;
|
|
10167
|
+
return (_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0;
|
|
10168
|
+
};
|
|
10169
|
+
var countPrefix = function countPrefix(prefix) {
|
|
10170
|
+
return Object.keys(funnel).reduce(function(total, stage) {
|
|
10171
|
+
var _funnel_stage;
|
|
10172
|
+
return stage.indexOf(prefix) === 0 ? total + ((_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0) : total;
|
|
10173
|
+
}, 0);
|
|
10174
|
+
};
|
|
10175
|
+
var breakId = this.opportunityEpoch;
|
|
10176
|
+
var requestRetries = count("gam_http_request_retry");
|
|
10177
|
+
var requests = count("gam_http_request_sent") - requestRetries;
|
|
10178
|
+
if (requests > 0 && count("impression_fired") === 0) {
|
|
10179
|
+
console.log("[AdBreak][FUNNEL] break_abandoned_before_start", {
|
|
10180
|
+
breakId: breakId,
|
|
10181
|
+
requests: requests,
|
|
10182
|
+
endReason: endReason
|
|
10183
|
+
});
|
|
10184
|
+
}
|
|
10185
|
+
console.log("[AdBreak][FUNNEL] Break summary", {
|
|
10186
|
+
breakId: breakId,
|
|
10187
|
+
endReason: endReason,
|
|
10188
|
+
opportunities: count("opportunity_created"),
|
|
10189
|
+
vastUrlsGenerated: count("vast_url_generated"),
|
|
10190
|
+
requests: requests,
|
|
10191
|
+
requestRetries: requestRetries,
|
|
10192
|
+
gamResponses: count("gam_response_received"),
|
|
10193
|
+
requestsSuppressed: count("request_suppressed"),
|
|
10194
|
+
duplicates: count("duplicate_request_detected") + count("duplicate_break_start"),
|
|
10195
|
+
filled: count("vast_received"),
|
|
10196
|
+
noFill: count("no_fill"),
|
|
10197
|
+
fillRejected: count("vast_fill_rejected"),
|
|
10198
|
+
gamAdWithoutImpression: count("gam_ad_without_impression"),
|
|
10199
|
+
playbackFailedAfterFill: count("request_outcome:playback_failed"),
|
|
10200
|
+
requestFailed: count("request_failed"),
|
|
10201
|
+
requestAbortedTimeout: count("request_aborted_timeout"),
|
|
10202
|
+
credentialsRetries: count("vast_credentials_retry"),
|
|
10203
|
+
wrapperFailures: count("wrapper_fetch:failure"),
|
|
10204
|
+
noSupportedMedia: count("vast_no_supported_media"),
|
|
10205
|
+
vpaidOnly: count("vast_no_supported_media:vpaid"),
|
|
10206
|
+
audioOnly: count("vast_no_supported_media:audio_only"),
|
|
10207
|
+
mediaFilesEvaluated: count("mediafile_evaluated"),
|
|
10208
|
+
mediaFilesAccepted: count("mediafile_evaluated:accepted"),
|
|
10209
|
+
controllerDestroys: countPrefix("controller_destroy:"),
|
|
10210
|
+
staleCallbacks: count("stale_callback_ignored") + count("stale_request_result_ignored"),
|
|
10211
|
+
tagAllowsAudio: count("tag_allows_audio"),
|
|
10212
|
+
missingImpression: count("vast_missing_impression"),
|
|
10213
|
+
discardedBudget: count("discarded_budget"),
|
|
10214
|
+
mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
|
|
10215
|
+
mediaRejected: count("media_candidate:rejected"),
|
|
10216
|
+
mediaFallbacks: count("media_fallback"),
|
|
10217
|
+
playCalled: count("play_called"),
|
|
10218
|
+
playRejected: count("play_rejected"),
|
|
10219
|
+
mutedRetry: count("muted_retry"),
|
|
10220
|
+
startTimeouts: count("play_resolved_but_never_started"),
|
|
10221
|
+
impressions: count("impression_fired"),
|
|
10222
|
+
impressionUrls: count("impression_urls"),
|
|
10223
|
+
trackingRequests: count("tracking_request_created"),
|
|
10224
|
+
trackingNotLoaded: count("tracking_request_settled:error") + count("tracking_request_settled:timeout"),
|
|
10225
|
+
trackingUnexpandedMacros: count("tracking_url_unexpanded_macro"),
|
|
10226
|
+
trackingInvalidUrls: count("tracking_url_invalid"),
|
|
10227
|
+
vastAdFallbacks: count("vast_ad_fallback"),
|
|
10228
|
+
mediaEvents: count("media_event"),
|
|
10229
|
+
quartile25: count("first_quartile"),
|
|
10230
|
+
quartile50: count("midpoint"),
|
|
10231
|
+
quartile75: count("third_quartile"),
|
|
10232
|
+
complete: count("complete"),
|
|
10233
|
+
stoppedBeforeStart: count("stopped_before_start"),
|
|
10234
|
+
stoppedBeforeStartByBreakEnd: count("ad_stopped_before_start"),
|
|
10235
|
+
unexpectedUnmutes: count("unexpected_unmute"),
|
|
10236
|
+
unmuteBlocked: count("unmute_blocked_without_gesture"),
|
|
10237
|
+
visibilityHidden: count("while_hidden"),
|
|
10238
|
+
playbackFailures: count("play_failed") + count("media_error") + count("hls_fatal") + count("stall") + count("decode_failure") + count("media_unsupported"),
|
|
10239
|
+
stages: funnel
|
|
10240
|
+
});
|
|
10241
|
+
}
|
|
10242
|
+
},
|
|
10243
|
+
{
|
|
9308
10244
|
key: "handleAdPodComplete",
|
|
9309
10245
|
value: function handleAdPodComplete() {
|
|
10246
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "unspecified";
|
|
9310
10247
|
if (this.debug) {
|
|
9311
|
-
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up"
|
|
10248
|
+
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up", {
|
|
10249
|
+
reason: reason
|
|
10250
|
+
});
|
|
9312
10251
|
}
|
|
10252
|
+
var previousState = this.slotState;
|
|
10253
|
+
var alreadyEnded = previousState === "IDLE" && !this.inAdBreak;
|
|
10254
|
+
this.setSlotState("ENDING", reason);
|
|
10255
|
+
this.cancelScheduledRequest();
|
|
10256
|
+
var adPlayer = this.host.getAdPlayer();
|
|
10257
|
+
if (previousState === "REQUESTING") {
|
|
10258
|
+
var _adPlayer_abortPendingRequest;
|
|
10259
|
+
(_adPlayer_abortPendingRequest = adPlayer.abortPendingRequest) === null || _adPlayer_abortPendingRequest === void 0 ? void 0 : _adPlayer_abortPendingRequest.call(adPlayer, "VAST request aborted: ad break ended (".concat(reason, ")"));
|
|
10260
|
+
}
|
|
10261
|
+
if (!alreadyEnded) {
|
|
10262
|
+
console.log("[AD-CONTROLLER] stop", {
|
|
10263
|
+
controllerId: this.controllerGeneration,
|
|
10264
|
+
requestId: this.currentRequestId,
|
|
10265
|
+
state: previousState,
|
|
10266
|
+
reason: reason
|
|
10267
|
+
});
|
|
10268
|
+
}
|
|
10269
|
+
this.finalizeRequestDiagnostics(this.currentRequestId, "break_ended:".concat(reason));
|
|
10270
|
+
this.currentRequestId = void 0;
|
|
9313
10271
|
this.timing.resetForBreakEnd();
|
|
9314
|
-
this.
|
|
10272
|
+
this.placeholder.hide();
|
|
9315
10273
|
this.clearPendingAdBreak();
|
|
9316
10274
|
if (this.isShowingPlaceholder) {
|
|
9317
|
-
|
|
10275
|
+
adPlayer.hidePlaceholder();
|
|
9318
10276
|
this.isShowingPlaceholder = false;
|
|
9319
10277
|
}
|
|
9320
|
-
this.adRequestQueue = [];
|
|
9321
10278
|
this.inAdBreak = false;
|
|
9322
10279
|
this.adDetectSentForCurrentBreak = false;
|
|
9323
10280
|
this.cueManager.activeScte35BreakKey = void 0;
|
|
9324
10281
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
9325
10282
|
this.adPodQueue = [];
|
|
9326
10283
|
this.showAds = false;
|
|
9327
|
-
this.
|
|
10284
|
+
this.breakSource = void 0;
|
|
10285
|
+
this.followUpBaseVastUrl = void 0;
|
|
10286
|
+
this.unusableResponsesInBreak = 0;
|
|
10287
|
+
adPlayer.stop().catch(function() {});
|
|
10288
|
+
if (!alreadyEnded) this.logBreakFunnel(reason);
|
|
10289
|
+
this.setSlotState("IDLE", "break_complete");
|
|
9328
10290
|
var restoredMuted = this.host.getAdPlayer().getOriginalMutedState();
|
|
9329
10291
|
var restoredVolume = this.host.getAdPlayer().getOriginalVolume();
|
|
9330
10292
|
if (this.host.video.muted !== restoredMuted) {
|
|
@@ -9618,25 +10580,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9618
10580
|
{
|
|
9619
10581
|
key: "handleAdFailure",
|
|
9620
10582
|
value: function handleAdFailure() {
|
|
9621
|
-
|
|
9622
|
-
this.
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
}
|
|
9628
|
-
}
|
|
9629
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9630
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Max consecutive failures reached (".concat(this.timing.consecutiveFailures, "), ending ad break gracefully"));
|
|
9631
|
-
this.handleAdPodComplete();
|
|
10583
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "ad_failure";
|
|
10584
|
+
if (!this.inAdBreak) return;
|
|
10585
|
+
if (this.slotState === "REQUESTING" || this.slotState === "ENDING") {
|
|
10586
|
+
this.logOrchestratorFunnel("failure_deferred_to_request", {
|
|
10587
|
+
reason: reason,
|
|
10588
|
+
state: this.slotState
|
|
10589
|
+
});
|
|
9632
10590
|
return;
|
|
9633
10591
|
}
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
this.
|
|
10592
|
+
this.timing.consecutiveFailures++;
|
|
10593
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
10594
|
+
if (diag && !diag.failureReason) diag.failureReason = reason;
|
|
10595
|
+
if (this.debug) {
|
|
10596
|
+
console.log("[AdBreak] Ad failure (".concat(reason, "): remaining=").concat(this.timing.getRemainingAdMs(), "ms, consecutiveFailures=").concat(this.timing.consecutiveFailures));
|
|
9639
10597
|
}
|
|
10598
|
+
this.setSlotState("NEEDS_NEXT_AD", reason);
|
|
10599
|
+
this.requestNextAd(reason);
|
|
9640
10600
|
}
|
|
9641
10601
|
}
|
|
9642
10602
|
]);
|
|
@@ -9676,10 +10636,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9676
10636
|
_this.startScte35AdBreak(marker, cueKey, marker.durationSeconds != null ? marker.durationSeconds * 1e3 : _this.timing.expectedAdBreakDurationMs);
|
|
9677
10637
|
},
|
|
9678
10638
|
onWatchdogTimeout: function onWatchdogTimeout() {
|
|
9679
|
-
return _this.adBreak.
|
|
10639
|
+
return _this.adBreak.handleRequestWatchdogTimeout();
|
|
9680
10640
|
},
|
|
9681
10641
|
onFailsafeTimeout: function onFailsafeTimeout() {
|
|
9682
|
-
return _this.adBreak.handleAdFailure();
|
|
10642
|
+
return _this.adBreak.handleAdFailure("failsafe_timeout");
|
|
9683
10643
|
},
|
|
9684
10644
|
getAdState: function getAdState() {
|
|
9685
10645
|
return {
|
|
@@ -9781,6 +10741,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9781
10741
|
licenseKey: this.config.licenseKey
|
|
9782
10742
|
} : {}, ((_this_hlsEngine = this.hlsEngine) === null || _this_hlsEngine === void 0 ? void 0 : _this_hlsEngine.hls) ? {
|
|
9783
10743
|
mainHlsInstance: this.hlsEngine.hls
|
|
10744
|
+
} : {}, this.config.adMediaStartTimeoutMs != null ? {
|
|
10745
|
+
mediaStartTimeoutMs: this.config.adMediaStartTimeoutMs
|
|
9784
10746
|
} : {}));
|
|
9785
10747
|
}
|
|
9786
10748
|
},
|
|
@@ -9927,6 +10889,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9927
10889
|
adBehavior: adBehavior
|
|
9928
10890
|
});
|
|
9929
10891
|
}
|
|
10892
|
+
if (this.adBreak.isBreakActive()) {
|
|
10893
|
+
console.log("[AD-CONTROLLER] destroy skipped", {
|
|
10894
|
+
reason: "manifest_parsed_during_break",
|
|
10895
|
+
state: this.adBreak.getSlotState()
|
|
10896
|
+
});
|
|
10897
|
+
return [
|
|
10898
|
+
2
|
|
10899
|
+
];
|
|
10900
|
+
}
|
|
10901
|
+
if (this.debug) {
|
|
10902
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
10903
|
+
reason: "manifest_parsed",
|
|
10904
|
+
state: "IDLE"
|
|
10905
|
+
});
|
|
10906
|
+
}
|
|
9930
10907
|
this.adPlayer.destroy();
|
|
9931
10908
|
this.adPlayer = this.createAdPlayer(this.shouldContinueLiveStreamDuringAds());
|
|
9932
10909
|
this.adPlayer.initialize();
|
|
@@ -10108,9 +11085,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10108
11085
|
this.timing.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
10109
11086
|
}
|
|
10110
11087
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
10111
|
-
if (!this.adPlayer.isAdPlaying() && this.timing.activeAdRequestToken === null && this.adBreak.adRequestQueue.length > 0 && this.timing.hasTimeToStartAnotherAd()) {
|
|
10112
|
-
this.adBreak.tryNextAvailableAdWithRateLimit();
|
|
10113
|
-
}
|
|
10114
11088
|
return;
|
|
10115
11089
|
}
|
|
10116
11090
|
if (marker.type === "end") {
|
|
@@ -10122,12 +11096,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10122
11096
|
}
|
|
10123
11097
|
var remaining = this.timing.getRemainingAdMs();
|
|
10124
11098
|
var adPlaying = this.adPlayer.isAdPlaying();
|
|
10125
|
-
var hasQueuedAds = this.adBreak.adRequestQueue.length > 0;
|
|
10126
11099
|
if (this.debug) {
|
|
10127
11100
|
console.log("[StormcloudVideoPlayer] SCTE-35 end marker received:", {
|
|
10128
11101
|
remaining: remaining,
|
|
10129
11102
|
adPlaying: adPlaying,
|
|
10130
|
-
|
|
11103
|
+
adSlotState: this.adBreak.getSlotState(),
|
|
10131
11104
|
activeAdRequest: this.timing.activeAdRequestToken !== null
|
|
10132
11105
|
});
|
|
10133
11106
|
}
|
|
@@ -10135,9 +11108,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10135
11108
|
this.timing.clearAdStartTimer();
|
|
10136
11109
|
this.timing.clearAdStopTimer();
|
|
10137
11110
|
if (adPlaying) {
|
|
11111
|
+
this.adBreak.noteStopBeforeStart("scte_end");
|
|
10138
11112
|
this.adPlayer.stop().catch(function() {});
|
|
10139
11113
|
}
|
|
10140
|
-
this.adBreak.handleAdPodComplete();
|
|
11114
|
+
this.adBreak.handleAdPodComplete("scte_end");
|
|
10141
11115
|
return;
|
|
10142
11116
|
}
|
|
10143
11117
|
}
|
|
@@ -10145,6 +11119,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10145
11119
|
{
|
|
10146
11120
|
key: "startScte35AdBreak",
|
|
10147
11121
|
value: function startScte35AdBreak(marker, cueKey, durationMs) {
|
|
11122
|
+
if (this.adBreak.isBreakActive()) {
|
|
11123
|
+
if (this.debug) {
|
|
11124
|
+
console.log("[StormcloudVideoPlayer] Ignoring SCTE-35 break start: a break is already active", {
|
|
11125
|
+
state: this.adBreak.getSlotState(),
|
|
11126
|
+
cueKey: cueKey
|
|
11127
|
+
});
|
|
11128
|
+
}
|
|
11129
|
+
return;
|
|
11130
|
+
}
|
|
10148
11131
|
this.adBreak.inAdBreak = true;
|
|
10149
11132
|
this.cueManager.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.cueManager.pendingScte35CueKey;
|
|
10150
11133
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
@@ -10174,9 +11157,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10174
11157
|
console.log("[StormcloudVideoPlayer] Ad break boundary reached (overrun=".concat(overrunMs, "ms) - hard-stopping ads and resuming stream"));
|
|
10175
11158
|
}
|
|
10176
11159
|
if (adPlaying) {
|
|
11160
|
+
this.adBreak.noteStopBeforeStart("break_boundary");
|
|
10177
11161
|
this.adPlayer.stop().catch(function() {});
|
|
10178
11162
|
}
|
|
10179
|
-
this.adBreak.handleAdPodComplete();
|
|
11163
|
+
this.adBreak.handleAdPodComplete("break_boundary");
|
|
10180
11164
|
}
|
|
10181
11165
|
},
|
|
10182
11166
|
{
|
|
@@ -10186,14 +11170,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10186
11170
|
key: "startAdPrefetch",
|
|
10187
11171
|
value: function startAdPrefetch(marker, fragmentSn, cueKey) {
|
|
10188
11172
|
if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
|
|
10189
|
-
var
|
|
10190
|
-
|
|
10191
|
-
var baseVastUrl;
|
|
10192
|
-
if (tags && tags.length > 0 && tags[0]) {
|
|
10193
|
-
baseVastUrl = tags[0];
|
|
10194
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
10195
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
10196
|
-
} else {
|
|
11173
|
+
var baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
11174
|
+
if (!baseVastUrl) {
|
|
10197
11175
|
if (this.debug) console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
|
|
10198
11176
|
return;
|
|
10199
11177
|
}
|
|
@@ -10223,8 +11201,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10223
11201
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
10224
11202
|
}, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
|
|
10225
11203
|
if (this.debug) {
|
|
10226
|
-
console.log("[PREFETCH]
|
|
10227
|
-
console.log("[PREFETCH] Pre-generated pod request URL");
|
|
11204
|
+
console.log("[PREFETCH] Pre-generated pod request URL for upcoming ad break");
|
|
10228
11205
|
}
|
|
10229
11206
|
}
|
|
10230
11207
|
},
|
|
@@ -10235,7 +11212,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10235
11212
|
key: "onTimeUpdate",
|
|
10236
11213
|
value: function onTimeUpdate(currentTimeSec) {
|
|
10237
11214
|
var _this = this;
|
|
10238
|
-
if (
|
|
11215
|
+
if (this.adConfig.vmapBreaks.length === 0) return;
|
|
10239
11216
|
if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
|
|
10240
11217
|
var nowMs = currentTimeSec * 1e3;
|
|
10241
11218
|
var breakToPlay = this.adConfig.findBreakForTime(nowMs);
|
|
@@ -10252,7 +11229,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10252
11229
|
key: "onVideoEnded",
|
|
10253
11230
|
value: function onVideoEnded() {
|
|
10254
11231
|
var _this = this;
|
|
10255
|
-
if (
|
|
11232
|
+
if (this.adConfig.vmapBreaks.length === 0) return;
|
|
10256
11233
|
if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
|
|
10257
11234
|
var durationMs = Number.isFinite(this.video.duration) ? Math.floor(this.video.duration * 1e3) : 0;
|
|
10258
11235
|
var postroll = this.adConfig.vmapBreaks.find(function(b) {
|
|
@@ -10302,6 +11279,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10302
11279
|
this.adBreak.showAds = true;
|
|
10303
11280
|
this.adBreak.inAdBreak = true;
|
|
10304
11281
|
this.timing.currentAdBreakStartWallClockMs = Date.now();
|
|
11282
|
+
if (durationMs > 0) {
|
|
11283
|
+
this.timing.setAdBreakDurationBoundary(durationMs);
|
|
11284
|
+
}
|
|
11285
|
+
this.adBreak.beginVmapBreak(key);
|
|
10305
11286
|
_state.label = 1;
|
|
10306
11287
|
case 1:
|
|
10307
11288
|
_state.trys.push([
|
|
@@ -10312,7 +11293,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10312
11293
|
]);
|
|
10313
11294
|
return [
|
|
10314
11295
|
4,
|
|
10315
|
-
this.adBreak.playSingleAd(first)
|
|
11296
|
+
this.adBreak.playSingleAd(first, "vmap")
|
|
10316
11297
|
];
|
|
10317
11298
|
case 2:
|
|
10318
11299
|
_state.sent();
|
|
@@ -10325,7 +11306,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10325
11306
|
if (this.debug) {
|
|
10326
11307
|
console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
|
|
10327
11308
|
}
|
|
10328
|
-
this.adBreak.
|
|
11309
|
+
this.adBreak.continueAfterRequestFailure();
|
|
10329
11310
|
return [
|
|
10330
11311
|
3,
|
|
10331
11312
|
4
|
|
@@ -10467,7 +11448,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10467
11448
|
key: "destroy",
|
|
10468
11449
|
value: function destroy() {
|
|
10469
11450
|
var _this_adPlayer;
|
|
10470
|
-
this.adBreak.
|
|
11451
|
+
this.adBreak.cancelScheduledRequest();
|
|
10471
11452
|
this.timing.destroy();
|
|
10472
11453
|
this.adBreak.clearPendingAdBreak();
|
|
10473
11454
|
this.placeholder.destroy();
|
|
@@ -10491,7 +11472,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10491
11472
|
this.palNonce.sendPlaybackEnd();
|
|
10492
11473
|
}
|
|
10493
11474
|
this.palNonce.reset();
|
|
10494
|
-
this.adBreak.adRequestQueue = [];
|
|
10495
11475
|
this.timing.consecutiveFailures = 0;
|
|
10496
11476
|
}
|
|
10497
11477
|
}
|