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/index.js
CHANGED
|
@@ -329,26 +329,6 @@ function _ts_generator(thisArg, body) {
|
|
|
329
329
|
};
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
-
function _ts_values(o) {
|
|
333
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
334
|
-
if (m) {
|
|
335
|
-
return m.call(o);
|
|
336
|
-
}
|
|
337
|
-
if (o && typeof o.length === "number") {
|
|
338
|
-
return {
|
|
339
|
-
next: function() {
|
|
340
|
-
if (o && i >= o.length) {
|
|
341
|
-
o = void 0;
|
|
342
|
-
}
|
|
343
|
-
return {
|
|
344
|
-
value: o && o[i++],
|
|
345
|
-
done: !o
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
351
|
-
}
|
|
352
332
|
function _type_of(obj) {
|
|
353
333
|
"@swc/helpers - typeof";
|
|
354
334
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
@@ -764,7 +744,7 @@ function toVastMediaErrorCode(error) {
|
|
|
764
744
|
}
|
|
765
745
|
}
|
|
766
746
|
function createHlsAdPlayer(contentVideo, options) {
|
|
767
|
-
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
|
|
747
|
+
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP, _ref;
|
|
768
748
|
var adPlaying = false;
|
|
769
749
|
var originalMutedState = false;
|
|
770
750
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
@@ -796,6 +776,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
796
776
|
var sawDecodedVideoFrame = false;
|
|
797
777
|
var videoFrameCallbackHandle;
|
|
798
778
|
var pendingPlayPromise;
|
|
779
|
+
var currentVastTagUrl;
|
|
780
|
+
var funnelContext = {};
|
|
781
|
+
var mediaProbe;
|
|
782
|
+
var lastPodAdElementCount = 0;
|
|
783
|
+
var mediaCandidates = [];
|
|
784
|
+
var mediaCandidateIndex = 0;
|
|
785
|
+
var mediaStartTimerId;
|
|
786
|
+
var MEDIA_START_TIMEOUT_MS = (_ref = options === null || options === void 0 ? void 0 : options.mediaStartTimeoutMs) !== null && _ref !== void 0 ? _ref : 8e3;
|
|
787
|
+
var VAST_ERROR_MEDIA_TIMEOUT = 402;
|
|
788
|
+
var pendingVastRequests = /* @__PURE__ */ new Set();
|
|
789
|
+
var pendingRequestAbortReason;
|
|
790
|
+
var forcedMuteByAutoplay = false;
|
|
799
791
|
function createTrackingState() {
|
|
800
792
|
return {
|
|
801
793
|
impression: false,
|
|
@@ -846,6 +838,78 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
846
838
|
}
|
|
847
839
|
}
|
|
848
840
|
}
|
|
841
|
+
var SENSITIVE_URL_PARAMS = /* @__PURE__ */ new Set([
|
|
842
|
+
"ppid",
|
|
843
|
+
"rdid",
|
|
844
|
+
"idtype",
|
|
845
|
+
"is_lat",
|
|
846
|
+
"ifa",
|
|
847
|
+
"idfa",
|
|
848
|
+
"aaid",
|
|
849
|
+
"uid",
|
|
850
|
+
"user_id",
|
|
851
|
+
"userid",
|
|
852
|
+
"device_id",
|
|
853
|
+
"deviceid",
|
|
854
|
+
"ip",
|
|
855
|
+
"ua",
|
|
856
|
+
"gdpr_consent",
|
|
857
|
+
"us_privacy",
|
|
858
|
+
"gpp",
|
|
859
|
+
"addtl_consent",
|
|
860
|
+
"cust_params",
|
|
861
|
+
"email"
|
|
862
|
+
]);
|
|
863
|
+
function redactUrl(url) {
|
|
864
|
+
if (!url) return url;
|
|
865
|
+
try {
|
|
866
|
+
var parsed = new URL(url);
|
|
867
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
868
|
+
try {
|
|
869
|
+
for(var _iterator = Array.from(parsed.searchParams.keys())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
870
|
+
var key = _step.value;
|
|
871
|
+
if (SENSITIVE_URL_PARAMS.has(key.toLowerCase())) {
|
|
872
|
+
parsed.searchParams.set(key, "REDACTED");
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
} catch (err) {
|
|
876
|
+
_didIteratorError = true;
|
|
877
|
+
_iteratorError = err;
|
|
878
|
+
} finally{
|
|
879
|
+
try {
|
|
880
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
881
|
+
_iterator.return();
|
|
882
|
+
}
|
|
883
|
+
} finally{
|
|
884
|
+
if (_didIteratorError) {
|
|
885
|
+
throw _iteratorError;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return parsed.toString();
|
|
890
|
+
} catch (unused) {
|
|
891
|
+
return url.split("?")[0];
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
function logFunnel(stage) {
|
|
895
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
896
|
+
var payload = _object_spread({
|
|
897
|
+
stage: stage,
|
|
898
|
+
breakId: funnelContext.breakId,
|
|
899
|
+
requestId: funnelContext.requestId,
|
|
900
|
+
controllerId: funnelContext.controllerId,
|
|
901
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0,
|
|
902
|
+
adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
|
|
903
|
+
podIndex: podIndex,
|
|
904
|
+
podSize: podAds.length,
|
|
905
|
+
vastUrl: redactUrl(currentVastTagUrl),
|
|
906
|
+
mediaUrl: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url,
|
|
907
|
+
mediaType: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.type,
|
|
908
|
+
muted: adVideoElement ? adVideoElement.muted : void 0
|
|
909
|
+
}, extra);
|
|
910
|
+
console.log("[HlsAdPlayer][FUNNEL] ".concat(stage), payload);
|
|
911
|
+
emit("ad_funnel", payload);
|
|
912
|
+
}
|
|
849
913
|
function buildTrackingMacroContext() {
|
|
850
914
|
var options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
851
915
|
var _options2_ad;
|
|
@@ -885,20 +949,53 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
885
949
|
urls.forEach(function(url) {
|
|
886
950
|
try {
|
|
887
951
|
var trackingUrl = substituteVastTrackingMacros(url, macroContext);
|
|
952
|
+
var trackingHost;
|
|
953
|
+
try {
|
|
954
|
+
trackingHost = new URL(trackingUrl).host;
|
|
955
|
+
} catch (unused) {
|
|
956
|
+
logFunnel("tracking_url_invalid", {
|
|
957
|
+
trackingUrl: redactUrl(trackingUrl)
|
|
958
|
+
});
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
var unexpanded = trackingUrl.match(/\[[A-Z_]+\]/g);
|
|
962
|
+
if (unexpanded) {
|
|
963
|
+
logFunnel("tracking_url_unexpanded_macro", {
|
|
964
|
+
trackingHost: trackingHost,
|
|
965
|
+
macros: Array.from(new Set(unexpanded))
|
|
966
|
+
});
|
|
967
|
+
}
|
|
888
968
|
var img = new Image(1, 1);
|
|
889
969
|
inFlightBeacons.add(img);
|
|
890
970
|
var timeoutId;
|
|
891
|
-
var release = function release() {
|
|
971
|
+
var release = function release(outcome) {
|
|
892
972
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
893
973
|
img.onload = null;
|
|
894
974
|
img.onerror = null;
|
|
895
975
|
inFlightBeacons.delete(img);
|
|
976
|
+
console.log("[HlsAdPlayer] Tracking pixel settled (".concat(outcome, "): ").concat(trackingUrl));
|
|
977
|
+
if (outcome !== "load") {
|
|
978
|
+
logFunnel("tracking_request_settled", {
|
|
979
|
+
reason: outcome,
|
|
980
|
+
trackingHost: trackingHost
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
img.onload = function() {
|
|
985
|
+
return release("load");
|
|
896
986
|
};
|
|
897
|
-
img.
|
|
898
|
-
|
|
899
|
-
|
|
987
|
+
img.onerror = function() {
|
|
988
|
+
return release("error");
|
|
989
|
+
};
|
|
990
|
+
timeoutId = setTimeout(function() {
|
|
991
|
+
return release("timeout");
|
|
992
|
+
}, BEACON_TIMEOUT_MS);
|
|
900
993
|
img.src = trackingUrl;
|
|
901
994
|
console.log("[HlsAdPlayer] Fired tracking pixel: ".concat(trackingUrl));
|
|
995
|
+
logFunnel("tracking_request_created", {
|
|
996
|
+
trackingHost: trackingHost,
|
|
997
|
+
errorCode: options2 === null || options2 === void 0 ? void 0 : options2.errorCode
|
|
998
|
+
});
|
|
902
999
|
} catch (error) {
|
|
903
1000
|
console.warn("[HlsAdPlayer] Error firing tracking pixel:", error);
|
|
904
1001
|
}
|
|
@@ -928,54 +1025,79 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
928
1025
|
bitrate: level.bitrate || 5e6
|
|
929
1026
|
};
|
|
930
1027
|
}
|
|
931
|
-
function
|
|
932
|
-
if (mediaFiles.length === 0) {
|
|
933
|
-
throw new Error("No media files available");
|
|
934
|
-
}
|
|
935
|
-
var firstFile = mediaFiles[0];
|
|
936
|
-
if (!firstFile) {
|
|
937
|
-
throw new Error("No media files available");
|
|
938
|
-
}
|
|
939
|
-
if (mediaFiles.length === 1) {
|
|
940
|
-
return firstFile;
|
|
941
|
-
}
|
|
1028
|
+
function getMediaTargetQuality() {
|
|
942
1029
|
var mainQuality = getMainStreamQuality();
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1030
|
+
var dpr = typeof window !== "undefined" && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1;
|
|
1031
|
+
var containerWidth = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientWidth) || contentVideo.clientWidth) * dpr;
|
|
1032
|
+
var containerHeight = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientHeight) || contentVideo.clientHeight) * dpr;
|
|
1033
|
+
if (!mainQuality && !(containerWidth > 0 && containerHeight > 0)) {
|
|
1034
|
+
return null;
|
|
1035
|
+
}
|
|
1036
|
+
var base = mainQuality !== null && mainQuality !== void 0 ? mainQuality : {
|
|
1037
|
+
width: containerWidth,
|
|
1038
|
+
height: containerHeight,
|
|
1039
|
+
bitrate: 5e6
|
|
1040
|
+
};
|
|
1041
|
+
var width = containerWidth > 0 ? Math.min(base.width, containerWidth) : base.width;
|
|
1042
|
+
var height = containerHeight > 0 ? Math.min(base.height, containerHeight) : base.height;
|
|
1043
|
+
return {
|
|
1044
|
+
width: width,
|
|
1045
|
+
height: height,
|
|
1046
|
+
bitrate: base.bitrate
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
function rankMediaCandidates(mediaFiles) {
|
|
1050
|
+
var probe = adVideoElement !== null && adVideoElement !== void 0 ? adVideoElement : document.createElement("video");
|
|
1051
|
+
var pageIsHttps = typeof location !== "undefined" && location.protocol === "https:";
|
|
1052
|
+
var target = getMediaTargetQuality();
|
|
1053
|
+
var accepted = [];
|
|
1054
|
+
mediaFiles.forEach(function(file, index) {
|
|
1055
|
+
var isHls = isHlsMediaFile(file);
|
|
1056
|
+
var mimeForProbe = isHls ? "application/vnd.apple.mpegurl" : file.type || "video/mp4";
|
|
1057
|
+
var canPlay2 = probe.canPlayType(mimeForProbe);
|
|
1058
|
+
var playable = isHls ? Hls.isSupported() || canPlay2 !== "" : canPlay2 !== "";
|
|
1059
|
+
var insecure = pageIsHttps && /^http:/i.test(file.url);
|
|
1060
|
+
var details = {
|
|
1061
|
+
index: index,
|
|
1062
|
+
candidateUrl: file.url,
|
|
1063
|
+
candidateType: file.type,
|
|
1064
|
+
width: file.width,
|
|
1065
|
+
height: file.height,
|
|
1066
|
+
bitrate: file.bitrate,
|
|
1067
|
+
canPlayType: canPlay2,
|
|
1068
|
+
hlsJs: isHls ? Hls.isSupported() : void 0
|
|
1069
|
+
};
|
|
1070
|
+
if (!playable) {
|
|
1071
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1072
|
+
reason: "rejected",
|
|
1073
|
+
why: "cannot_play_type"
|
|
1074
|
+
}));
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
var score = 0;
|
|
1078
|
+
if (target) {
|
|
1079
|
+
var resolutionDiff = Math.abs(file.width - target.width) + Math.abs(file.height - target.height);
|
|
1080
|
+
var bitrateDiff = Math.abs((file.bitrate || 5e3) * 1e3 - target.bitrate);
|
|
1081
|
+
score = resolutionDiff * 2 + bitrateDiff / 1e3;
|
|
1082
|
+
}
|
|
1083
|
+
accepted.push({
|
|
956
1084
|
file: file,
|
|
957
1085
|
score: score,
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
}
|
|
1086
|
+
insecure: insecure
|
|
1087
|
+
});
|
|
1088
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1089
|
+
reason: "accepted",
|
|
1090
|
+
why: insecure ? "insecure_http_deprioritized" : "playable",
|
|
1091
|
+
score: score
|
|
1092
|
+
}));
|
|
961
1093
|
});
|
|
962
|
-
|
|
1094
|
+
accepted.sort(function(a, b) {
|
|
1095
|
+
if (a.insecure !== b.insecure) return a.insecure ? 1 : -1;
|
|
963
1096
|
return a.score - b.score;
|
|
964
1097
|
});
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
console.log("[HlsAdPlayer] No best match found, using first media file");
|
|
968
|
-
return firstFile;
|
|
969
|
-
}
|
|
970
|
-
console.log("[HlsAdPlayer] Selected media file:", {
|
|
971
|
-
url: bestMatch.file.url,
|
|
972
|
-
resolution: "".concat(bestMatch.file.width, "x").concat(bestMatch.file.height),
|
|
973
|
-
bitrate: bestMatch.file.bitrate,
|
|
974
|
-
score: bestMatch.score,
|
|
975
|
-
resolutionDiff: bestMatch.resolutionDiff,
|
|
976
|
-
bitrateDiff: bestMatch.bitrateDiff
|
|
1098
|
+
return accepted.map(function(entry) {
|
|
1099
|
+
return entry.file;
|
|
977
1100
|
});
|
|
978
|
-
return bestMatch.file;
|
|
979
1101
|
}
|
|
980
1102
|
function isHlsMediaFile(mediaFile) {
|
|
981
1103
|
var type = mediaFile.type.toLowerCase();
|
|
@@ -992,59 +1114,181 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
992
1114
|
var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
|
|
993
1115
|
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");
|
|
994
1116
|
}
|
|
995
|
-
function
|
|
1117
|
+
function getMediaProbe() {
|
|
1118
|
+
if (adVideoElement) return adVideoElement;
|
|
1119
|
+
if (!mediaProbe && typeof document !== "undefined") {
|
|
1120
|
+
mediaProbe = document.createElement("video");
|
|
1121
|
+
}
|
|
1122
|
+
return mediaProbe;
|
|
1123
|
+
}
|
|
1124
|
+
function evaluateMediaFile(mf) {
|
|
1125
|
+
var _mf_textContent;
|
|
1126
|
+
var type = mf.getAttribute("type") || "";
|
|
1127
|
+
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1128
|
+
var delivery = mf.getAttribute("delivery") || void 0;
|
|
1129
|
+
var codec = mf.getAttribute("codec") || void 0;
|
|
1130
|
+
if (!url) {
|
|
1131
|
+
return {
|
|
1132
|
+
category: "missing_media",
|
|
1133
|
+
whyRejected: "empty_url",
|
|
1134
|
+
canPlayType: ""
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
var apiFramework = (mf.getAttribute("apiFramework") || "").toUpperCase();
|
|
1138
|
+
if (apiFramework === "VPAID") {
|
|
1139
|
+
return {
|
|
1140
|
+
category: "vpaid",
|
|
1141
|
+
whyRejected: "vpaid_not_supported",
|
|
1142
|
+
canPlayType: ""
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
try {
|
|
1146
|
+
var protocol = new URL(url).protocol;
|
|
1147
|
+
if (protocol !== "https:" && protocol !== "http:") {
|
|
1148
|
+
return {
|
|
1149
|
+
category: "invalid_url",
|
|
1150
|
+
whyRejected: "protocol_".concat(protocol),
|
|
1151
|
+
canPlayType: ""
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
} catch (unused) {
|
|
1155
|
+
return {
|
|
1156
|
+
category: "invalid_url",
|
|
1157
|
+
whyRejected: "unparseable_url",
|
|
1158
|
+
canPlayType: ""
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1162
|
+
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1163
|
+
var file = {
|
|
1164
|
+
url: url,
|
|
1165
|
+
type: type,
|
|
1166
|
+
width: parseInt(mf.getAttribute("width") || "1920", 10),
|
|
1167
|
+
height: parseInt(mf.getAttribute("height") || "1080", 10),
|
|
1168
|
+
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0,
|
|
1169
|
+
delivery: delivery,
|
|
1170
|
+
codec: codec
|
|
1171
|
+
};
|
|
1172
|
+
if (isAudioMediaFile(file)) {
|
|
1173
|
+
return {
|
|
1174
|
+
category: "audio_only",
|
|
1175
|
+
whyRejected: type.toLowerCase().startsWith("audio/") ? "audio_mime" : "audio_extension",
|
|
1176
|
+
canPlayType: ""
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
var isHls = isHlsMediaFile(file);
|
|
1180
|
+
var hasExplicitDimensions = mf.getAttribute("width") != null && mf.getAttribute("height") != null;
|
|
1181
|
+
if (!isHls && hasExplicitDimensions && (file.width <= 1 || file.height <= 1)) {
|
|
1182
|
+
return {
|
|
1183
|
+
category: "audio_only",
|
|
1184
|
+
whyRejected: "zero_dimensions",
|
|
1185
|
+
canPlayType: ""
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
var probe = getMediaProbe();
|
|
1189
|
+
if (isHls) {
|
|
1190
|
+
var _ref;
|
|
1191
|
+
var nativeHls = (_ref = probe === null || probe === void 0 ? void 0 : probe.canPlayType("application/vnd.apple.mpegurl")) !== null && _ref !== void 0 ? _ref : "";
|
|
1192
|
+
if (Hls.isSupported()) {
|
|
1193
|
+
return {
|
|
1194
|
+
file: file,
|
|
1195
|
+
whyAccepted: "hls_js",
|
|
1196
|
+
canPlayType: nativeHls
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
if (nativeHls !== "") {
|
|
1200
|
+
return {
|
|
1201
|
+
file: file,
|
|
1202
|
+
whyAccepted: "native_hls",
|
|
1203
|
+
canPlayType: nativeHls
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
return {
|
|
1207
|
+
category: "unsupported_hls",
|
|
1208
|
+
whyRejected: "no_hls_support",
|
|
1209
|
+
canPlayType: nativeHls
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
if (!isProgressiveMediaFile(file)) {
|
|
1213
|
+
return {
|
|
1214
|
+
category: "unsupported_mime",
|
|
1215
|
+
whyRejected: "not_a_video_mime",
|
|
1216
|
+
canPlayType: ""
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
if (!probe) {
|
|
1220
|
+
return {
|
|
1221
|
+
file: file,
|
|
1222
|
+
whyAccepted: "no_probe_available",
|
|
1223
|
+
canPlayType: ""
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
var baseType = type || "video/mp4";
|
|
1227
|
+
var canPlay2 = probe.canPlayType(baseType);
|
|
1228
|
+
if (canPlay2 === "") {
|
|
1229
|
+
return {
|
|
1230
|
+
category: "unsupported_mime",
|
|
1231
|
+
whyRejected: "canPlayType_empty",
|
|
1232
|
+
canPlayType: canPlay2
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
if (codec) {
|
|
1236
|
+
var withCodec = probe.canPlayType("".concat(baseType, '; codecs="').concat(codec, '"'));
|
|
1237
|
+
if (withCodec === "") {
|
|
1238
|
+
return {
|
|
1239
|
+
category: "unsupported_codec",
|
|
1240
|
+
whyRejected: "codec_canPlayType_empty",
|
|
1241
|
+
canPlayType: withCodec
|
|
1242
|
+
};
|
|
1243
|
+
}
|
|
1244
|
+
return {
|
|
1245
|
+
file: file,
|
|
1246
|
+
whyAccepted: "canPlayType_".concat(withCodec),
|
|
1247
|
+
canPlayType: withCodec
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
return {
|
|
1251
|
+
file: file,
|
|
1252
|
+
whyAccepted: "canPlayType_".concat(canPlay2),
|
|
1253
|
+
canPlayType: canPlay2
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
function collectVideoMediaFiles(linear, verbose, stats) {
|
|
996
1257
|
var mediaFileElements = linear.querySelectorAll(":scope > MediaFiles > MediaFile");
|
|
997
1258
|
var mediaFiles = [];
|
|
1259
|
+
if (stats) stats.total += mediaFileElements.length;
|
|
998
1260
|
if (verbose) {
|
|
999
1261
|
console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
|
|
1000
1262
|
}
|
|
1001
1263
|
mediaFileElements.forEach(function(mf, index) {
|
|
1002
1264
|
var _mf_textContent;
|
|
1003
|
-
var
|
|
1265
|
+
var result = evaluateMediaFile(mf);
|
|
1004
1266
|
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
1005
|
-
var
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
}
|
|
1023
|
-
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1024
|
-
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1025
|
-
var mediaFile = {
|
|
1026
|
-
url: url,
|
|
1027
|
-
type: type,
|
|
1028
|
-
width: parseInt(width || "1920", 10),
|
|
1029
|
-
height: parseInt(height || "1080", 10),
|
|
1030
|
-
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
1031
|
-
};
|
|
1032
|
-
if (isAudioMediaFile(mediaFile)) {
|
|
1033
|
-
console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
|
|
1267
|
+
var accepted = "file" in result;
|
|
1268
|
+
logFunnel("mediafile_evaluated", {
|
|
1269
|
+
reason: accepted ? "accepted" : result.category,
|
|
1270
|
+
index: index,
|
|
1271
|
+
type: mf.getAttribute("type") || "",
|
|
1272
|
+
delivery: mf.getAttribute("delivery") || void 0,
|
|
1273
|
+
codec: mf.getAttribute("codec") || void 0,
|
|
1274
|
+
apiFramework: mf.getAttribute("apiFramework") || void 0,
|
|
1275
|
+
width: mf.getAttribute("width"),
|
|
1276
|
+
height: mf.getAttribute("height"),
|
|
1277
|
+
fileUrl: redactUrl(url),
|
|
1278
|
+
canPlayType: result.canPlayType,
|
|
1279
|
+
whyAccepted: accepted ? result.whyAccepted : void 0,
|
|
1280
|
+
whyRejected: accepted ? void 0 : result.whyRejected
|
|
1281
|
+
});
|
|
1282
|
+
if ("file" in result) {
|
|
1283
|
+
mediaFiles.push(result.file);
|
|
1034
1284
|
return;
|
|
1035
1285
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
return;
|
|
1286
|
+
if (stats) {
|
|
1287
|
+
var _stats_categories_result_category;
|
|
1288
|
+
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;
|
|
1040
1289
|
}
|
|
1041
|
-
if (
|
|
1042
|
-
|
|
1043
|
-
if (verbose) {
|
|
1044
|
-
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
1045
|
-
}
|
|
1046
|
-
} else if (verbose) {
|
|
1047
|
-
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
1290
|
+
if (result.category === "audio_only") {
|
|
1291
|
+
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'));
|
|
1048
1292
|
}
|
|
1049
1293
|
});
|
|
1050
1294
|
return mediaFiles;
|
|
@@ -1168,26 +1412,58 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1168
1412
|
}
|
|
1169
1413
|
function parseVastXml(xmlString) {
|
|
1170
1414
|
try {
|
|
1171
|
-
var _adElements_find;
|
|
1172
1415
|
var xmlDoc = parseXml(xmlString);
|
|
1173
1416
|
if (!xmlDoc) return {
|
|
1174
1417
|
type: "empty"
|
|
1175
1418
|
};
|
|
1176
1419
|
var root = xmlDoc.documentElement;
|
|
1177
1420
|
var adElements = Array.from(root.querySelectorAll(":scope > Ad"));
|
|
1178
|
-
|
|
1179
|
-
return getAdSequence(el) === void 0;
|
|
1180
|
-
})) !== null && _adElements_find !== void 0 ? _adElements_find : adElements[0];
|
|
1181
|
-
if (!adElement) {
|
|
1421
|
+
if (adElements.length === 0) {
|
|
1182
1422
|
var _root_getAttribute;
|
|
1183
1423
|
console.warn("[HlsAdPlayer] No Ad element found in VAST ".concat((_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : "", " response"));
|
|
1184
1424
|
return emptyVastResult(root);
|
|
1185
1425
|
}
|
|
1186
|
-
var
|
|
1187
|
-
|
|
1188
|
-
|
|
1426
|
+
var ordered = _to_consumable_array(adElements.filter(function(el) {
|
|
1427
|
+
return getAdSequence(el) === void 0;
|
|
1428
|
+
})).concat(_to_consumable_array(adElements.filter(function(el) {
|
|
1429
|
+
return getAdSequence(el) !== void 0;
|
|
1430
|
+
})));
|
|
1431
|
+
var firstEmpty;
|
|
1432
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1433
|
+
try {
|
|
1434
|
+
for(var _iterator = ordered.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1435
|
+
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], adElement = _step_value[1];
|
|
1436
|
+
var parsed = parseAdElement(adElement, true);
|
|
1437
|
+
if (parsed.type === "empty") {
|
|
1438
|
+
firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : firstEmpty = parsed;
|
|
1439
|
+
continue;
|
|
1440
|
+
}
|
|
1441
|
+
if (index > 0) {
|
|
1442
|
+
logFunnel("vast_ad_fallback", {
|
|
1443
|
+
usedAdIndex: index,
|
|
1444
|
+
adCount: ordered.length
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
if (parsed.type === "wrapper") {
|
|
1448
|
+
console.log("[HlsAdPlayer] VAST wrapper detected, following VASTAdTagURI: ".concat(parsed.vastAdTagUri));
|
|
1449
|
+
}
|
|
1450
|
+
return parsed;
|
|
1451
|
+
}
|
|
1452
|
+
} catch (err) {
|
|
1453
|
+
_didIteratorError = true;
|
|
1454
|
+
_iteratorError = err;
|
|
1455
|
+
} finally{
|
|
1456
|
+
try {
|
|
1457
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1458
|
+
_iterator.return();
|
|
1459
|
+
}
|
|
1460
|
+
} finally{
|
|
1461
|
+
if (_didIteratorError) {
|
|
1462
|
+
throw _iteratorError;
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1189
1465
|
}
|
|
1190
|
-
return
|
|
1466
|
+
return firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : emptyVastResult(root);
|
|
1191
1467
|
} catch (error) {
|
|
1192
1468
|
console.error("[HlsAdPlayer] Error parsing VAST XML:", error);
|
|
1193
1469
|
return {
|
|
@@ -1233,6 +1509,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1233
1509
|
pushUrls(errorUrls, inLine.querySelectorAll(":scope > Error"));
|
|
1234
1510
|
if (adElement.getAttribute("conditionalAd") === "true") {
|
|
1235
1511
|
console.warn("[HlsAdPlayer] Skipping conditional <Ad> (VPAID-only)");
|
|
1512
|
+
logFunnel("vast_no_supported_media", {
|
|
1513
|
+
reason: "vpaid",
|
|
1514
|
+
conditionalAd: true
|
|
1515
|
+
});
|
|
1236
1516
|
return {
|
|
1237
1517
|
type: "empty",
|
|
1238
1518
|
errorUrls: errorUrls,
|
|
@@ -1241,11 +1521,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1241
1521
|
}
|
|
1242
1522
|
var linear;
|
|
1243
1523
|
var mediaFiles = [];
|
|
1524
|
+
var rejectStats = {
|
|
1525
|
+
total: 0,
|
|
1526
|
+
categories: {}
|
|
1527
|
+
};
|
|
1244
1528
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1245
1529
|
try {
|
|
1246
1530
|
for(var _iterator = Array.from(inLine.querySelectorAll(":scope > Creatives > Creative > Linear"))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1247
1531
|
var candidate = _step.value;
|
|
1248
|
-
var files = collectVideoMediaFiles(candidate, verbose);
|
|
1532
|
+
var files = collectVideoMediaFiles(candidate, verbose, rejectStats);
|
|
1249
1533
|
if (files.length > 0) {
|
|
1250
1534
|
linear = candidate;
|
|
1251
1535
|
mediaFiles = files;
|
|
@@ -1268,6 +1552,39 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1268
1552
|
}
|
|
1269
1553
|
if (!linear) {
|
|
1270
1554
|
console.warn("[HlsAdPlayer] No supported linear media files in <Ad>");
|
|
1555
|
+
var reason = "missing_media";
|
|
1556
|
+
var top = 0;
|
|
1557
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
1558
|
+
try {
|
|
1559
|
+
for(var _iterator1 = Object.keys(rejectStats.categories)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
1560
|
+
var category = _step1.value;
|
|
1561
|
+
var _rejectStats_categories_category;
|
|
1562
|
+
var count = (_rejectStats_categories_category = rejectStats.categories[category]) !== null && _rejectStats_categories_category !== void 0 ? _rejectStats_categories_category : 0;
|
|
1563
|
+
if (count > top) {
|
|
1564
|
+
top = count;
|
|
1565
|
+
reason = category;
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
} catch (err) {
|
|
1569
|
+
_didIteratorError1 = true;
|
|
1570
|
+
_iteratorError1 = err;
|
|
1571
|
+
} finally{
|
|
1572
|
+
try {
|
|
1573
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1574
|
+
_iterator1.return();
|
|
1575
|
+
}
|
|
1576
|
+
} finally{
|
|
1577
|
+
if (_didIteratorError1) {
|
|
1578
|
+
throw _iteratorError1;
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
if (rejectStats.total > 0 && top === 0) reason = "other";
|
|
1583
|
+
logFunnel("vast_no_supported_media", {
|
|
1584
|
+
reason: reason,
|
|
1585
|
+
mediaFileCount: rejectStats.total,
|
|
1586
|
+
rejectedByCategory: rejectStats.categories
|
|
1587
|
+
});
|
|
1271
1588
|
return {
|
|
1272
1589
|
type: "empty",
|
|
1273
1590
|
errorUrls: errorUrls,
|
|
@@ -1297,27 +1614,65 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1297
1614
|
}
|
|
1298
1615
|
}
|
|
1299
1616
|
function fetchVastXml(vastTagUrl) {
|
|
1300
|
-
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
1617
|
+
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include", kind = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "gam";
|
|
1301
1618
|
return _async_to_generator(function() {
|
|
1302
|
-
var controller, timeoutId, requestVast, response, error, error1;
|
|
1619
|
+
var controller, timeoutId, startedAt, attempt, requestVast, response, error, error1;
|
|
1303
1620
|
return _ts_generator(this, function(_state) {
|
|
1304
1621
|
switch(_state.label){
|
|
1305
1622
|
case 0:
|
|
1623
|
+
if (destroyed) {
|
|
1624
|
+
throw new Error("VAST request skipped: ad player destroyed");
|
|
1625
|
+
}
|
|
1306
1626
|
controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1627
|
+
if (controller) pendingVastRequests.add(controller);
|
|
1307
1628
|
timeoutId = controller ? setTimeout(function() {
|
|
1308
1629
|
return controller.abort();
|
|
1309
1630
|
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
1631
|
+
startedAt = Date.now();
|
|
1632
|
+
attempt = 0;
|
|
1310
1633
|
requestVast = function requestVast(creds) {
|
|
1311
|
-
return
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1634
|
+
return _async_to_generator(function() {
|
|
1635
|
+
var response;
|
|
1636
|
+
return _ts_generator(this, function(_state) {
|
|
1637
|
+
switch(_state.label){
|
|
1638
|
+
case 0:
|
|
1639
|
+
attempt++;
|
|
1640
|
+
if (kind === "gam") {
|
|
1641
|
+
logFunnel("gam_http_request_sent", {
|
|
1642
|
+
attempt: attempt,
|
|
1643
|
+
credentials: creds
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
return [
|
|
1647
|
+
4,
|
|
1648
|
+
fetch(vastTagUrl, _object_spread({
|
|
1649
|
+
mode: "cors",
|
|
1650
|
+
credentials: creds,
|
|
1651
|
+
headers: {
|
|
1652
|
+
"Accept": "application/xml, text/xml, */*"
|
|
1653
|
+
},
|
|
1654
|
+
referrerPolicy: "no-referrer-when-downgrade"
|
|
1655
|
+
}, controller ? {
|
|
1656
|
+
signal: controller.signal
|
|
1657
|
+
} : {}))
|
|
1658
|
+
];
|
|
1659
|
+
case 1:
|
|
1660
|
+
response = _state.sent();
|
|
1661
|
+
if (kind === "gam") {
|
|
1662
|
+
logFunnel("gam_response_received", {
|
|
1663
|
+
attempt: attempt,
|
|
1664
|
+
httpStatus: response.status,
|
|
1665
|
+
ok: response.ok,
|
|
1666
|
+
elapsedMs: Date.now() - startedAt
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
return [
|
|
1670
|
+
2,
|
|
1671
|
+
response
|
|
1672
|
+
];
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
})();
|
|
1321
1676
|
};
|
|
1322
1677
|
_state.label = 1;
|
|
1323
1678
|
case 1:
|
|
@@ -1352,6 +1707,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1352
1707
|
6
|
|
1353
1708
|
];
|
|
1354
1709
|
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
1710
|
+
logFunnel("vast_credentials_retry", {
|
|
1711
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1712
|
+
});
|
|
1355
1713
|
return [
|
|
1356
1714
|
4,
|
|
1357
1715
|
requestVast("omit")
|
|
@@ -1371,7 +1729,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1371
1729
|
];
|
|
1372
1730
|
case 8:
|
|
1373
1731
|
if (!response.ok) {
|
|
1374
|
-
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
1732
|
+
throw new Error("Failed to fetch VAST: HTTP ".concat(response.status, " ").concat(response.statusText));
|
|
1375
1733
|
}
|
|
1376
1734
|
return [
|
|
1377
1735
|
4,
|
|
@@ -1385,11 +1743,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1385
1743
|
case 10:
|
|
1386
1744
|
error1 = _state.sent();
|
|
1387
1745
|
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1746
|
+
if (pendingRequestAbortReason) {
|
|
1747
|
+
throw new Error("".concat(pendingRequestAbortReason, ": ").concat(vastTagUrl));
|
|
1748
|
+
}
|
|
1388
1749
|
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1389
1750
|
}
|
|
1390
1751
|
throw error1;
|
|
1391
1752
|
case 11:
|
|
1392
1753
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1754
|
+
if (controller) pendingVastRequests.delete(controller);
|
|
1393
1755
|
return [
|
|
1394
1756
|
7
|
|
1395
1757
|
];
|
|
@@ -1403,7 +1765,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1403
1765
|
}
|
|
1404
1766
|
function fetchAndParseVastAd(_0) {
|
|
1405
1767
|
return _async_to_generator(function(vastTagUrl) {
|
|
1406
|
-
var depth, accumulatedTracking, rules, vastXml, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1768
|
+
var depth, accumulatedTracking, rules, vastXml, fetchStartedAt, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1407
1769
|
var _arguments = arguments;
|
|
1408
1770
|
return _ts_generator(this, function(_state) {
|
|
1409
1771
|
switch(_state.label){
|
|
@@ -1411,6 +1773,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1411
1773
|
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] : {
|
|
1412
1774
|
followAdditionalWrappers: true
|
|
1413
1775
|
};
|
|
1776
|
+
if (destroyed) return [
|
|
1777
|
+
2,
|
|
1778
|
+
null
|
|
1779
|
+
];
|
|
1780
|
+
fetchStartedAt = Date.now();
|
|
1414
1781
|
_state.label = 1;
|
|
1415
1782
|
case 1:
|
|
1416
1783
|
_state.trys.push([
|
|
@@ -1421,7 +1788,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1421
1788
|
]);
|
|
1422
1789
|
return [
|
|
1423
1790
|
4,
|
|
1424
|
-
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit")
|
|
1791
|
+
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit", depth === 0 ? "gam" : "wrapper")
|
|
1425
1792
|
];
|
|
1426
1793
|
case 2:
|
|
1427
1794
|
vastXml = _state.sent();
|
|
@@ -1433,14 +1800,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1433
1800
|
error = _state.sent();
|
|
1434
1801
|
if (depth === 0) throw error;
|
|
1435
1802
|
console.warn("[HlsAdPlayer] Wrapped VAST request failed:", error);
|
|
1436
|
-
|
|
1437
|
-
|
|
1803
|
+
logFunnel("wrapper_fetch", {
|
|
1804
|
+
reason: "failure",
|
|
1805
|
+
depth: depth,
|
|
1806
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
1807
|
+
elapsedMs: Date.now() - fetchStartedAt,
|
|
1808
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1438
1809
|
});
|
|
1810
|
+
if (!destroyed) {
|
|
1811
|
+
fireTrackingPixels(accumulatedTracking.error, {
|
|
1812
|
+
errorCode: VAST_ERROR_WRAPPER_TIMEOUT
|
|
1813
|
+
});
|
|
1814
|
+
}
|
|
1439
1815
|
return [
|
|
1440
1816
|
2,
|
|
1441
1817
|
null
|
|
1442
1818
|
];
|
|
1443
1819
|
case 4:
|
|
1820
|
+
if (destroyed) return [
|
|
1821
|
+
2,
|
|
1822
|
+
null
|
|
1823
|
+
];
|
|
1824
|
+
if (depth > 0) {
|
|
1825
|
+
logFunnel("wrapper_fetch", {
|
|
1826
|
+
reason: "success",
|
|
1827
|
+
depth: depth,
|
|
1828
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
1829
|
+
elapsedMs: Date.now() - fetchStartedAt
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1444
1832
|
console.log("[HlsAdPlayer] VAST XML received");
|
|
1445
1833
|
console.log("[HlsAdPlayer] VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1446
1834
|
parsed = parseVastXml(vastXml);
|
|
@@ -1472,6 +1860,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1472
1860
|
];
|
|
1473
1861
|
}
|
|
1474
1862
|
mergeTrackingUrls(parsed.ad.trackingUrls, accumulatedTracking);
|
|
1863
|
+
logFunnel("inline_resolved", {
|
|
1864
|
+
depth: depth
|
|
1865
|
+
});
|
|
1475
1866
|
return [
|
|
1476
1867
|
2,
|
|
1477
1868
|
parsed.ad
|
|
@@ -1482,20 +1873,29 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1482
1873
|
}
|
|
1483
1874
|
function fetchAndParsePod(vastTagUrl) {
|
|
1484
1875
|
return _async_to_generator(function() {
|
|
1485
|
-
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements,
|
|
1876
|
+
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;
|
|
1486
1877
|
return _ts_generator(this, function(_state) {
|
|
1487
1878
|
switch(_state.label){
|
|
1488
1879
|
case 0:
|
|
1880
|
+
lastPodAdElementCount = 0;
|
|
1489
1881
|
return [
|
|
1490
1882
|
4,
|
|
1491
1883
|
fetchVastXml(vastTagUrl)
|
|
1492
1884
|
];
|
|
1493
1885
|
case 1:
|
|
1494
1886
|
vastXml = _state.sent();
|
|
1887
|
+
if (destroyed) return [
|
|
1888
|
+
2,
|
|
1889
|
+
[]
|
|
1890
|
+
];
|
|
1495
1891
|
console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
|
|
1496
1892
|
trimmedXml = vastXml.trim();
|
|
1497
1893
|
if (trimmedXml.length === 0) {
|
|
1498
1894
|
console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
|
|
1895
|
+
logFunnel("vast_parsed", {
|
|
1896
|
+
adElementCount: 0,
|
|
1897
|
+
reason: "empty_body"
|
|
1898
|
+
});
|
|
1499
1899
|
return [
|
|
1500
1900
|
2,
|
|
1501
1901
|
[]
|
|
@@ -1504,6 +1904,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1504
1904
|
xmlDoc = parseXml(vastXml);
|
|
1505
1905
|
if (!xmlDoc) {
|
|
1506
1906
|
console.error("[HlsAdPlayer] Pod VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1907
|
+
logFunnel("vast_parsed", {
|
|
1908
|
+
adElementCount: 0,
|
|
1909
|
+
reason: "xml_parse_error"
|
|
1910
|
+
});
|
|
1507
1911
|
return [
|
|
1508
1912
|
2,
|
|
1509
1913
|
[]
|
|
@@ -1511,10 +1915,21 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1511
1915
|
}
|
|
1512
1916
|
root = xmlDoc.documentElement;
|
|
1513
1917
|
adElements = Array.from(root.querySelectorAll(":scope > Ad"));
|
|
1918
|
+
logFunnel("vast_parsed", {
|
|
1919
|
+
reason: adElements.length > 0 ? "has_ads" : "no_ads",
|
|
1920
|
+
vastVersion: (_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : void 0,
|
|
1921
|
+
adElementCount: adElements.length,
|
|
1922
|
+
inlineCount: adElements.filter(function(el) {
|
|
1923
|
+
return el.querySelector(":scope > InLine");
|
|
1924
|
+
}).length,
|
|
1925
|
+
wrapperCount: adElements.filter(function(el) {
|
|
1926
|
+
return el.querySelector(":scope > Wrapper");
|
|
1927
|
+
}).length
|
|
1928
|
+
});
|
|
1514
1929
|
if (adElements.length === 0) {
|
|
1515
1930
|
;
|
|
1516
1931
|
;
|
|
1517
|
-
console.warn("[HlsAdPlayer] No <Ad> elements in VAST ".concat((
|
|
1932
|
+
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)"));
|
|
1518
1933
|
empty = emptyVastResult(root);
|
|
1519
1934
|
if (empty.type === "empty" && ((_empty_errorUrls = empty.errorUrls) === null || _empty_errorUrls === void 0 ? void 0 : _empty_errorUrls.length)) {
|
|
1520
1935
|
;
|
|
@@ -1532,10 +1947,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1532
1947
|
var _parsed_errorUrls, parsed, _parsed_errorCode;
|
|
1533
1948
|
return _ts_generator(this, function(_state) {
|
|
1534
1949
|
parsed = parseAdElement(adElement);
|
|
1535
|
-
if (parsed.type === "inline")
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1950
|
+
if (parsed.type === "inline") {
|
|
1951
|
+
logFunnel("inline_resolved", {
|
|
1952
|
+
depth: 0
|
|
1953
|
+
});
|
|
1954
|
+
return [
|
|
1955
|
+
2,
|
|
1956
|
+
parsed.ad
|
|
1957
|
+
];
|
|
1958
|
+
}
|
|
1539
1959
|
if (parsed.type === "wrapper") {
|
|
1540
1960
|
return [
|
|
1541
1961
|
2,
|
|
@@ -1713,7 +2133,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1713
2133
|
7
|
|
1714
2134
|
];
|
|
1715
2135
|
case 21:
|
|
1716
|
-
console.log("[HlsAdPlayer] Parsed ".concat(ads.length, " ad(s) from VAST ").concat((
|
|
2136
|
+
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"));
|
|
2137
|
+
lastPodAdElementCount = adElements.length;
|
|
1717
2138
|
return [
|
|
1718
2139
|
2,
|
|
1719
2140
|
ads
|
|
@@ -1779,14 +2200,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1779
2200
|
var progress = currentTime / currentAd.duration;
|
|
1780
2201
|
if (progress >= 0.25 && !trackingFired.firstQuartile) {
|
|
1781
2202
|
trackingFired.firstQuartile = true;
|
|
2203
|
+
logFunnel("first_quartile");
|
|
1782
2204
|
fireTrackingPixels(currentAd.trackingUrls.firstQuartile);
|
|
1783
2205
|
}
|
|
1784
2206
|
if (progress >= 0.5 && !trackingFired.midpoint) {
|
|
1785
2207
|
trackingFired.midpoint = true;
|
|
2208
|
+
logFunnel("midpoint");
|
|
1786
2209
|
fireTrackingPixels(currentAd.trackingUrls.midpoint);
|
|
1787
2210
|
}
|
|
1788
2211
|
if (progress >= 0.75 && !trackingFired.thirdQuartile) {
|
|
1789
2212
|
trackingFired.thirdQuartile = true;
|
|
2213
|
+
logFunnel("third_quartile");
|
|
1790
2214
|
fireTrackingPixels(currentAd.trackingUrls.thirdQuartile);
|
|
1791
2215
|
}
|
|
1792
2216
|
};
|
|
@@ -1809,6 +2233,16 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1809
2233
|
if (!trackingFired.impression) {
|
|
1810
2234
|
trackingFired.impression = true;
|
|
1811
2235
|
resolvedAds.add(currentAd);
|
|
2236
|
+
logFunnel("playing", {
|
|
2237
|
+
mutedByAutoplay: forcedMuteByAutoplay,
|
|
2238
|
+
candidateIndex: mediaCandidateIndex
|
|
2239
|
+
});
|
|
2240
|
+
logFunnel("impression_fired", {
|
|
2241
|
+
pixelCount: currentAd.trackingUrls.impression.length
|
|
2242
|
+
});
|
|
2243
|
+
if (currentAd.trackingUrls.impression.length === 0) {
|
|
2244
|
+
console.warn("[HlsAdPlayer] Ad started but VAST contained no <Impression> URLs - GAM will not count it");
|
|
2245
|
+
}
|
|
1812
2246
|
fireTrackingPixels(currentAd.trackingUrls.impression);
|
|
1813
2247
|
fireTrackingPixels(currentAd.trackingUrls.creativeView);
|
|
1814
2248
|
fireTrackingPixels(currentAd.trackingUrls.verificationNotExecuted, {
|
|
@@ -1831,6 +2265,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1831
2265
|
sampleViewability();
|
|
1832
2266
|
settleViewability();
|
|
1833
2267
|
trackingFired.complete = true;
|
|
2268
|
+
logFunnel("complete");
|
|
1834
2269
|
fireTrackingPixels(currentAd.trackingUrls.complete);
|
|
1835
2270
|
console.log("[HlsAdPlayer] Ad completed");
|
|
1836
2271
|
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
|
|
@@ -1839,16 +2274,41 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1839
2274
|
handleAdComplete();
|
|
1840
2275
|
};
|
|
1841
2276
|
var onError = function onError(e) {
|
|
2277
|
+
var _adVideoElement_error, _adVideoElement_error1;
|
|
1842
2278
|
if (!adPlaying) return;
|
|
1843
2279
|
console.error("[HlsAdPlayer] Ad video error:", e);
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
2280
|
+
var vastErrorCode = toVastMediaErrorCode(adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.error);
|
|
2281
|
+
logFunnel("media_error", {
|
|
2282
|
+
mediaErrorCode: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error = adVideoElement.error) === null || _adVideoElement_error === void 0 ? void 0 : _adVideoElement_error.code,
|
|
2283
|
+
errorMessage: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error1 = adVideoElement.error) === null || _adVideoElement_error1 === void 0 ? void 0 : _adVideoElement_error1.message,
|
|
2284
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2285
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2286
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2287
|
+
vastErrorCode: vastErrorCode
|
|
2288
|
+
});
|
|
2289
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2290
|
+
};
|
|
2291
|
+
var onMediaDiagnostic = function onMediaDiagnostic(event) {
|
|
2292
|
+
if (!adPlaying || !adVideoElement || trackingFired.impression) return;
|
|
2293
|
+
if (!adVideoElement.currentSrc) return;
|
|
2294
|
+
logFunnel("media_event", {
|
|
2295
|
+
reason: event.type,
|
|
2296
|
+
readyState: adVideoElement.readyState,
|
|
2297
|
+
networkState: adVideoElement.networkState,
|
|
2298
|
+
currentSrc: adVideoElement.currentSrc
|
|
2299
|
+
});
|
|
1849
2300
|
};
|
|
1850
2301
|
var onVolumeChange = function onVolumeChange() {
|
|
1851
2302
|
if (!currentAd || !adVideoElement) return;
|
|
2303
|
+
if (forcedMuteByAutoplay && !adVideoElement.muted) {
|
|
2304
|
+
var userActivation = navigator.userActivation;
|
|
2305
|
+
if (userActivation && !userActivation.isActive) {
|
|
2306
|
+
logFunnel("unexpected_unmute", {
|
|
2307
|
+
paused: adVideoElement.paused
|
|
2308
|
+
});
|
|
2309
|
+
}
|
|
2310
|
+
forcedMuteByAutoplay = false;
|
|
2311
|
+
}
|
|
1852
2312
|
var muted = adVideoElement.muted || adVideoElement.volume === 0;
|
|
1853
2313
|
if (!trackingFired.start) {
|
|
1854
2314
|
trackingFired.lastMuted = muted;
|
|
@@ -1908,6 +2368,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1908
2368
|
{
|
|
1909
2369
|
type: "play",
|
|
1910
2370
|
handler: onPlay
|
|
2371
|
+
},
|
|
2372
|
+
{
|
|
2373
|
+
type: "stalled",
|
|
2374
|
+
handler: onMediaDiagnostic
|
|
2375
|
+
},
|
|
2376
|
+
{
|
|
2377
|
+
type: "suspend",
|
|
2378
|
+
handler: onMediaDiagnostic
|
|
2379
|
+
},
|
|
2380
|
+
{
|
|
2381
|
+
type: "abort",
|
|
2382
|
+
handler: onMediaDiagnostic
|
|
2383
|
+
},
|
|
2384
|
+
{
|
|
2385
|
+
type: "emptied",
|
|
2386
|
+
handler: onMediaDiagnostic
|
|
1911
2387
|
}
|
|
1912
2388
|
];
|
|
1913
2389
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -2197,16 +2673,51 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2197
2673
|
function settlePendingPlay() {
|
|
2198
2674
|
pendingPlayPromise = void 0;
|
|
2199
2675
|
}
|
|
2676
|
+
function toVastPlayErrorCode(error) {
|
|
2677
|
+
return (error === null || error === void 0 ? void 0 : error.name) === "NotSupportedError" ? VAST_ERROR_NO_SUPPORTED_MEDIA : VAST_ERROR_MEDIA_DISPLAY;
|
|
2678
|
+
}
|
|
2679
|
+
function failAdPlayback(context, error) {
|
|
2680
|
+
var vastErrorCode = toVastPlayErrorCode(error);
|
|
2681
|
+
console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
|
|
2682
|
+
logFunnel("play_failed", {
|
|
2683
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2684
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message,
|
|
2685
|
+
vastErrorCode: vastErrorCode
|
|
2686
|
+
});
|
|
2687
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2688
|
+
}
|
|
2200
2689
|
function startAdPlayback(context) {
|
|
2690
|
+
var isMutedRetry = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
2201
2691
|
if (!adVideoElement) return;
|
|
2692
|
+
var computed = typeof getComputedStyle === "function" && adContainerEl ? getComputedStyle(adContainerEl) : void 0;
|
|
2693
|
+
logFunnel(isMutedRetry ? "muted_retry" : "play_called", {
|
|
2694
|
+
context: context,
|
|
2695
|
+
isConnected: adVideoElement.isConnected,
|
|
2696
|
+
clientWidth: adVideoElement.clientWidth,
|
|
2697
|
+
clientHeight: adVideoElement.clientHeight,
|
|
2698
|
+
containerDisplay: computed === null || computed === void 0 ? void 0 : computed.display,
|
|
2699
|
+
containerVisibility: computed === null || computed === void 0 ? void 0 : computed.visibility
|
|
2700
|
+
});
|
|
2202
2701
|
var playPromise = adVideoElement.play();
|
|
2203
2702
|
pendingPlayPromise = playPromise;
|
|
2204
2703
|
playPromise.catch(function(error) {
|
|
2205
2704
|
if (pendingPlayPromise !== playPromise) {
|
|
2206
2705
|
return;
|
|
2207
2706
|
}
|
|
2208
|
-
|
|
2209
|
-
|
|
2707
|
+
logFunnel("play_rejected", {
|
|
2708
|
+
context: context,
|
|
2709
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2710
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
2711
|
+
});
|
|
2712
|
+
if (!isMutedRetry && (error === null || error === void 0 ? void 0 : error.name) === "NotAllowedError" && adVideoElement && !adVideoElement.muted) {
|
|
2713
|
+
console.warn("[HlsAdPlayer] Unmuted ".concat(context, " blocked by autoplay policy - retrying muted"));
|
|
2714
|
+
originalMutedState = true;
|
|
2715
|
+
forcedMuteByAutoplay = true;
|
|
2716
|
+
adVideoElement.muted = true;
|
|
2717
|
+
startAdPlayback(context, true);
|
|
2718
|
+
return;
|
|
2719
|
+
}
|
|
2720
|
+
failAdPlayback(context, error);
|
|
2210
2721
|
}).finally(function() {
|
|
2211
2722
|
if (pendingPlayPromise === playPromise) {
|
|
2212
2723
|
pendingPlayPromise = void 0;
|
|
@@ -2245,17 +2756,109 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2245
2756
|
adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
|
|
2246
2757
|
adVideoElement.muted = originalMutedState;
|
|
2247
2758
|
}
|
|
2759
|
+
function clearMediaStartTimer() {
|
|
2760
|
+
if (mediaStartTimerId !== void 0) {
|
|
2761
|
+
clearTimeout(mediaStartTimerId);
|
|
2762
|
+
mediaStartTimerId = void 0;
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
function startMediaStartTimer() {
|
|
2766
|
+
clearMediaStartTimer();
|
|
2767
|
+
if (!(MEDIA_START_TIMEOUT_MS > 0)) return;
|
|
2768
|
+
var startedAt = Date.now();
|
|
2769
|
+
mediaStartTimerId = setTimeout(function() {
|
|
2770
|
+
mediaStartTimerId = void 0;
|
|
2771
|
+
if (!adPlaying || trackingFired.impression) return;
|
|
2772
|
+
console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(MEDIA_START_TIMEOUT_MS, "ms"));
|
|
2773
|
+
logFunnel("play_resolved_but_never_started", {
|
|
2774
|
+
timeoutMs: MEDIA_START_TIMEOUT_MS,
|
|
2775
|
+
elapsedMs: Date.now() - startedAt,
|
|
2776
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2777
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2778
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2779
|
+
paused: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.paused,
|
|
2780
|
+
vastErrorCode: VAST_ERROR_MEDIA_TIMEOUT
|
|
2781
|
+
});
|
|
2782
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_TIMEOUT);
|
|
2783
|
+
}, MEDIA_START_TIMEOUT_MS);
|
|
2784
|
+
}
|
|
2785
|
+
function resetVideoElementForNextSource() {
|
|
2786
|
+
clearStallWatchdog();
|
|
2787
|
+
if (requiresMediaPipelineResetAfterAds()) {
|
|
2788
|
+
recreateAdVideoElement();
|
|
2789
|
+
setupAdEventListeners();
|
|
2790
|
+
} else {
|
|
2791
|
+
prepareVideoElementForNewSource();
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
function tryNextMediaCandidate() {
|
|
2795
|
+
if (!currentAd || trackingFired.impression) return false;
|
|
2796
|
+
if (mediaCandidateIndex >= mediaCandidates.length - 1) return false;
|
|
2797
|
+
var failedUrl = currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url;
|
|
2798
|
+
mediaCandidateIndex++;
|
|
2799
|
+
var next = mediaCandidates[mediaCandidateIndex];
|
|
2800
|
+
if (!next) return false;
|
|
2801
|
+
logFunnel("media_fallback", {
|
|
2802
|
+
failedUrl: failedUrl,
|
|
2803
|
+
nextUrl: next.url,
|
|
2804
|
+
nextType: next.type,
|
|
2805
|
+
candidateIndex: mediaCandidateIndex,
|
|
2806
|
+
candidateCount: mediaCandidates.length
|
|
2807
|
+
});
|
|
2808
|
+
resetVideoElementForNextSource();
|
|
2809
|
+
try {
|
|
2810
|
+
loadMediaCandidate(next);
|
|
2811
|
+
return true;
|
|
2812
|
+
} catch (error) {
|
|
2813
|
+
console.error("[HlsAdPlayer] Failed to load fallback media file:", error);
|
|
2814
|
+
return tryNextMediaCandidate();
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
function recoverFromAdFailure(vastErrorCode) {
|
|
2818
|
+
clearMediaStartTimer();
|
|
2819
|
+
if (tryNextMediaCandidate()) return;
|
|
2820
|
+
reportCurrentAdError(vastErrorCode);
|
|
2821
|
+
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) return;
|
|
2822
|
+
handleAdError();
|
|
2823
|
+
}
|
|
2248
2824
|
function loadCurrentAdMedia() {
|
|
2249
2825
|
if (!adVideoElement || !currentAd) {
|
|
2250
2826
|
throw new Error("No ad video element or ad to load");
|
|
2251
2827
|
}
|
|
2252
|
-
|
|
2828
|
+
mediaCandidates = rankMediaCandidates(currentAd.mediaFiles);
|
|
2829
|
+
mediaCandidateIndex = 0;
|
|
2830
|
+
var mediaFile = mediaCandidates[0];
|
|
2253
2831
|
if (!mediaFile) {
|
|
2254
|
-
|
|
2832
|
+
logFunnel("media_unsupported", {
|
|
2833
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA,
|
|
2834
|
+
candidates: currentAd.mediaFiles.length
|
|
2835
|
+
});
|
|
2836
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
2837
|
+
throw new Error("No media file this browser can play");
|
|
2838
|
+
}
|
|
2839
|
+
try {
|
|
2840
|
+
loadMediaCandidate(mediaFile);
|
|
2841
|
+
} catch (error) {
|
|
2842
|
+
if (tryNextMediaCandidate()) return;
|
|
2843
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
2844
|
+
throw error;
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
function loadMediaCandidate(mediaFile) {
|
|
2848
|
+
if (!adVideoElement || !currentAd) {
|
|
2849
|
+
throw new Error("No ad video element or ad to load");
|
|
2255
2850
|
}
|
|
2256
2851
|
currentAdMediaFile = mediaFile;
|
|
2257
2852
|
var isHlsAd = isHlsMediaFile(mediaFile);
|
|
2853
|
+
logFunnel("media_selected", {
|
|
2854
|
+
width: mediaFile.width,
|
|
2855
|
+
height: mediaFile.height,
|
|
2856
|
+
bitrate: mediaFile.bitrate,
|
|
2857
|
+
candidateIndex: mediaCandidateIndex,
|
|
2858
|
+
candidates: mediaCandidates.length
|
|
2859
|
+
});
|
|
2258
2860
|
console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad (pod ").concat(podIndex + 1, "/").concat(podAds.length || 1, ") from: ").concat(mediaFile.url));
|
|
2861
|
+
startMediaStartTimer();
|
|
2259
2862
|
if (isHlsAd && Hls.isSupported()) {
|
|
2260
2863
|
if (adHls) {
|
|
2261
2864
|
adHls.destroy();
|
|
@@ -2264,6 +2867,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2264
2867
|
enableWorker: true,
|
|
2265
2868
|
lowLatencyMode: false
|
|
2266
2869
|
});
|
|
2870
|
+
logFunnel("media_load", {
|
|
2871
|
+
pipeline: "hls.js"
|
|
2872
|
+
});
|
|
2267
2873
|
adHls.loadSource(mediaFile.url);
|
|
2268
2874
|
adHls.attachMedia(adVideoElement);
|
|
2269
2875
|
adHls.on(Hls.Events.MANIFEST_PARSED, function() {
|
|
@@ -2273,10 +2879,24 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2273
2879
|
adHls.on(Hls.Events.ERROR, function(_event, data) {
|
|
2274
2880
|
console.error("[HlsAdPlayer] HLS error:", data);
|
|
2275
2881
|
if (data.fatal) {
|
|
2276
|
-
|
|
2882
|
+
var _data_response, _data_response1, _data_frag;
|
|
2883
|
+
var vastErrorCode = data.type === Hls.ErrorTypes.NETWORK_ERROR ? 401 : VAST_ERROR_MEDIA_DISPLAY;
|
|
2884
|
+
logFunnel("hls_fatal", {
|
|
2885
|
+
reason: data.details,
|
|
2886
|
+
errorName: data.type,
|
|
2887
|
+
errorMessage: data.details,
|
|
2888
|
+
responseCode: (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.code,
|
|
2889
|
+
responseText: (_data_response1 = data.response) === null || _data_response1 === void 0 ? void 0 : _data_response1.text,
|
|
2890
|
+
fragUrl: (_data_frag = data.frag) === null || _data_frag === void 0 ? void 0 : _data_frag.url,
|
|
2891
|
+
vastErrorCode: vastErrorCode
|
|
2892
|
+
});
|
|
2893
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2277
2894
|
}
|
|
2278
2895
|
});
|
|
2279
2896
|
} else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
|
|
2897
|
+
logFunnel("media_load", {
|
|
2898
|
+
pipeline: "native-hls"
|
|
2899
|
+
});
|
|
2280
2900
|
adVideoElement.src = mediaFile.url;
|
|
2281
2901
|
startAdPlayback("native HLS ad playback");
|
|
2282
2902
|
} else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
|
|
@@ -2284,45 +2904,47 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2284
2904
|
adHls.destroy();
|
|
2285
2905
|
adHls = void 0;
|
|
2286
2906
|
}
|
|
2907
|
+
logFunnel("media_load", {
|
|
2908
|
+
pipeline: "progressive"
|
|
2909
|
+
});
|
|
2287
2910
|
adVideoElement.src = mediaFile.url;
|
|
2288
2911
|
adVideoElement.load();
|
|
2289
2912
|
startAdPlayback("progressive ad playback");
|
|
2290
2913
|
} else {
|
|
2914
|
+
clearMediaStartTimer();
|
|
2915
|
+
logFunnel("media_unsupported", {
|
|
2916
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA
|
|
2917
|
+
});
|
|
2291
2918
|
throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
|
|
2292
2919
|
}
|
|
2293
2920
|
}
|
|
2294
2921
|
function advanceToNextPodAd() {
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
index: podIndex,
|
|
2317
|
-
total: podAds.length
|
|
2318
|
-
});
|
|
2319
|
-
return true;
|
|
2320
|
-
} catch (error) {
|
|
2321
|
-
console.error("[HlsAdPlayer] Failed to load next pod ad:", error);
|
|
2322
|
-
return false;
|
|
2922
|
+
clearMediaStartTimer();
|
|
2923
|
+
while(podIndex < podAds.length - 1){
|
|
2924
|
+
settleViewability();
|
|
2925
|
+
podIndex++;
|
|
2926
|
+
currentAd = podAds[podIndex];
|
|
2927
|
+
currentAdMediaFile = void 0;
|
|
2928
|
+
resetAdTracking();
|
|
2929
|
+
if (currentAd) {
|
|
2930
|
+
console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
|
|
2931
|
+
}
|
|
2932
|
+
resetVideoElementForNextSource();
|
|
2933
|
+
try {
|
|
2934
|
+
loadCurrentAdMedia();
|
|
2935
|
+
emit("pod_ad_started", {
|
|
2936
|
+
index: podIndex,
|
|
2937
|
+
total: podAds.length
|
|
2938
|
+
});
|
|
2939
|
+
return true;
|
|
2940
|
+
} catch (error) {
|
|
2941
|
+
console.error("[HlsAdPlayer] Failed to load next pod ad:", error);
|
|
2942
|
+
}
|
|
2323
2943
|
}
|
|
2944
|
+
return false;
|
|
2324
2945
|
}
|
|
2325
2946
|
function clearStallWatchdog() {
|
|
2947
|
+
clearMediaStartTimer();
|
|
2326
2948
|
if (stallWatchdogId != null) {
|
|
2327
2949
|
clearInterval(stallWatchdogId);
|
|
2328
2950
|
stallWatchdogId = void 0;
|
|
@@ -2338,11 +2960,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2338
2960
|
function handleAdStall() {
|
|
2339
2961
|
console.warn("[HlsAdPlayer] Ad playback stalled (no progress) - recovering to avoid a blank frame");
|
|
2340
2962
|
clearStallWatchdog();
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
handleAdError();
|
|
2963
|
+
logFunnel("stall", {
|
|
2964
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
2965
|
+
});
|
|
2966
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2346
2967
|
}
|
|
2347
2968
|
function getDecodedVideoFrameCount(video) {
|
|
2348
2969
|
try {
|
|
@@ -2404,11 +3025,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2404
3025
|
function handleVideoDecodeFailure() {
|
|
2405
3026
|
console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
|
|
2406
3027
|
clearStallWatchdog();
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
handleAdError();
|
|
3028
|
+
logFunnel("decode_failure", {
|
|
3029
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
3030
|
+
});
|
|
3031
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2412
3032
|
}
|
|
2413
3033
|
function startStallWatchdog() {
|
|
2414
3034
|
clearStallWatchdog();
|
|
@@ -2532,6 +3152,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2532
3152
|
Promise.reject(new Error("Ad already playing"))
|
|
2533
3153
|
];
|
|
2534
3154
|
}
|
|
3155
|
+
if (destroyed) {
|
|
3156
|
+
return [
|
|
3157
|
+
2,
|
|
3158
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
3159
|
+
];
|
|
3160
|
+
}
|
|
3161
|
+
currentVastTagUrl = vastTagUrl;
|
|
3162
|
+
pendingRequestAbortReason = void 0;
|
|
3163
|
+
logFunnel("request_sent");
|
|
2535
3164
|
_state.label = 1;
|
|
2536
3165
|
case 1:
|
|
2537
3166
|
_state.trys.push([
|
|
@@ -2566,8 +3195,29 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2566
3195
|
ads = _state.sent();
|
|
2567
3196
|
_state.label = 4;
|
|
2568
3197
|
case 4:
|
|
3198
|
+
if (destroyed) {
|
|
3199
|
+
return [
|
|
3200
|
+
2,
|
|
3201
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
3202
|
+
];
|
|
3203
|
+
}
|
|
3204
|
+
if (!ads.length && pendingRequestAbortReason) {
|
|
3205
|
+
throw new Error(pendingRequestAbortReason);
|
|
3206
|
+
}
|
|
3207
|
+
if (!ads.length && lastPodAdElementCount > 0) {
|
|
3208
|
+
console.warn("[HlsAdPlayer] VAST response had ads but none were playable");
|
|
3209
|
+
logFunnel("vast_fill_rejected", {
|
|
3210
|
+
adElementCount: lastPodAdElementCount
|
|
3211
|
+
});
|
|
3212
|
+
emit("ad_error");
|
|
3213
|
+
return [
|
|
3214
|
+
2,
|
|
3215
|
+
Promise.reject(new Error("VAST fill rejected: no playable ad in response"))
|
|
3216
|
+
];
|
|
3217
|
+
}
|
|
2569
3218
|
if (!ads.length) {
|
|
2570
3219
|
console.warn("[HlsAdPlayer] No ads available from VAST response");
|
|
3220
|
+
logFunnel("no_fill");
|
|
2571
3221
|
emit("ad_error");
|
|
2572
3222
|
return [
|
|
2573
3223
|
2,
|
|
@@ -2578,6 +3228,23 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2578
3228
|
podIndex = 0;
|
|
2579
3229
|
currentAd = ads[0];
|
|
2580
3230
|
currentAdMediaFile = void 0;
|
|
3231
|
+
logFunnel("vast_received", {
|
|
3232
|
+
adCount: ads.length,
|
|
3233
|
+
durations: ads.map(function(ad) {
|
|
3234
|
+
return ad.duration;
|
|
3235
|
+
}),
|
|
3236
|
+
impressionUrls: ads.map(function(ad) {
|
|
3237
|
+
return ad.trackingUrls.impression.length;
|
|
3238
|
+
})
|
|
3239
|
+
});
|
|
3240
|
+
ads.forEach(function(ad, index) {
|
|
3241
|
+
if (ad.trackingUrls.impression.length === 0) {
|
|
3242
|
+
logFunnel("vast_missing_impression", {
|
|
3243
|
+
adIndex: index,
|
|
3244
|
+
missingAdId: ad.id
|
|
3245
|
+
});
|
|
3246
|
+
}
|
|
3247
|
+
});
|
|
2581
3248
|
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"));
|
|
2582
3249
|
return [
|
|
2583
3250
|
2,
|
|
@@ -2586,6 +3253,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2586
3253
|
case 5:
|
|
2587
3254
|
error = _state.sent();
|
|
2588
3255
|
console.error("[HlsAdPlayer] Error requesting ads:", error);
|
|
3256
|
+
logFunnel("request_failed", {
|
|
3257
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3258
|
+
});
|
|
2589
3259
|
emit("ad_error");
|
|
2590
3260
|
return [
|
|
2591
3261
|
2,
|
|
@@ -2641,13 +3311,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2641
3311
|
adContainerEl.style.pointerEvents = "auto";
|
|
2642
3312
|
}
|
|
2643
3313
|
emit("content_pause");
|
|
2644
|
-
|
|
3314
|
+
try {
|
|
3315
|
+
loadCurrentAdMedia();
|
|
3316
|
+
} catch (loadError) {
|
|
3317
|
+
if (!(podIndex < podAds.length - 1 && advanceToNextPodAd())) {
|
|
3318
|
+
throw loadError;
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
2645
3321
|
return [
|
|
2646
3322
|
2,
|
|
2647
3323
|
Promise.resolve()
|
|
2648
3324
|
];
|
|
2649
3325
|
} catch (error) {
|
|
2650
3326
|
console.error("[HlsAdPlayer] Error playing ad:", error);
|
|
3327
|
+
logFunnel("play_failed", {
|
|
3328
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3329
|
+
});
|
|
2651
3330
|
handleAdError();
|
|
2652
3331
|
return [
|
|
2653
3332
|
2,
|
|
@@ -2689,6 +3368,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2689
3368
|
var previousMutedState;
|
|
2690
3369
|
return _ts_generator(this, function(_state) {
|
|
2691
3370
|
console.log("[HlsAdPlayer] Stopping ad");
|
|
3371
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3372
|
+
logFunnel("stopped_before_start");
|
|
3373
|
+
}
|
|
2692
3374
|
settleViewability();
|
|
2693
3375
|
fireNotUsedForUnplayedAds();
|
|
2694
3376
|
clearStallWatchdog();
|
|
@@ -2721,15 +3403,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2721
3403
|
},
|
|
2722
3404
|
destroy: function destroy() {
|
|
2723
3405
|
console.log("[HlsAdPlayer] Destroying");
|
|
3406
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3407
|
+
logFunnel("stopped_before_start");
|
|
3408
|
+
}
|
|
2724
3409
|
settleViewability();
|
|
2725
3410
|
fireNotUsedForUnplayedAds();
|
|
2726
3411
|
destroyed = true;
|
|
2727
|
-
|
|
3412
|
+
pendingRequestAbortReason = "Ad player destroyed";
|
|
2728
3413
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2729
3414
|
try {
|
|
2730
|
-
for(var _iterator =
|
|
2731
|
-
var
|
|
2732
|
-
|
|
3415
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3416
|
+
var controller = _step.value;
|
|
3417
|
+
controller.abort();
|
|
2733
3418
|
}
|
|
2734
3419
|
} catch (err) {
|
|
2735
3420
|
_didIteratorError = true;
|
|
@@ -2745,6 +3430,28 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2745
3430
|
}
|
|
2746
3431
|
}
|
|
2747
3432
|
}
|
|
3433
|
+
pendingVastRequests.clear();
|
|
3434
|
+
clearStallWatchdog();
|
|
3435
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3436
|
+
try {
|
|
3437
|
+
for(var _iterator1 = pendingTimeouts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3438
|
+
var timeoutId = _step1.value;
|
|
3439
|
+
clearTimeout(timeoutId);
|
|
3440
|
+
}
|
|
3441
|
+
} catch (err) {
|
|
3442
|
+
_didIteratorError1 = true;
|
|
3443
|
+
_iteratorError1 = err;
|
|
3444
|
+
} finally{
|
|
3445
|
+
try {
|
|
3446
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
3447
|
+
_iterator1.return();
|
|
3448
|
+
}
|
|
3449
|
+
} finally{
|
|
3450
|
+
if (_didIteratorError1) {
|
|
3451
|
+
throw _iteratorError1;
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
}
|
|
2748
3455
|
pendingTimeouts = [];
|
|
2749
3456
|
adPlaying = false;
|
|
2750
3457
|
setAdPlayingFlag(false);
|
|
@@ -2764,6 +3471,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2764
3471
|
isAdPlaying: function isAdPlaying() {
|
|
2765
3472
|
return adPlaying;
|
|
2766
3473
|
},
|
|
3474
|
+
setFunnelContext: function setFunnelContext(context) {
|
|
3475
|
+
funnelContext = _object_spread({}, context);
|
|
3476
|
+
},
|
|
3477
|
+
abortPendingRequest: function abortPendingRequest() {
|
|
3478
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "VAST request aborted (timeout)";
|
|
3479
|
+
if (pendingVastRequests.size === 0) return;
|
|
3480
|
+
pendingRequestAbortReason = reason;
|
|
3481
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3482
|
+
try {
|
|
3483
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3484
|
+
var controller = _step.value;
|
|
3485
|
+
controller.abort();
|
|
3486
|
+
}
|
|
3487
|
+
} catch (err) {
|
|
3488
|
+
_didIteratorError = true;
|
|
3489
|
+
_iteratorError = err;
|
|
3490
|
+
} finally{
|
|
3491
|
+
try {
|
|
3492
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3493
|
+
_iterator.return();
|
|
3494
|
+
}
|
|
3495
|
+
} finally{
|
|
3496
|
+
if (_didIteratorError) {
|
|
3497
|
+
throw _iteratorError;
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
pendingVastRequests.clear();
|
|
3502
|
+
},
|
|
2767
3503
|
resize: function resize(width, height) {
|
|
2768
3504
|
console.log("[HlsAdPlayer] Resizing to ".concat(width, "x").concat(height));
|
|
2769
3505
|
if (adContainerEl) {
|
|
@@ -2799,6 +3535,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2799
3535
|
if (adVideoElement && adPlaying) {
|
|
2800
3536
|
var clamped = Math.max(0, Math.min(1, volume));
|
|
2801
3537
|
adVideoElement.volume = clamped;
|
|
3538
|
+
var userActivation = navigator.userActivation;
|
|
3539
|
+
if (clamped > 0 && forcedMuteByAutoplay && userActivation && !userActivation.isActive) {
|
|
3540
|
+
logFunnel("unmute_blocked_without_gesture", {
|
|
3541
|
+
requestedVolume: clamped
|
|
3542
|
+
});
|
|
3543
|
+
return;
|
|
3544
|
+
}
|
|
2802
3545
|
adVideoElement.muted = clamped === 0;
|
|
2803
3546
|
}
|
|
2804
3547
|
},
|
|
@@ -4913,6 +5656,21 @@ function normalizeVastTagUrl(raw) {
|
|
|
4913
5656
|
return raw;
|
|
4914
5657
|
}
|
|
4915
5658
|
}
|
|
5659
|
+
var GAM_AD_HOSTS = /* @__PURE__ */ new Set([
|
|
5660
|
+
"pubads.g.doubleclick.net",
|
|
5661
|
+
"securepubads.g.doubleclick.net"
|
|
5662
|
+
]);
|
|
5663
|
+
function ensureVideoAdType(rawUrl) {
|
|
5664
|
+
try {
|
|
5665
|
+
var url = new URL(rawUrl);
|
|
5666
|
+
if (!GAM_AD_HOSTS.has(url.hostname)) return rawUrl;
|
|
5667
|
+
if (url.searchParams.has("ad_type")) return rawUrl;
|
|
5668
|
+
url.searchParams.set("ad_type", "video");
|
|
5669
|
+
return url.toString();
|
|
5670
|
+
} catch (unused) {
|
|
5671
|
+
return rawUrl;
|
|
5672
|
+
}
|
|
5673
|
+
}
|
|
4916
5674
|
function applyVastMacros(baseUrl, ctx) {
|
|
4917
5675
|
var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
|
|
4918
5676
|
var url;
|
|
@@ -6626,7 +7384,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
6626
7384
|
} : {}), {
|
|
6627
7385
|
consent: this.consentSignals
|
|
6628
7386
|
}));
|
|
6629
|
-
var finalUrl = palNonce.injectNonce(urlWithMacros);
|
|
7387
|
+
var finalUrl = palNonce.injectNonce(ensureVideoAdType(urlWithMacros));
|
|
6630
7388
|
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);
|
|
6631
7389
|
return finalUrl;
|
|
6632
7390
|
}
|
|
@@ -6874,7 +7632,7 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6874
7632
|
{
|
|
6875
7633
|
key: "adFitsRemainingBudget",
|
|
6876
7634
|
value: function adFitsRemainingBudget(durationMs) {
|
|
6877
|
-
if (durationMs <= 0) {
|
|
7635
|
+
if (durationMs <= 0 || this.expectedAdBreakDurationMs == null) {
|
|
6878
7636
|
return true;
|
|
6879
7637
|
}
|
|
6880
7638
|
return durationMs <= this.getDurationBudgetRemainingMs();
|
|
@@ -6933,6 +7691,11 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6933
7691
|
value: function markAdStarted() {
|
|
6934
7692
|
this.currentAdIndex++;
|
|
6935
7693
|
this.totalAdsInBreak = this.currentAdIndex;
|
|
7694
|
+
}
|
|
7695
|
+
},
|
|
7696
|
+
{
|
|
7697
|
+
key: "noteAdRequestSent",
|
|
7698
|
+
value: function noteAdRequestSent() {
|
|
6936
7699
|
this.totalAdRequestsInBreak++;
|
|
6937
7700
|
this.lastAdRequestTime = Date.now();
|
|
6938
7701
|
}
|
|
@@ -6984,6 +7747,9 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6984
7747
|
if (message.includes("timeout")) {
|
|
6985
7748
|
return true;
|
|
6986
7749
|
}
|
|
7750
|
+
if (message.includes("ad player destroyed") || message.includes("aborted")) {
|
|
7751
|
+
return true;
|
|
7752
|
+
}
|
|
6987
7753
|
if (message.includes("rate limit") || message.includes("too many requests")) {
|
|
6988
7754
|
return true;
|
|
6989
7755
|
}
|
|
@@ -8110,6 +8876,18 @@ function resizePlayer(video, adPlayer, debug) {
|
|
|
8110
8876
|
}
|
|
8111
8877
|
}
|
|
8112
8878
|
// src/player/AdBreakOrchestrator.ts
|
|
8879
|
+
var REQUEST_FAILURE_STAGES = /* @__PURE__ */ new Set([
|
|
8880
|
+
"no_fill",
|
|
8881
|
+
"vast_fill_rejected",
|
|
8882
|
+
"request_failed",
|
|
8883
|
+
"media_unsupported",
|
|
8884
|
+
"play_failed",
|
|
8885
|
+
"play_resolved_but_never_started",
|
|
8886
|
+
"hls_fatal",
|
|
8887
|
+
"media_error",
|
|
8888
|
+
"stall",
|
|
8889
|
+
"decode_failure"
|
|
8890
|
+
]);
|
|
8113
8891
|
var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
8114
8892
|
"use strict";
|
|
8115
8893
|
function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
|
|
@@ -8118,11 +8896,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8118
8896
|
this.showAds = false;
|
|
8119
8897
|
this.isShowingPlaceholder = false;
|
|
8120
8898
|
this.adDetectSentForCurrentBreak = false;
|
|
8121
|
-
this.
|
|
8122
|
-
this.
|
|
8123
|
-
this.
|
|
8899
|
+
this.slotState = "IDLE";
|
|
8900
|
+
this.unusableResponsesInBreak = 0;
|
|
8901
|
+
this.controllerGeneration = 0;
|
|
8902
|
+
this.requestDiagnostics = /* @__PURE__ */ new Map();
|
|
8903
|
+
this.breakFunnel = {};
|
|
8904
|
+
this.controllerCallInFlight = false;
|
|
8905
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8906
|
+
this.opportunityEpoch = -1;
|
|
8124
8907
|
this.adPodQueue = [];
|
|
8125
|
-
this.
|
|
8908
|
+
this.defaultMinRemainingMsToRequestAd = 1e4;
|
|
8909
|
+
this.defaultMaxNoFillsPerBreak = 2;
|
|
8126
8910
|
this.pendingAdBreak = null;
|
|
8127
8911
|
this.host = host;
|
|
8128
8912
|
this.timing = timing;
|
|
@@ -8158,7 +8942,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8158
8942
|
key: "attachImaEventListeners",
|
|
8159
8943
|
value: function attachImaEventListeners() {
|
|
8160
8944
|
var _this = this;
|
|
8161
|
-
var
|
|
8945
|
+
var controller = this.host.getAdPlayer();
|
|
8946
|
+
var generation = this.controllerGeneration;
|
|
8947
|
+
var adPlayer = {
|
|
8948
|
+
on: function on(event, handler) {
|
|
8949
|
+
controller.on(event, function(payload) {
|
|
8950
|
+
if (generation !== _this.controllerGeneration) {
|
|
8951
|
+
_this.logOrchestratorFunnel("stale_callback_ignored", {
|
|
8952
|
+
event: event,
|
|
8953
|
+
staleControllerId: generation,
|
|
8954
|
+
currentControllerId: _this.controllerGeneration
|
|
8955
|
+
});
|
|
8956
|
+
return;
|
|
8957
|
+
}
|
|
8958
|
+
handler(payload);
|
|
8959
|
+
});
|
|
8960
|
+
}
|
|
8961
|
+
};
|
|
8162
8962
|
adPlayer.on("pod_ad_started", function(payload) {
|
|
8163
8963
|
_this.timing.notePodAdStarted();
|
|
8164
8964
|
if (_this.debug) {
|
|
@@ -8172,7 +8972,35 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8172
8972
|
adPlayer.on("ad_interaction", function(event) {
|
|
8173
8973
|
if (event) _this.host.onAdInteraction(event);
|
|
8174
8974
|
});
|
|
8975
|
+
adPlayer.on("ad_funnel", function(payload) {
|
|
8976
|
+
if (!(payload === null || payload === void 0 ? void 0 : payload.stage)) return;
|
|
8977
|
+
var stage = payload.stage;
|
|
8978
|
+
_this.countFunnelStage(stage);
|
|
8979
|
+
if (payload.reason) {
|
|
8980
|
+
_this.countFunnelStage("".concat(stage, ":").concat(payload.reason));
|
|
8981
|
+
}
|
|
8982
|
+
if (stage === "impression_fired" && payload.pixelCount != null) {
|
|
8983
|
+
_this.countFunnelStage("impression_urls", payload.pixelCount);
|
|
8984
|
+
}
|
|
8985
|
+
if (payload.visibilityState === "hidden") {
|
|
8986
|
+
_this.countFunnelStage("while_hidden");
|
|
8987
|
+
}
|
|
8988
|
+
if (stage === "gam_http_request_sent") {
|
|
8989
|
+
if (payload.attempt === 1) {
|
|
8990
|
+
_this.timing.noteAdRequestSent();
|
|
8991
|
+
} else {
|
|
8992
|
+
_this.countFunnelStage("gam_http_request_retry");
|
|
8993
|
+
}
|
|
8994
|
+
}
|
|
8995
|
+
_this.recordRequestDiagnostic(payload);
|
|
8996
|
+
});
|
|
8175
8997
|
adPlayer.on("ad_impression", function() {
|
|
8998
|
+
_this.timing.consecutiveFailures = 0;
|
|
8999
|
+
_this.setSlotState("PLAYING", "impression");
|
|
9000
|
+
if (!_this.playbackStartedForCurrentRequest) {
|
|
9001
|
+
_this.playbackStartedForCurrentRequest = true;
|
|
9002
|
+
_this.timing.markAdStarted();
|
|
9003
|
+
}
|
|
8176
9004
|
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
8177
9005
|
source: "hls",
|
|
8178
9006
|
adIndex: _this.timing.currentAdIndex
|
|
@@ -8187,16 +9015,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8187
9015
|
var remaining = _this.timing.getRemainingAdMs();
|
|
8188
9016
|
_this.timing.consecutiveFailures = 0;
|
|
8189
9017
|
if (_this.debug) {
|
|
8190
|
-
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms
|
|
8191
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
8192
|
-
} : {});
|
|
9018
|
+
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms"));
|
|
8193
9019
|
}
|
|
8194
9020
|
if (_this.inAdBreak) {
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
} else {
|
|
8198
|
-
_this.handleAdPodComplete();
|
|
8199
|
-
}
|
|
9021
|
+
_this.setSlotState("NEEDS_NEXT_AD", "all_ads_completed");
|
|
9022
|
+
_this.requestNextAd("all_ads_completed");
|
|
8200
9023
|
}
|
|
8201
9024
|
});
|
|
8202
9025
|
adPlayer.on("ad_error", function(errorPayload) {
|
|
@@ -8216,7 +9039,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8216
9039
|
}
|
|
8217
9040
|
}
|
|
8218
9041
|
console.error("[AD-ERROR]", errorMessage, errorPayload || "");
|
|
8219
|
-
_this.
|
|
9042
|
+
if (_this.controllerCallInFlight) {
|
|
9043
|
+
return;
|
|
9044
|
+
}
|
|
9045
|
+
_this.handleAdFailure("ad_error");
|
|
8220
9046
|
});
|
|
8221
9047
|
adPlayer.on("content_pause", function() {
|
|
8222
9048
|
_this.timing.clearAdFailsafeTimer();
|
|
@@ -8255,26 +9081,32 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8255
9081
|
}
|
|
8256
9082
|
_this.timing.consecutiveFailures = 0;
|
|
8257
9083
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
8258
|
-
var remaining = _this.timing.getRemainingAdMs();
|
|
8259
9084
|
if (_this.debug) {
|
|
8260
|
-
console.log("[
|
|
8261
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
8262
|
-
} : {});
|
|
8263
|
-
}
|
|
8264
|
-
if (_this.timing.hasTimeToStartAnotherAd()) {
|
|
8265
|
-
_this.tryNextAvailableAdWithRateLimit();
|
|
8266
|
-
} else {
|
|
8267
|
-
_this.handleAdPodComplete();
|
|
9085
|
+
console.log("[AdBreak] content_resume: remaining=".concat(_this.timing.getRemainingAdMs(), "ms"));
|
|
8268
9086
|
}
|
|
9087
|
+
_this.setSlotState("NEEDS_NEXT_AD", "ad_complete");
|
|
9088
|
+
_this.requestNextAd("ad_complete");
|
|
8269
9089
|
});
|
|
8270
9090
|
}
|
|
8271
9091
|
},
|
|
8272
9092
|
{
|
|
8273
9093
|
key: "recreateAdController",
|
|
8274
|
-
value: function recreateAdController() {
|
|
8275
|
-
if (this.
|
|
8276
|
-
console.
|
|
9094
|
+
value: function recreateAdController(reason) {
|
|
9095
|
+
if (reason === "new_request" && (this.slotState === "REQUESTING" || this.slotState === "READY")) {
|
|
9096
|
+
console.warn("[AD-CONTROLLER] destroy during active request", {
|
|
9097
|
+
controllerId: this.controllerGeneration,
|
|
9098
|
+
requestId: this.currentRequestId,
|
|
9099
|
+
state: this.slotState,
|
|
9100
|
+
reason: reason
|
|
9101
|
+
});
|
|
8277
9102
|
}
|
|
9103
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
9104
|
+
controllerId: this.controllerGeneration,
|
|
9105
|
+
requestId: this.currentRequestId,
|
|
9106
|
+
state: this.slotState,
|
|
9107
|
+
reason: reason
|
|
9108
|
+
});
|
|
9109
|
+
this.countFunnelStage("controller_destroy:".concat(reason));
|
|
8278
9110
|
var shouldShowPlaceholder = this.inAdBreak && this.showAds;
|
|
8279
9111
|
var adPlayer = this.host.getAdPlayer();
|
|
8280
9112
|
if (shouldShowPlaceholder && adPlayer) {
|
|
@@ -8287,6 +9119,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8287
9119
|
}
|
|
8288
9120
|
var preservedMutedState = adPlayer.getOriginalMutedState();
|
|
8289
9121
|
var preservedVolumeState = adPlayer.getOriginalVolume();
|
|
9122
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8290
9123
|
if (adPlayer) {
|
|
8291
9124
|
try {
|
|
8292
9125
|
adPlayer.destroy();
|
|
@@ -8300,9 +9133,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8300
9133
|
var continueLiveStreamDuringAds = this.host.shouldContinueLiveStreamDuringAds();
|
|
8301
9134
|
var newAdPlayer = this.host.createAdPlayer(continueLiveStreamDuringAds);
|
|
8302
9135
|
this.host.setAdPlayer(newAdPlayer);
|
|
9136
|
+
this.controllerGeneration++;
|
|
8303
9137
|
newAdPlayer.initialize();
|
|
8304
9138
|
newAdPlayer.updateOriginalMutedState(preservedMutedState, preservedVolumeState);
|
|
8305
9139
|
this.attachImaEventListeners();
|
|
9140
|
+
if (this.debug) {
|
|
9141
|
+
console.log("[AD-CONTROLLER] create", {
|
|
9142
|
+
controllerId: this.controllerGeneration,
|
|
9143
|
+
reason: reason
|
|
9144
|
+
});
|
|
9145
|
+
}
|
|
8306
9146
|
if (shouldShowPlaceholder) {
|
|
8307
9147
|
this.placeholder.show();
|
|
8308
9148
|
newAdPlayer.showPlaceholder();
|
|
@@ -8323,32 +9163,57 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8323
9163
|
}
|
|
8324
9164
|
},
|
|
8325
9165
|
{
|
|
8326
|
-
|
|
8327
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9166
|
+
// ───────────────────────────────────────────────────────────────
|
|
8328
9167
|
// Ad break start
|
|
8329
9168
|
// ───────────────────────────────────────────────────────────────
|
|
8330
|
-
|
|
9169
|
+
key: "isBreakActive",
|
|
9170
|
+
value: function isBreakActive() {
|
|
9171
|
+
return this.slotState !== "IDLE";
|
|
9172
|
+
}
|
|
9173
|
+
},
|
|
9174
|
+
{
|
|
9175
|
+
key: "getSlotState",
|
|
9176
|
+
value: function getSlotState() {
|
|
9177
|
+
return this.slotState;
|
|
9178
|
+
}
|
|
9179
|
+
},
|
|
9180
|
+
{
|
|
9181
|
+
key: "beginVmapBreak",
|
|
9182
|
+
value: function beginVmapBreak(breakKey) {
|
|
9183
|
+
this.breakSource = "vmap";
|
|
9184
|
+
this.followUpBaseVastUrl = void 0;
|
|
9185
|
+
this.unusableResponsesInBreak = 0;
|
|
9186
|
+
this.timing.totalAdRequestsInBreak = 0;
|
|
9187
|
+
this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
|
|
9188
|
+
this.noteOpportunity("vmap", breakKey);
|
|
9189
|
+
}
|
|
9190
|
+
},
|
|
9191
|
+
{
|
|
9192
|
+
key: "handleAdStart",
|
|
9193
|
+
value: function handleAdStart(marker) {
|
|
8331
9194
|
return _async_to_generator(function() {
|
|
8332
|
-
var
|
|
9195
|
+
var baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, epoch, podPlayed;
|
|
8333
9196
|
return _ts_generator(this, function(_state) {
|
|
8334
9197
|
switch(_state.label){
|
|
8335
9198
|
case 0:
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
9199
|
+
if (this.slotState !== "IDLE") {
|
|
9200
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
9201
|
+
source: "scte35",
|
|
9202
|
+
state: this.slotState
|
|
9203
|
+
});
|
|
9204
|
+
return [
|
|
9205
|
+
2
|
|
9206
|
+
];
|
|
8339
9207
|
}
|
|
8340
|
-
|
|
8341
|
-
if (
|
|
8342
|
-
|
|
8343
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
8344
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
8345
|
-
} else {
|
|
9208
|
+
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
9209
|
+
if (!baseVastUrl) {
|
|
9210
|
+
console.warn("[AdBreak] SCTE-35 break started but no direct VAST tag is configured");
|
|
8346
9211
|
this.clearPendingAdBreak();
|
|
8347
9212
|
return [
|
|
8348
9213
|
2
|
|
8349
9214
|
];
|
|
8350
9215
|
}
|
|
8351
|
-
adBreakDurationMs =
|
|
9216
|
+
adBreakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : this.timing.expectedAdBreakDurationMs;
|
|
8352
9217
|
if (this.debug) {
|
|
8353
9218
|
mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
|
|
8354
9219
|
console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
@@ -8356,9 +9221,12 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8356
9221
|
this.timing.failedVastUrls.clear();
|
|
8357
9222
|
this.timing.temporaryFailureUrls.clear();
|
|
8358
9223
|
this.timing.consecutiveFailures = 0;
|
|
8359
|
-
this.continuousFetchingActive = true;
|
|
8360
9224
|
this.isShowingPlaceholder = false;
|
|
8361
9225
|
this.timing.totalAdRequestsInBreak = 0;
|
|
9226
|
+
this.breakSource = "scte35";
|
|
9227
|
+
this.followUpBaseVastUrl = baseVastUrl;
|
|
9228
|
+
this.unusableResponsesInBreak = 0;
|
|
9229
|
+
this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
|
|
8362
9230
|
if (this.adConfig.podAssignedByPrefetch) {
|
|
8363
9231
|
this.adConfig.podAssignedByPrefetch = false;
|
|
8364
9232
|
} else {
|
|
@@ -8376,29 +9244,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8376
9244
|
if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
8377
9245
|
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
8378
9246
|
}
|
|
9247
|
+
this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
|
|
9248
|
+
epoch = this.timing.adBreakEpoch;
|
|
8379
9249
|
return [
|
|
8380
9250
|
4,
|
|
8381
|
-
this.startOptimizedPod(baseVastUrl, adBreakDurationMs
|
|
9251
|
+
this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
|
|
8382
9252
|
];
|
|
8383
9253
|
case 1:
|
|
8384
9254
|
podPlayed = _state.sent();
|
|
8385
|
-
if (
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
];
|
|
8389
|
-
if (this.debug) {
|
|
8390
|
-
console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
|
|
9255
|
+
if (!podPlayed && this.inAdBreak && epoch === this.timing.adBreakEpoch) {
|
|
9256
|
+
this.setSlotState("NEEDS_NEXT_AD", "initial_request_failed");
|
|
9257
|
+
this.requestNextAd("initial_request_failed");
|
|
8391
9258
|
}
|
|
8392
|
-
this.continuousFetchingActive = true;
|
|
8393
|
-
this.startContinuousFetching(baseVastUrl);
|
|
8394
|
-
return [
|
|
8395
|
-
4,
|
|
8396
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
8397
|
-
];
|
|
8398
|
-
case 2:
|
|
8399
|
-
_state.sent();
|
|
8400
|
-
_state.label = 3;
|
|
8401
|
-
case 3:
|
|
8402
9259
|
return [
|
|
8403
9260
|
2
|
|
8404
9261
|
];
|
|
@@ -8412,12 +9269,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8412
9269
|
value: // ───────────────────────────────────────────────────────────────
|
|
8413
9270
|
// Optimized pod (single multi-ad request)
|
|
8414
9271
|
// ───────────────────────────────────────────────────────────────
|
|
8415
|
-
function startOptimizedPod(baseVastUrl, breakDurationMs
|
|
9272
|
+
function startOptimizedPod(baseVastUrl, breakDurationMs) {
|
|
8416
9273
|
return _async_to_generator(function() {
|
|
8417
|
-
var podUrl, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
9274
|
+
var podUrl, prefetched, epoch, generation, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
8418
9275
|
return _ts_generator(this, function(_state) {
|
|
8419
9276
|
switch(_state.label){
|
|
8420
9277
|
case 0:
|
|
9278
|
+
prefetched = !!(this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0);
|
|
8421
9279
|
if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
|
|
8422
9280
|
podUrl = this.pendingAdBreak.vastUrls[0];
|
|
8423
9281
|
this.clearPendingAdBreak();
|
|
@@ -8430,12 +9288,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8430
9288
|
false
|
|
8431
9289
|
];
|
|
8432
9290
|
}
|
|
8433
|
-
this.
|
|
8434
|
-
this.
|
|
9291
|
+
this.noteVastUrlGenerated(podUrl, prefetched ? "prefetch" : "break_start");
|
|
9292
|
+
epoch = this.timing.adBreakEpoch;
|
|
9293
|
+
this.recreateAdController("new_request");
|
|
9294
|
+
generation = this.controllerGeneration;
|
|
8435
9295
|
adPlayer = this.host.getAdPlayer();
|
|
8436
9296
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8437
9297
|
this.timing.activeAdRequestToken = requestToken;
|
|
8438
9298
|
this.currentVastUrl = podUrl;
|
|
9299
|
+
this.setSlotState("REQUESTING", "initial_pod");
|
|
9300
|
+
this.beginFunnelRequest(adPlayer, requestToken, "initial_pod");
|
|
8439
9301
|
_state.label = 1;
|
|
8440
9302
|
case 1:
|
|
8441
9303
|
_state.trys.push([
|
|
@@ -8450,16 +9312,24 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8450
9312
|
];
|
|
8451
9313
|
case 2:
|
|
8452
9314
|
_state.sent();
|
|
9315
|
+
if (this.isStale(epoch, generation)) return [
|
|
9316
|
+
2,
|
|
9317
|
+
true
|
|
9318
|
+
];
|
|
8453
9319
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
8454
|
-
this.timing.lastAdRequestTime = Date.now();
|
|
8455
9320
|
return [
|
|
8456
9321
|
4,
|
|
8457
|
-
|
|
9322
|
+
this.callController(function() {
|
|
9323
|
+
return adPlayer.requestAds(podUrl);
|
|
9324
|
+
})
|
|
8458
9325
|
];
|
|
8459
9326
|
case 3:
|
|
8460
9327
|
_state.sent();
|
|
8461
9328
|
this.timing.clearAdRequestWatchdog();
|
|
8462
|
-
if (this.
|
|
9329
|
+
if (this.isStale(epoch, generation)) {
|
|
9330
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9331
|
+
requestId: requestToken
|
|
9332
|
+
});
|
|
8463
9333
|
return [
|
|
8464
9334
|
2,
|
|
8465
9335
|
true
|
|
@@ -8467,11 +9337,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8467
9337
|
}
|
|
8468
9338
|
podCount = (_ref = (_adPlayer_getPodAdCount = adPlayer.getPodAdCount) === null || _adPlayer_getPodAdCount === void 0 ? void 0 : _adPlayer_getPodAdCount.call(adPlayer)) !== null && _ref !== void 0 ? _ref : 1;
|
|
8469
9339
|
if (podCount < 1) {
|
|
9340
|
+
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9341
|
+
this.timing.activeAdRequestToken = null;
|
|
9342
|
+
}
|
|
9343
|
+
this.recordRequestFailure(new Error("No ads available"), podUrl);
|
|
8470
9344
|
return [
|
|
8471
9345
|
2,
|
|
8472
9346
|
false
|
|
8473
9347
|
];
|
|
8474
9348
|
}
|
|
9349
|
+
this.setSlotState("READY", "vast_ready");
|
|
8475
9350
|
if (this.debug) {
|
|
8476
9351
|
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"));
|
|
8477
9352
|
}
|
|
@@ -8483,18 +9358,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8483
9358
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
8484
9359
|
return [
|
|
8485
9360
|
4,
|
|
8486
|
-
|
|
9361
|
+
this.callController(function() {
|
|
9362
|
+
return adPlayer.play();
|
|
9363
|
+
})
|
|
8487
9364
|
];
|
|
8488
9365
|
case 4:
|
|
8489
9366
|
_state.sent();
|
|
8490
|
-
this.
|
|
9367
|
+
if (this.isStale(epoch, generation)) return [
|
|
9368
|
+
2,
|
|
9369
|
+
true
|
|
9370
|
+
];
|
|
8491
9371
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
8492
9372
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
8493
9373
|
}
|
|
8494
|
-
adPlayer.setAdVolume(
|
|
8495
|
-
this.timing.consecutiveFailures = 0;
|
|
8496
|
-
this.continuousFetchingActive = true;
|
|
8497
|
-
this.startContinuousFetching(baseVastUrl);
|
|
9374
|
+
adPlayer.setAdVolume(getAdAudioVolume(adPlayer));
|
|
8498
9375
|
return [
|
|
8499
9376
|
2,
|
|
8500
9377
|
true
|
|
@@ -8506,14 +9383,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8506
9383
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
8507
9384
|
this.timing.activeAdRequestToken = null;
|
|
8508
9385
|
}
|
|
9386
|
+
if (this.isStale(epoch, generation)) {
|
|
9387
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
9388
|
+
requestId: requestToken,
|
|
9389
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
9390
|
+
});
|
|
9391
|
+
return [
|
|
9392
|
+
2,
|
|
9393
|
+
true
|
|
9394
|
+
];
|
|
9395
|
+
}
|
|
8509
9396
|
if (this.debug) {
|
|
8510
9397
|
console.warn("[POD] Optimized pod request/play failed:", error);
|
|
8511
9398
|
}
|
|
8512
|
-
|
|
8513
|
-
this.timing.temporaryFailureUrls.set(podUrl, Date.now());
|
|
8514
|
-
}
|
|
8515
|
-
this.continuousFetchingActive = true;
|
|
8516
|
-
this.recreateAdController();
|
|
9399
|
+
this.recordRequestFailure(error, podUrl);
|
|
8517
9400
|
return [
|
|
8518
9401
|
2,
|
|
8519
9402
|
false
|
|
@@ -8529,168 +9412,204 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8529
9412
|
},
|
|
8530
9413
|
{
|
|
8531
9414
|
// ───────────────────────────────────────────────────────────────
|
|
8532
|
-
//
|
|
9415
|
+
// Next-ad scheduling (single flight)
|
|
8533
9416
|
// ───────────────────────────────────────────────────────────────
|
|
8534
|
-
key: "
|
|
8535
|
-
value: function
|
|
8536
|
-
if (
|
|
9417
|
+
key: "setSlotState",
|
|
9418
|
+
value: function setSlotState(next, reason) {
|
|
9419
|
+
if (this.slotState === next) return;
|
|
9420
|
+
var previous = this.slotState;
|
|
9421
|
+
this.slotState = next;
|
|
9422
|
+
if (this.debug) {
|
|
9423
|
+
console.log("[AdBreak][STATE] ".concat(previous, " -> ").concat(next), {
|
|
9424
|
+
reason: reason,
|
|
9425
|
+
breakId: this.timing.adBreakEpoch,
|
|
9426
|
+
requestId: this.currentRequestId,
|
|
9427
|
+
controllerId: this.controllerGeneration
|
|
9428
|
+
});
|
|
9429
|
+
}
|
|
9430
|
+
}
|
|
9431
|
+
},
|
|
9432
|
+
{
|
|
9433
|
+
key: "isStale",
|
|
9434
|
+
value: function isStale(epoch, generation) {
|
|
9435
|
+
return !this.inAdBreak || epoch !== this.timing.adBreakEpoch || generation !== this.controllerGeneration;
|
|
9436
|
+
}
|
|
9437
|
+
},
|
|
9438
|
+
{
|
|
9439
|
+
key: "getMinRemainingMsToRequestAd",
|
|
9440
|
+
value: function getMinRemainingMsToRequestAd() {
|
|
9441
|
+
var configured = this.host.config.minRemainingMsToRequestAd;
|
|
9442
|
+
var floor = this.timing.getMinRemainingMsToStartAd();
|
|
9443
|
+
if (typeof configured === "number" && configured >= 0) {
|
|
9444
|
+
return Math.max(configured, floor);
|
|
9445
|
+
}
|
|
9446
|
+
return Math.max(this.defaultMinRemainingMsToRequestAd, floor);
|
|
9447
|
+
}
|
|
9448
|
+
},
|
|
9449
|
+
{
|
|
9450
|
+
key: "getMaxNoFillsPerBreak",
|
|
9451
|
+
value: function getMaxNoFillsPerBreak() {
|
|
9452
|
+
var configured = this.host.config.maxNoFillsPerBreak;
|
|
9453
|
+
return typeof configured === "number" && configured > 0 ? configured : this.defaultMaxNoFillsPerBreak;
|
|
9454
|
+
}
|
|
9455
|
+
},
|
|
9456
|
+
{
|
|
9457
|
+
key: "isBreakTimeBounded",
|
|
9458
|
+
value: function isBreakTimeBounded() {
|
|
9459
|
+
return this.breakSource === "scte35" || this.timing.expectedAdBreakDurationMs != null;
|
|
9460
|
+
}
|
|
9461
|
+
},
|
|
9462
|
+
{
|
|
9463
|
+
key: "getStopRequestingReason",
|
|
9464
|
+
value: function getStopRequestingReason(remainingMs) {
|
|
9465
|
+
if (this.breakSource === "vmap") {
|
|
9466
|
+
if (this.adPodQueue.length === 0) return "vmap_queue_empty";
|
|
9467
|
+
} else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl) {
|
|
9468
|
+
return "no_follow_up_source";
|
|
9469
|
+
}
|
|
9470
|
+
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9471
|
+
return "max_consecutive_failures";
|
|
9472
|
+
}
|
|
9473
|
+
if (this.unusableResponsesInBreak >= this.getMaxNoFillsPerBreak()) {
|
|
9474
|
+
return "unusable_response_limit";
|
|
9475
|
+
}
|
|
9476
|
+
if (this.timing.totalAdRequestsInBreak >= this.timing.maxTotalAdRequestsPerBreak) {
|
|
9477
|
+
return "request_cap";
|
|
9478
|
+
}
|
|
9479
|
+
if (this.timing.isGamInCooldown()) {
|
|
9480
|
+
return "gam_cooldown";
|
|
9481
|
+
}
|
|
9482
|
+
if (this.isBreakTimeBounded() && remainingMs < this.getMinRemainingMsToRequestAd()) {
|
|
9483
|
+
return "insufficient_break_time";
|
|
9484
|
+
}
|
|
9485
|
+
return void 0;
|
|
9486
|
+
}
|
|
9487
|
+
},
|
|
9488
|
+
{
|
|
9489
|
+
key: "getNextRequestDelayMs",
|
|
9490
|
+
value: function getNextRequestDelayMs() {
|
|
9491
|
+
var failures = this.timing.consecutiveFailures;
|
|
9492
|
+
var backoff = failures > 0 ? Math.min(this.timing.backoffBaseMs * Math.pow(2, failures), this.timing.maxBackoffMs) : 0;
|
|
9493
|
+
var minInterval = this.timing.minAdRequestIntervalMs + backoff;
|
|
9494
|
+
var sinceLast = Date.now() - this.timing.lastAdRequestTime;
|
|
9495
|
+
return Math.max(0, minInterval - sinceLast);
|
|
9496
|
+
}
|
|
9497
|
+
},
|
|
9498
|
+
{
|
|
9499
|
+
key: "requestNextAd",
|
|
9500
|
+
value: function requestNextAd(trigger) {
|
|
9501
|
+
var _this = this;
|
|
9502
|
+
if (!this.inAdBreak) return;
|
|
9503
|
+
if (this.slotState !== "NEEDS_NEXT_AD") {
|
|
9504
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9505
|
+
trigger: trigger,
|
|
9506
|
+
state: this.slotState,
|
|
9507
|
+
why: "slot_busy"
|
|
9508
|
+
});
|
|
8537
9509
|
return;
|
|
8538
9510
|
}
|
|
8539
|
-
if (this.
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
9511
|
+
if (this.nextAdTimerId != null) {
|
|
9512
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9513
|
+
trigger: trigger,
|
|
9514
|
+
state: this.slotState,
|
|
9515
|
+
why: "request_already_scheduled"
|
|
9516
|
+
});
|
|
8543
9517
|
return;
|
|
8544
9518
|
}
|
|
8545
|
-
|
|
8546
|
-
|
|
9519
|
+
var remainingMs = this.timing.getRemainingAdMs();
|
|
9520
|
+
var stopReason = this.getStopRequestingReason(remainingMs);
|
|
9521
|
+
if (stopReason) {
|
|
9522
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9523
|
+
trigger: trigger,
|
|
9524
|
+
decision: "end_break",
|
|
9525
|
+
reason: stopReason,
|
|
9526
|
+
remainingMs: remainingMs,
|
|
9527
|
+
requestsSent: this.timing.totalAdRequestsInBreak,
|
|
9528
|
+
unusableResponses: this.unusableResponsesInBreak,
|
|
9529
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
9530
|
+
});
|
|
9531
|
+
this.handleAdPodComplete(stopReason);
|
|
9532
|
+
return;
|
|
9533
|
+
}
|
|
9534
|
+
var waitMs = this.getNextRequestDelayMs();
|
|
9535
|
+
if (waitMs > 0 && this.isBreakTimeBounded() && remainingMs - waitMs < this.getMinRemainingMsToRequestAd()) {
|
|
9536
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9537
|
+
trigger: trigger,
|
|
9538
|
+
decision: "end_break",
|
|
9539
|
+
reason: "insufficient_break_time_after_backoff",
|
|
9540
|
+
remainingMs: remainingMs,
|
|
9541
|
+
waitMs: waitMs
|
|
9542
|
+
});
|
|
9543
|
+
this.handleAdPodComplete("insufficient_break_time_after_backoff");
|
|
9544
|
+
return;
|
|
9545
|
+
}
|
|
9546
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
9547
|
+
trigger: trigger,
|
|
9548
|
+
decision: waitMs > 0 ? "request_after_delay" : "request_now",
|
|
9549
|
+
waitMs: waitMs,
|
|
9550
|
+
remainingMs: remainingMs,
|
|
9551
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
9552
|
+
});
|
|
9553
|
+
if (waitMs > 0) {
|
|
9554
|
+
if (!this.isShowingPlaceholder) {
|
|
9555
|
+
this.isShowingPlaceholder = true;
|
|
9556
|
+
this.host.getAdPlayer().showPlaceholder();
|
|
9557
|
+
}
|
|
9558
|
+
var epoch = this.timing.adBreakEpoch;
|
|
9559
|
+
this.nextAdTimerId = window.setTimeout(function() {
|
|
9560
|
+
_this.nextAdTimerId = void 0;
|
|
9561
|
+
if (!_this.inAdBreak || epoch !== _this.timing.adBreakEpoch) return;
|
|
9562
|
+
_this.requestNextAd("".concat(trigger, ":after_delay"));
|
|
9563
|
+
}, waitMs);
|
|
9564
|
+
return;
|
|
8547
9565
|
}
|
|
8548
|
-
this.
|
|
8549
|
-
this.continuousFetchLoop(baseVastUrl);
|
|
9566
|
+
void this.requestFollowUpAd(trigger);
|
|
8550
9567
|
}
|
|
8551
9568
|
},
|
|
8552
9569
|
{
|
|
8553
|
-
key: "
|
|
8554
|
-
value: function
|
|
9570
|
+
key: "requestFollowUpAd",
|
|
9571
|
+
value: function requestFollowUpAd(trigger) {
|
|
8555
9572
|
return _async_to_generator(function() {
|
|
8556
|
-
var
|
|
9573
|
+
var url, epoch, unused;
|
|
8557
9574
|
return _ts_generator(this, function(_state) {
|
|
8558
9575
|
switch(_state.label){
|
|
8559
9576
|
case 0:
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
}
|
|
8570
|
-
return [
|
|
8571
|
-
2,
|
|
8572
|
-
"break"
|
|
8573
|
-
];
|
|
8574
|
-
}
|
|
8575
|
-
if (_this.timing.isGamInCooldown()) {
|
|
8576
|
-
if (_this.debug) {
|
|
8577
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping URL generation");
|
|
8578
|
-
}
|
|
8579
|
-
return [
|
|
8580
|
-
2,
|
|
8581
|
-
"break"
|
|
8582
|
-
];
|
|
8583
|
-
}
|
|
8584
|
-
if (_this.timing.consecutiveFailures >= _this.timing.maxConsecutiveFailures) {
|
|
8585
|
-
if (_this.debug) {
|
|
8586
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(_this.timing.consecutiveFailures, "), stopping URL generation"));
|
|
8587
|
-
}
|
|
8588
|
-
return [
|
|
8589
|
-
2,
|
|
8590
|
-
"break"
|
|
8591
|
-
];
|
|
8592
|
-
}
|
|
8593
|
-
if (_this.timing.totalAdRequestsInBreak >= _this.timing.maxTotalAdRequestsPerBreak) {
|
|
8594
|
-
if (_this.debug) {
|
|
8595
|
-
console.log("[CONTINUOUS-FETCH] Maximum ad requests reached (".concat(_this.timing.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
8596
|
-
}
|
|
8597
|
-
return [
|
|
8598
|
-
2,
|
|
8599
|
-
"break"
|
|
8600
|
-
];
|
|
8601
|
-
}
|
|
8602
|
-
maxQueueSize = 5;
|
|
8603
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
8604
|
-
3,
|
|
8605
|
-
2
|
|
8606
|
-
];
|
|
8607
|
-
if (_this.debug) {
|
|
8608
|
-
console.log("[CONTINUOUS-FETCH] URL queue full (".concat(_this.adRequestQueue.length, "), waiting..."));
|
|
8609
|
-
}
|
|
8610
|
-
return [
|
|
8611
|
-
4,
|
|
8612
|
-
new Promise(function(resolve) {
|
|
8613
|
-
return setTimeout(resolve, 1e3);
|
|
8614
|
-
})
|
|
8615
|
-
];
|
|
8616
|
-
case 1:
|
|
8617
|
-
_state.sent();
|
|
8618
|
-
return [
|
|
8619
|
-
2,
|
|
8620
|
-
"continue"
|
|
8621
|
-
];
|
|
8622
|
-
case 2:
|
|
8623
|
-
newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
|
|
8624
|
-
if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
|
|
8625
|
-
3,
|
|
8626
|
-
4
|
|
8627
|
-
];
|
|
8628
|
-
return [
|
|
8629
|
-
4,
|
|
8630
|
-
new Promise(function(resolve) {
|
|
8631
|
-
return setTimeout(resolve, 500);
|
|
8632
|
-
})
|
|
8633
|
-
];
|
|
8634
|
-
case 3:
|
|
8635
|
-
_state.sent();
|
|
8636
|
-
return [
|
|
8637
|
-
2,
|
|
8638
|
-
"continue"
|
|
8639
|
-
];
|
|
8640
|
-
case 4:
|
|
8641
|
-
if (_this.debug) {
|
|
8642
|
-
queuedUrlsPreview = _to_consumable_array(_this.adRequestQueue).concat([
|
|
8643
|
-
newAdUrl
|
|
8644
|
-
]);
|
|
8645
|
-
console.log("[CONTINUOUS-FETCH] Queued VAST URL (queue size: ".concat(queuedUrlsPreview.length, ")"), {
|
|
8646
|
-
queuedUrls: queuedUrlsPreview
|
|
8647
|
-
});
|
|
8648
|
-
}
|
|
8649
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
8650
|
-
generationDelay = _this.timing.consecutiveFailures > 0 ? Math.min(1e3 * Math.pow(2, _this.timing.consecutiveFailures), 5e3) : 500;
|
|
8651
|
-
return [
|
|
8652
|
-
4,
|
|
8653
|
-
new Promise(function(resolve) {
|
|
8654
|
-
return setTimeout(resolve, generationDelay);
|
|
8655
|
-
})
|
|
8656
|
-
];
|
|
8657
|
-
case 5:
|
|
8658
|
-
_state.sent();
|
|
8659
|
-
return [
|
|
8660
|
-
2
|
|
8661
|
-
];
|
|
8662
|
-
}
|
|
8663
|
-
});
|
|
8664
|
-
};
|
|
9577
|
+
if (this.breakSource === "vmap") {
|
|
9578
|
+
url = this.adPodQueue.shift();
|
|
9579
|
+
} else if (this.followUpBaseVastUrl) {
|
|
9580
|
+
url = this.nextAdRequestUrl(this.followUpBaseVastUrl);
|
|
9581
|
+
}
|
|
9582
|
+
if (!url) return [
|
|
9583
|
+
2
|
|
9584
|
+
];
|
|
9585
|
+
this.noteVastUrlGenerated(ensureVideoAdType(url), trigger);
|
|
8665
9586
|
epoch = this.timing.adBreakEpoch;
|
|
8666
9587
|
_state.label = 1;
|
|
8667
9588
|
case 1:
|
|
8668
|
-
|
|
9589
|
+
_state.trys.push([
|
|
9590
|
+
1,
|
|
8669
9591
|
3,
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
9592
|
+
,
|
|
9593
|
+
4
|
|
9594
|
+
]);
|
|
8673
9595
|
return [
|
|
8674
|
-
|
|
8675
|
-
|
|
9596
|
+
4,
|
|
9597
|
+
this.playSingleAd(url, trigger)
|
|
8676
9598
|
];
|
|
8677
9599
|
case 2:
|
|
8678
|
-
|
|
8679
|
-
|
|
9600
|
+
_state.sent();
|
|
9601
|
+
return [
|
|
8680
9602
|
3,
|
|
8681
|
-
|
|
9603
|
+
4
|
|
8682
9604
|
];
|
|
9605
|
+
case 3:
|
|
9606
|
+
unused = _state.sent();
|
|
9607
|
+
this.continueAfterRequestFailure(epoch);
|
|
8683
9608
|
return [
|
|
8684
9609
|
3,
|
|
8685
|
-
|
|
9610
|
+
4
|
|
8686
9611
|
];
|
|
8687
|
-
case
|
|
8688
|
-
this.continuousFetchLoopRunning = false;
|
|
8689
|
-
if (this.debug) {
|
|
8690
|
-
console.log("[CONTINUOUS-FETCH] URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"), this.adRequestQueue.length > 0 ? {
|
|
8691
|
-
queuedUrls: _to_consumable_array(this.adRequestQueue)
|
|
8692
|
-
} : {});
|
|
8693
|
-
}
|
|
9612
|
+
case 4:
|
|
8694
9613
|
return [
|
|
8695
9614
|
2
|
|
8696
9615
|
];
|
|
@@ -8700,236 +9619,318 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8700
9619
|
}
|
|
8701
9620
|
},
|
|
8702
9621
|
{
|
|
8703
|
-
key: "
|
|
8704
|
-
value: function
|
|
8705
|
-
|
|
8706
|
-
this.
|
|
8707
|
-
this.
|
|
8708
|
-
|
|
8709
|
-
|
|
9622
|
+
key: "continueAfterRequestFailure",
|
|
9623
|
+
value: function continueAfterRequestFailure() {
|
|
9624
|
+
var epoch = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.timing.adBreakEpoch;
|
|
9625
|
+
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) return;
|
|
9626
|
+
this.setSlotState("NEEDS_NEXT_AD", "request_failed");
|
|
9627
|
+
this.requestNextAd("after_failure");
|
|
9628
|
+
}
|
|
9629
|
+
},
|
|
9630
|
+
{
|
|
9631
|
+
key: "cancelScheduledRequest",
|
|
9632
|
+
value: function cancelScheduledRequest() {
|
|
9633
|
+
if (this.nextAdTimerId != null) {
|
|
9634
|
+
clearTimeout(this.nextAdTimerId);
|
|
9635
|
+
this.nextAdTimerId = void 0;
|
|
8710
9636
|
}
|
|
8711
9637
|
}
|
|
8712
9638
|
},
|
|
8713
9639
|
{
|
|
8714
|
-
key: "
|
|
8715
|
-
value:
|
|
8716
|
-
|
|
9640
|
+
key: "noteVastUrlGenerated",
|
|
9641
|
+
value: function noteVastUrlGenerated(url, source) {
|
|
9642
|
+
var _ref, _ref1, _ref2, _ref3, _ref4;
|
|
9643
|
+
var params;
|
|
9644
|
+
try {
|
|
9645
|
+
params = new URL(url).searchParams;
|
|
9646
|
+
} catch (unused) {}
|
|
9647
|
+
var adType = (_ref = params === null || params === void 0 ? void 0 : params.get("ad_type")) !== null && _ref !== void 0 ? _ref : void 0;
|
|
9648
|
+
this.logOrchestratorFunnel("vast_url_generated", {
|
|
9649
|
+
source: source,
|
|
9650
|
+
pod: (_ref1 = params === null || params === void 0 ? void 0 : params.get("pod")) !== null && _ref1 !== void 0 ? _ref1 : void 0,
|
|
9651
|
+
pmad: (_ref2 = params === null || params === void 0 ? void 0 : params.get("pmad")) !== null && _ref2 !== void 0 ? _ref2 : void 0,
|
|
9652
|
+
pmnd: (_ref3 = params === null || params === void 0 ? void 0 : params.get("pmnd")) !== null && _ref3 !== void 0 ? _ref3 : void 0,
|
|
9653
|
+
pmxd: (_ref4 = params === null || params === void 0 ? void 0 : params.get("pmxd")) !== null && _ref4 !== void 0 ? _ref4 : void 0,
|
|
9654
|
+
adType: adType
|
|
9655
|
+
});
|
|
9656
|
+
if (adType === "audio" || adType === "audio_video") {
|
|
9657
|
+
console.warn("[AdBreak] VAST tag requests ad_type=".concat(adType, "; GAM may return audio-only creatives, which this video player rejects"));
|
|
9658
|
+
this.countFunnelStage("tag_allows_audio");
|
|
9659
|
+
}
|
|
9660
|
+
}
|
|
9661
|
+
},
|
|
9662
|
+
{
|
|
9663
|
+
key: "recordRequestFailure",
|
|
9664
|
+
value: function recordRequestFailure(error, vastTagUrl) {
|
|
9665
|
+
var _diag_vastAdCount;
|
|
9666
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
9667
|
+
var message = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
9668
|
+
var outcome;
|
|
9669
|
+
if (message.includes("ad_duration_exceeds_budget")) {
|
|
9670
|
+
outcome = "discarded_budget";
|
|
9671
|
+
} else if (message.includes("VAST fill rejected")) {
|
|
9672
|
+
outcome = "fill_rejected";
|
|
9673
|
+
} else if (/no ads available|no fill|nofill/i.test(message)) {
|
|
9674
|
+
outcome = "no_fill";
|
|
9675
|
+
} else if (/timeout/i.test(message)) {
|
|
9676
|
+
outcome = "request_timeout";
|
|
9677
|
+
} else if (/destroyed|aborted/i.test(message)) {
|
|
9678
|
+
outcome = "request_aborted";
|
|
9679
|
+
} else if (diag && ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired) {
|
|
9680
|
+
outcome = "playback_failed";
|
|
9681
|
+
} else {
|
|
9682
|
+
outcome = "request_failed";
|
|
9683
|
+
}
|
|
9684
|
+
this.timing.consecutiveFailures++;
|
|
9685
|
+
if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
|
|
9686
|
+
this.unusableResponsesInBreak++;
|
|
9687
|
+
}
|
|
9688
|
+
if (outcome === "no_fill") {
|
|
9689
|
+
this.timing.recordGamNoFill();
|
|
9690
|
+
}
|
|
9691
|
+
if (diag && !diag.failureReason) {
|
|
9692
|
+
diag.failureReason = "".concat(outcome, ": ").concat(message);
|
|
9693
|
+
}
|
|
9694
|
+
if (this.timing.isTemporaryAdError(error)) {
|
|
9695
|
+
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9696
|
+
} else if (outcome !== "discarded_budget") {
|
|
9697
|
+
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9698
|
+
}
|
|
9699
|
+
this.countFunnelStage("request_outcome:".concat(outcome));
|
|
9700
|
+
this.logOrchestratorFunnel("request_outcome", {
|
|
9701
|
+
outcome: outcome,
|
|
9702
|
+
errorMessage: message,
|
|
9703
|
+
consecutiveFailures: this.timing.consecutiveFailures,
|
|
9704
|
+
unusableResponsesInBreak: this.unusableResponsesInBreak
|
|
9705
|
+
});
|
|
9706
|
+
}
|
|
9707
|
+
},
|
|
9708
|
+
{
|
|
8717
9709
|
// ───────────────────────────────────────────────────────────────
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
backoffDelay = Math.min(this.timing.backoffBaseMs * backoffMultiplier, this.timing.maxBackoffMs);
|
|
8741
|
-
effectiveMinInterval = this.timing.minAdRequestIntervalMs + (this.timing.consecutiveFailures > 0 ? backoffDelay : 0);
|
|
8742
|
-
timeSinceLastRequest = Date.now() - this.timing.lastAdRequestTime;
|
|
8743
|
-
if (!(timeSinceLastRequest < effectiveMinInterval)) return [
|
|
8744
|
-
3,
|
|
8745
|
-
2
|
|
8746
|
-
];
|
|
8747
|
-
waitTime = effectiveMinInterval - timeSinceLastRequest;
|
|
8748
|
-
if (this.debug) {
|
|
8749
|
-
console.log("[CONTINUOUS-FETCH] Rate limiting: waiting ".concat(waitTime, "ms before next request (backoff: ").concat(this.timing.consecutiveFailures, " failures)"));
|
|
8750
|
-
}
|
|
8751
|
-
return [
|
|
8752
|
-
4,
|
|
8753
|
-
new Promise(function(resolve) {
|
|
8754
|
-
return setTimeout(resolve, waitTime);
|
|
8755
|
-
})
|
|
8756
|
-
];
|
|
8757
|
-
case 1:
|
|
8758
|
-
_state.sent();
|
|
8759
|
-
_state.label = 2;
|
|
8760
|
-
case 2:
|
|
8761
|
-
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) {
|
|
8762
|
-
return [
|
|
8763
|
-
2
|
|
8764
|
-
];
|
|
8765
|
-
}
|
|
8766
|
-
return [
|
|
8767
|
-
2,
|
|
8768
|
-
this.tryNextAvailableAd(0)
|
|
8769
|
-
];
|
|
9710
|
+
// Per-request diagnostics
|
|
9711
|
+
// ───────────────────────────────────────────────────────────────
|
|
9712
|
+
key: "recordRequestDiagnostic",
|
|
9713
|
+
value: function recordRequestDiagnostic(payload) {
|
|
9714
|
+
var requestId = payload.requestId;
|
|
9715
|
+
if (typeof requestId !== "number") return;
|
|
9716
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
9717
|
+
if (!diag) return;
|
|
9718
|
+
switch(payload.stage){
|
|
9719
|
+
case "gam_http_request_sent":
|
|
9720
|
+
diag.gamRequestSent++;
|
|
9721
|
+
break;
|
|
9722
|
+
case "gam_response_received":
|
|
9723
|
+
diag.vastHttpStatus = payload.httpStatus;
|
|
9724
|
+
break;
|
|
9725
|
+
case "vast_parsed":
|
|
9726
|
+
diag.vastAdCount = payload.adElementCount;
|
|
9727
|
+
break;
|
|
9728
|
+
case "wrapper_fetch":
|
|
9729
|
+
case "inline_resolved":
|
|
9730
|
+
if (typeof payload.depth === "number") {
|
|
9731
|
+
diag.wrapperDepth = Math.max(diag.wrapperDepth, payload.depth);
|
|
8770
9732
|
}
|
|
9733
|
+
if (payload.stage === "inline_resolved") diag.inlineResolved = true;
|
|
9734
|
+
break;
|
|
9735
|
+
case "mediafile_evaluated":
|
|
9736
|
+
diag.mediaCandidateCount++;
|
|
9737
|
+
if (payload.whyAccepted) diag.supportedMediaCount++;
|
|
9738
|
+
break;
|
|
9739
|
+
case "playing":
|
|
9740
|
+
diag.playStarted = true;
|
|
9741
|
+
break;
|
|
9742
|
+
case "impression_fired":
|
|
9743
|
+
diag.impressionFired = true;
|
|
9744
|
+
break;
|
|
9745
|
+
default:
|
|
9746
|
+
if (REQUEST_FAILURE_STAGES.has(payload.stage) && !diag.failureReason) {
|
|
9747
|
+
diag.failureReason = payload.reason ? "".concat(payload.stage, ":").concat(payload.reason) : payload.stage;
|
|
9748
|
+
}
|
|
9749
|
+
}
|
|
9750
|
+
}
|
|
9751
|
+
},
|
|
9752
|
+
{
|
|
9753
|
+
key: "finalizeRequestDiagnostics",
|
|
9754
|
+
value: function finalizeRequestDiagnostics(requestId, endReason) {
|
|
9755
|
+
var _diag_vastAdCount;
|
|
9756
|
+
if (requestId == null) return;
|
|
9757
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
9758
|
+
if (!diag) return;
|
|
9759
|
+
this.requestDiagnostics.delete(requestId);
|
|
9760
|
+
if (!diag.impressionFired && !diag.failureReason && endReason) {
|
|
9761
|
+
diag.failureReason = endReason;
|
|
9762
|
+
}
|
|
9763
|
+
var gamReturnedAdWithoutImpression = ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired;
|
|
9764
|
+
if (gamReturnedAdWithoutImpression) {
|
|
9765
|
+
this.countFunnelStage("gam_ad_without_impression");
|
|
9766
|
+
}
|
|
9767
|
+
var startedAt = diag.startedAt, fields = _object_without_properties(diag, [
|
|
9768
|
+
"startedAt"
|
|
9769
|
+
]);
|
|
9770
|
+
console.log("[AdBreak][REQUEST] summary", _object_spread_props(_object_spread({}, fields), {
|
|
9771
|
+
durationMs: Date.now() - startedAt,
|
|
9772
|
+
gamReturnedAdWithoutImpression: gamReturnedAdWithoutImpression
|
|
9773
|
+
}));
|
|
9774
|
+
}
|
|
9775
|
+
},
|
|
9776
|
+
{
|
|
9777
|
+
// ───────────────────────────────────────────────────────────────
|
|
9778
|
+
// Single ad playback
|
|
9779
|
+
// ───────────────────────────────────────────────────────────────
|
|
9780
|
+
key: "withCurrentPodBudget",
|
|
9781
|
+
value: function withCurrentPodBudget(rawVastTagUrl) {
|
|
9782
|
+
var vastTagUrl = ensureVideoAdType(rawVastTagUrl);
|
|
9783
|
+
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9784
|
+
if (!(remaining > 0)) return vastTagUrl;
|
|
9785
|
+
try {
|
|
9786
|
+
var url = new URL(vastTagUrl);
|
|
9787
|
+
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
9788
|
+
var maxMs = Math.round(remaining);
|
|
9789
|
+
url.searchParams.set("pmxd", String(maxMs));
|
|
9790
|
+
var minMs = Number(url.searchParams.get("pmnd"));
|
|
9791
|
+
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
9792
|
+
url.searchParams.set("pmnd", String(maxMs));
|
|
9793
|
+
}
|
|
9794
|
+
return url.toString();
|
|
9795
|
+
} catch (unused) {
|
|
9796
|
+
return vastTagUrl;
|
|
9797
|
+
}
|
|
9798
|
+
}
|
|
9799
|
+
},
|
|
9800
|
+
{
|
|
9801
|
+
key: "countFunnelStage",
|
|
9802
|
+
value: function countFunnelStage(stage) {
|
|
9803
|
+
var amount = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
|
|
9804
|
+
var _this_breakFunnel_stage;
|
|
9805
|
+
this.breakFunnel[stage] = ((_this_breakFunnel_stage = this.breakFunnel[stage]) !== null && _this_breakFunnel_stage !== void 0 ? _this_breakFunnel_stage : 0) + amount;
|
|
9806
|
+
}
|
|
9807
|
+
},
|
|
9808
|
+
{
|
|
9809
|
+
key: "logOrchestratorFunnel",
|
|
9810
|
+
value: function logOrchestratorFunnel(stage) {
|
|
9811
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
9812
|
+
this.countFunnelStage(stage);
|
|
9813
|
+
console.log("[AdBreak][FUNNEL] ".concat(stage), _object_spread({
|
|
9814
|
+
breakId: this.timing.adBreakEpoch,
|
|
9815
|
+
requestId: this.currentRequestId,
|
|
9816
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0
|
|
9817
|
+
}, extra));
|
|
9818
|
+
}
|
|
9819
|
+
},
|
|
9820
|
+
{
|
|
9821
|
+
key: "noteOpportunity",
|
|
9822
|
+
value: function noteOpportunity(source, breakKey) {
|
|
9823
|
+
if (breakKey && breakKey === this.opportunityBreakKey && this.opportunityEpoch === this.timing.adBreakEpoch) {
|
|
9824
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
9825
|
+
source: source,
|
|
9826
|
+
breakKey: breakKey
|
|
8771
9827
|
});
|
|
8772
|
-
|
|
9828
|
+
return;
|
|
9829
|
+
}
|
|
9830
|
+
this.opportunityBreakKey = breakKey;
|
|
9831
|
+
this.opportunityEpoch = this.timing.adBreakEpoch;
|
|
9832
|
+
this.logOrchestratorFunnel("opportunity_created", {
|
|
9833
|
+
source: source,
|
|
9834
|
+
breakKey: breakKey,
|
|
9835
|
+
expectedDurationMs: this.timing.expectedAdBreakDurationMs
|
|
9836
|
+
});
|
|
9837
|
+
}
|
|
9838
|
+
},
|
|
9839
|
+
{
|
|
9840
|
+
key: "beginFunnelRequest",
|
|
9841
|
+
value: function beginFunnelRequest(adPlayer, requestToken, trigger) {
|
|
9842
|
+
var _adPlayer_setFunnelContext;
|
|
9843
|
+
if (this.controllerCallInFlight) {
|
|
9844
|
+
this.logOrchestratorFunnel("duplicate_request_detected", {
|
|
9845
|
+
newRequestId: requestToken
|
|
9846
|
+
});
|
|
9847
|
+
}
|
|
9848
|
+
this.finalizeRequestDiagnostics(this.currentRequestId);
|
|
9849
|
+
this.currentRequestId = requestToken;
|
|
9850
|
+
this.requestStartedAt = Date.now();
|
|
9851
|
+
this.requestDiagnostics.set(requestToken, {
|
|
9852
|
+
breakId: this.timing.adBreakEpoch,
|
|
9853
|
+
requestId: requestToken,
|
|
9854
|
+
controllerId: this.controllerGeneration,
|
|
9855
|
+
trigger: trigger,
|
|
9856
|
+
gamRequestSent: 0,
|
|
9857
|
+
wrapperDepth: 0,
|
|
9858
|
+
inlineResolved: false,
|
|
9859
|
+
mediaCandidateCount: 0,
|
|
9860
|
+
supportedMediaCount: 0,
|
|
9861
|
+
playStarted: false,
|
|
9862
|
+
impressionFired: false,
|
|
9863
|
+
startedAt: Date.now()
|
|
9864
|
+
});
|
|
9865
|
+
(_adPlayer_setFunnelContext = adPlayer.setFunnelContext) === null || _adPlayer_setFunnelContext === void 0 ? void 0 : _adPlayer_setFunnelContext.call(adPlayer, {
|
|
9866
|
+
breakId: this.timing.adBreakEpoch,
|
|
9867
|
+
requestId: requestToken,
|
|
9868
|
+
controllerId: this.controllerGeneration
|
|
9869
|
+
});
|
|
9870
|
+
}
|
|
9871
|
+
},
|
|
9872
|
+
{
|
|
9873
|
+
key: "isAdLoadingWithoutPlayback",
|
|
9874
|
+
value: function isAdLoadingWithoutPlayback() {
|
|
9875
|
+
return this.host.getAdPlayer().isAdPlaying() && !this.playbackStartedForCurrentRequest;
|
|
9876
|
+
}
|
|
9877
|
+
},
|
|
9878
|
+
{
|
|
9879
|
+
key: "noteStopBeforeStart",
|
|
9880
|
+
value: function noteStopBeforeStart(reason) {
|
|
9881
|
+
if (!this.isAdLoadingWithoutPlayback()) return;
|
|
9882
|
+
this.logOrchestratorFunnel("ad_stopped_before_start", {
|
|
9883
|
+
reason: reason,
|
|
9884
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
9885
|
+
});
|
|
9886
|
+
}
|
|
9887
|
+
},
|
|
9888
|
+
{
|
|
9889
|
+
key: "handleRequestWatchdogTimeout",
|
|
9890
|
+
value: function handleRequestWatchdogTimeout() {
|
|
9891
|
+
var adPlayer = this.host.getAdPlayer();
|
|
9892
|
+
if (this.controllerCallInFlight && adPlayer.abortPendingRequest) {
|
|
9893
|
+
this.logOrchestratorFunnel("request_aborted_timeout", {
|
|
9894
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
9895
|
+
});
|
|
9896
|
+
adPlayer.abortPendingRequest("VAST request aborted after request watchdog timeout");
|
|
9897
|
+
return;
|
|
9898
|
+
}
|
|
9899
|
+
this.handleAdFailure("request_watchdog_timeout");
|
|
8773
9900
|
}
|
|
8774
9901
|
},
|
|
8775
9902
|
{
|
|
8776
|
-
key: "
|
|
8777
|
-
value: function
|
|
8778
|
-
var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
|
9903
|
+
key: "callController",
|
|
9904
|
+
value: function callController(call) {
|
|
8779
9905
|
return _async_to_generator(function() {
|
|
8780
|
-
var remaining, nextAdUrl, error, errorMessage, maxRetries;
|
|
8781
9906
|
return _ts_generator(this, function(_state) {
|
|
8782
9907
|
switch(_state.label){
|
|
8783
9908
|
case 0:
|
|
8784
|
-
|
|
8785
|
-
return [
|
|
8786
|
-
2
|
|
8787
|
-
];
|
|
8788
|
-
}
|
|
8789
|
-
remaining = this.timing.getRemainingAdMs();
|
|
8790
|
-
if (!this.timing.hasTimeToStartAnotherAd()) {
|
|
8791
|
-
if (this.debug) {
|
|
8792
|
-
console.log("[CONTINUOUS-FETCH] Not enough time remaining (".concat(remaining, "ms) to start another ad, ending ad break"));
|
|
8793
|
-
}
|
|
8794
|
-
this.handleAdPodComplete();
|
|
8795
|
-
return [
|
|
8796
|
-
2
|
|
8797
|
-
];
|
|
8798
|
-
}
|
|
8799
|
-
if (this.timing.isGamInCooldown()) {
|
|
8800
|
-
if (this.debug) {
|
|
8801
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, ending ad break gracefully");
|
|
8802
|
-
}
|
|
8803
|
-
this.handleAdPodComplete();
|
|
8804
|
-
return [
|
|
8805
|
-
2
|
|
8806
|
-
];
|
|
8807
|
-
}
|
|
8808
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
8809
|
-
if (this.debug) {
|
|
8810
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(this.timing.consecutiveFailures, "), ending ad break"));
|
|
8811
|
-
}
|
|
8812
|
-
this.handleAdPodComplete();
|
|
8813
|
-
return [
|
|
8814
|
-
2
|
|
8815
|
-
];
|
|
8816
|
-
}
|
|
8817
|
-
this.timing.cleanupTemporaryFailures();
|
|
9909
|
+
this.controllerCallInFlight = true;
|
|
8818
9910
|
_state.label = 1;
|
|
8819
9911
|
case 1:
|
|
8820
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
8821
|
-
3,
|
|
8822
|
-
9
|
|
8823
|
-
];
|
|
8824
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
8825
|
-
if (!nextAdUrl) return [
|
|
8826
|
-
3,
|
|
8827
|
-
1
|
|
8828
|
-
];
|
|
8829
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) {
|
|
8830
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
|
|
8831
|
-
return [
|
|
8832
|
-
3,
|
|
8833
|
-
1
|
|
8834
|
-
];
|
|
8835
|
-
}
|
|
8836
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) {
|
|
8837
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
|
|
8838
|
-
return [
|
|
8839
|
-
3,
|
|
8840
|
-
1
|
|
8841
|
-
];
|
|
8842
|
-
}
|
|
8843
|
-
if (this.debug) {
|
|
8844
|
-
console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
|
|
8845
|
-
}
|
|
8846
|
-
_state.label = 2;
|
|
8847
|
-
case 2:
|
|
8848
9912
|
_state.trys.push([
|
|
8849
|
-
|
|
8850
|
-
4,
|
|
9913
|
+
1,
|
|
8851
9914
|
,
|
|
8852
|
-
8
|
|
8853
|
-
]);
|
|
8854
|
-
return [
|
|
8855
|
-
4,
|
|
8856
|
-
this.playSingleAd(nextAdUrl)
|
|
8857
|
-
];
|
|
8858
|
-
case 3:
|
|
8859
|
-
_state.sent();
|
|
8860
|
-
this.timing.consecutiveFailures = 0;
|
|
8861
|
-
return [
|
|
8862
9915
|
3,
|
|
8863
|
-
|
|
8864
|
-
];
|
|
8865
|
-
case 4:
|
|
8866
|
-
error = _state.sent();
|
|
8867
|
-
errorMessage = error.message;
|
|
8868
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
|
|
8869
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
8870
|
-
3,
|
|
8871
|
-
6
|
|
8872
|
-
];
|
|
8873
|
-
return [
|
|
8874
|
-
4,
|
|
8875
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
8876
|
-
];
|
|
8877
|
-
case 5:
|
|
8878
|
-
_state.sent();
|
|
8879
|
-
return [
|
|
8880
|
-
2
|
|
8881
|
-
];
|
|
8882
|
-
case 6:
|
|
8883
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
8884
|
-
this.timing.consecutiveFailures++;
|
|
8885
|
-
}
|
|
9916
|
+
4
|
|
9917
|
+
]);
|
|
8886
9918
|
return [
|
|
8887
9919
|
4,
|
|
8888
|
-
|
|
9920
|
+
call()
|
|
8889
9921
|
];
|
|
8890
|
-
case
|
|
9922
|
+
case 2:
|
|
8891
9923
|
_state.sent();
|
|
8892
9924
|
return [
|
|
8893
9925
|
3,
|
|
8894
|
-
|
|
8895
|
-
];
|
|
8896
|
-
case 8:
|
|
8897
|
-
return [
|
|
8898
|
-
2
|
|
8899
|
-
];
|
|
8900
|
-
case 9:
|
|
8901
|
-
maxRetries = 3;
|
|
8902
|
-
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
8903
|
-
3,
|
|
8904
|
-
12
|
|
8905
|
-
];
|
|
8906
|
-
if (this.debug) {
|
|
8907
|
-
console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
8908
|
-
}
|
|
8909
|
-
return [
|
|
8910
|
-
4,
|
|
8911
|
-
new Promise(function(resolve) {
|
|
8912
|
-
return setTimeout(resolve, 500);
|
|
8913
|
-
})
|
|
8914
|
-
];
|
|
8915
|
-
case 10:
|
|
8916
|
-
_state.sent();
|
|
8917
|
-
return [
|
|
8918
|
-
4,
|
|
8919
|
-
this.tryNextAvailableAd(retryCount + 1)
|
|
9926
|
+
4
|
|
8920
9927
|
];
|
|
8921
|
-
case
|
|
8922
|
-
|
|
9928
|
+
case 3:
|
|
9929
|
+
this.controllerCallInFlight = false;
|
|
8923
9930
|
return [
|
|
8924
|
-
|
|
9931
|
+
7
|
|
8925
9932
|
];
|
|
8926
|
-
case
|
|
8927
|
-
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
8928
|
-
this.showPlaceholderAndWaitForAds();
|
|
8929
|
-
} else {
|
|
8930
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] No more ads available, ending ad break");
|
|
8931
|
-
this.handleAdPodComplete();
|
|
8932
|
-
}
|
|
9933
|
+
case 4:
|
|
8933
9934
|
return [
|
|
8934
9935
|
2
|
|
8935
9936
|
];
|
|
@@ -8938,47 +9939,33 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8938
9939
|
}).call(this);
|
|
8939
9940
|
}
|
|
8940
9941
|
},
|
|
8941
|
-
{
|
|
8942
|
-
// ───────────────────────────────────────────────────────────────
|
|
8943
|
-
// Single ad playback
|
|
8944
|
-
// ───────────────────────────────────────────────────────────────
|
|
8945
|
-
key: "withCurrentPodBudget",
|
|
8946
|
-
value: function withCurrentPodBudget(vastTagUrl) {
|
|
8947
|
-
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
8948
|
-
if (!(remaining > 0)) return vastTagUrl;
|
|
8949
|
-
try {
|
|
8950
|
-
var url = new URL(vastTagUrl);
|
|
8951
|
-
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
8952
|
-
var maxMs = Math.round(remaining);
|
|
8953
|
-
url.searchParams.set("pmxd", String(maxMs));
|
|
8954
|
-
var minMs = Number(url.searchParams.get("pmnd"));
|
|
8955
|
-
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
8956
|
-
url.searchParams.set("pmnd", String(maxMs));
|
|
8957
|
-
}
|
|
8958
|
-
return url.toString();
|
|
8959
|
-
} catch (unused) {
|
|
8960
|
-
return vastTagUrl;
|
|
8961
|
-
}
|
|
8962
|
-
}
|
|
8963
|
-
},
|
|
8964
9942
|
{
|
|
8965
9943
|
key: "playSingleAd",
|
|
8966
9944
|
value: function playSingleAd(vastTagUrl) {
|
|
9945
|
+
var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
|
|
8967
9946
|
return _async_to_generator(function() {
|
|
8968
|
-
var
|
|
9947
|
+
var epoch, generation, requestToken, ap, requestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
|
|
8969
9948
|
return _ts_generator(this, function(_state) {
|
|
8970
9949
|
switch(_state.label){
|
|
8971
9950
|
case 0:
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
9951
|
+
if (this.slotState === "REQUESTING" || this.slotState === "READY" || this.slotState === "PLAYING" || this.slotState === "ENDING") {
|
|
9952
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
9953
|
+
trigger: trigger,
|
|
9954
|
+
state: this.slotState,
|
|
9955
|
+
why: "request_in_flight"
|
|
9956
|
+
});
|
|
9957
|
+
return [
|
|
9958
|
+
2
|
|
9959
|
+
];
|
|
9960
|
+
}
|
|
8976
9961
|
if (this.timing.failedVastUrls.has(vastTagUrl)) {
|
|
8977
9962
|
if (this.debug) console.warn("[AD-ERROR] Skipping permanently-failed VAST URL:", vastTagUrl);
|
|
9963
|
+
this.timing.consecutiveFailures++;
|
|
8978
9964
|
throw new Error("VAST URL permanently failed");
|
|
8979
9965
|
}
|
|
8980
9966
|
if (this.timing.isUrlInCooldown(vastTagUrl)) {
|
|
8981
9967
|
if (this.debug) console.warn("[AD-ERROR] Skipping URL in cooldown (recent no-fill):", vastTagUrl);
|
|
9968
|
+
this.timing.consecutiveFailures++;
|
|
8982
9969
|
throw new Error("VAST URL in cooldown after no-fill");
|
|
8983
9970
|
}
|
|
8984
9971
|
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
@@ -8989,16 +9976,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8989
9976
|
if (this.debug) console.warn("[CIRCUIT-BREAKER] GAM in cooldown, skipping ad request");
|
|
8990
9977
|
throw new Error("GAM in cooldown");
|
|
8991
9978
|
}
|
|
8992
|
-
this.
|
|
9979
|
+
epoch = this.timing.adBreakEpoch;
|
|
9980
|
+
this.recreateAdController("new_request");
|
|
9981
|
+
generation = this.controllerGeneration;
|
|
8993
9982
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8994
9983
|
this.timing.activeAdRequestToken = requestToken;
|
|
9984
|
+
ap = this.host.getAdPlayer();
|
|
9985
|
+
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9986
|
+
this.currentVastUrl = requestUrl;
|
|
9987
|
+
this.setSlotState("REQUESTING", trigger);
|
|
9988
|
+
this.beginFunnelRequest(ap, requestToken, trigger);
|
|
8995
9989
|
_state.label = 1;
|
|
8996
9990
|
case 1:
|
|
8997
9991
|
_state.trys.push([
|
|
8998
9992
|
1,
|
|
8999
|
-
|
|
9993
|
+
5,
|
|
9000
9994
|
,
|
|
9001
|
-
|
|
9995
|
+
6
|
|
9002
9996
|
]);
|
|
9003
9997
|
return [
|
|
9004
9998
|
4,
|
|
@@ -9006,265 +10000,87 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9006
10000
|
];
|
|
9007
10001
|
case 2:
|
|
9008
10002
|
_state.sent();
|
|
10003
|
+
if (this.isStale(epoch, generation)) return [
|
|
10004
|
+
2
|
|
10005
|
+
];
|
|
9009
10006
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
9010
|
-
this.timing.lastAdRequestTime = Date.now();
|
|
9011
|
-
ap = this.host.getAdPlayer();
|
|
9012
|
-
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9013
|
-
this.currentVastUrl = requestUrl;
|
|
9014
10007
|
return [
|
|
9015
10008
|
4,
|
|
9016
|
-
|
|
10009
|
+
this.callController(function() {
|
|
10010
|
+
return ap.requestAds(requestUrl);
|
|
10011
|
+
})
|
|
9017
10012
|
];
|
|
9018
10013
|
case 3:
|
|
9019
10014
|
_state.sent();
|
|
10015
|
+
this.timing.clearAdRequestWatchdog();
|
|
10016
|
+
if (this.isStale(epoch, generation)) {
|
|
10017
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
10018
|
+
requestId: requestToken
|
|
10019
|
+
});
|
|
10020
|
+
return [
|
|
10021
|
+
2
|
|
10022
|
+
];
|
|
10023
|
+
}
|
|
9020
10024
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
9021
10025
|
source: "hls",
|
|
9022
10026
|
vastUrl: requestUrl,
|
|
9023
10027
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
9024
10028
|
}, this.analyticsContext).catch(function() {});
|
|
9025
|
-
this.timing.clearAdRequestWatchdog();
|
|
9026
|
-
if (this.timing.activeAdRequestToken !== requestToken) return [
|
|
9027
|
-
2
|
|
9028
|
-
];
|
|
9029
10029
|
if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
|
|
9030
|
-
|
|
9031
|
-
|
|
10030
|
+
;
|
|
10031
|
+
adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
|
|
10032
|
+
remainingMs = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
10033
|
+
this.logOrchestratorFunnel("discarded_budget", {
|
|
10034
|
+
adDurationMs: adDurationS != null ? adDurationS * 1e3 : void 0,
|
|
10035
|
+
remainingMs: remainingMs
|
|
10036
|
+
});
|
|
9032
10037
|
throw new Error("ad_duration_exceeds_budget");
|
|
9033
10038
|
}
|
|
9034
|
-
|
|
9035
|
-
case 4:
|
|
9036
|
-
_state.trys.push([
|
|
9037
|
-
4,
|
|
9038
|
-
6,
|
|
9039
|
-
,
|
|
9040
|
-
7
|
|
9041
|
-
]);
|
|
10039
|
+
this.setSlotState("READY", "vast_ready");
|
|
9042
10040
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
9043
10041
|
return [
|
|
9044
10042
|
4,
|
|
9045
|
-
|
|
10043
|
+
this.callController(function() {
|
|
10044
|
+
return ap.play();
|
|
10045
|
+
})
|
|
9046
10046
|
];
|
|
9047
|
-
case
|
|
10047
|
+
case 4:
|
|
9048
10048
|
_state.sent();
|
|
9049
|
-
this.
|
|
10049
|
+
if (this.isStale(epoch, generation)) return [
|
|
10050
|
+
2
|
|
10051
|
+
];
|
|
9050
10052
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
9051
10053
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
9052
10054
|
}
|
|
9053
10055
|
ap.setAdVolume(getAdAudioVolume(ap));
|
|
9054
|
-
this.timing.consecutiveFailures = 0;
|
|
9055
10056
|
this.timing.temporaryFailureUrls.delete(vastTagUrl);
|
|
9056
10057
|
return [
|
|
9057
10058
|
3,
|
|
9058
|
-
|
|
9059
|
-
];
|
|
9060
|
-
case 6:
|
|
9061
|
-
playError = _state.sent();
|
|
9062
|
-
if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
|
|
9063
|
-
if (this.timing.isTemporaryAdError(playError)) {
|
|
9064
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9065
|
-
if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
|
|
9066
|
-
} else {
|
|
9067
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9068
|
-
if (this.debug) console.log("[AD-ERROR] Permanent play error - URL blacklisted");
|
|
9069
|
-
}
|
|
9070
|
-
this.timing.clearAdFailsafeTimer();
|
|
9071
|
-
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9072
|
-
this.timing.activeAdRequestToken = null;
|
|
9073
|
-
}
|
|
9074
|
-
throw playError;
|
|
9075
|
-
case 7:
|
|
9076
|
-
return [
|
|
9077
|
-
3,
|
|
9078
|
-
9
|
|
10059
|
+
6
|
|
9079
10060
|
];
|
|
9080
|
-
case
|
|
10061
|
+
case 5:
|
|
9081
10062
|
error = _state.sent();
|
|
9082
|
-
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
9083
|
-
if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
|
|
9084
|
-
if (this.timing.isTemporaryAdError(error)) {
|
|
9085
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
9086
|
-
if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
|
|
9087
|
-
} else {
|
|
9088
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
9089
|
-
if (this.debug) console.log("[AD-ERROR] Permanent error - URL blacklisted:", errorMessage);
|
|
9090
|
-
}
|
|
9091
10063
|
this.timing.clearAdRequestWatchdog();
|
|
9092
10064
|
this.timing.clearAdFailsafeTimer();
|
|
9093
10065
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
9094
10066
|
this.timing.activeAdRequestToken = null;
|
|
9095
10067
|
}
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
}
|
|
9102
|
-
});
|
|
9103
|
-
}).call(this);
|
|
9104
|
-
}
|
|
9105
|
-
},
|
|
9106
|
-
{
|
|
9107
|
-
key: "showPlaceholderAndWaitForAds",
|
|
9108
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9109
|
-
// Placeholder wait
|
|
9110
|
-
// ───────────────────────────────────────────────────────────────
|
|
9111
|
-
function showPlaceholderAndWaitForAds() {
|
|
9112
|
-
return _async_to_generator(function() {
|
|
9113
|
-
var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
|
|
9114
|
-
return _ts_generator(this, function(_state) {
|
|
9115
|
-
switch(_state.label){
|
|
9116
|
-
case 0:
|
|
9117
|
-
remaining = this.timing.getRemainingAdMs();
|
|
9118
|
-
waitTime = Math.min(this.maxPlaceholderDurationMs, remaining);
|
|
9119
|
-
if (this.timing.isGamInCooldown()) {
|
|
9120
|
-
if (this.debug) console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping placeholder wait");
|
|
9121
|
-
this.handleAdPodComplete();
|
|
9122
|
-
return [
|
|
9123
|
-
2
|
|
9124
|
-
];
|
|
9125
|
-
}
|
|
9126
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9127
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping placeholder - too many consecutive failures");
|
|
9128
|
-
this.handleAdPodComplete();
|
|
9129
|
-
return [
|
|
9130
|
-
2
|
|
9131
|
-
];
|
|
9132
|
-
}
|
|
9133
|
-
if (waitTime < 1e3) {
|
|
9134
|
-
this.handleAdPodComplete();
|
|
10068
|
+
if (this.isStale(epoch, generation)) {
|
|
10069
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
10070
|
+
requestId: requestToken,
|
|
10071
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
10072
|
+
});
|
|
9135
10073
|
return [
|
|
9136
10074
|
2
|
|
9137
10075
|
];
|
|
9138
10076
|
}
|
|
9139
|
-
if (this.debug)
|
|
9140
|
-
|
|
10077
|
+
if (this.debug) console.error("[AD-ERROR] Ad request failed:", error === null || error === void 0 ? void 0 : error.message);
|
|
10078
|
+
this.recordRequestFailure(error, vastTagUrl);
|
|
10079
|
+
if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
|
|
10080
|
+
this.recreateAdController("discarded_budget");
|
|
9141
10081
|
}
|
|
9142
|
-
|
|
9143
|
-
this.host.getAdPlayer().showPlaceholder();
|
|
9144
|
-
checkInterval = 300;
|
|
9145
|
-
maxChecks = Math.floor(waitTime / checkInterval);
|
|
9146
|
-
i = 0;
|
|
9147
|
-
_state.label = 1;
|
|
9148
|
-
case 1:
|
|
9149
|
-
if (!(i < maxChecks)) return [
|
|
9150
|
-
3,
|
|
9151
|
-
12
|
|
9152
|
-
];
|
|
9153
|
-
return [
|
|
9154
|
-
4,
|
|
9155
|
-
new Promise(function(resolve) {
|
|
9156
|
-
return setTimeout(resolve, checkInterval);
|
|
9157
|
-
})
|
|
9158
|
-
];
|
|
9159
|
-
case 2:
|
|
9160
|
-
_state.sent();
|
|
9161
|
-
if (!this.inAdBreak) return [
|
|
9162
|
-
2
|
|
9163
|
-
];
|
|
9164
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9165
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Too many failures during placeholder wait");
|
|
9166
|
-
return [
|
|
9167
|
-
3,
|
|
9168
|
-
12
|
|
9169
|
-
];
|
|
9170
|
-
}
|
|
9171
|
-
if (!this.timing.hasTimeToStartAnotherAd()) {
|
|
9172
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Not enough time remaining during placeholder wait, ending ad break");
|
|
9173
|
-
return [
|
|
9174
|
-
3,
|
|
9175
|
-
12
|
|
9176
|
-
];
|
|
9177
|
-
}
|
|
9178
|
-
_state.label = 3;
|
|
9179
|
-
case 3:
|
|
9180
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
9181
|
-
3,
|
|
9182
|
-
11
|
|
9183
|
-
];
|
|
9184
|
-
if (!this.timing.hasTimeToStartAnotherAd()) return [
|
|
9185
|
-
3,
|
|
9186
|
-
11
|
|
9187
|
-
];
|
|
9188
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
9189
|
-
if (!nextAdUrl) return [
|
|
9190
|
-
3,
|
|
9191
|
-
3
|
|
9192
|
-
];
|
|
9193
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) return [
|
|
9194
|
-
3,
|
|
9195
|
-
3
|
|
9196
|
-
];
|
|
9197
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) return [
|
|
9198
|
-
3,
|
|
9199
|
-
3
|
|
9200
|
-
];
|
|
9201
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad URL available, requesting via HLS ad player");
|
|
9202
|
-
this.isShowingPlaceholder = false;
|
|
9203
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
9204
|
-
_state.label = 4;
|
|
9205
|
-
case 4:
|
|
9206
|
-
_state.trys.push([
|
|
9207
|
-
4,
|
|
9208
|
-
6,
|
|
9209
|
-
,
|
|
9210
|
-
10
|
|
9211
|
-
]);
|
|
9212
|
-
return [
|
|
9213
|
-
4,
|
|
9214
|
-
this.playSingleAd(nextAdUrl)
|
|
9215
|
-
];
|
|
9216
|
-
case 5:
|
|
9217
|
-
_state.sent();
|
|
9218
|
-
this.timing.consecutiveFailures = 0;
|
|
9219
|
-
return [
|
|
9220
|
-
3,
|
|
9221
|
-
10
|
|
9222
|
-
];
|
|
10082
|
+
throw error;
|
|
9223
10083
|
case 6:
|
|
9224
|
-
error = _state.sent();
|
|
9225
|
-
errorMessage = error.message;
|
|
9226
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
9227
|
-
3,
|
|
9228
|
-
8
|
|
9229
|
-
];
|
|
9230
|
-
return [
|
|
9231
|
-
4,
|
|
9232
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9233
|
-
];
|
|
9234
|
-
case 7:
|
|
9235
|
-
_state.sent();
|
|
9236
|
-
return [
|
|
9237
|
-
2
|
|
9238
|
-
];
|
|
9239
|
-
case 8:
|
|
9240
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
9241
|
-
this.timing.consecutiveFailures++;
|
|
9242
|
-
}
|
|
9243
|
-
return [
|
|
9244
|
-
4,
|
|
9245
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
9246
|
-
];
|
|
9247
|
-
case 9:
|
|
9248
|
-
_state.sent();
|
|
9249
|
-
return [
|
|
9250
|
-
3,
|
|
9251
|
-
10
|
|
9252
|
-
];
|
|
9253
|
-
case 10:
|
|
9254
|
-
return [
|
|
9255
|
-
2
|
|
9256
|
-
];
|
|
9257
|
-
case 11:
|
|
9258
|
-
i++;
|
|
9259
|
-
return [
|
|
9260
|
-
3,
|
|
9261
|
-
1
|
|
9262
|
-
];
|
|
9263
|
-
case 12:
|
|
9264
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Placeholder timeout, ending ad break");
|
|
9265
|
-
this.isShowingPlaceholder = false;
|
|
9266
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
9267
|
-
this.handleAdPodComplete();
|
|
9268
10084
|
return [
|
|
9269
10085
|
2
|
|
9270
10086
|
];
|
|
@@ -9277,26 +10093,136 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9277
10093
|
// ───────────────────────────────────────────────────────────────
|
|
9278
10094
|
// Ad break completion
|
|
9279
10095
|
// ───────────────────────────────────────────────────────────────
|
|
10096
|
+
key: "logBreakFunnel",
|
|
10097
|
+
value: function logBreakFunnel(endReason) {
|
|
10098
|
+
var funnel = this.breakFunnel;
|
|
10099
|
+
this.breakFunnel = {};
|
|
10100
|
+
if (Object.keys(funnel).length === 0) return;
|
|
10101
|
+
var count = function count(stage) {
|
|
10102
|
+
var _funnel_stage;
|
|
10103
|
+
return (_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0;
|
|
10104
|
+
};
|
|
10105
|
+
var countPrefix = function countPrefix(prefix) {
|
|
10106
|
+
return Object.keys(funnel).reduce(function(total, stage) {
|
|
10107
|
+
var _funnel_stage;
|
|
10108
|
+
return stage.indexOf(prefix) === 0 ? total + ((_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0) : total;
|
|
10109
|
+
}, 0);
|
|
10110
|
+
};
|
|
10111
|
+
var breakId = this.opportunityEpoch;
|
|
10112
|
+
var requestRetries = count("gam_http_request_retry");
|
|
10113
|
+
var requests = count("gam_http_request_sent") - requestRetries;
|
|
10114
|
+
if (requests > 0 && count("impression_fired") === 0) {
|
|
10115
|
+
console.log("[AdBreak][FUNNEL] break_abandoned_before_start", {
|
|
10116
|
+
breakId: breakId,
|
|
10117
|
+
requests: requests,
|
|
10118
|
+
endReason: endReason
|
|
10119
|
+
});
|
|
10120
|
+
}
|
|
10121
|
+
console.log("[AdBreak][FUNNEL] Break summary", {
|
|
10122
|
+
breakId: breakId,
|
|
10123
|
+
endReason: endReason,
|
|
10124
|
+
opportunities: count("opportunity_created"),
|
|
10125
|
+
vastUrlsGenerated: count("vast_url_generated"),
|
|
10126
|
+
requests: requests,
|
|
10127
|
+
requestRetries: requestRetries,
|
|
10128
|
+
gamResponses: count("gam_response_received"),
|
|
10129
|
+
requestsSuppressed: count("request_suppressed"),
|
|
10130
|
+
duplicates: count("duplicate_request_detected") + count("duplicate_break_start"),
|
|
10131
|
+
filled: count("vast_received"),
|
|
10132
|
+
noFill: count("no_fill"),
|
|
10133
|
+
fillRejected: count("vast_fill_rejected"),
|
|
10134
|
+
gamAdWithoutImpression: count("gam_ad_without_impression"),
|
|
10135
|
+
playbackFailedAfterFill: count("request_outcome:playback_failed"),
|
|
10136
|
+
requestFailed: count("request_failed"),
|
|
10137
|
+
requestAbortedTimeout: count("request_aborted_timeout"),
|
|
10138
|
+
credentialsRetries: count("vast_credentials_retry"),
|
|
10139
|
+
wrapperFailures: count("wrapper_fetch:failure"),
|
|
10140
|
+
noSupportedMedia: count("vast_no_supported_media"),
|
|
10141
|
+
vpaidOnly: count("vast_no_supported_media:vpaid"),
|
|
10142
|
+
audioOnly: count("vast_no_supported_media:audio_only"),
|
|
10143
|
+
mediaFilesEvaluated: count("mediafile_evaluated"),
|
|
10144
|
+
mediaFilesAccepted: count("mediafile_evaluated:accepted"),
|
|
10145
|
+
controllerDestroys: countPrefix("controller_destroy:"),
|
|
10146
|
+
staleCallbacks: count("stale_callback_ignored") + count("stale_request_result_ignored"),
|
|
10147
|
+
tagAllowsAudio: count("tag_allows_audio"),
|
|
10148
|
+
missingImpression: count("vast_missing_impression"),
|
|
10149
|
+
discardedBudget: count("discarded_budget"),
|
|
10150
|
+
mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
|
|
10151
|
+
mediaRejected: count("media_candidate:rejected"),
|
|
10152
|
+
mediaFallbacks: count("media_fallback"),
|
|
10153
|
+
playCalled: count("play_called"),
|
|
10154
|
+
playRejected: count("play_rejected"),
|
|
10155
|
+
mutedRetry: count("muted_retry"),
|
|
10156
|
+
startTimeouts: count("play_resolved_but_never_started"),
|
|
10157
|
+
impressions: count("impression_fired"),
|
|
10158
|
+
impressionUrls: count("impression_urls"),
|
|
10159
|
+
trackingRequests: count("tracking_request_created"),
|
|
10160
|
+
trackingNotLoaded: count("tracking_request_settled:error") + count("tracking_request_settled:timeout"),
|
|
10161
|
+
trackingUnexpandedMacros: count("tracking_url_unexpanded_macro"),
|
|
10162
|
+
trackingInvalidUrls: count("tracking_url_invalid"),
|
|
10163
|
+
vastAdFallbacks: count("vast_ad_fallback"),
|
|
10164
|
+
mediaEvents: count("media_event"),
|
|
10165
|
+
quartile25: count("first_quartile"),
|
|
10166
|
+
quartile50: count("midpoint"),
|
|
10167
|
+
quartile75: count("third_quartile"),
|
|
10168
|
+
complete: count("complete"),
|
|
10169
|
+
stoppedBeforeStart: count("stopped_before_start"),
|
|
10170
|
+
stoppedBeforeStartByBreakEnd: count("ad_stopped_before_start"),
|
|
10171
|
+
unexpectedUnmutes: count("unexpected_unmute"),
|
|
10172
|
+
unmuteBlocked: count("unmute_blocked_without_gesture"),
|
|
10173
|
+
visibilityHidden: count("while_hidden"),
|
|
10174
|
+
playbackFailures: count("play_failed") + count("media_error") + count("hls_fatal") + count("stall") + count("decode_failure") + count("media_unsupported"),
|
|
10175
|
+
stages: funnel
|
|
10176
|
+
});
|
|
10177
|
+
}
|
|
10178
|
+
},
|
|
10179
|
+
{
|
|
9280
10180
|
key: "handleAdPodComplete",
|
|
9281
10181
|
value: function handleAdPodComplete() {
|
|
10182
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "unspecified";
|
|
9282
10183
|
if (this.debug) {
|
|
9283
|
-
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up"
|
|
10184
|
+
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up", {
|
|
10185
|
+
reason: reason
|
|
10186
|
+
});
|
|
9284
10187
|
}
|
|
10188
|
+
var previousState = this.slotState;
|
|
10189
|
+
var alreadyEnded = previousState === "IDLE" && !this.inAdBreak;
|
|
10190
|
+
this.setSlotState("ENDING", reason);
|
|
10191
|
+
this.cancelScheduledRequest();
|
|
10192
|
+
var adPlayer = this.host.getAdPlayer();
|
|
10193
|
+
if (previousState === "REQUESTING") {
|
|
10194
|
+
var _adPlayer_abortPendingRequest;
|
|
10195
|
+
(_adPlayer_abortPendingRequest = adPlayer.abortPendingRequest) === null || _adPlayer_abortPendingRequest === void 0 ? void 0 : _adPlayer_abortPendingRequest.call(adPlayer, "VAST request aborted: ad break ended (".concat(reason, ")"));
|
|
10196
|
+
}
|
|
10197
|
+
if (!alreadyEnded) {
|
|
10198
|
+
console.log("[AD-CONTROLLER] stop", {
|
|
10199
|
+
controllerId: this.controllerGeneration,
|
|
10200
|
+
requestId: this.currentRequestId,
|
|
10201
|
+
state: previousState,
|
|
10202
|
+
reason: reason
|
|
10203
|
+
});
|
|
10204
|
+
}
|
|
10205
|
+
this.finalizeRequestDiagnostics(this.currentRequestId, "break_ended:".concat(reason));
|
|
10206
|
+
this.currentRequestId = void 0;
|
|
9285
10207
|
this.timing.resetForBreakEnd();
|
|
9286
|
-
this.
|
|
10208
|
+
this.placeholder.hide();
|
|
9287
10209
|
this.clearPendingAdBreak();
|
|
9288
10210
|
if (this.isShowingPlaceholder) {
|
|
9289
|
-
|
|
10211
|
+
adPlayer.hidePlaceholder();
|
|
9290
10212
|
this.isShowingPlaceholder = false;
|
|
9291
10213
|
}
|
|
9292
|
-
this.adRequestQueue = [];
|
|
9293
10214
|
this.inAdBreak = false;
|
|
9294
10215
|
this.adDetectSentForCurrentBreak = false;
|
|
9295
10216
|
this.cueManager.activeScte35BreakKey = void 0;
|
|
9296
10217
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
9297
10218
|
this.adPodQueue = [];
|
|
9298
10219
|
this.showAds = false;
|
|
9299
|
-
this.
|
|
10220
|
+
this.breakSource = void 0;
|
|
10221
|
+
this.followUpBaseVastUrl = void 0;
|
|
10222
|
+
this.unusableResponsesInBreak = 0;
|
|
10223
|
+
adPlayer.stop().catch(function() {});
|
|
10224
|
+
if (!alreadyEnded) this.logBreakFunnel(reason);
|
|
10225
|
+
this.setSlotState("IDLE", "break_complete");
|
|
9300
10226
|
var restoredMuted = this.host.getAdPlayer().getOriginalMutedState();
|
|
9301
10227
|
var restoredVolume = this.host.getAdPlayer().getOriginalVolume();
|
|
9302
10228
|
if (this.host.video.muted !== restoredMuted) {
|
|
@@ -9590,25 +10516,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9590
10516
|
{
|
|
9591
10517
|
key: "handleAdFailure",
|
|
9592
10518
|
value: function handleAdFailure() {
|
|
9593
|
-
|
|
9594
|
-
this.
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
}
|
|
9600
|
-
}
|
|
9601
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
9602
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Max consecutive failures reached (".concat(this.timing.consecutiveFailures, "), ending ad break gracefully"));
|
|
9603
|
-
this.handleAdPodComplete();
|
|
10519
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "ad_failure";
|
|
10520
|
+
if (!this.inAdBreak) return;
|
|
10521
|
+
if (this.slotState === "REQUESTING" || this.slotState === "ENDING") {
|
|
10522
|
+
this.logOrchestratorFunnel("failure_deferred_to_request", {
|
|
10523
|
+
reason: reason,
|
|
10524
|
+
state: this.slotState
|
|
10525
|
+
});
|
|
9604
10526
|
return;
|
|
9605
10527
|
}
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
this.
|
|
10528
|
+
this.timing.consecutiveFailures++;
|
|
10529
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
10530
|
+
if (diag && !diag.failureReason) diag.failureReason = reason;
|
|
10531
|
+
if (this.debug) {
|
|
10532
|
+
console.log("[AdBreak] Ad failure (".concat(reason, "): remaining=").concat(this.timing.getRemainingAdMs(), "ms, consecutiveFailures=").concat(this.timing.consecutiveFailures));
|
|
9611
10533
|
}
|
|
10534
|
+
this.setSlotState("NEEDS_NEXT_AD", reason);
|
|
10535
|
+
this.requestNextAd(reason);
|
|
9612
10536
|
}
|
|
9613
10537
|
}
|
|
9614
10538
|
]);
|
|
@@ -9649,10 +10573,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9649
10573
|
_this.startScte35AdBreak(marker, cueKey, marker.durationSeconds != null ? marker.durationSeconds * 1e3 : _this.timing.expectedAdBreakDurationMs);
|
|
9650
10574
|
},
|
|
9651
10575
|
onWatchdogTimeout: function onWatchdogTimeout() {
|
|
9652
|
-
return _this.adBreak.
|
|
10576
|
+
return _this.adBreak.handleRequestWatchdogTimeout();
|
|
9653
10577
|
},
|
|
9654
10578
|
onFailsafeTimeout: function onFailsafeTimeout() {
|
|
9655
|
-
return _this.adBreak.handleAdFailure();
|
|
10579
|
+
return _this.adBreak.handleAdFailure("failsafe_timeout");
|
|
9656
10580
|
},
|
|
9657
10581
|
getAdState: function getAdState() {
|
|
9658
10582
|
return {
|
|
@@ -9754,6 +10678,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9754
10678
|
licenseKey: this.config.licenseKey
|
|
9755
10679
|
} : {}, ((_this_hlsEngine = this.hlsEngine) === null || _this_hlsEngine === void 0 ? void 0 : _this_hlsEngine.hls) ? {
|
|
9756
10680
|
mainHlsInstance: this.hlsEngine.hls
|
|
10681
|
+
} : {}, this.config.adMediaStartTimeoutMs != null ? {
|
|
10682
|
+
mediaStartTimeoutMs: this.config.adMediaStartTimeoutMs
|
|
9757
10683
|
} : {}));
|
|
9758
10684
|
}
|
|
9759
10685
|
},
|
|
@@ -9900,6 +10826,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9900
10826
|
adBehavior: adBehavior
|
|
9901
10827
|
});
|
|
9902
10828
|
}
|
|
10829
|
+
if (this.adBreak.isBreakActive()) {
|
|
10830
|
+
console.log("[AD-CONTROLLER] destroy skipped", {
|
|
10831
|
+
reason: "manifest_parsed_during_break",
|
|
10832
|
+
state: this.adBreak.getSlotState()
|
|
10833
|
+
});
|
|
10834
|
+
return [
|
|
10835
|
+
2
|
|
10836
|
+
];
|
|
10837
|
+
}
|
|
10838
|
+
if (this.debug) {
|
|
10839
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
10840
|
+
reason: "manifest_parsed",
|
|
10841
|
+
state: "IDLE"
|
|
10842
|
+
});
|
|
10843
|
+
}
|
|
9903
10844
|
this.adPlayer.destroy();
|
|
9904
10845
|
this.adPlayer = this.createAdPlayer(this.shouldContinueLiveStreamDuringAds());
|
|
9905
10846
|
this.adPlayer.initialize();
|
|
@@ -10081,9 +11022,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10081
11022
|
this.timing.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
10082
11023
|
}
|
|
10083
11024
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
10084
|
-
if (!this.adPlayer.isAdPlaying() && this.timing.activeAdRequestToken === null && this.adBreak.adRequestQueue.length > 0 && this.timing.hasTimeToStartAnotherAd()) {
|
|
10085
|
-
this.adBreak.tryNextAvailableAdWithRateLimit();
|
|
10086
|
-
}
|
|
10087
11025
|
return;
|
|
10088
11026
|
}
|
|
10089
11027
|
if (marker.type === "end") {
|
|
@@ -10095,12 +11033,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10095
11033
|
}
|
|
10096
11034
|
var remaining = this.timing.getRemainingAdMs();
|
|
10097
11035
|
var adPlaying = this.adPlayer.isAdPlaying();
|
|
10098
|
-
var hasQueuedAds = this.adBreak.adRequestQueue.length > 0;
|
|
10099
11036
|
if (this.debug) {
|
|
10100
11037
|
console.log("[StormcloudVideoPlayer] SCTE-35 end marker received:", {
|
|
10101
11038
|
remaining: remaining,
|
|
10102
11039
|
adPlaying: adPlaying,
|
|
10103
|
-
|
|
11040
|
+
adSlotState: this.adBreak.getSlotState(),
|
|
10104
11041
|
activeAdRequest: this.timing.activeAdRequestToken !== null
|
|
10105
11042
|
});
|
|
10106
11043
|
}
|
|
@@ -10108,9 +11045,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10108
11045
|
this.timing.clearAdStartTimer();
|
|
10109
11046
|
this.timing.clearAdStopTimer();
|
|
10110
11047
|
if (adPlaying) {
|
|
11048
|
+
this.adBreak.noteStopBeforeStart("scte_end");
|
|
10111
11049
|
this.adPlayer.stop().catch(function() {});
|
|
10112
11050
|
}
|
|
10113
|
-
this.adBreak.handleAdPodComplete();
|
|
11051
|
+
this.adBreak.handleAdPodComplete("scte_end");
|
|
10114
11052
|
return;
|
|
10115
11053
|
}
|
|
10116
11054
|
}
|
|
@@ -10118,6 +11056,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10118
11056
|
{
|
|
10119
11057
|
key: "startScte35AdBreak",
|
|
10120
11058
|
value: function startScte35AdBreak(marker, cueKey, durationMs) {
|
|
11059
|
+
if (this.adBreak.isBreakActive()) {
|
|
11060
|
+
if (this.debug) {
|
|
11061
|
+
console.log("[StormcloudVideoPlayer] Ignoring SCTE-35 break start: a break is already active", {
|
|
11062
|
+
state: this.adBreak.getSlotState(),
|
|
11063
|
+
cueKey: cueKey
|
|
11064
|
+
});
|
|
11065
|
+
}
|
|
11066
|
+
return;
|
|
11067
|
+
}
|
|
10121
11068
|
this.adBreak.inAdBreak = true;
|
|
10122
11069
|
this.cueManager.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.cueManager.pendingScte35CueKey;
|
|
10123
11070
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
@@ -10147,9 +11094,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10147
11094
|
console.log("[StormcloudVideoPlayer] Ad break boundary reached (overrun=".concat(overrunMs, "ms) - hard-stopping ads and resuming stream"));
|
|
10148
11095
|
}
|
|
10149
11096
|
if (adPlaying) {
|
|
11097
|
+
this.adBreak.noteStopBeforeStart("break_boundary");
|
|
10150
11098
|
this.adPlayer.stop().catch(function() {});
|
|
10151
11099
|
}
|
|
10152
|
-
this.adBreak.handleAdPodComplete();
|
|
11100
|
+
this.adBreak.handleAdPodComplete("break_boundary");
|
|
10153
11101
|
}
|
|
10154
11102
|
},
|
|
10155
11103
|
{
|
|
@@ -10159,14 +11107,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10159
11107
|
key: "startAdPrefetch",
|
|
10160
11108
|
value: function startAdPrefetch(marker, fragmentSn, cueKey) {
|
|
10161
11109
|
if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
|
|
10162
|
-
var
|
|
10163
|
-
|
|
10164
|
-
var baseVastUrl;
|
|
10165
|
-
if (tags && tags.length > 0 && tags[0]) {
|
|
10166
|
-
baseVastUrl = tags[0];
|
|
10167
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
10168
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
10169
|
-
} else {
|
|
11110
|
+
var baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
11111
|
+
if (!baseVastUrl) {
|
|
10170
11112
|
if (this.debug) console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
|
|
10171
11113
|
return;
|
|
10172
11114
|
}
|
|
@@ -10196,8 +11138,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10196
11138
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
10197
11139
|
}, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
|
|
10198
11140
|
if (this.debug) {
|
|
10199
|
-
console.log("[PREFETCH]
|
|
10200
|
-
console.log("[PREFETCH] Pre-generated pod request URL");
|
|
11141
|
+
console.log("[PREFETCH] Pre-generated pod request URL for upcoming ad break");
|
|
10201
11142
|
}
|
|
10202
11143
|
}
|
|
10203
11144
|
},
|
|
@@ -10208,7 +11149,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10208
11149
|
key: "onTimeUpdate",
|
|
10209
11150
|
value: function onTimeUpdate(currentTimeSec) {
|
|
10210
11151
|
var _this = this;
|
|
10211
|
-
if (
|
|
11152
|
+
if (this.adConfig.vmapBreaks.length === 0) return;
|
|
10212
11153
|
if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
|
|
10213
11154
|
var nowMs = currentTimeSec * 1e3;
|
|
10214
11155
|
var breakToPlay = this.adConfig.findBreakForTime(nowMs);
|
|
@@ -10225,7 +11166,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10225
11166
|
key: "onVideoEnded",
|
|
10226
11167
|
value: function onVideoEnded() {
|
|
10227
11168
|
var _this = this;
|
|
10228
|
-
if (
|
|
11169
|
+
if (this.adConfig.vmapBreaks.length === 0) return;
|
|
10229
11170
|
if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
|
|
10230
11171
|
var durationMs = Number.isFinite(this.video.duration) ? Math.floor(this.video.duration * 1e3) : 0;
|
|
10231
11172
|
var postroll = this.adConfig.vmapBreaks.find(function(b) {
|
|
@@ -10275,6 +11216,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10275
11216
|
this.adBreak.showAds = true;
|
|
10276
11217
|
this.adBreak.inAdBreak = true;
|
|
10277
11218
|
this.timing.currentAdBreakStartWallClockMs = Date.now();
|
|
11219
|
+
if (durationMs > 0) {
|
|
11220
|
+
this.timing.setAdBreakDurationBoundary(durationMs);
|
|
11221
|
+
}
|
|
11222
|
+
this.adBreak.beginVmapBreak(key);
|
|
10278
11223
|
_state.label = 1;
|
|
10279
11224
|
case 1:
|
|
10280
11225
|
_state.trys.push([
|
|
@@ -10285,7 +11230,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10285
11230
|
]);
|
|
10286
11231
|
return [
|
|
10287
11232
|
4,
|
|
10288
|
-
this.adBreak.playSingleAd(first)
|
|
11233
|
+
this.adBreak.playSingleAd(first, "vmap")
|
|
10289
11234
|
];
|
|
10290
11235
|
case 2:
|
|
10291
11236
|
_state.sent();
|
|
@@ -10298,7 +11243,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10298
11243
|
if (this.debug) {
|
|
10299
11244
|
console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
|
|
10300
11245
|
}
|
|
10301
|
-
this.adBreak.
|
|
11246
|
+
this.adBreak.continueAfterRequestFailure();
|
|
10302
11247
|
return [
|
|
10303
11248
|
3,
|
|
10304
11249
|
4
|
|
@@ -10440,7 +11385,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10440
11385
|
key: "destroy",
|
|
10441
11386
|
value: function destroy() {
|
|
10442
11387
|
var _this_adPlayer;
|
|
10443
|
-
this.adBreak.
|
|
11388
|
+
this.adBreak.cancelScheduledRequest();
|
|
10444
11389
|
this.timing.destroy();
|
|
10445
11390
|
this.adBreak.clearPendingAdBreak();
|
|
10446
11391
|
this.placeholder.destroy();
|
|
@@ -10464,7 +11409,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10464
11409
|
this.palNonce.sendPlaybackEnd();
|
|
10465
11410
|
}
|
|
10466
11411
|
this.palNonce.reset();
|
|
10467
|
-
this.adBreak.adRequestQueue = [];
|
|
10468
11412
|
this.timing.consecutiveFailures = 0;
|
|
10469
11413
|
}
|
|
10470
11414
|
}
|