stormcloud-video-player 0.8.64 → 0.8.65
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 +927 -133
- package/lib/StormcloudPlayer.cjs.map +1 -1
- package/lib/index.cjs +927 -133
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +7 -0
- package/lib/index.js +927 -133
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +246 -16
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +16 -0
- 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 +927 -133
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +927 -133
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +927 -133
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +700 -115
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -0
- package/lib/types.d.cts +6 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +927 -133
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -764,7 +764,7 @@ function toVastMediaErrorCode(error) {
|
|
|
764
764
|
}
|
|
765
765
|
}
|
|
766
766
|
function createHlsAdPlayer(contentVideo, options) {
|
|
767
|
-
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
|
|
767
|
+
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP, _ref;
|
|
768
768
|
var adPlaying = false;
|
|
769
769
|
var originalMutedState = false;
|
|
770
770
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
@@ -796,6 +796,16 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
796
796
|
var sawDecodedVideoFrame = false;
|
|
797
797
|
var videoFrameCallbackHandle;
|
|
798
798
|
var pendingPlayPromise;
|
|
799
|
+
var currentVastTagUrl;
|
|
800
|
+
var funnelContext = {};
|
|
801
|
+
var mediaCandidates = [];
|
|
802
|
+
var mediaCandidateIndex = 0;
|
|
803
|
+
var mediaStartTimerId;
|
|
804
|
+
var MEDIA_START_TIMEOUT_MS = (_ref = options === null || options === void 0 ? void 0 : options.mediaStartTimeoutMs) !== null && _ref !== void 0 ? _ref : 8e3;
|
|
805
|
+
var VAST_ERROR_MEDIA_TIMEOUT = 402;
|
|
806
|
+
var pendingVastRequests = /* @__PURE__ */ new Set();
|
|
807
|
+
var pendingRequestAbortReason;
|
|
808
|
+
var forcedMuteByAutoplay = false;
|
|
799
809
|
function createTrackingState() {
|
|
800
810
|
return {
|
|
801
811
|
impression: false,
|
|
@@ -846,6 +856,77 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
846
856
|
}
|
|
847
857
|
}
|
|
848
858
|
}
|
|
859
|
+
var SENSITIVE_URL_PARAMS = /* @__PURE__ */ new Set([
|
|
860
|
+
"ppid",
|
|
861
|
+
"rdid",
|
|
862
|
+
"idtype",
|
|
863
|
+
"is_lat",
|
|
864
|
+
"ifa",
|
|
865
|
+
"idfa",
|
|
866
|
+
"aaid",
|
|
867
|
+
"uid",
|
|
868
|
+
"user_id",
|
|
869
|
+
"userid",
|
|
870
|
+
"device_id",
|
|
871
|
+
"deviceid",
|
|
872
|
+
"ip",
|
|
873
|
+
"ua",
|
|
874
|
+
"gdpr_consent",
|
|
875
|
+
"us_privacy",
|
|
876
|
+
"gpp",
|
|
877
|
+
"addtl_consent",
|
|
878
|
+
"cust_params",
|
|
879
|
+
"email"
|
|
880
|
+
]);
|
|
881
|
+
function redactUrl(url) {
|
|
882
|
+
if (!url) return url;
|
|
883
|
+
try {
|
|
884
|
+
var parsed = new URL(url);
|
|
885
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
886
|
+
try {
|
|
887
|
+
for(var _iterator = Array.from(parsed.searchParams.keys())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
888
|
+
var key = _step.value;
|
|
889
|
+
if (SENSITIVE_URL_PARAMS.has(key.toLowerCase())) {
|
|
890
|
+
parsed.searchParams.set(key, "REDACTED");
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
} catch (err) {
|
|
894
|
+
_didIteratorError = true;
|
|
895
|
+
_iteratorError = err;
|
|
896
|
+
} finally{
|
|
897
|
+
try {
|
|
898
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
899
|
+
_iterator.return();
|
|
900
|
+
}
|
|
901
|
+
} finally{
|
|
902
|
+
if (_didIteratorError) {
|
|
903
|
+
throw _iteratorError;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
return parsed.toString();
|
|
908
|
+
} catch (unused) {
|
|
909
|
+
return url.split("?")[0];
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
function logFunnel(stage) {
|
|
913
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
914
|
+
var payload = _object_spread({
|
|
915
|
+
stage: stage,
|
|
916
|
+
breakId: funnelContext.breakId,
|
|
917
|
+
requestId: funnelContext.requestId,
|
|
918
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0,
|
|
919
|
+
adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
|
|
920
|
+
podIndex: podIndex,
|
|
921
|
+
podSize: podAds.length,
|
|
922
|
+
vastUrl: redactUrl(currentVastTagUrl),
|
|
923
|
+
mediaUrl: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url,
|
|
924
|
+
mediaType: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.type,
|
|
925
|
+
muted: adVideoElement ? adVideoElement.muted : void 0
|
|
926
|
+
}, extra);
|
|
927
|
+
console.log("[HlsAdPlayer][FUNNEL] ".concat(stage), payload);
|
|
928
|
+
emit("ad_funnel", payload);
|
|
929
|
+
}
|
|
849
930
|
function buildTrackingMacroContext() {
|
|
850
931
|
var options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
851
932
|
var _options2_ad;
|
|
@@ -885,20 +966,53 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
885
966
|
urls.forEach(function(url) {
|
|
886
967
|
try {
|
|
887
968
|
var trackingUrl = substituteVastTrackingMacros(url, macroContext);
|
|
969
|
+
var trackingHost;
|
|
970
|
+
try {
|
|
971
|
+
trackingHost = new URL(trackingUrl).host;
|
|
972
|
+
} catch (unused) {
|
|
973
|
+
logFunnel("tracking_url_invalid", {
|
|
974
|
+
trackingUrl: redactUrl(trackingUrl)
|
|
975
|
+
});
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
var unexpanded = trackingUrl.match(/\[[A-Z_]+\]/g);
|
|
979
|
+
if (unexpanded) {
|
|
980
|
+
logFunnel("tracking_url_unexpanded_macro", {
|
|
981
|
+
trackingHost: trackingHost,
|
|
982
|
+
macros: Array.from(new Set(unexpanded))
|
|
983
|
+
});
|
|
984
|
+
}
|
|
888
985
|
var img = new Image(1, 1);
|
|
889
986
|
inFlightBeacons.add(img);
|
|
890
987
|
var timeoutId;
|
|
891
|
-
var release = function release() {
|
|
988
|
+
var release = function release(outcome) {
|
|
892
989
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
893
990
|
img.onload = null;
|
|
894
991
|
img.onerror = null;
|
|
895
992
|
inFlightBeacons.delete(img);
|
|
993
|
+
console.log("[HlsAdPlayer] Tracking pixel settled (".concat(outcome, "): ").concat(trackingUrl));
|
|
994
|
+
if (outcome !== "load") {
|
|
995
|
+
logFunnel("tracking_request_settled", {
|
|
996
|
+
reason: outcome,
|
|
997
|
+
trackingHost: trackingHost
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
img.onload = function() {
|
|
1002
|
+
return release("load");
|
|
1003
|
+
};
|
|
1004
|
+
img.onerror = function() {
|
|
1005
|
+
return release("error");
|
|
896
1006
|
};
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
1007
|
+
timeoutId = setTimeout(function() {
|
|
1008
|
+
return release("timeout");
|
|
1009
|
+
}, BEACON_TIMEOUT_MS);
|
|
900
1010
|
img.src = trackingUrl;
|
|
901
1011
|
console.log("[HlsAdPlayer] Fired tracking pixel: ".concat(trackingUrl));
|
|
1012
|
+
logFunnel("tracking_request_created", {
|
|
1013
|
+
trackingHost: trackingHost,
|
|
1014
|
+
errorCode: options2 === null || options2 === void 0 ? void 0 : options2.errorCode
|
|
1015
|
+
});
|
|
902
1016
|
} catch (error) {
|
|
903
1017
|
console.warn("[HlsAdPlayer] Error firing tracking pixel:", error);
|
|
904
1018
|
}
|
|
@@ -928,54 +1042,80 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
928
1042
|
bitrate: level.bitrate || 5e6
|
|
929
1043
|
};
|
|
930
1044
|
}
|
|
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
|
-
}
|
|
1045
|
+
function getMediaTargetQuality() {
|
|
942
1046
|
var mainQuality = getMainStreamQuality();
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1047
|
+
var dpr = typeof window !== "undefined" && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1;
|
|
1048
|
+
var containerWidth = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientWidth) || contentVideo.clientWidth) * dpr;
|
|
1049
|
+
var containerHeight = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientHeight) || contentVideo.clientHeight) * dpr;
|
|
1050
|
+
if (!mainQuality && !(containerWidth > 0 && containerHeight > 0)) {
|
|
1051
|
+
return null;
|
|
1052
|
+
}
|
|
1053
|
+
var base = mainQuality !== null && mainQuality !== void 0 ? mainQuality : {
|
|
1054
|
+
width: containerWidth,
|
|
1055
|
+
height: containerHeight,
|
|
1056
|
+
bitrate: 5e6
|
|
1057
|
+
};
|
|
1058
|
+
var width = containerWidth > 0 ? Math.min(base.width, containerWidth) : base.width;
|
|
1059
|
+
var height = containerHeight > 0 ? Math.min(base.height, containerHeight) : base.height;
|
|
1060
|
+
return {
|
|
1061
|
+
width: width,
|
|
1062
|
+
height: height,
|
|
1063
|
+
bitrate: base.bitrate
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
function rankMediaCandidates(mediaFiles) {
|
|
1067
|
+
var probe = adVideoElement !== null && adVideoElement !== void 0 ? adVideoElement : document.createElement("video");
|
|
1068
|
+
var pageIsHttps = typeof location !== "undefined" && location.protocol === "https:";
|
|
1069
|
+
var target = getMediaTargetQuality();
|
|
1070
|
+
var accepted = [];
|
|
1071
|
+
mediaFiles.forEach(function(file, index) {
|
|
1072
|
+
var isHls = isHlsMediaFile(file);
|
|
1073
|
+
var mimeForProbe = isHls ? "application/vnd.apple.mpegurl" : file.type || "video/mp4";
|
|
1074
|
+
var canPlay2 = probe.canPlayType(mimeForProbe);
|
|
1075
|
+
var playable = isHls ? Hls.isSupported() || canPlay2 !== "" : canPlay2 !== "";
|
|
1076
|
+
var insecure = pageIsHttps && /^http:/i.test(file.url);
|
|
1077
|
+
var details = {
|
|
1078
|
+
index: index,
|
|
1079
|
+
candidateUrl: file.url,
|
|
1080
|
+
candidateType: file.type,
|
|
1081
|
+
width: file.width,
|
|
1082
|
+
height: file.height,
|
|
1083
|
+
bitrate: file.bitrate,
|
|
1084
|
+
canPlayType: canPlay2,
|
|
1085
|
+
hlsJs: isHls ? Hls.isSupported() : void 0
|
|
1086
|
+
};
|
|
1087
|
+
if (!playable) {
|
|
1088
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1089
|
+
reason: "rejected",
|
|
1090
|
+
why: "cannot_play_type"
|
|
1091
|
+
}));
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
var score = 0;
|
|
1095
|
+
if (target) {
|
|
1096
|
+
var resolutionDiff = Math.abs(file.width - target.width) + Math.abs(file.height - target.height);
|
|
1097
|
+
var bitrateDiff = Math.abs((file.bitrate || 5e3) * 1e3 - target.bitrate);
|
|
1098
|
+
score = resolutionDiff * 2 + bitrateDiff / 1e3;
|
|
1099
|
+
}
|
|
1100
|
+
accepted.push({
|
|
956
1101
|
file: file,
|
|
957
1102
|
score: score,
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
}
|
|
1103
|
+
insecure: insecure
|
|
1104
|
+
});
|
|
1105
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1106
|
+
reason: "accepted",
|
|
1107
|
+
// Mixed-content media is often auto-upgraded, so it is kept as a last resort.
|
|
1108
|
+
why: insecure ? "insecure_http_deprioritized" : "playable",
|
|
1109
|
+
score: score
|
|
1110
|
+
}));
|
|
961
1111
|
});
|
|
962
|
-
|
|
1112
|
+
accepted.sort(function(a, b) {
|
|
1113
|
+
if (a.insecure !== b.insecure) return a.insecure ? 1 : -1;
|
|
963
1114
|
return a.score - b.score;
|
|
964
1115
|
});
|
|
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
|
|
1116
|
+
return accepted.map(function(entry) {
|
|
1117
|
+
return entry.file;
|
|
977
1118
|
});
|
|
978
|
-
return bestMatch.file;
|
|
979
1119
|
}
|
|
980
1120
|
function isHlsMediaFile(mediaFile) {
|
|
981
1121
|
var type = mediaFile.type.toLowerCase();
|
|
@@ -992,9 +1132,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
992
1132
|
var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
|
|
993
1133
|
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
1134
|
}
|
|
995
|
-
function collectVideoMediaFiles(linear, verbose) {
|
|
1135
|
+
function collectVideoMediaFiles(linear, verbose, stats) {
|
|
996
1136
|
var mediaFileElements = linear.querySelectorAll(":scope > MediaFiles > MediaFile");
|
|
997
1137
|
var mediaFiles = [];
|
|
1138
|
+
if (stats) stats.total += mediaFileElements.length;
|
|
998
1139
|
if (verbose) {
|
|
999
1140
|
console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
|
|
1000
1141
|
}
|
|
@@ -1015,6 +1156,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1015
1156
|
}
|
|
1016
1157
|
var apiFramework = (mf.getAttribute("apiFramework") || "").toUpperCase();
|
|
1017
1158
|
if (apiFramework === "VPAID") {
|
|
1159
|
+
if (stats) stats.vpaid++;
|
|
1018
1160
|
if (verbose) {
|
|
1019
1161
|
console.log("[HlsAdPlayer] MediaFile ".concat(index, " ignored (VPAID creatives are not supported)"));
|
|
1020
1162
|
}
|
|
@@ -1030,11 +1172,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1030
1172
|
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
1031
1173
|
};
|
|
1032
1174
|
if (isAudioMediaFile(mediaFile)) {
|
|
1175
|
+
if (stats) stats.audio++;
|
|
1033
1176
|
console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
|
|
1034
1177
|
return;
|
|
1035
1178
|
}
|
|
1036
1179
|
var hasExplicitDimensions = mf.getAttribute("width") != null && mf.getAttribute("height") != null;
|
|
1037
1180
|
if (!isHlsMediaFile(mediaFile) && hasExplicitDimensions && (mediaFile.width <= 1 || mediaFile.height <= 1)) {
|
|
1181
|
+
if (stats) stats.audio++;
|
|
1038
1182
|
console.warn("[HlsAdPlayer] MediaFile ".concat(index, " skipped (degenerate dimensions ").concat(mediaFile.width, "x").concat(mediaFile.height, ', type="').concat(type, '") — likely an audio-only placeholder rendition'));
|
|
1039
1183
|
return;
|
|
1040
1184
|
}
|
|
@@ -1043,8 +1187,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1043
1187
|
if (verbose) {
|
|
1044
1188
|
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
1045
1189
|
}
|
|
1046
|
-
} else
|
|
1047
|
-
|
|
1190
|
+
} else {
|
|
1191
|
+
if (stats) stats.unsupported++;
|
|
1192
|
+
if (verbose) {
|
|
1193
|
+
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
1194
|
+
}
|
|
1048
1195
|
}
|
|
1049
1196
|
});
|
|
1050
1197
|
return mediaFiles;
|
|
@@ -1168,26 +1315,58 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1168
1315
|
}
|
|
1169
1316
|
function parseVastXml(xmlString) {
|
|
1170
1317
|
try {
|
|
1171
|
-
var _adElements_find;
|
|
1172
1318
|
var xmlDoc = parseXml(xmlString);
|
|
1173
1319
|
if (!xmlDoc) return {
|
|
1174
1320
|
type: "empty"
|
|
1175
1321
|
};
|
|
1176
1322
|
var root = xmlDoc.documentElement;
|
|
1177
1323
|
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) {
|
|
1324
|
+
if (adElements.length === 0) {
|
|
1182
1325
|
var _root_getAttribute;
|
|
1183
1326
|
console.warn("[HlsAdPlayer] No Ad element found in VAST ".concat((_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : "", " response"));
|
|
1184
1327
|
return emptyVastResult(root);
|
|
1185
1328
|
}
|
|
1186
|
-
var
|
|
1187
|
-
|
|
1188
|
-
|
|
1329
|
+
var ordered = _to_consumable_array(adElements.filter(function(el) {
|
|
1330
|
+
return getAdSequence(el) === void 0;
|
|
1331
|
+
})).concat(_to_consumable_array(adElements.filter(function(el) {
|
|
1332
|
+
return getAdSequence(el) !== void 0;
|
|
1333
|
+
})));
|
|
1334
|
+
var firstEmpty;
|
|
1335
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1336
|
+
try {
|
|
1337
|
+
for(var _iterator = ordered.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1338
|
+
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], adElement = _step_value[1];
|
|
1339
|
+
var parsed = parseAdElement(adElement, true);
|
|
1340
|
+
if (parsed.type === "empty") {
|
|
1341
|
+
firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : firstEmpty = parsed;
|
|
1342
|
+
continue;
|
|
1343
|
+
}
|
|
1344
|
+
if (index > 0) {
|
|
1345
|
+
logFunnel("vast_ad_fallback", {
|
|
1346
|
+
usedAdIndex: index,
|
|
1347
|
+
adCount: ordered.length
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
if (parsed.type === "wrapper") {
|
|
1351
|
+
console.log("[HlsAdPlayer] VAST wrapper detected, following VASTAdTagURI: ".concat(parsed.vastAdTagUri));
|
|
1352
|
+
}
|
|
1353
|
+
return parsed;
|
|
1354
|
+
}
|
|
1355
|
+
} catch (err) {
|
|
1356
|
+
_didIteratorError = true;
|
|
1357
|
+
_iteratorError = err;
|
|
1358
|
+
} finally{
|
|
1359
|
+
try {
|
|
1360
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1361
|
+
_iterator.return();
|
|
1362
|
+
}
|
|
1363
|
+
} finally{
|
|
1364
|
+
if (_didIteratorError) {
|
|
1365
|
+
throw _iteratorError;
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1189
1368
|
}
|
|
1190
|
-
return
|
|
1369
|
+
return firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : emptyVastResult(root);
|
|
1191
1370
|
} catch (error) {
|
|
1192
1371
|
console.error("[HlsAdPlayer] Error parsing VAST XML:", error);
|
|
1193
1372
|
return {
|
|
@@ -1233,6 +1412,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1233
1412
|
pushUrls(errorUrls, inLine.querySelectorAll(":scope > Error"));
|
|
1234
1413
|
if (adElement.getAttribute("conditionalAd") === "true") {
|
|
1235
1414
|
console.warn("[HlsAdPlayer] Skipping conditional <Ad> (VPAID-only)");
|
|
1415
|
+
logFunnel("vast_no_supported_media", {
|
|
1416
|
+
reason: "vpaid_only",
|
|
1417
|
+
conditionalAd: true
|
|
1418
|
+
});
|
|
1236
1419
|
return {
|
|
1237
1420
|
type: "empty",
|
|
1238
1421
|
errorUrls: errorUrls,
|
|
@@ -1241,11 +1424,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1241
1424
|
}
|
|
1242
1425
|
var linear;
|
|
1243
1426
|
var mediaFiles = [];
|
|
1427
|
+
var rejectStats = {
|
|
1428
|
+
total: 0,
|
|
1429
|
+
vpaid: 0,
|
|
1430
|
+
audio: 0,
|
|
1431
|
+
unsupported: 0
|
|
1432
|
+
};
|
|
1244
1433
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1245
1434
|
try {
|
|
1246
1435
|
for(var _iterator = Array.from(inLine.querySelectorAll(":scope > Creatives > Creative > Linear"))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1247
1436
|
var candidate = _step.value;
|
|
1248
|
-
var files = collectVideoMediaFiles(candidate, verbose);
|
|
1437
|
+
var files = collectVideoMediaFiles(candidate, verbose, rejectStats);
|
|
1249
1438
|
if (files.length > 0) {
|
|
1250
1439
|
linear = candidate;
|
|
1251
1440
|
mediaFiles = files;
|
|
@@ -1268,6 +1457,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1268
1457
|
}
|
|
1269
1458
|
if (!linear) {
|
|
1270
1459
|
console.warn("[HlsAdPlayer] No supported linear media files in <Ad>");
|
|
1460
|
+
var reason = rejectStats.total === 0 ? "no_mediafiles" : rejectStats.vpaid > 0 ? "vpaid_only" : rejectStats.audio > 0 ? "audio_only" : "unsupported_type";
|
|
1461
|
+
logFunnel("vast_no_supported_media", _object_spread({
|
|
1462
|
+
reason: reason
|
|
1463
|
+
}, rejectStats));
|
|
1271
1464
|
return {
|
|
1272
1465
|
type: "empty",
|
|
1273
1466
|
errorUrls: errorUrls,
|
|
@@ -1303,7 +1496,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1303
1496
|
return _ts_generator(this, function(_state) {
|
|
1304
1497
|
switch(_state.label){
|
|
1305
1498
|
case 0:
|
|
1499
|
+
if (destroyed) {
|
|
1500
|
+
throw new Error("VAST request skipped: ad player destroyed");
|
|
1501
|
+
}
|
|
1306
1502
|
controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1503
|
+
if (controller) pendingVastRequests.add(controller);
|
|
1307
1504
|
timeoutId = controller ? setTimeout(function() {
|
|
1308
1505
|
return controller.abort();
|
|
1309
1506
|
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
@@ -1352,6 +1549,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1352
1549
|
6
|
|
1353
1550
|
];
|
|
1354
1551
|
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
1552
|
+
logFunnel("vast_credentials_retry", {
|
|
1553
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1554
|
+
});
|
|
1355
1555
|
return [
|
|
1356
1556
|
4,
|
|
1357
1557
|
requestVast("omit")
|
|
@@ -1385,11 +1585,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1385
1585
|
case 10:
|
|
1386
1586
|
error1 = _state.sent();
|
|
1387
1587
|
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1588
|
+
if (pendingRequestAbortReason) {
|
|
1589
|
+
throw new Error("".concat(pendingRequestAbortReason, " (timeout): ").concat(vastTagUrl));
|
|
1590
|
+
}
|
|
1388
1591
|
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1389
1592
|
}
|
|
1390
1593
|
throw error1;
|
|
1391
1594
|
case 11:
|
|
1392
1595
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1596
|
+
if (controller) pendingVastRequests.delete(controller);
|
|
1393
1597
|
return [
|
|
1394
1598
|
7
|
|
1395
1599
|
];
|
|
@@ -1403,7 +1607,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1403
1607
|
}
|
|
1404
1608
|
function fetchAndParseVastAd(_0) {
|
|
1405
1609
|
return _async_to_generator(function(vastTagUrl) {
|
|
1406
|
-
var depth, accumulatedTracking, rules, vastXml, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1610
|
+
var depth, accumulatedTracking, rules, vastXml, fetchStartedAt, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1407
1611
|
var _arguments = arguments;
|
|
1408
1612
|
return _ts_generator(this, function(_state) {
|
|
1409
1613
|
switch(_state.label){
|
|
@@ -1411,6 +1615,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1411
1615
|
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
1616
|
followAdditionalWrappers: true
|
|
1413
1617
|
};
|
|
1618
|
+
if (destroyed) return [
|
|
1619
|
+
2,
|
|
1620
|
+
null
|
|
1621
|
+
];
|
|
1622
|
+
fetchStartedAt = Date.now();
|
|
1414
1623
|
_state.label = 1;
|
|
1415
1624
|
case 1:
|
|
1416
1625
|
_state.trys.push([
|
|
@@ -1433,14 +1642,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1433
1642
|
error = _state.sent();
|
|
1434
1643
|
if (depth === 0) throw error;
|
|
1435
1644
|
console.warn("[HlsAdPlayer] Wrapped VAST request failed:", error);
|
|
1436
|
-
|
|
1437
|
-
|
|
1645
|
+
logFunnel("wrapper_fetch", {
|
|
1646
|
+
reason: "failure",
|
|
1647
|
+
depth: depth,
|
|
1648
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
1649
|
+
elapsedMs: Date.now() - fetchStartedAt,
|
|
1650
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1438
1651
|
});
|
|
1652
|
+
if (!destroyed) {
|
|
1653
|
+
fireTrackingPixels(accumulatedTracking.error, {
|
|
1654
|
+
errorCode: VAST_ERROR_WRAPPER_TIMEOUT
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1439
1657
|
return [
|
|
1440
1658
|
2,
|
|
1441
1659
|
null
|
|
1442
1660
|
];
|
|
1443
1661
|
case 4:
|
|
1662
|
+
if (destroyed) return [
|
|
1663
|
+
2,
|
|
1664
|
+
null
|
|
1665
|
+
];
|
|
1666
|
+
if (depth > 0) {
|
|
1667
|
+
logFunnel("wrapper_fetch", {
|
|
1668
|
+
reason: "success",
|
|
1669
|
+
depth: depth,
|
|
1670
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
1671
|
+
elapsedMs: Date.now() - fetchStartedAt
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1444
1674
|
console.log("[HlsAdPlayer] VAST XML received");
|
|
1445
1675
|
console.log("[HlsAdPlayer] VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1446
1676
|
parsed = parseVastXml(vastXml);
|
|
@@ -1472,6 +1702,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1472
1702
|
];
|
|
1473
1703
|
}
|
|
1474
1704
|
mergeTrackingUrls(parsed.ad.trackingUrls, accumulatedTracking);
|
|
1705
|
+
logFunnel("inline_resolved", {
|
|
1706
|
+
depth: depth
|
|
1707
|
+
});
|
|
1475
1708
|
return [
|
|
1476
1709
|
2,
|
|
1477
1710
|
parsed.ad
|
|
@@ -1492,6 +1725,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1492
1725
|
];
|
|
1493
1726
|
case 1:
|
|
1494
1727
|
vastXml = _state.sent();
|
|
1728
|
+
if (destroyed) return [
|
|
1729
|
+
2,
|
|
1730
|
+
[]
|
|
1731
|
+
];
|
|
1495
1732
|
console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
|
|
1496
1733
|
trimmedXml = vastXml.trim();
|
|
1497
1734
|
if (trimmedXml.length === 0) {
|
|
@@ -1779,14 +2016,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1779
2016
|
var progress = currentTime / currentAd.duration;
|
|
1780
2017
|
if (progress >= 0.25 && !trackingFired.firstQuartile) {
|
|
1781
2018
|
trackingFired.firstQuartile = true;
|
|
2019
|
+
logFunnel("first_quartile");
|
|
1782
2020
|
fireTrackingPixels(currentAd.trackingUrls.firstQuartile);
|
|
1783
2021
|
}
|
|
1784
2022
|
if (progress >= 0.5 && !trackingFired.midpoint) {
|
|
1785
2023
|
trackingFired.midpoint = true;
|
|
2024
|
+
logFunnel("midpoint");
|
|
1786
2025
|
fireTrackingPixels(currentAd.trackingUrls.midpoint);
|
|
1787
2026
|
}
|
|
1788
2027
|
if (progress >= 0.75 && !trackingFired.thirdQuartile) {
|
|
1789
2028
|
trackingFired.thirdQuartile = true;
|
|
2029
|
+
logFunnel("third_quartile");
|
|
1790
2030
|
fireTrackingPixels(currentAd.trackingUrls.thirdQuartile);
|
|
1791
2031
|
}
|
|
1792
2032
|
};
|
|
@@ -1809,6 +2049,16 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1809
2049
|
if (!trackingFired.impression) {
|
|
1810
2050
|
trackingFired.impression = true;
|
|
1811
2051
|
resolvedAds.add(currentAd);
|
|
2052
|
+
logFunnel("playing", {
|
|
2053
|
+
mutedByAutoplay: forcedMuteByAutoplay,
|
|
2054
|
+
candidateIndex: mediaCandidateIndex
|
|
2055
|
+
});
|
|
2056
|
+
logFunnel("impression_fired", {
|
|
2057
|
+
pixelCount: currentAd.trackingUrls.impression.length
|
|
2058
|
+
});
|
|
2059
|
+
if (currentAd.trackingUrls.impression.length === 0) {
|
|
2060
|
+
console.warn("[HlsAdPlayer] Ad started but VAST contained no <Impression> URLs - GAM will not count it");
|
|
2061
|
+
}
|
|
1812
2062
|
fireTrackingPixels(currentAd.trackingUrls.impression);
|
|
1813
2063
|
fireTrackingPixels(currentAd.trackingUrls.creativeView);
|
|
1814
2064
|
fireTrackingPixels(currentAd.trackingUrls.verificationNotExecuted, {
|
|
@@ -1831,6 +2081,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1831
2081
|
sampleViewability();
|
|
1832
2082
|
settleViewability();
|
|
1833
2083
|
trackingFired.complete = true;
|
|
2084
|
+
logFunnel("complete");
|
|
1834
2085
|
fireTrackingPixels(currentAd.trackingUrls.complete);
|
|
1835
2086
|
console.log("[HlsAdPlayer] Ad completed");
|
|
1836
2087
|
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
|
|
@@ -1839,16 +2090,41 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1839
2090
|
handleAdComplete();
|
|
1840
2091
|
};
|
|
1841
2092
|
var onError = function onError(e) {
|
|
2093
|
+
var _adVideoElement_error, _adVideoElement_error1;
|
|
1842
2094
|
if (!adPlaying) return;
|
|
1843
2095
|
console.error("[HlsAdPlayer] Ad video error:", e);
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
2096
|
+
var vastErrorCode = toVastMediaErrorCode(adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.error);
|
|
2097
|
+
logFunnel("media_error", {
|
|
2098
|
+
mediaErrorCode: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error = adVideoElement.error) === null || _adVideoElement_error === void 0 ? void 0 : _adVideoElement_error.code,
|
|
2099
|
+
errorMessage: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error1 = adVideoElement.error) === null || _adVideoElement_error1 === void 0 ? void 0 : _adVideoElement_error1.message,
|
|
2100
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2101
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2102
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2103
|
+
vastErrorCode: vastErrorCode
|
|
2104
|
+
});
|
|
2105
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2106
|
+
};
|
|
2107
|
+
var onMediaDiagnostic = function onMediaDiagnostic(event) {
|
|
2108
|
+
if (!adPlaying || !adVideoElement || trackingFired.impression) return;
|
|
2109
|
+
if (!adVideoElement.currentSrc) return;
|
|
2110
|
+
logFunnel("media_event", {
|
|
2111
|
+
reason: event.type,
|
|
2112
|
+
readyState: adVideoElement.readyState,
|
|
2113
|
+
networkState: adVideoElement.networkState,
|
|
2114
|
+
currentSrc: adVideoElement.currentSrc
|
|
2115
|
+
});
|
|
1849
2116
|
};
|
|
1850
2117
|
var onVolumeChange = function onVolumeChange() {
|
|
1851
2118
|
if (!currentAd || !adVideoElement) return;
|
|
2119
|
+
if (forcedMuteByAutoplay && !adVideoElement.muted) {
|
|
2120
|
+
var userActivation = navigator.userActivation;
|
|
2121
|
+
if (userActivation && !userActivation.isActive) {
|
|
2122
|
+
logFunnel("unexpected_unmute", {
|
|
2123
|
+
paused: adVideoElement.paused
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
forcedMuteByAutoplay = false;
|
|
2127
|
+
}
|
|
1852
2128
|
var muted = adVideoElement.muted || adVideoElement.volume === 0;
|
|
1853
2129
|
if (!trackingFired.start) {
|
|
1854
2130
|
trackingFired.lastMuted = muted;
|
|
@@ -1908,6 +2184,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1908
2184
|
{
|
|
1909
2185
|
type: "play",
|
|
1910
2186
|
handler: onPlay
|
|
2187
|
+
},
|
|
2188
|
+
{
|
|
2189
|
+
type: "stalled",
|
|
2190
|
+
handler: onMediaDiagnostic
|
|
2191
|
+
},
|
|
2192
|
+
{
|
|
2193
|
+
type: "suspend",
|
|
2194
|
+
handler: onMediaDiagnostic
|
|
2195
|
+
},
|
|
2196
|
+
{
|
|
2197
|
+
type: "abort",
|
|
2198
|
+
handler: onMediaDiagnostic
|
|
2199
|
+
},
|
|
2200
|
+
{
|
|
2201
|
+
type: "emptied",
|
|
2202
|
+
handler: onMediaDiagnostic
|
|
1911
2203
|
}
|
|
1912
2204
|
];
|
|
1913
2205
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -2197,16 +2489,51 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2197
2489
|
function settlePendingPlay() {
|
|
2198
2490
|
pendingPlayPromise = void 0;
|
|
2199
2491
|
}
|
|
2492
|
+
function toVastPlayErrorCode(error) {
|
|
2493
|
+
return (error === null || error === void 0 ? void 0 : error.name) === "NotSupportedError" ? VAST_ERROR_NO_SUPPORTED_MEDIA : VAST_ERROR_MEDIA_DISPLAY;
|
|
2494
|
+
}
|
|
2495
|
+
function failAdPlayback(context, error) {
|
|
2496
|
+
var vastErrorCode = toVastPlayErrorCode(error);
|
|
2497
|
+
console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
|
|
2498
|
+
logFunnel("play_failed", {
|
|
2499
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2500
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message,
|
|
2501
|
+
vastErrorCode: vastErrorCode
|
|
2502
|
+
});
|
|
2503
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2504
|
+
}
|
|
2200
2505
|
function startAdPlayback(context) {
|
|
2506
|
+
var isMutedRetry = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
2201
2507
|
if (!adVideoElement) return;
|
|
2508
|
+
var computed = typeof getComputedStyle === "function" && adContainerEl ? getComputedStyle(adContainerEl) : void 0;
|
|
2509
|
+
logFunnel(isMutedRetry ? "muted_retry" : "play_called", {
|
|
2510
|
+
context: context,
|
|
2511
|
+
isConnected: adVideoElement.isConnected,
|
|
2512
|
+
clientWidth: adVideoElement.clientWidth,
|
|
2513
|
+
clientHeight: adVideoElement.clientHeight,
|
|
2514
|
+
containerDisplay: computed === null || computed === void 0 ? void 0 : computed.display,
|
|
2515
|
+
containerVisibility: computed === null || computed === void 0 ? void 0 : computed.visibility
|
|
2516
|
+
});
|
|
2202
2517
|
var playPromise = adVideoElement.play();
|
|
2203
2518
|
pendingPlayPromise = playPromise;
|
|
2204
2519
|
playPromise.catch(function(error) {
|
|
2205
2520
|
if (pendingPlayPromise !== playPromise) {
|
|
2206
2521
|
return;
|
|
2207
2522
|
}
|
|
2208
|
-
|
|
2209
|
-
|
|
2523
|
+
logFunnel("play_rejected", {
|
|
2524
|
+
context: context,
|
|
2525
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2526
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
2527
|
+
});
|
|
2528
|
+
if (!isMutedRetry && (error === null || error === void 0 ? void 0 : error.name) === "NotAllowedError" && adVideoElement && !adVideoElement.muted) {
|
|
2529
|
+
console.warn("[HlsAdPlayer] Unmuted ".concat(context, " blocked by autoplay policy - retrying muted"));
|
|
2530
|
+
originalMutedState = true;
|
|
2531
|
+
forcedMuteByAutoplay = true;
|
|
2532
|
+
adVideoElement.muted = true;
|
|
2533
|
+
startAdPlayback(context, true);
|
|
2534
|
+
return;
|
|
2535
|
+
}
|
|
2536
|
+
failAdPlayback(context, error);
|
|
2210
2537
|
}).finally(function() {
|
|
2211
2538
|
if (pendingPlayPromise === playPromise) {
|
|
2212
2539
|
pendingPlayPromise = void 0;
|
|
@@ -2245,17 +2572,109 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2245
2572
|
adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
|
|
2246
2573
|
adVideoElement.muted = originalMutedState;
|
|
2247
2574
|
}
|
|
2575
|
+
function clearMediaStartTimer() {
|
|
2576
|
+
if (mediaStartTimerId !== void 0) {
|
|
2577
|
+
clearTimeout(mediaStartTimerId);
|
|
2578
|
+
mediaStartTimerId = void 0;
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
function startMediaStartTimer() {
|
|
2582
|
+
clearMediaStartTimer();
|
|
2583
|
+
if (!(MEDIA_START_TIMEOUT_MS > 0)) return;
|
|
2584
|
+
var startedAt = Date.now();
|
|
2585
|
+
mediaStartTimerId = setTimeout(function() {
|
|
2586
|
+
mediaStartTimerId = void 0;
|
|
2587
|
+
if (!adPlaying || trackingFired.impression) return;
|
|
2588
|
+
console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(MEDIA_START_TIMEOUT_MS, "ms"));
|
|
2589
|
+
logFunnel("play_resolved_but_never_started", {
|
|
2590
|
+
timeoutMs: MEDIA_START_TIMEOUT_MS,
|
|
2591
|
+
elapsedMs: Date.now() - startedAt,
|
|
2592
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2593
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2594
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2595
|
+
paused: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.paused,
|
|
2596
|
+
vastErrorCode: VAST_ERROR_MEDIA_TIMEOUT
|
|
2597
|
+
});
|
|
2598
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_TIMEOUT);
|
|
2599
|
+
}, MEDIA_START_TIMEOUT_MS);
|
|
2600
|
+
}
|
|
2601
|
+
function resetVideoElementForNextSource() {
|
|
2602
|
+
clearStallWatchdog();
|
|
2603
|
+
if (requiresMediaPipelineResetAfterAds()) {
|
|
2604
|
+
recreateAdVideoElement();
|
|
2605
|
+
setupAdEventListeners();
|
|
2606
|
+
} else {
|
|
2607
|
+
prepareVideoElementForNewSource();
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
function tryNextMediaCandidate() {
|
|
2611
|
+
if (!currentAd || trackingFired.impression) return false;
|
|
2612
|
+
if (mediaCandidateIndex >= mediaCandidates.length - 1) return false;
|
|
2613
|
+
var failedUrl = currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url;
|
|
2614
|
+
mediaCandidateIndex++;
|
|
2615
|
+
var next = mediaCandidates[mediaCandidateIndex];
|
|
2616
|
+
if (!next) return false;
|
|
2617
|
+
logFunnel("media_fallback", {
|
|
2618
|
+
failedUrl: failedUrl,
|
|
2619
|
+
nextUrl: next.url,
|
|
2620
|
+
nextType: next.type,
|
|
2621
|
+
candidateIndex: mediaCandidateIndex,
|
|
2622
|
+
candidateCount: mediaCandidates.length
|
|
2623
|
+
});
|
|
2624
|
+
resetVideoElementForNextSource();
|
|
2625
|
+
try {
|
|
2626
|
+
loadMediaCandidate(next);
|
|
2627
|
+
return true;
|
|
2628
|
+
} catch (error) {
|
|
2629
|
+
console.error("[HlsAdPlayer] Failed to load fallback media file:", error);
|
|
2630
|
+
return tryNextMediaCandidate();
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
function recoverFromAdFailure(vastErrorCode) {
|
|
2634
|
+
clearMediaStartTimer();
|
|
2635
|
+
if (tryNextMediaCandidate()) return;
|
|
2636
|
+
reportCurrentAdError(vastErrorCode);
|
|
2637
|
+
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) return;
|
|
2638
|
+
handleAdError();
|
|
2639
|
+
}
|
|
2248
2640
|
function loadCurrentAdMedia() {
|
|
2249
2641
|
if (!adVideoElement || !currentAd) {
|
|
2250
2642
|
throw new Error("No ad video element or ad to load");
|
|
2251
2643
|
}
|
|
2252
|
-
|
|
2644
|
+
mediaCandidates = rankMediaCandidates(currentAd.mediaFiles);
|
|
2645
|
+
mediaCandidateIndex = 0;
|
|
2646
|
+
var mediaFile = mediaCandidates[0];
|
|
2253
2647
|
if (!mediaFile) {
|
|
2254
|
-
|
|
2648
|
+
logFunnel("media_unsupported", {
|
|
2649
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA,
|
|
2650
|
+
candidates: currentAd.mediaFiles.length
|
|
2651
|
+
});
|
|
2652
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
2653
|
+
throw new Error("No media file this browser can play");
|
|
2654
|
+
}
|
|
2655
|
+
try {
|
|
2656
|
+
loadMediaCandidate(mediaFile);
|
|
2657
|
+
} catch (error) {
|
|
2658
|
+
if (tryNextMediaCandidate()) return;
|
|
2659
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
2660
|
+
throw error;
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
function loadMediaCandidate(mediaFile) {
|
|
2664
|
+
if (!adVideoElement || !currentAd) {
|
|
2665
|
+
throw new Error("No ad video element or ad to load");
|
|
2255
2666
|
}
|
|
2256
2667
|
currentAdMediaFile = mediaFile;
|
|
2257
2668
|
var isHlsAd = isHlsMediaFile(mediaFile);
|
|
2669
|
+
logFunnel("media_selected", {
|
|
2670
|
+
width: mediaFile.width,
|
|
2671
|
+
height: mediaFile.height,
|
|
2672
|
+
bitrate: mediaFile.bitrate,
|
|
2673
|
+
candidateIndex: mediaCandidateIndex,
|
|
2674
|
+
candidates: mediaCandidates.length
|
|
2675
|
+
});
|
|
2258
2676
|
console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad (pod ").concat(podIndex + 1, "/").concat(podAds.length || 1, ") from: ").concat(mediaFile.url));
|
|
2677
|
+
startMediaStartTimer();
|
|
2259
2678
|
if (isHlsAd && Hls.isSupported()) {
|
|
2260
2679
|
if (adHls) {
|
|
2261
2680
|
adHls.destroy();
|
|
@@ -2264,6 +2683,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2264
2683
|
enableWorker: true,
|
|
2265
2684
|
lowLatencyMode: false
|
|
2266
2685
|
});
|
|
2686
|
+
logFunnel("media_load", {
|
|
2687
|
+
pipeline: "hls.js"
|
|
2688
|
+
});
|
|
2267
2689
|
adHls.loadSource(mediaFile.url);
|
|
2268
2690
|
adHls.attachMedia(adVideoElement);
|
|
2269
2691
|
adHls.on(Hls.Events.MANIFEST_PARSED, function() {
|
|
@@ -2273,10 +2695,24 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2273
2695
|
adHls.on(Hls.Events.ERROR, function(_event, data) {
|
|
2274
2696
|
console.error("[HlsAdPlayer] HLS error:", data);
|
|
2275
2697
|
if (data.fatal) {
|
|
2276
|
-
|
|
2698
|
+
var _data_response, _data_response1, _data_frag;
|
|
2699
|
+
var vastErrorCode = data.type === Hls.ErrorTypes.NETWORK_ERROR ? 401 : VAST_ERROR_MEDIA_DISPLAY;
|
|
2700
|
+
logFunnel("hls_fatal", {
|
|
2701
|
+
reason: data.details,
|
|
2702
|
+
errorName: data.type,
|
|
2703
|
+
errorMessage: data.details,
|
|
2704
|
+
responseCode: (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.code,
|
|
2705
|
+
responseText: (_data_response1 = data.response) === null || _data_response1 === void 0 ? void 0 : _data_response1.text,
|
|
2706
|
+
fragUrl: (_data_frag = data.frag) === null || _data_frag === void 0 ? void 0 : _data_frag.url,
|
|
2707
|
+
vastErrorCode: vastErrorCode
|
|
2708
|
+
});
|
|
2709
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2277
2710
|
}
|
|
2278
2711
|
});
|
|
2279
2712
|
} else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
|
|
2713
|
+
logFunnel("media_load", {
|
|
2714
|
+
pipeline: "native-hls"
|
|
2715
|
+
});
|
|
2280
2716
|
adVideoElement.src = mediaFile.url;
|
|
2281
2717
|
startAdPlayback("native HLS ad playback");
|
|
2282
2718
|
} else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
|
|
@@ -2284,45 +2720,47 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2284
2720
|
adHls.destroy();
|
|
2285
2721
|
adHls = void 0;
|
|
2286
2722
|
}
|
|
2723
|
+
logFunnel("media_load", {
|
|
2724
|
+
pipeline: "progressive"
|
|
2725
|
+
});
|
|
2287
2726
|
adVideoElement.src = mediaFile.url;
|
|
2288
2727
|
adVideoElement.load();
|
|
2289
2728
|
startAdPlayback("progressive ad playback");
|
|
2290
2729
|
} else {
|
|
2730
|
+
clearMediaStartTimer();
|
|
2731
|
+
logFunnel("media_unsupported", {
|
|
2732
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA
|
|
2733
|
+
});
|
|
2291
2734
|
throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
|
|
2292
2735
|
}
|
|
2293
2736
|
}
|
|
2294
2737
|
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;
|
|
2738
|
+
clearMediaStartTimer();
|
|
2739
|
+
while(podIndex < podAds.length - 1){
|
|
2740
|
+
settleViewability();
|
|
2741
|
+
podIndex++;
|
|
2742
|
+
currentAd = podAds[podIndex];
|
|
2743
|
+
currentAdMediaFile = void 0;
|
|
2744
|
+
resetAdTracking();
|
|
2745
|
+
if (currentAd) {
|
|
2746
|
+
console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
|
|
2747
|
+
}
|
|
2748
|
+
resetVideoElementForNextSource();
|
|
2749
|
+
try {
|
|
2750
|
+
loadCurrentAdMedia();
|
|
2751
|
+
emit("pod_ad_started", {
|
|
2752
|
+
index: podIndex,
|
|
2753
|
+
total: podAds.length
|
|
2754
|
+
});
|
|
2755
|
+
return true;
|
|
2756
|
+
} catch (error) {
|
|
2757
|
+
console.error("[HlsAdPlayer] Failed to load next pod ad:", error);
|
|
2758
|
+
}
|
|
2323
2759
|
}
|
|
2760
|
+
return false;
|
|
2324
2761
|
}
|
|
2325
2762
|
function clearStallWatchdog() {
|
|
2763
|
+
clearMediaStartTimer();
|
|
2326
2764
|
if (stallWatchdogId != null) {
|
|
2327
2765
|
clearInterval(stallWatchdogId);
|
|
2328
2766
|
stallWatchdogId = void 0;
|
|
@@ -2338,11 +2776,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2338
2776
|
function handleAdStall() {
|
|
2339
2777
|
console.warn("[HlsAdPlayer] Ad playback stalled (no progress) - recovering to avoid a blank frame");
|
|
2340
2778
|
clearStallWatchdog();
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
handleAdError();
|
|
2779
|
+
logFunnel("stall", {
|
|
2780
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
2781
|
+
});
|
|
2782
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2346
2783
|
}
|
|
2347
2784
|
function getDecodedVideoFrameCount(video) {
|
|
2348
2785
|
try {
|
|
@@ -2404,11 +2841,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2404
2841
|
function handleVideoDecodeFailure() {
|
|
2405
2842
|
console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
|
|
2406
2843
|
clearStallWatchdog();
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
handleAdError();
|
|
2844
|
+
logFunnel("decode_failure", {
|
|
2845
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
2846
|
+
});
|
|
2847
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2412
2848
|
}
|
|
2413
2849
|
function startStallWatchdog() {
|
|
2414
2850
|
clearStallWatchdog();
|
|
@@ -2532,6 +2968,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2532
2968
|
Promise.reject(new Error("Ad already playing"))
|
|
2533
2969
|
];
|
|
2534
2970
|
}
|
|
2971
|
+
if (destroyed) {
|
|
2972
|
+
return [
|
|
2973
|
+
2,
|
|
2974
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
2975
|
+
];
|
|
2976
|
+
}
|
|
2977
|
+
currentVastTagUrl = vastTagUrl;
|
|
2978
|
+
pendingRequestAbortReason = void 0;
|
|
2979
|
+
logFunnel("request_sent");
|
|
2535
2980
|
_state.label = 1;
|
|
2536
2981
|
case 1:
|
|
2537
2982
|
_state.trys.push([
|
|
@@ -2566,8 +3011,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2566
3011
|
ads = _state.sent();
|
|
2567
3012
|
_state.label = 4;
|
|
2568
3013
|
case 4:
|
|
3014
|
+
if (destroyed) {
|
|
3015
|
+
return [
|
|
3016
|
+
2,
|
|
3017
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
3018
|
+
];
|
|
3019
|
+
}
|
|
3020
|
+
if (!ads.length && pendingRequestAbortReason) {
|
|
3021
|
+
throw new Error(pendingRequestAbortReason);
|
|
3022
|
+
}
|
|
2569
3023
|
if (!ads.length) {
|
|
2570
3024
|
console.warn("[HlsAdPlayer] No ads available from VAST response");
|
|
3025
|
+
logFunnel("no_fill");
|
|
2571
3026
|
emit("ad_error");
|
|
2572
3027
|
return [
|
|
2573
3028
|
2,
|
|
@@ -2578,6 +3033,23 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2578
3033
|
podIndex = 0;
|
|
2579
3034
|
currentAd = ads[0];
|
|
2580
3035
|
currentAdMediaFile = void 0;
|
|
3036
|
+
logFunnel("vast_received", {
|
|
3037
|
+
adCount: ads.length,
|
|
3038
|
+
durations: ads.map(function(ad) {
|
|
3039
|
+
return ad.duration;
|
|
3040
|
+
}),
|
|
3041
|
+
impressionUrls: ads.map(function(ad) {
|
|
3042
|
+
return ad.trackingUrls.impression.length;
|
|
3043
|
+
})
|
|
3044
|
+
});
|
|
3045
|
+
ads.forEach(function(ad, index) {
|
|
3046
|
+
if (ad.trackingUrls.impression.length === 0) {
|
|
3047
|
+
logFunnel("vast_missing_impression", {
|
|
3048
|
+
adIndex: index,
|
|
3049
|
+
missingAdId: ad.id
|
|
3050
|
+
});
|
|
3051
|
+
}
|
|
3052
|
+
});
|
|
2581
3053
|
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
3054
|
return [
|
|
2583
3055
|
2,
|
|
@@ -2586,6 +3058,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2586
3058
|
case 5:
|
|
2587
3059
|
error = _state.sent();
|
|
2588
3060
|
console.error("[HlsAdPlayer] Error requesting ads:", error);
|
|
3061
|
+
logFunnel("request_failed", {
|
|
3062
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3063
|
+
});
|
|
2589
3064
|
emit("ad_error");
|
|
2590
3065
|
return [
|
|
2591
3066
|
2,
|
|
@@ -2641,13 +3116,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2641
3116
|
adContainerEl.style.pointerEvents = "auto";
|
|
2642
3117
|
}
|
|
2643
3118
|
emit("content_pause");
|
|
2644
|
-
|
|
3119
|
+
try {
|
|
3120
|
+
loadCurrentAdMedia();
|
|
3121
|
+
} catch (loadError) {
|
|
3122
|
+
if (!(podIndex < podAds.length - 1 && advanceToNextPodAd())) {
|
|
3123
|
+
throw loadError;
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
2645
3126
|
return [
|
|
2646
3127
|
2,
|
|
2647
3128
|
Promise.resolve()
|
|
2648
3129
|
];
|
|
2649
3130
|
} catch (error) {
|
|
2650
3131
|
console.error("[HlsAdPlayer] Error playing ad:", error);
|
|
3132
|
+
logFunnel("play_failed", {
|
|
3133
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3134
|
+
});
|
|
2651
3135
|
handleAdError();
|
|
2652
3136
|
return [
|
|
2653
3137
|
2,
|
|
@@ -2689,6 +3173,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2689
3173
|
var previousMutedState;
|
|
2690
3174
|
return _ts_generator(this, function(_state) {
|
|
2691
3175
|
console.log("[HlsAdPlayer] Stopping ad");
|
|
3176
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3177
|
+
logFunnel("stopped_before_start");
|
|
3178
|
+
}
|
|
2692
3179
|
settleViewability();
|
|
2693
3180
|
fireNotUsedForUnplayedAds();
|
|
2694
3181
|
clearStallWatchdog();
|
|
@@ -2721,15 +3208,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2721
3208
|
},
|
|
2722
3209
|
destroy: function destroy() {
|
|
2723
3210
|
console.log("[HlsAdPlayer] Destroying");
|
|
3211
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3212
|
+
logFunnel("stopped_before_start");
|
|
3213
|
+
}
|
|
2724
3214
|
settleViewability();
|
|
2725
3215
|
fireNotUsedForUnplayedAds();
|
|
2726
3216
|
destroyed = true;
|
|
2727
|
-
|
|
3217
|
+
pendingRequestAbortReason = "Ad player destroyed";
|
|
2728
3218
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2729
3219
|
try {
|
|
2730
|
-
for(var _iterator =
|
|
2731
|
-
var
|
|
2732
|
-
|
|
3220
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3221
|
+
var controller = _step.value;
|
|
3222
|
+
controller.abort();
|
|
2733
3223
|
}
|
|
2734
3224
|
} catch (err) {
|
|
2735
3225
|
_didIteratorError = true;
|
|
@@ -2745,6 +3235,28 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2745
3235
|
}
|
|
2746
3236
|
}
|
|
2747
3237
|
}
|
|
3238
|
+
pendingVastRequests.clear();
|
|
3239
|
+
clearStallWatchdog();
|
|
3240
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3241
|
+
try {
|
|
3242
|
+
for(var _iterator1 = pendingTimeouts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3243
|
+
var timeoutId = _step1.value;
|
|
3244
|
+
clearTimeout(timeoutId);
|
|
3245
|
+
}
|
|
3246
|
+
} catch (err) {
|
|
3247
|
+
_didIteratorError1 = true;
|
|
3248
|
+
_iteratorError1 = err;
|
|
3249
|
+
} finally{
|
|
3250
|
+
try {
|
|
3251
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
3252
|
+
_iterator1.return();
|
|
3253
|
+
}
|
|
3254
|
+
} finally{
|
|
3255
|
+
if (_didIteratorError1) {
|
|
3256
|
+
throw _iteratorError1;
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
2748
3260
|
pendingTimeouts = [];
|
|
2749
3261
|
adPlaying = false;
|
|
2750
3262
|
setAdPlayingFlag(false);
|
|
@@ -2764,6 +3276,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2764
3276
|
isAdPlaying: function isAdPlaying() {
|
|
2765
3277
|
return adPlaying;
|
|
2766
3278
|
},
|
|
3279
|
+
setFunnelContext: function setFunnelContext(context) {
|
|
3280
|
+
funnelContext = _object_spread({}, context);
|
|
3281
|
+
},
|
|
3282
|
+
abortPendingRequest: function abortPendingRequest() {
|
|
3283
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "VAST request aborted (timeout)";
|
|
3284
|
+
if (pendingVastRequests.size === 0) return;
|
|
3285
|
+
pendingRequestAbortReason = reason;
|
|
3286
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3287
|
+
try {
|
|
3288
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3289
|
+
var controller = _step.value;
|
|
3290
|
+
controller.abort();
|
|
3291
|
+
}
|
|
3292
|
+
} catch (err) {
|
|
3293
|
+
_didIteratorError = true;
|
|
3294
|
+
_iteratorError = err;
|
|
3295
|
+
} finally{
|
|
3296
|
+
try {
|
|
3297
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3298
|
+
_iterator.return();
|
|
3299
|
+
}
|
|
3300
|
+
} finally{
|
|
3301
|
+
if (_didIteratorError) {
|
|
3302
|
+
throw _iteratorError;
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
pendingVastRequests.clear();
|
|
3307
|
+
},
|
|
2767
3308
|
resize: function resize(width, height) {
|
|
2768
3309
|
console.log("[HlsAdPlayer] Resizing to ".concat(width, "x").concat(height));
|
|
2769
3310
|
if (adContainerEl) {
|
|
@@ -2799,6 +3340,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2799
3340
|
if (adVideoElement && adPlaying) {
|
|
2800
3341
|
var clamped = Math.max(0, Math.min(1, volume));
|
|
2801
3342
|
adVideoElement.volume = clamped;
|
|
3343
|
+
var userActivation = navigator.userActivation;
|
|
3344
|
+
if (clamped > 0 && forcedMuteByAutoplay && userActivation && !userActivation.isActive) {
|
|
3345
|
+
logFunnel("unmute_blocked_without_gesture", {
|
|
3346
|
+
requestedVolume: clamped
|
|
3347
|
+
});
|
|
3348
|
+
return;
|
|
3349
|
+
}
|
|
2802
3350
|
adVideoElement.muted = clamped === 0;
|
|
2803
3351
|
}
|
|
2804
3352
|
},
|
|
@@ -6874,7 +7422,7 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6874
7422
|
{
|
|
6875
7423
|
key: "adFitsRemainingBudget",
|
|
6876
7424
|
value: function adFitsRemainingBudget(durationMs) {
|
|
6877
|
-
if (durationMs <= 0) {
|
|
7425
|
+
if (durationMs <= 0 || this.expectedAdBreakDurationMs == null) {
|
|
6878
7426
|
return true;
|
|
6879
7427
|
}
|
|
6880
7428
|
return durationMs <= this.getDurationBudgetRemainingMs();
|
|
@@ -6933,6 +7481,11 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6933
7481
|
value: function markAdStarted() {
|
|
6934
7482
|
this.currentAdIndex++;
|
|
6935
7483
|
this.totalAdsInBreak = this.currentAdIndex;
|
|
7484
|
+
}
|
|
7485
|
+
},
|
|
7486
|
+
{
|
|
7487
|
+
key: "noteAdRequestSent",
|
|
7488
|
+
value: function noteAdRequestSent() {
|
|
6936
7489
|
this.totalAdRequestsInBreak++;
|
|
6937
7490
|
this.lastAdRequestTime = Date.now();
|
|
6938
7491
|
}
|
|
@@ -6984,6 +7537,9 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6984
7537
|
if (message.includes("timeout")) {
|
|
6985
7538
|
return true;
|
|
6986
7539
|
}
|
|
7540
|
+
if (message.includes("ad player destroyed") || message.includes("aborted")) {
|
|
7541
|
+
return true;
|
|
7542
|
+
}
|
|
6987
7543
|
if (message.includes("rate limit") || message.includes("too many requests")) {
|
|
6988
7544
|
return true;
|
|
6989
7545
|
}
|
|
@@ -8120,6 +8676,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8120
8676
|
this.adDetectSentForCurrentBreak = false;
|
|
8121
8677
|
this.continuousFetchingActive = false;
|
|
8122
8678
|
this.continuousFetchLoopRunning = false;
|
|
8679
|
+
this.breakFunnel = {};
|
|
8680
|
+
this.controllerCallInFlight = false;
|
|
8681
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8682
|
+
this.opportunityEpoch = -1;
|
|
8123
8683
|
this.adRequestQueue = [];
|
|
8124
8684
|
this.adPodQueue = [];
|
|
8125
8685
|
this.maxPlaceholderDurationMs = 5e3;
|
|
@@ -8172,7 +8732,25 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8172
8732
|
adPlayer.on("ad_interaction", function(event) {
|
|
8173
8733
|
if (event) _this.host.onAdInteraction(event);
|
|
8174
8734
|
});
|
|
8735
|
+
adPlayer.on("ad_funnel", function(payload) {
|
|
8736
|
+
if (!(payload === null || payload === void 0 ? void 0 : payload.stage)) return;
|
|
8737
|
+
_this.countFunnelStage(payload.stage);
|
|
8738
|
+
if (payload.reason) {
|
|
8739
|
+
_this.countFunnelStage("".concat(payload.stage, ":").concat(payload.reason));
|
|
8740
|
+
}
|
|
8741
|
+
if (payload.stage === "impression_fired" && payload.pixelCount != null) {
|
|
8742
|
+
_this.countFunnelStage("impression_urls", payload.pixelCount);
|
|
8743
|
+
}
|
|
8744
|
+
if (payload.visibilityState === "hidden") {
|
|
8745
|
+
_this.countFunnelStage("while_hidden");
|
|
8746
|
+
}
|
|
8747
|
+
});
|
|
8175
8748
|
adPlayer.on("ad_impression", function() {
|
|
8749
|
+
_this.timing.consecutiveFailures = 0;
|
|
8750
|
+
if (!_this.playbackStartedForCurrentRequest) {
|
|
8751
|
+
_this.playbackStartedForCurrentRequest = true;
|
|
8752
|
+
_this.timing.markAdStarted();
|
|
8753
|
+
}
|
|
8176
8754
|
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
8177
8755
|
source: "hls",
|
|
8178
8756
|
adIndex: _this.timing.currentAdIndex
|
|
@@ -8216,6 +8794,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8216
8794
|
}
|
|
8217
8795
|
}
|
|
8218
8796
|
console.error("[AD-ERROR]", errorMessage, errorPayload || "");
|
|
8797
|
+
if (_this.controllerCallInFlight) {
|
|
8798
|
+
_this.timing.recordGamNoFill();
|
|
8799
|
+
return;
|
|
8800
|
+
}
|
|
8219
8801
|
_this.handleAdFailure();
|
|
8220
8802
|
});
|
|
8221
8803
|
adPlayer.on("content_pause", function() {
|
|
@@ -8287,6 +8869,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8287
8869
|
}
|
|
8288
8870
|
var preservedMutedState = adPlayer.getOriginalMutedState();
|
|
8289
8871
|
var preservedVolumeState = adPlayer.getOriginalVolume();
|
|
8872
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8290
8873
|
if (adPlayer) {
|
|
8291
8874
|
try {
|
|
8292
8875
|
adPlayer.destroy();
|
|
@@ -8376,9 +8959,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8376
8959
|
if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
8377
8960
|
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
8378
8961
|
}
|
|
8962
|
+
this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
|
|
8379
8963
|
return [
|
|
8380
8964
|
4,
|
|
8381
|
-
this.startOptimizedPod(baseVastUrl, adBreakDurationMs
|
|
8965
|
+
this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
|
|
8382
8966
|
];
|
|
8383
8967
|
case 1:
|
|
8384
8968
|
podPlayed = _state.sent();
|
|
@@ -8412,7 +8996,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8412
8996
|
value: // ───────────────────────────────────────────────────────────────
|
|
8413
8997
|
// Optimized pod (single multi-ad request)
|
|
8414
8998
|
// ───────────────────────────────────────────────────────────────
|
|
8415
|
-
function startOptimizedPod(baseVastUrl, breakDurationMs
|
|
8999
|
+
function startOptimizedPod(baseVastUrl, breakDurationMs) {
|
|
8416
9000
|
return _async_to_generator(function() {
|
|
8417
9001
|
var podUrl, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
8418
9002
|
return _ts_generator(this, function(_state) {
|
|
@@ -8451,10 +9035,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8451
9035
|
case 2:
|
|
8452
9036
|
_state.sent();
|
|
8453
9037
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
8454
|
-
this.timing.
|
|
9038
|
+
this.timing.noteAdRequestSent();
|
|
9039
|
+
this.beginFunnelRequest(adPlayer, requestToken);
|
|
8455
9040
|
return [
|
|
8456
9041
|
4,
|
|
8457
|
-
|
|
9042
|
+
this.callController(function() {
|
|
9043
|
+
return adPlayer.requestAds(podUrl);
|
|
9044
|
+
})
|
|
8458
9045
|
];
|
|
8459
9046
|
case 3:
|
|
8460
9047
|
_state.sent();
|
|
@@ -8483,16 +9070,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8483
9070
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
8484
9071
|
return [
|
|
8485
9072
|
4,
|
|
8486
|
-
|
|
9073
|
+
this.callController(function() {
|
|
9074
|
+
return adPlayer.play();
|
|
9075
|
+
})
|
|
8487
9076
|
];
|
|
8488
9077
|
case 4:
|
|
8489
9078
|
_state.sent();
|
|
8490
|
-
this.timing.markAdStarted();
|
|
8491
9079
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
8492
9080
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
8493
9081
|
}
|
|
8494
|
-
adPlayer.setAdVolume(
|
|
8495
|
-
this.timing.consecutiveFailures = 0;
|
|
9082
|
+
adPlayer.setAdVolume(getAdAudioVolume(adPlayer));
|
|
8496
9083
|
this.continuousFetchingActive = true;
|
|
8497
9084
|
this.startContinuousFetching(baseVastUrl);
|
|
8498
9085
|
return [
|
|
@@ -8857,7 +9444,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8857
9444
|
];
|
|
8858
9445
|
case 3:
|
|
8859
9446
|
_state.sent();
|
|
8860
|
-
this.timing.consecutiveFailures = 0;
|
|
8861
9447
|
return [
|
|
8862
9448
|
3,
|
|
8863
9449
|
8
|
|
@@ -8870,6 +9456,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8870
9456
|
3,
|
|
8871
9457
|
6
|
|
8872
9458
|
];
|
|
9459
|
+
this.timing.consecutiveFailures++;
|
|
8873
9460
|
return [
|
|
8874
9461
|
4,
|
|
8875
9462
|
this.tryNextAvailableAdWithRateLimit()
|
|
@@ -8961,11 +9548,137 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8961
9548
|
}
|
|
8962
9549
|
}
|
|
8963
9550
|
},
|
|
9551
|
+
{
|
|
9552
|
+
key: "countFunnelStage",
|
|
9553
|
+
value: function countFunnelStage(stage) {
|
|
9554
|
+
var amount = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
|
|
9555
|
+
var _this_breakFunnel_stage;
|
|
9556
|
+
this.breakFunnel[stage] = ((_this_breakFunnel_stage = this.breakFunnel[stage]) !== null && _this_breakFunnel_stage !== void 0 ? _this_breakFunnel_stage : 0) + amount;
|
|
9557
|
+
}
|
|
9558
|
+
},
|
|
9559
|
+
{
|
|
9560
|
+
key: "logOrchestratorFunnel",
|
|
9561
|
+
value: function logOrchestratorFunnel(stage) {
|
|
9562
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
9563
|
+
this.countFunnelStage(stage);
|
|
9564
|
+
console.log("[AdBreak][FUNNEL] ".concat(stage), _object_spread({
|
|
9565
|
+
breakId: this.timing.adBreakEpoch,
|
|
9566
|
+
requestId: this.currentRequestId,
|
|
9567
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0
|
|
9568
|
+
}, extra));
|
|
9569
|
+
}
|
|
9570
|
+
},
|
|
9571
|
+
{
|
|
9572
|
+
key: "noteOpportunity",
|
|
9573
|
+
value: function noteOpportunity(source, breakKey) {
|
|
9574
|
+
if (breakKey && breakKey === this.opportunityBreakKey && this.opportunityEpoch === this.timing.adBreakEpoch) {
|
|
9575
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
9576
|
+
source: source,
|
|
9577
|
+
breakKey: breakKey
|
|
9578
|
+
});
|
|
9579
|
+
return;
|
|
9580
|
+
}
|
|
9581
|
+
this.opportunityBreakKey = breakKey;
|
|
9582
|
+
this.opportunityEpoch = this.timing.adBreakEpoch;
|
|
9583
|
+
this.logOrchestratorFunnel("opportunity_created", {
|
|
9584
|
+
source: source,
|
|
9585
|
+
breakKey: breakKey,
|
|
9586
|
+
expectedDurationMs: this.timing.expectedAdBreakDurationMs
|
|
9587
|
+
});
|
|
9588
|
+
}
|
|
9589
|
+
},
|
|
9590
|
+
{
|
|
9591
|
+
key: "beginFunnelRequest",
|
|
9592
|
+
value: function beginFunnelRequest(adPlayer, requestToken) {
|
|
9593
|
+
var _adPlayer_setFunnelContext;
|
|
9594
|
+
if (this.controllerCallInFlight) {
|
|
9595
|
+
this.logOrchestratorFunnel("duplicate_request_detected", {
|
|
9596
|
+
newRequestId: requestToken
|
|
9597
|
+
});
|
|
9598
|
+
}
|
|
9599
|
+
this.currentRequestId = requestToken;
|
|
9600
|
+
this.requestStartedAt = Date.now();
|
|
9601
|
+
(_adPlayer_setFunnelContext = adPlayer.setFunnelContext) === null || _adPlayer_setFunnelContext === void 0 ? void 0 : _adPlayer_setFunnelContext.call(adPlayer, {
|
|
9602
|
+
breakId: this.timing.adBreakEpoch,
|
|
9603
|
+
requestId: requestToken
|
|
9604
|
+
});
|
|
9605
|
+
}
|
|
9606
|
+
},
|
|
9607
|
+
{
|
|
9608
|
+
key: "isAdLoadingWithoutPlayback",
|
|
9609
|
+
value: function isAdLoadingWithoutPlayback() {
|
|
9610
|
+
return this.host.getAdPlayer().isAdPlaying() && !this.playbackStartedForCurrentRequest;
|
|
9611
|
+
}
|
|
9612
|
+
},
|
|
9613
|
+
{
|
|
9614
|
+
key: "noteStopBeforeStart",
|
|
9615
|
+
value: function noteStopBeforeStart(reason) {
|
|
9616
|
+
if (!this.isAdLoadingWithoutPlayback()) return;
|
|
9617
|
+
this.logOrchestratorFunnel("ad_stopped_before_start", {
|
|
9618
|
+
reason: reason,
|
|
9619
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
9620
|
+
});
|
|
9621
|
+
}
|
|
9622
|
+
},
|
|
9623
|
+
{
|
|
9624
|
+
key: "handleRequestWatchdogTimeout",
|
|
9625
|
+
value: function handleRequestWatchdogTimeout() {
|
|
9626
|
+
var adPlayer = this.host.getAdPlayer();
|
|
9627
|
+
if (this.controllerCallInFlight && adPlayer.abortPendingRequest) {
|
|
9628
|
+
this.logOrchestratorFunnel("request_aborted_timeout", {
|
|
9629
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
9630
|
+
});
|
|
9631
|
+
adPlayer.abortPendingRequest("VAST request aborted after request watchdog timeout");
|
|
9632
|
+
return;
|
|
9633
|
+
}
|
|
9634
|
+
this.handleAdFailure();
|
|
9635
|
+
}
|
|
9636
|
+
},
|
|
9637
|
+
{
|
|
9638
|
+
key: "callController",
|
|
9639
|
+
value: function callController(call) {
|
|
9640
|
+
return _async_to_generator(function() {
|
|
9641
|
+
return _ts_generator(this, function(_state) {
|
|
9642
|
+
switch(_state.label){
|
|
9643
|
+
case 0:
|
|
9644
|
+
this.controllerCallInFlight = true;
|
|
9645
|
+
_state.label = 1;
|
|
9646
|
+
case 1:
|
|
9647
|
+
_state.trys.push([
|
|
9648
|
+
1,
|
|
9649
|
+
,
|
|
9650
|
+
3,
|
|
9651
|
+
4
|
|
9652
|
+
]);
|
|
9653
|
+
return [
|
|
9654
|
+
4,
|
|
9655
|
+
call()
|
|
9656
|
+
];
|
|
9657
|
+
case 2:
|
|
9658
|
+
_state.sent();
|
|
9659
|
+
return [
|
|
9660
|
+
3,
|
|
9661
|
+
4
|
|
9662
|
+
];
|
|
9663
|
+
case 3:
|
|
9664
|
+
this.controllerCallInFlight = false;
|
|
9665
|
+
return [
|
|
9666
|
+
7
|
|
9667
|
+
];
|
|
9668
|
+
case 4:
|
|
9669
|
+
return [
|
|
9670
|
+
2
|
|
9671
|
+
];
|
|
9672
|
+
}
|
|
9673
|
+
});
|
|
9674
|
+
}).call(this);
|
|
9675
|
+
}
|
|
9676
|
+
},
|
|
8964
9677
|
{
|
|
8965
9678
|
key: "playSingleAd",
|
|
8966
9679
|
value: function playSingleAd(vastTagUrl) {
|
|
8967
9680
|
return _async_to_generator(function() {
|
|
8968
|
-
var adPlayer, requestToken, ap, requestUrl, playError, error, errorMessage;
|
|
9681
|
+
var adPlayer, requestToken, ap, requestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, playError, error, errorMessage;
|
|
8969
9682
|
return _ts_generator(this, function(_state) {
|
|
8970
9683
|
switch(_state.label){
|
|
8971
9684
|
case 0:
|
|
@@ -9007,13 +9720,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9007
9720
|
case 2:
|
|
9008
9721
|
_state.sent();
|
|
9009
9722
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
9010
|
-
this.timing.
|
|
9723
|
+
this.timing.noteAdRequestSent();
|
|
9011
9724
|
ap = this.host.getAdPlayer();
|
|
9012
9725
|
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9013
9726
|
this.currentVastUrl = requestUrl;
|
|
9727
|
+
this.beginFunnelRequest(ap, requestToken);
|
|
9014
9728
|
return [
|
|
9015
9729
|
4,
|
|
9016
|
-
|
|
9730
|
+
this.callController(function() {
|
|
9731
|
+
return ap.requestAds(requestUrl);
|
|
9732
|
+
})
|
|
9017
9733
|
];
|
|
9018
9734
|
case 3:
|
|
9019
9735
|
_state.sent();
|
|
@@ -9027,6 +9743,14 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9027
9743
|
2
|
|
9028
9744
|
];
|
|
9029
9745
|
if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
|
|
9746
|
+
;
|
|
9747
|
+
adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
|
|
9748
|
+
remainingMs = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9749
|
+
this.logOrchestratorFunnel("discarded_budget", {
|
|
9750
|
+
vastUrl: requestUrl,
|
|
9751
|
+
adDurationMs: adDurationS != null ? adDurationS * 1e3 : void 0,
|
|
9752
|
+
remainingMs: remainingMs
|
|
9753
|
+
});
|
|
9030
9754
|
this.timing.rejectLoadedAdForDuration(ap);
|
|
9031
9755
|
this.recreateAdController();
|
|
9032
9756
|
throw new Error("ad_duration_exceeds_budget");
|
|
@@ -9042,16 +9766,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9042
9766
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
9043
9767
|
return [
|
|
9044
9768
|
4,
|
|
9045
|
-
|
|
9769
|
+
this.callController(function() {
|
|
9770
|
+
return ap.play();
|
|
9771
|
+
})
|
|
9046
9772
|
];
|
|
9047
9773
|
case 5:
|
|
9048
9774
|
_state.sent();
|
|
9049
|
-
this.timing.markAdStarted();
|
|
9050
9775
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
9051
9776
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
9052
9777
|
}
|
|
9053
9778
|
ap.setAdVolume(getAdAudioVolume(ap));
|
|
9054
|
-
this.timing.consecutiveFailures = 0;
|
|
9055
9779
|
this.timing.temporaryFailureUrls.delete(vastTagUrl);
|
|
9056
9780
|
return [
|
|
9057
9781
|
3,
|
|
@@ -9215,7 +9939,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9215
9939
|
];
|
|
9216
9940
|
case 5:
|
|
9217
9941
|
_state.sent();
|
|
9218
|
-
this.timing.consecutiveFailures = 0;
|
|
9219
9942
|
return [
|
|
9220
9943
|
3,
|
|
9221
9944
|
10
|
|
@@ -9227,6 +9950,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9227
9950
|
3,
|
|
9228
9951
|
8
|
|
9229
9952
|
];
|
|
9953
|
+
this.timing.consecutiveFailures++;
|
|
9230
9954
|
return [
|
|
9231
9955
|
4,
|
|
9232
9956
|
this.tryNextAvailableAdWithRateLimit()
|
|
@@ -9277,6 +10001,67 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9277
10001
|
// ───────────────────────────────────────────────────────────────
|
|
9278
10002
|
// Ad break completion
|
|
9279
10003
|
// ───────────────────────────────────────────────────────────────
|
|
10004
|
+
key: "logBreakFunnel",
|
|
10005
|
+
value: function logBreakFunnel() {
|
|
10006
|
+
var funnel = this.breakFunnel;
|
|
10007
|
+
this.breakFunnel = {};
|
|
10008
|
+
if (Object.keys(funnel).length === 0) return;
|
|
10009
|
+
var count = function count(stage) {
|
|
10010
|
+
var _funnel_stage;
|
|
10011
|
+
return (_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0;
|
|
10012
|
+
};
|
|
10013
|
+
var breakId = this.opportunityEpoch;
|
|
10014
|
+
if (count("request_sent") > 0 && count("impression_fired") === 0) {
|
|
10015
|
+
console.log("[AdBreak][FUNNEL] break_abandoned_before_start", {
|
|
10016
|
+
breakId: breakId,
|
|
10017
|
+
requests: count("request_sent")
|
|
10018
|
+
});
|
|
10019
|
+
}
|
|
10020
|
+
console.log("[AdBreak][FUNNEL] Break summary", {
|
|
10021
|
+
breakId: breakId,
|
|
10022
|
+
opportunities: count("opportunity_created"),
|
|
10023
|
+
requests: count("request_sent"),
|
|
10024
|
+
duplicates: count("duplicate_request_detected") + count("duplicate_break_start"),
|
|
10025
|
+
filled: count("vast_received"),
|
|
10026
|
+
noFill: count("no_fill"),
|
|
10027
|
+
requestFailed: count("request_failed"),
|
|
10028
|
+
requestAbortedTimeout: count("request_aborted_timeout"),
|
|
10029
|
+
credentialsRetries: count("vast_credentials_retry"),
|
|
10030
|
+
wrapperFailures: count("wrapper_fetch:failure"),
|
|
10031
|
+
noSupportedMedia: count("vast_no_supported_media"),
|
|
10032
|
+
vpaidOnly: count("vast_no_supported_media:vpaid_only"),
|
|
10033
|
+
missingImpression: count("vast_missing_impression"),
|
|
10034
|
+
discardedBudget: count("discarded_budget"),
|
|
10035
|
+
mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
|
|
10036
|
+
mediaRejected: count("media_candidate:rejected"),
|
|
10037
|
+
mediaFallbacks: count("media_fallback"),
|
|
10038
|
+
playCalled: count("play_called"),
|
|
10039
|
+
playRejected: count("play_rejected"),
|
|
10040
|
+
mutedRetry: count("muted_retry"),
|
|
10041
|
+
startTimeouts: count("play_resolved_but_never_started"),
|
|
10042
|
+
impressions: count("impression_fired"),
|
|
10043
|
+
impressionUrls: count("impression_urls"),
|
|
10044
|
+
trackingRequests: count("tracking_request_created"),
|
|
10045
|
+
trackingNotLoaded: count("tracking_request_settled:error") + count("tracking_request_settled:timeout"),
|
|
10046
|
+
trackingUnexpandedMacros: count("tracking_url_unexpanded_macro"),
|
|
10047
|
+
trackingInvalidUrls: count("tracking_url_invalid"),
|
|
10048
|
+
vastAdFallbacks: count("vast_ad_fallback"),
|
|
10049
|
+
mediaEvents: count("media_event"),
|
|
10050
|
+
quartile25: count("first_quartile"),
|
|
10051
|
+
quartile50: count("midpoint"),
|
|
10052
|
+
quartile75: count("third_quartile"),
|
|
10053
|
+
complete: count("complete"),
|
|
10054
|
+
stoppedBeforeStart: count("stopped_before_start"),
|
|
10055
|
+
stoppedBeforeStartByBreakEnd: count("ad_stopped_before_start"),
|
|
10056
|
+
unexpectedUnmutes: count("unexpected_unmute"),
|
|
10057
|
+
unmuteBlocked: count("unmute_blocked_without_gesture"),
|
|
10058
|
+
visibilityHidden: count("while_hidden"),
|
|
10059
|
+
playbackFailures: count("play_failed") + count("media_error") + count("hls_fatal") + count("stall") + count("decode_failure") + count("media_unsupported"),
|
|
10060
|
+
stages: funnel
|
|
10061
|
+
});
|
|
10062
|
+
}
|
|
10063
|
+
},
|
|
10064
|
+
{
|
|
9280
10065
|
key: "handleAdPodComplete",
|
|
9281
10066
|
value: function handleAdPodComplete() {
|
|
9282
10067
|
if (this.debug) {
|
|
@@ -9297,6 +10082,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9297
10082
|
this.adPodQueue = [];
|
|
9298
10083
|
this.showAds = false;
|
|
9299
10084
|
this.host.getAdPlayer().stop().catch(function() {});
|
|
10085
|
+
this.logBreakFunnel();
|
|
9300
10086
|
var restoredMuted = this.host.getAdPlayer().getOriginalMutedState();
|
|
9301
10087
|
var restoredVolume = this.host.getAdPlayer().getOriginalVolume();
|
|
9302
10088
|
if (this.host.video.muted !== restoredMuted) {
|
|
@@ -9649,7 +10435,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9649
10435
|
_this.startScte35AdBreak(marker, cueKey, marker.durationSeconds != null ? marker.durationSeconds * 1e3 : _this.timing.expectedAdBreakDurationMs);
|
|
9650
10436
|
},
|
|
9651
10437
|
onWatchdogTimeout: function onWatchdogTimeout() {
|
|
9652
|
-
return _this.adBreak.
|
|
10438
|
+
return _this.adBreak.handleRequestWatchdogTimeout();
|
|
9653
10439
|
},
|
|
9654
10440
|
onFailsafeTimeout: function onFailsafeTimeout() {
|
|
9655
10441
|
return _this.adBreak.handleAdFailure();
|
|
@@ -9754,6 +10540,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9754
10540
|
licenseKey: this.config.licenseKey
|
|
9755
10541
|
} : {}, ((_this_hlsEngine = this.hlsEngine) === null || _this_hlsEngine === void 0 ? void 0 : _this_hlsEngine.hls) ? {
|
|
9756
10542
|
mainHlsInstance: this.hlsEngine.hls
|
|
10543
|
+
} : {}, this.config.adMediaStartTimeoutMs != null ? {
|
|
10544
|
+
mediaStartTimeoutMs: this.config.adMediaStartTimeoutMs
|
|
9757
10545
|
} : {}));
|
|
9758
10546
|
}
|
|
9759
10547
|
},
|
|
@@ -10108,6 +10896,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10108
10896
|
this.timing.clearAdStartTimer();
|
|
10109
10897
|
this.timing.clearAdStopTimer();
|
|
10110
10898
|
if (adPlaying) {
|
|
10899
|
+
this.adBreak.noteStopBeforeStart("scte_end");
|
|
10111
10900
|
this.adPlayer.stop().catch(function() {});
|
|
10112
10901
|
}
|
|
10113
10902
|
this.adBreak.handleAdPodComplete();
|
|
@@ -10147,6 +10936,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10147
10936
|
console.log("[StormcloudVideoPlayer] Ad break boundary reached (overrun=".concat(overrunMs, "ms) - hard-stopping ads and resuming stream"));
|
|
10148
10937
|
}
|
|
10149
10938
|
if (adPlaying) {
|
|
10939
|
+
this.adBreak.noteStopBeforeStart("break_boundary");
|
|
10150
10940
|
this.adPlayer.stop().catch(function() {});
|
|
10151
10941
|
}
|
|
10152
10942
|
this.adBreak.handleAdPodComplete();
|
|
@@ -10275,6 +11065,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10275
11065
|
this.adBreak.showAds = true;
|
|
10276
11066
|
this.adBreak.inAdBreak = true;
|
|
10277
11067
|
this.timing.currentAdBreakStartWallClockMs = Date.now();
|
|
11068
|
+
if (durationMs > 0) {
|
|
11069
|
+
this.timing.setAdBreakDurationBoundary(durationMs);
|
|
11070
|
+
}
|
|
11071
|
+
this.adBreak.noteOpportunity("vmap", key);
|
|
10278
11072
|
_state.label = 1;
|
|
10279
11073
|
case 1:
|
|
10280
11074
|
_state.trys.push([
|