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
|
@@ -724,7 +724,7 @@ function toVastMediaErrorCode(error) {
|
|
|
724
724
|
}
|
|
725
725
|
}
|
|
726
726
|
function createHlsAdPlayer(contentVideo, options) {
|
|
727
|
-
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
|
|
727
|
+
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP, _ref;
|
|
728
728
|
var adPlaying = false;
|
|
729
729
|
var originalMutedState = false;
|
|
730
730
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
@@ -756,6 +756,16 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
756
756
|
var sawDecodedVideoFrame = false;
|
|
757
757
|
var videoFrameCallbackHandle;
|
|
758
758
|
var pendingPlayPromise;
|
|
759
|
+
var currentVastTagUrl;
|
|
760
|
+
var funnelContext = {};
|
|
761
|
+
var mediaCandidates = [];
|
|
762
|
+
var mediaCandidateIndex = 0;
|
|
763
|
+
var mediaStartTimerId;
|
|
764
|
+
var MEDIA_START_TIMEOUT_MS = (_ref = options === null || options === void 0 ? void 0 : options.mediaStartTimeoutMs) !== null && _ref !== void 0 ? _ref : 8e3;
|
|
765
|
+
var VAST_ERROR_MEDIA_TIMEOUT = 402;
|
|
766
|
+
var pendingVastRequests = /* @__PURE__ */ new Set();
|
|
767
|
+
var pendingRequestAbortReason;
|
|
768
|
+
var forcedMuteByAutoplay = false;
|
|
759
769
|
function createTrackingState() {
|
|
760
770
|
return {
|
|
761
771
|
impression: false,
|
|
@@ -806,6 +816,77 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
806
816
|
}
|
|
807
817
|
}
|
|
808
818
|
}
|
|
819
|
+
var SENSITIVE_URL_PARAMS = /* @__PURE__ */ new Set([
|
|
820
|
+
"ppid",
|
|
821
|
+
"rdid",
|
|
822
|
+
"idtype",
|
|
823
|
+
"is_lat",
|
|
824
|
+
"ifa",
|
|
825
|
+
"idfa",
|
|
826
|
+
"aaid",
|
|
827
|
+
"uid",
|
|
828
|
+
"user_id",
|
|
829
|
+
"userid",
|
|
830
|
+
"device_id",
|
|
831
|
+
"deviceid",
|
|
832
|
+
"ip",
|
|
833
|
+
"ua",
|
|
834
|
+
"gdpr_consent",
|
|
835
|
+
"us_privacy",
|
|
836
|
+
"gpp",
|
|
837
|
+
"addtl_consent",
|
|
838
|
+
"cust_params",
|
|
839
|
+
"email"
|
|
840
|
+
]);
|
|
841
|
+
function redactUrl(url) {
|
|
842
|
+
if (!url) return url;
|
|
843
|
+
try {
|
|
844
|
+
var parsed = new URL(url);
|
|
845
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
846
|
+
try {
|
|
847
|
+
for(var _iterator = Array.from(parsed.searchParams.keys())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
848
|
+
var key = _step.value;
|
|
849
|
+
if (SENSITIVE_URL_PARAMS.has(key.toLowerCase())) {
|
|
850
|
+
parsed.searchParams.set(key, "REDACTED");
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
} catch (err) {
|
|
854
|
+
_didIteratorError = true;
|
|
855
|
+
_iteratorError = err;
|
|
856
|
+
} finally{
|
|
857
|
+
try {
|
|
858
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
859
|
+
_iterator.return();
|
|
860
|
+
}
|
|
861
|
+
} finally{
|
|
862
|
+
if (_didIteratorError) {
|
|
863
|
+
throw _iteratorError;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
return parsed.toString();
|
|
868
|
+
} catch (unused) {
|
|
869
|
+
return url.split("?")[0];
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
function logFunnel(stage) {
|
|
873
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
874
|
+
var payload = _object_spread({
|
|
875
|
+
stage: stage,
|
|
876
|
+
breakId: funnelContext.breakId,
|
|
877
|
+
requestId: funnelContext.requestId,
|
|
878
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0,
|
|
879
|
+
adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
|
|
880
|
+
podIndex: podIndex,
|
|
881
|
+
podSize: podAds.length,
|
|
882
|
+
vastUrl: redactUrl(currentVastTagUrl),
|
|
883
|
+
mediaUrl: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url,
|
|
884
|
+
mediaType: currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.type,
|
|
885
|
+
muted: adVideoElement ? adVideoElement.muted : void 0
|
|
886
|
+
}, extra);
|
|
887
|
+
console.log("[HlsAdPlayer][FUNNEL] ".concat(stage), payload);
|
|
888
|
+
emit("ad_funnel", payload);
|
|
889
|
+
}
|
|
809
890
|
function buildTrackingMacroContext() {
|
|
810
891
|
var options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
811
892
|
var _options2_ad;
|
|
@@ -845,20 +926,53 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
845
926
|
urls.forEach(function(url) {
|
|
846
927
|
try {
|
|
847
928
|
var trackingUrl = substituteVastTrackingMacros(url, macroContext);
|
|
929
|
+
var trackingHost;
|
|
930
|
+
try {
|
|
931
|
+
trackingHost = new URL(trackingUrl).host;
|
|
932
|
+
} catch (unused) {
|
|
933
|
+
logFunnel("tracking_url_invalid", {
|
|
934
|
+
trackingUrl: redactUrl(trackingUrl)
|
|
935
|
+
});
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
var unexpanded = trackingUrl.match(/\[[A-Z_]+\]/g);
|
|
939
|
+
if (unexpanded) {
|
|
940
|
+
logFunnel("tracking_url_unexpanded_macro", {
|
|
941
|
+
trackingHost: trackingHost,
|
|
942
|
+
macros: Array.from(new Set(unexpanded))
|
|
943
|
+
});
|
|
944
|
+
}
|
|
848
945
|
var img = new Image(1, 1);
|
|
849
946
|
inFlightBeacons.add(img);
|
|
850
947
|
var timeoutId;
|
|
851
|
-
var release = function release() {
|
|
948
|
+
var release = function release(outcome) {
|
|
852
949
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
853
950
|
img.onload = null;
|
|
854
951
|
img.onerror = null;
|
|
855
952
|
inFlightBeacons.delete(img);
|
|
953
|
+
console.log("[HlsAdPlayer] Tracking pixel settled (".concat(outcome, "): ").concat(trackingUrl));
|
|
954
|
+
if (outcome !== "load") {
|
|
955
|
+
logFunnel("tracking_request_settled", {
|
|
956
|
+
reason: outcome,
|
|
957
|
+
trackingHost: trackingHost
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
img.onload = function() {
|
|
962
|
+
return release("load");
|
|
963
|
+
};
|
|
964
|
+
img.onerror = function() {
|
|
965
|
+
return release("error");
|
|
856
966
|
};
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
967
|
+
timeoutId = setTimeout(function() {
|
|
968
|
+
return release("timeout");
|
|
969
|
+
}, BEACON_TIMEOUT_MS);
|
|
860
970
|
img.src = trackingUrl;
|
|
861
971
|
console.log("[HlsAdPlayer] Fired tracking pixel: ".concat(trackingUrl));
|
|
972
|
+
logFunnel("tracking_request_created", {
|
|
973
|
+
trackingHost: trackingHost,
|
|
974
|
+
errorCode: options2 === null || options2 === void 0 ? void 0 : options2.errorCode
|
|
975
|
+
});
|
|
862
976
|
} catch (error) {
|
|
863
977
|
console.warn("[HlsAdPlayer] Error firing tracking pixel:", error);
|
|
864
978
|
}
|
|
@@ -888,54 +1002,80 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
888
1002
|
bitrate: level.bitrate || 5e6
|
|
889
1003
|
};
|
|
890
1004
|
}
|
|
891
|
-
function
|
|
892
|
-
if (mediaFiles.length === 0) {
|
|
893
|
-
throw new Error("No media files available");
|
|
894
|
-
}
|
|
895
|
-
var firstFile = mediaFiles[0];
|
|
896
|
-
if (!firstFile) {
|
|
897
|
-
throw new Error("No media files available");
|
|
898
|
-
}
|
|
899
|
-
if (mediaFiles.length === 1) {
|
|
900
|
-
return firstFile;
|
|
901
|
-
}
|
|
1005
|
+
function getMediaTargetQuality() {
|
|
902
1006
|
var mainQuality = getMainStreamQuality();
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
1007
|
+
var dpr = typeof window !== "undefined" && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1;
|
|
1008
|
+
var containerWidth = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientWidth) || contentVideo.clientWidth) * dpr;
|
|
1009
|
+
var containerHeight = ((adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.clientHeight) || contentVideo.clientHeight) * dpr;
|
|
1010
|
+
if (!mainQuality && !(containerWidth > 0 && containerHeight > 0)) {
|
|
1011
|
+
return null;
|
|
1012
|
+
}
|
|
1013
|
+
var base = mainQuality !== null && mainQuality !== void 0 ? mainQuality : {
|
|
1014
|
+
width: containerWidth,
|
|
1015
|
+
height: containerHeight,
|
|
1016
|
+
bitrate: 5e6
|
|
1017
|
+
};
|
|
1018
|
+
var width = containerWidth > 0 ? Math.min(base.width, containerWidth) : base.width;
|
|
1019
|
+
var height = containerHeight > 0 ? Math.min(base.height, containerHeight) : base.height;
|
|
1020
|
+
return {
|
|
1021
|
+
width: width,
|
|
1022
|
+
height: height,
|
|
1023
|
+
bitrate: base.bitrate
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
function rankMediaCandidates(mediaFiles) {
|
|
1027
|
+
var probe = adVideoElement !== null && adVideoElement !== void 0 ? adVideoElement : document.createElement("video");
|
|
1028
|
+
var pageIsHttps = typeof location !== "undefined" && location.protocol === "https:";
|
|
1029
|
+
var target = getMediaTargetQuality();
|
|
1030
|
+
var accepted = [];
|
|
1031
|
+
mediaFiles.forEach(function(file, index) {
|
|
1032
|
+
var isHls = isHlsMediaFile(file);
|
|
1033
|
+
var mimeForProbe = isHls ? "application/vnd.apple.mpegurl" : file.type || "video/mp4";
|
|
1034
|
+
var canPlay = probe.canPlayType(mimeForProbe);
|
|
1035
|
+
var playable = isHls ? import_hls.default.isSupported() || canPlay !== "" : canPlay !== "";
|
|
1036
|
+
var insecure = pageIsHttps && /^http:/i.test(file.url);
|
|
1037
|
+
var details = {
|
|
1038
|
+
index: index,
|
|
1039
|
+
candidateUrl: file.url,
|
|
1040
|
+
candidateType: file.type,
|
|
1041
|
+
width: file.width,
|
|
1042
|
+
height: file.height,
|
|
1043
|
+
bitrate: file.bitrate,
|
|
1044
|
+
canPlayType: canPlay,
|
|
1045
|
+
hlsJs: isHls ? import_hls.default.isSupported() : void 0
|
|
1046
|
+
};
|
|
1047
|
+
if (!playable) {
|
|
1048
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1049
|
+
reason: "rejected",
|
|
1050
|
+
why: "cannot_play_type"
|
|
1051
|
+
}));
|
|
1052
|
+
return;
|
|
1053
|
+
}
|
|
1054
|
+
var score = 0;
|
|
1055
|
+
if (target) {
|
|
1056
|
+
var resolutionDiff = Math.abs(file.width - target.width) + Math.abs(file.height - target.height);
|
|
1057
|
+
var bitrateDiff = Math.abs((file.bitrate || 5e3) * 1e3 - target.bitrate);
|
|
1058
|
+
score = resolutionDiff * 2 + bitrateDiff / 1e3;
|
|
1059
|
+
}
|
|
1060
|
+
accepted.push({
|
|
916
1061
|
file: file,
|
|
917
1062
|
score: score,
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
}
|
|
1063
|
+
insecure: insecure
|
|
1064
|
+
});
|
|
1065
|
+
logFunnel("media_candidate", _object_spread_props(_object_spread({}, details), {
|
|
1066
|
+
reason: "accepted",
|
|
1067
|
+
// Mixed-content media is often auto-upgraded, so it is kept as a last resort.
|
|
1068
|
+
why: insecure ? "insecure_http_deprioritized" : "playable",
|
|
1069
|
+
score: score
|
|
1070
|
+
}));
|
|
921
1071
|
});
|
|
922
|
-
|
|
1072
|
+
accepted.sort(function(a, b) {
|
|
1073
|
+
if (a.insecure !== b.insecure) return a.insecure ? 1 : -1;
|
|
923
1074
|
return a.score - b.score;
|
|
924
1075
|
});
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
console.log("[HlsAdPlayer] No best match found, using first media file");
|
|
928
|
-
return firstFile;
|
|
929
|
-
}
|
|
930
|
-
console.log("[HlsAdPlayer] Selected media file:", {
|
|
931
|
-
url: bestMatch.file.url,
|
|
932
|
-
resolution: "".concat(bestMatch.file.width, "x").concat(bestMatch.file.height),
|
|
933
|
-
bitrate: bestMatch.file.bitrate,
|
|
934
|
-
score: bestMatch.score,
|
|
935
|
-
resolutionDiff: bestMatch.resolutionDiff,
|
|
936
|
-
bitrateDiff: bestMatch.bitrateDiff
|
|
1076
|
+
return accepted.map(function(entry) {
|
|
1077
|
+
return entry.file;
|
|
937
1078
|
});
|
|
938
|
-
return bestMatch.file;
|
|
939
1079
|
}
|
|
940
1080
|
function isHlsMediaFile(mediaFile) {
|
|
941
1081
|
var type = mediaFile.type.toLowerCase();
|
|
@@ -952,9 +1092,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
952
1092
|
var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
|
|
953
1093
|
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");
|
|
954
1094
|
}
|
|
955
|
-
function collectVideoMediaFiles(linear, verbose) {
|
|
1095
|
+
function collectVideoMediaFiles(linear, verbose, stats) {
|
|
956
1096
|
var mediaFileElements = linear.querySelectorAll(":scope > MediaFiles > MediaFile");
|
|
957
1097
|
var mediaFiles = [];
|
|
1098
|
+
if (stats) stats.total += mediaFileElements.length;
|
|
958
1099
|
if (verbose) {
|
|
959
1100
|
console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
|
|
960
1101
|
}
|
|
@@ -975,6 +1116,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
975
1116
|
}
|
|
976
1117
|
var apiFramework = (mf.getAttribute("apiFramework") || "").toUpperCase();
|
|
977
1118
|
if (apiFramework === "VPAID") {
|
|
1119
|
+
if (stats) stats.vpaid++;
|
|
978
1120
|
if (verbose) {
|
|
979
1121
|
console.log("[HlsAdPlayer] MediaFile ".concat(index, " ignored (VPAID creatives are not supported)"));
|
|
980
1122
|
}
|
|
@@ -990,11 +1132,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
990
1132
|
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
991
1133
|
};
|
|
992
1134
|
if (isAudioMediaFile(mediaFile)) {
|
|
1135
|
+
if (stats) stats.audio++;
|
|
993
1136
|
console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
|
|
994
1137
|
return;
|
|
995
1138
|
}
|
|
996
1139
|
var hasExplicitDimensions = mf.getAttribute("width") != null && mf.getAttribute("height") != null;
|
|
997
1140
|
if (!isHlsMediaFile(mediaFile) && hasExplicitDimensions && (mediaFile.width <= 1 || mediaFile.height <= 1)) {
|
|
1141
|
+
if (stats) stats.audio++;
|
|
998
1142
|
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'));
|
|
999
1143
|
return;
|
|
1000
1144
|
}
|
|
@@ -1003,8 +1147,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1003
1147
|
if (verbose) {
|
|
1004
1148
|
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
1005
1149
|
}
|
|
1006
|
-
} else
|
|
1007
|
-
|
|
1150
|
+
} else {
|
|
1151
|
+
if (stats) stats.unsupported++;
|
|
1152
|
+
if (verbose) {
|
|
1153
|
+
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
1154
|
+
}
|
|
1008
1155
|
}
|
|
1009
1156
|
});
|
|
1010
1157
|
return mediaFiles;
|
|
@@ -1128,26 +1275,58 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1128
1275
|
}
|
|
1129
1276
|
function parseVastXml(xmlString) {
|
|
1130
1277
|
try {
|
|
1131
|
-
var _adElements_find;
|
|
1132
1278
|
var xmlDoc = parseXml(xmlString);
|
|
1133
1279
|
if (!xmlDoc) return {
|
|
1134
1280
|
type: "empty"
|
|
1135
1281
|
};
|
|
1136
1282
|
var root = xmlDoc.documentElement;
|
|
1137
1283
|
var adElements = Array.from(root.querySelectorAll(":scope > Ad"));
|
|
1138
|
-
|
|
1139
|
-
return getAdSequence(el) === void 0;
|
|
1140
|
-
})) !== null && _adElements_find !== void 0 ? _adElements_find : adElements[0];
|
|
1141
|
-
if (!adElement) {
|
|
1284
|
+
if (adElements.length === 0) {
|
|
1142
1285
|
var _root_getAttribute;
|
|
1143
1286
|
console.warn("[HlsAdPlayer] No Ad element found in VAST ".concat((_root_getAttribute = root.getAttribute("version")) !== null && _root_getAttribute !== void 0 ? _root_getAttribute : "", " response"));
|
|
1144
1287
|
return emptyVastResult(root);
|
|
1145
1288
|
}
|
|
1146
|
-
var
|
|
1147
|
-
|
|
1148
|
-
|
|
1289
|
+
var ordered = _to_consumable_array(adElements.filter(function(el) {
|
|
1290
|
+
return getAdSequence(el) === void 0;
|
|
1291
|
+
})).concat(_to_consumable_array(adElements.filter(function(el) {
|
|
1292
|
+
return getAdSequence(el) !== void 0;
|
|
1293
|
+
})));
|
|
1294
|
+
var firstEmpty;
|
|
1295
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1296
|
+
try {
|
|
1297
|
+
for(var _iterator = ordered.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1298
|
+
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], adElement = _step_value[1];
|
|
1299
|
+
var parsed = parseAdElement(adElement, true);
|
|
1300
|
+
if (parsed.type === "empty") {
|
|
1301
|
+
firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : firstEmpty = parsed;
|
|
1302
|
+
continue;
|
|
1303
|
+
}
|
|
1304
|
+
if (index > 0) {
|
|
1305
|
+
logFunnel("vast_ad_fallback", {
|
|
1306
|
+
usedAdIndex: index,
|
|
1307
|
+
adCount: ordered.length
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
if (parsed.type === "wrapper") {
|
|
1311
|
+
console.log("[HlsAdPlayer] VAST wrapper detected, following VASTAdTagURI: ".concat(parsed.vastAdTagUri));
|
|
1312
|
+
}
|
|
1313
|
+
return parsed;
|
|
1314
|
+
}
|
|
1315
|
+
} catch (err) {
|
|
1316
|
+
_didIteratorError = true;
|
|
1317
|
+
_iteratorError = err;
|
|
1318
|
+
} finally{
|
|
1319
|
+
try {
|
|
1320
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1321
|
+
_iterator.return();
|
|
1322
|
+
}
|
|
1323
|
+
} finally{
|
|
1324
|
+
if (_didIteratorError) {
|
|
1325
|
+
throw _iteratorError;
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1149
1328
|
}
|
|
1150
|
-
return
|
|
1329
|
+
return firstEmpty !== null && firstEmpty !== void 0 ? firstEmpty : emptyVastResult(root);
|
|
1151
1330
|
} catch (error) {
|
|
1152
1331
|
console.error("[HlsAdPlayer] Error parsing VAST XML:", error);
|
|
1153
1332
|
return {
|
|
@@ -1193,6 +1372,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1193
1372
|
pushUrls(errorUrls, inLine.querySelectorAll(":scope > Error"));
|
|
1194
1373
|
if (adElement.getAttribute("conditionalAd") === "true") {
|
|
1195
1374
|
console.warn("[HlsAdPlayer] Skipping conditional <Ad> (VPAID-only)");
|
|
1375
|
+
logFunnel("vast_no_supported_media", {
|
|
1376
|
+
reason: "vpaid_only",
|
|
1377
|
+
conditionalAd: true
|
|
1378
|
+
});
|
|
1196
1379
|
return {
|
|
1197
1380
|
type: "empty",
|
|
1198
1381
|
errorUrls: errorUrls,
|
|
@@ -1201,11 +1384,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1201
1384
|
}
|
|
1202
1385
|
var linear;
|
|
1203
1386
|
var mediaFiles = [];
|
|
1387
|
+
var rejectStats = {
|
|
1388
|
+
total: 0,
|
|
1389
|
+
vpaid: 0,
|
|
1390
|
+
audio: 0,
|
|
1391
|
+
unsupported: 0
|
|
1392
|
+
};
|
|
1204
1393
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1205
1394
|
try {
|
|
1206
1395
|
for(var _iterator = Array.from(inLine.querySelectorAll(":scope > Creatives > Creative > Linear"))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1207
1396
|
var candidate = _step.value;
|
|
1208
|
-
var files = collectVideoMediaFiles(candidate, verbose);
|
|
1397
|
+
var files = collectVideoMediaFiles(candidate, verbose, rejectStats);
|
|
1209
1398
|
if (files.length > 0) {
|
|
1210
1399
|
linear = candidate;
|
|
1211
1400
|
mediaFiles = files;
|
|
@@ -1228,6 +1417,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1228
1417
|
}
|
|
1229
1418
|
if (!linear) {
|
|
1230
1419
|
console.warn("[HlsAdPlayer] No supported linear media files in <Ad>");
|
|
1420
|
+
var reason = rejectStats.total === 0 ? "no_mediafiles" : rejectStats.vpaid > 0 ? "vpaid_only" : rejectStats.audio > 0 ? "audio_only" : "unsupported_type";
|
|
1421
|
+
logFunnel("vast_no_supported_media", _object_spread({
|
|
1422
|
+
reason: reason
|
|
1423
|
+
}, rejectStats));
|
|
1231
1424
|
return {
|
|
1232
1425
|
type: "empty",
|
|
1233
1426
|
errorUrls: errorUrls,
|
|
@@ -1263,7 +1456,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1263
1456
|
return _ts_generator(this, function(_state) {
|
|
1264
1457
|
switch(_state.label){
|
|
1265
1458
|
case 0:
|
|
1459
|
+
if (destroyed) {
|
|
1460
|
+
throw new Error("VAST request skipped: ad player destroyed");
|
|
1461
|
+
}
|
|
1266
1462
|
controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1463
|
+
if (controller) pendingVastRequests.add(controller);
|
|
1267
1464
|
timeoutId = controller ? setTimeout(function() {
|
|
1268
1465
|
return controller.abort();
|
|
1269
1466
|
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
@@ -1312,6 +1509,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1312
1509
|
6
|
|
1313
1510
|
];
|
|
1314
1511
|
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
1512
|
+
logFunnel("vast_credentials_retry", {
|
|
1513
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1514
|
+
});
|
|
1315
1515
|
return [
|
|
1316
1516
|
4,
|
|
1317
1517
|
requestVast("omit")
|
|
@@ -1345,11 +1545,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1345
1545
|
case 10:
|
|
1346
1546
|
error1 = _state.sent();
|
|
1347
1547
|
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1548
|
+
if (pendingRequestAbortReason) {
|
|
1549
|
+
throw new Error("".concat(pendingRequestAbortReason, " (timeout): ").concat(vastTagUrl));
|
|
1550
|
+
}
|
|
1348
1551
|
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1349
1552
|
}
|
|
1350
1553
|
throw error1;
|
|
1351
1554
|
case 11:
|
|
1352
1555
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1556
|
+
if (controller) pendingVastRequests.delete(controller);
|
|
1353
1557
|
return [
|
|
1354
1558
|
7
|
|
1355
1559
|
];
|
|
@@ -1363,7 +1567,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1363
1567
|
}
|
|
1364
1568
|
function fetchAndParseVastAd(_0) {
|
|
1365
1569
|
return _async_to_generator(function(vastTagUrl) {
|
|
1366
|
-
var depth, accumulatedTracking, rules, vastXml, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1570
|
+
var depth, accumulatedTracking, rules, vastXml, fetchStartedAt, error, parsed, _parsed_errorUrls, _parsed_errorCode;
|
|
1367
1571
|
var _arguments = arguments;
|
|
1368
1572
|
return _ts_generator(this, function(_state) {
|
|
1369
1573
|
switch(_state.label){
|
|
@@ -1371,6 +1575,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1371
1575
|
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] : {
|
|
1372
1576
|
followAdditionalWrappers: true
|
|
1373
1577
|
};
|
|
1578
|
+
if (destroyed) return [
|
|
1579
|
+
2,
|
|
1580
|
+
null
|
|
1581
|
+
];
|
|
1582
|
+
fetchStartedAt = Date.now();
|
|
1374
1583
|
_state.label = 1;
|
|
1375
1584
|
case 1:
|
|
1376
1585
|
_state.trys.push([
|
|
@@ -1393,14 +1602,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1393
1602
|
error = _state.sent();
|
|
1394
1603
|
if (depth === 0) throw error;
|
|
1395
1604
|
console.warn("[HlsAdPlayer] Wrapped VAST request failed:", error);
|
|
1396
|
-
|
|
1397
|
-
|
|
1605
|
+
logFunnel("wrapper_fetch", {
|
|
1606
|
+
reason: "failure",
|
|
1607
|
+
depth: depth,
|
|
1608
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
1609
|
+
elapsedMs: Date.now() - fetchStartedAt,
|
|
1610
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1398
1611
|
});
|
|
1612
|
+
if (!destroyed) {
|
|
1613
|
+
fireTrackingPixels(accumulatedTracking.error, {
|
|
1614
|
+
errorCode: VAST_ERROR_WRAPPER_TIMEOUT
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1399
1617
|
return [
|
|
1400
1618
|
2,
|
|
1401
1619
|
null
|
|
1402
1620
|
];
|
|
1403
1621
|
case 4:
|
|
1622
|
+
if (destroyed) return [
|
|
1623
|
+
2,
|
|
1624
|
+
null
|
|
1625
|
+
];
|
|
1626
|
+
if (depth > 0) {
|
|
1627
|
+
logFunnel("wrapper_fetch", {
|
|
1628
|
+
reason: "success",
|
|
1629
|
+
depth: depth,
|
|
1630
|
+
wrapperUrl: redactUrl(vastTagUrl),
|
|
1631
|
+
elapsedMs: Date.now() - fetchStartedAt
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1404
1634
|
console.log("[HlsAdPlayer] VAST XML received");
|
|
1405
1635
|
console.log("[HlsAdPlayer] VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
|
|
1406
1636
|
parsed = parseVastXml(vastXml);
|
|
@@ -1432,6 +1662,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1432
1662
|
];
|
|
1433
1663
|
}
|
|
1434
1664
|
mergeTrackingUrls(parsed.ad.trackingUrls, accumulatedTracking);
|
|
1665
|
+
logFunnel("inline_resolved", {
|
|
1666
|
+
depth: depth
|
|
1667
|
+
});
|
|
1435
1668
|
return [
|
|
1436
1669
|
2,
|
|
1437
1670
|
parsed.ad
|
|
@@ -1452,6 +1685,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1452
1685
|
];
|
|
1453
1686
|
case 1:
|
|
1454
1687
|
vastXml = _state.sent();
|
|
1688
|
+
if (destroyed) return [
|
|
1689
|
+
2,
|
|
1690
|
+
[]
|
|
1691
|
+
];
|
|
1455
1692
|
console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
|
|
1456
1693
|
trimmedXml = vastXml.trim();
|
|
1457
1694
|
if (trimmedXml.length === 0) {
|
|
@@ -1739,14 +1976,17 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1739
1976
|
var progress = currentTime / currentAd.duration;
|
|
1740
1977
|
if (progress >= 0.25 && !trackingFired.firstQuartile) {
|
|
1741
1978
|
trackingFired.firstQuartile = true;
|
|
1979
|
+
logFunnel("first_quartile");
|
|
1742
1980
|
fireTrackingPixels(currentAd.trackingUrls.firstQuartile);
|
|
1743
1981
|
}
|
|
1744
1982
|
if (progress >= 0.5 && !trackingFired.midpoint) {
|
|
1745
1983
|
trackingFired.midpoint = true;
|
|
1984
|
+
logFunnel("midpoint");
|
|
1746
1985
|
fireTrackingPixels(currentAd.trackingUrls.midpoint);
|
|
1747
1986
|
}
|
|
1748
1987
|
if (progress >= 0.75 && !trackingFired.thirdQuartile) {
|
|
1749
1988
|
trackingFired.thirdQuartile = true;
|
|
1989
|
+
logFunnel("third_quartile");
|
|
1750
1990
|
fireTrackingPixels(currentAd.trackingUrls.thirdQuartile);
|
|
1751
1991
|
}
|
|
1752
1992
|
};
|
|
@@ -1769,6 +2009,16 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1769
2009
|
if (!trackingFired.impression) {
|
|
1770
2010
|
trackingFired.impression = true;
|
|
1771
2011
|
resolvedAds.add(currentAd);
|
|
2012
|
+
logFunnel("playing", {
|
|
2013
|
+
mutedByAutoplay: forcedMuteByAutoplay,
|
|
2014
|
+
candidateIndex: mediaCandidateIndex
|
|
2015
|
+
});
|
|
2016
|
+
logFunnel("impression_fired", {
|
|
2017
|
+
pixelCount: currentAd.trackingUrls.impression.length
|
|
2018
|
+
});
|
|
2019
|
+
if (currentAd.trackingUrls.impression.length === 0) {
|
|
2020
|
+
console.warn("[HlsAdPlayer] Ad started but VAST contained no <Impression> URLs - GAM will not count it");
|
|
2021
|
+
}
|
|
1772
2022
|
fireTrackingPixels(currentAd.trackingUrls.impression);
|
|
1773
2023
|
fireTrackingPixels(currentAd.trackingUrls.creativeView);
|
|
1774
2024
|
fireTrackingPixels(currentAd.trackingUrls.verificationNotExecuted, {
|
|
@@ -1791,6 +2041,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1791
2041
|
sampleViewability();
|
|
1792
2042
|
settleViewability();
|
|
1793
2043
|
trackingFired.complete = true;
|
|
2044
|
+
logFunnel("complete");
|
|
1794
2045
|
fireTrackingPixels(currentAd.trackingUrls.complete);
|
|
1795
2046
|
console.log("[HlsAdPlayer] Ad completed");
|
|
1796
2047
|
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
|
|
@@ -1799,16 +2050,41 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1799
2050
|
handleAdComplete();
|
|
1800
2051
|
};
|
|
1801
2052
|
var onError = function onError(e) {
|
|
2053
|
+
var _adVideoElement_error, _adVideoElement_error1;
|
|
1802
2054
|
if (!adPlaying) return;
|
|
1803
2055
|
console.error("[HlsAdPlayer] Ad video error:", e);
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
2056
|
+
var vastErrorCode = toVastMediaErrorCode(adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.error);
|
|
2057
|
+
logFunnel("media_error", {
|
|
2058
|
+
mediaErrorCode: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error = adVideoElement.error) === null || _adVideoElement_error === void 0 ? void 0 : _adVideoElement_error.code,
|
|
2059
|
+
errorMessage: adVideoElement === null || adVideoElement === void 0 ? void 0 : (_adVideoElement_error1 = adVideoElement.error) === null || _adVideoElement_error1 === void 0 ? void 0 : _adVideoElement_error1.message,
|
|
2060
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2061
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2062
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2063
|
+
vastErrorCode: vastErrorCode
|
|
2064
|
+
});
|
|
2065
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2066
|
+
};
|
|
2067
|
+
var onMediaDiagnostic = function onMediaDiagnostic(event) {
|
|
2068
|
+
if (!adPlaying || !adVideoElement || trackingFired.impression) return;
|
|
2069
|
+
if (!adVideoElement.currentSrc) return;
|
|
2070
|
+
logFunnel("media_event", {
|
|
2071
|
+
reason: event.type,
|
|
2072
|
+
readyState: adVideoElement.readyState,
|
|
2073
|
+
networkState: adVideoElement.networkState,
|
|
2074
|
+
currentSrc: adVideoElement.currentSrc
|
|
2075
|
+
});
|
|
1809
2076
|
};
|
|
1810
2077
|
var onVolumeChange = function onVolumeChange() {
|
|
1811
2078
|
if (!currentAd || !adVideoElement) return;
|
|
2079
|
+
if (forcedMuteByAutoplay && !adVideoElement.muted) {
|
|
2080
|
+
var userActivation = navigator.userActivation;
|
|
2081
|
+
if (userActivation && !userActivation.isActive) {
|
|
2082
|
+
logFunnel("unexpected_unmute", {
|
|
2083
|
+
paused: adVideoElement.paused
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
forcedMuteByAutoplay = false;
|
|
2087
|
+
}
|
|
1812
2088
|
var muted = adVideoElement.muted || adVideoElement.volume === 0;
|
|
1813
2089
|
if (!trackingFired.start) {
|
|
1814
2090
|
trackingFired.lastMuted = muted;
|
|
@@ -1868,6 +2144,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1868
2144
|
{
|
|
1869
2145
|
type: "play",
|
|
1870
2146
|
handler: onPlay
|
|
2147
|
+
},
|
|
2148
|
+
{
|
|
2149
|
+
type: "stalled",
|
|
2150
|
+
handler: onMediaDiagnostic
|
|
2151
|
+
},
|
|
2152
|
+
{
|
|
2153
|
+
type: "suspend",
|
|
2154
|
+
handler: onMediaDiagnostic
|
|
2155
|
+
},
|
|
2156
|
+
{
|
|
2157
|
+
type: "abort",
|
|
2158
|
+
handler: onMediaDiagnostic
|
|
2159
|
+
},
|
|
2160
|
+
{
|
|
2161
|
+
type: "emptied",
|
|
2162
|
+
handler: onMediaDiagnostic
|
|
1871
2163
|
}
|
|
1872
2164
|
];
|
|
1873
2165
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -2157,16 +2449,51 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2157
2449
|
function settlePendingPlay() {
|
|
2158
2450
|
pendingPlayPromise = void 0;
|
|
2159
2451
|
}
|
|
2452
|
+
function toVastPlayErrorCode(error) {
|
|
2453
|
+
return (error === null || error === void 0 ? void 0 : error.name) === "NotSupportedError" ? VAST_ERROR_NO_SUPPORTED_MEDIA : VAST_ERROR_MEDIA_DISPLAY;
|
|
2454
|
+
}
|
|
2455
|
+
function failAdPlayback(context, error) {
|
|
2456
|
+
var vastErrorCode = toVastPlayErrorCode(error);
|
|
2457
|
+
console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
|
|
2458
|
+
logFunnel("play_failed", {
|
|
2459
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2460
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message,
|
|
2461
|
+
vastErrorCode: vastErrorCode
|
|
2462
|
+
});
|
|
2463
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2464
|
+
}
|
|
2160
2465
|
function startAdPlayback(context) {
|
|
2466
|
+
var isMutedRetry = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
2161
2467
|
if (!adVideoElement) return;
|
|
2468
|
+
var computed = typeof getComputedStyle === "function" && adContainerEl ? getComputedStyle(adContainerEl) : void 0;
|
|
2469
|
+
logFunnel(isMutedRetry ? "muted_retry" : "play_called", {
|
|
2470
|
+
context: context,
|
|
2471
|
+
isConnected: adVideoElement.isConnected,
|
|
2472
|
+
clientWidth: adVideoElement.clientWidth,
|
|
2473
|
+
clientHeight: adVideoElement.clientHeight,
|
|
2474
|
+
containerDisplay: computed === null || computed === void 0 ? void 0 : computed.display,
|
|
2475
|
+
containerVisibility: computed === null || computed === void 0 ? void 0 : computed.visibility
|
|
2476
|
+
});
|
|
2162
2477
|
var playPromise = adVideoElement.play();
|
|
2163
2478
|
pendingPlayPromise = playPromise;
|
|
2164
2479
|
playPromise.catch(function(error) {
|
|
2165
2480
|
if (pendingPlayPromise !== playPromise) {
|
|
2166
2481
|
return;
|
|
2167
2482
|
}
|
|
2168
|
-
|
|
2169
|
-
|
|
2483
|
+
logFunnel("play_rejected", {
|
|
2484
|
+
context: context,
|
|
2485
|
+
errorName: error === null || error === void 0 ? void 0 : error.name,
|
|
2486
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
2487
|
+
});
|
|
2488
|
+
if (!isMutedRetry && (error === null || error === void 0 ? void 0 : error.name) === "NotAllowedError" && adVideoElement && !adVideoElement.muted) {
|
|
2489
|
+
console.warn("[HlsAdPlayer] Unmuted ".concat(context, " blocked by autoplay policy - retrying muted"));
|
|
2490
|
+
originalMutedState = true;
|
|
2491
|
+
forcedMuteByAutoplay = true;
|
|
2492
|
+
adVideoElement.muted = true;
|
|
2493
|
+
startAdPlayback(context, true);
|
|
2494
|
+
return;
|
|
2495
|
+
}
|
|
2496
|
+
failAdPlayback(context, error);
|
|
2170
2497
|
}).finally(function() {
|
|
2171
2498
|
if (pendingPlayPromise === playPromise) {
|
|
2172
2499
|
pendingPlayPromise = void 0;
|
|
@@ -2205,17 +2532,109 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2205
2532
|
adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
|
|
2206
2533
|
adVideoElement.muted = originalMutedState;
|
|
2207
2534
|
}
|
|
2535
|
+
function clearMediaStartTimer() {
|
|
2536
|
+
if (mediaStartTimerId !== void 0) {
|
|
2537
|
+
clearTimeout(mediaStartTimerId);
|
|
2538
|
+
mediaStartTimerId = void 0;
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
function startMediaStartTimer() {
|
|
2542
|
+
clearMediaStartTimer();
|
|
2543
|
+
if (!(MEDIA_START_TIMEOUT_MS > 0)) return;
|
|
2544
|
+
var startedAt = Date.now();
|
|
2545
|
+
mediaStartTimerId = setTimeout(function() {
|
|
2546
|
+
mediaStartTimerId = void 0;
|
|
2547
|
+
if (!adPlaying || trackingFired.impression) return;
|
|
2548
|
+
console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(MEDIA_START_TIMEOUT_MS, "ms"));
|
|
2549
|
+
logFunnel("play_resolved_but_never_started", {
|
|
2550
|
+
timeoutMs: MEDIA_START_TIMEOUT_MS,
|
|
2551
|
+
elapsedMs: Date.now() - startedAt,
|
|
2552
|
+
readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
|
|
2553
|
+
networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
|
|
2554
|
+
currentSrc: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.currentSrc,
|
|
2555
|
+
paused: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.paused,
|
|
2556
|
+
vastErrorCode: VAST_ERROR_MEDIA_TIMEOUT
|
|
2557
|
+
});
|
|
2558
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_TIMEOUT);
|
|
2559
|
+
}, MEDIA_START_TIMEOUT_MS);
|
|
2560
|
+
}
|
|
2561
|
+
function resetVideoElementForNextSource() {
|
|
2562
|
+
clearStallWatchdog();
|
|
2563
|
+
if (requiresMediaPipelineResetAfterAds()) {
|
|
2564
|
+
recreateAdVideoElement();
|
|
2565
|
+
setupAdEventListeners();
|
|
2566
|
+
} else {
|
|
2567
|
+
prepareVideoElementForNewSource();
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
function tryNextMediaCandidate() {
|
|
2571
|
+
if (!currentAd || trackingFired.impression) return false;
|
|
2572
|
+
if (mediaCandidateIndex >= mediaCandidates.length - 1) return false;
|
|
2573
|
+
var failedUrl = currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url;
|
|
2574
|
+
mediaCandidateIndex++;
|
|
2575
|
+
var next = mediaCandidates[mediaCandidateIndex];
|
|
2576
|
+
if (!next) return false;
|
|
2577
|
+
logFunnel("media_fallback", {
|
|
2578
|
+
failedUrl: failedUrl,
|
|
2579
|
+
nextUrl: next.url,
|
|
2580
|
+
nextType: next.type,
|
|
2581
|
+
candidateIndex: mediaCandidateIndex,
|
|
2582
|
+
candidateCount: mediaCandidates.length
|
|
2583
|
+
});
|
|
2584
|
+
resetVideoElementForNextSource();
|
|
2585
|
+
try {
|
|
2586
|
+
loadMediaCandidate(next);
|
|
2587
|
+
return true;
|
|
2588
|
+
} catch (error) {
|
|
2589
|
+
console.error("[HlsAdPlayer] Failed to load fallback media file:", error);
|
|
2590
|
+
return tryNextMediaCandidate();
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
function recoverFromAdFailure(vastErrorCode) {
|
|
2594
|
+
clearMediaStartTimer();
|
|
2595
|
+
if (tryNextMediaCandidate()) return;
|
|
2596
|
+
reportCurrentAdError(vastErrorCode);
|
|
2597
|
+
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) return;
|
|
2598
|
+
handleAdError();
|
|
2599
|
+
}
|
|
2208
2600
|
function loadCurrentAdMedia() {
|
|
2209
2601
|
if (!adVideoElement || !currentAd) {
|
|
2210
2602
|
throw new Error("No ad video element or ad to load");
|
|
2211
2603
|
}
|
|
2212
|
-
|
|
2604
|
+
mediaCandidates = rankMediaCandidates(currentAd.mediaFiles);
|
|
2605
|
+
mediaCandidateIndex = 0;
|
|
2606
|
+
var mediaFile = mediaCandidates[0];
|
|
2213
2607
|
if (!mediaFile) {
|
|
2214
|
-
|
|
2608
|
+
logFunnel("media_unsupported", {
|
|
2609
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA,
|
|
2610
|
+
candidates: currentAd.mediaFiles.length
|
|
2611
|
+
});
|
|
2612
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
2613
|
+
throw new Error("No media file this browser can play");
|
|
2614
|
+
}
|
|
2615
|
+
try {
|
|
2616
|
+
loadMediaCandidate(mediaFile);
|
|
2617
|
+
} catch (error) {
|
|
2618
|
+
if (tryNextMediaCandidate()) return;
|
|
2619
|
+
reportCurrentAdError(VAST_ERROR_NO_SUPPORTED_MEDIA);
|
|
2620
|
+
throw error;
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
function loadMediaCandidate(mediaFile) {
|
|
2624
|
+
if (!adVideoElement || !currentAd) {
|
|
2625
|
+
throw new Error("No ad video element or ad to load");
|
|
2215
2626
|
}
|
|
2216
2627
|
currentAdMediaFile = mediaFile;
|
|
2217
2628
|
var isHlsAd = isHlsMediaFile(mediaFile);
|
|
2629
|
+
logFunnel("media_selected", {
|
|
2630
|
+
width: mediaFile.width,
|
|
2631
|
+
height: mediaFile.height,
|
|
2632
|
+
bitrate: mediaFile.bitrate,
|
|
2633
|
+
candidateIndex: mediaCandidateIndex,
|
|
2634
|
+
candidates: mediaCandidates.length
|
|
2635
|
+
});
|
|
2218
2636
|
console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad (pod ").concat(podIndex + 1, "/").concat(podAds.length || 1, ") from: ").concat(mediaFile.url));
|
|
2637
|
+
startMediaStartTimer();
|
|
2219
2638
|
if (isHlsAd && import_hls.default.isSupported()) {
|
|
2220
2639
|
if (adHls) {
|
|
2221
2640
|
adHls.destroy();
|
|
@@ -2224,6 +2643,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2224
2643
|
enableWorker: true,
|
|
2225
2644
|
lowLatencyMode: false
|
|
2226
2645
|
});
|
|
2646
|
+
logFunnel("media_load", {
|
|
2647
|
+
pipeline: "hls.js"
|
|
2648
|
+
});
|
|
2227
2649
|
adHls.loadSource(mediaFile.url);
|
|
2228
2650
|
adHls.attachMedia(adVideoElement);
|
|
2229
2651
|
adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
|
|
@@ -2233,10 +2655,24 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2233
2655
|
adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
|
|
2234
2656
|
console.error("[HlsAdPlayer] HLS error:", data);
|
|
2235
2657
|
if (data.fatal) {
|
|
2236
|
-
|
|
2658
|
+
var _data_response, _data_response1, _data_frag;
|
|
2659
|
+
var vastErrorCode = data.type === import_hls.default.ErrorTypes.NETWORK_ERROR ? 401 : VAST_ERROR_MEDIA_DISPLAY;
|
|
2660
|
+
logFunnel("hls_fatal", {
|
|
2661
|
+
reason: data.details,
|
|
2662
|
+
errorName: data.type,
|
|
2663
|
+
errorMessage: data.details,
|
|
2664
|
+
responseCode: (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.code,
|
|
2665
|
+
responseText: (_data_response1 = data.response) === null || _data_response1 === void 0 ? void 0 : _data_response1.text,
|
|
2666
|
+
fragUrl: (_data_frag = data.frag) === null || _data_frag === void 0 ? void 0 : _data_frag.url,
|
|
2667
|
+
vastErrorCode: vastErrorCode
|
|
2668
|
+
});
|
|
2669
|
+
recoverFromAdFailure(vastErrorCode);
|
|
2237
2670
|
}
|
|
2238
2671
|
});
|
|
2239
2672
|
} else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
|
|
2673
|
+
logFunnel("media_load", {
|
|
2674
|
+
pipeline: "native-hls"
|
|
2675
|
+
});
|
|
2240
2676
|
adVideoElement.src = mediaFile.url;
|
|
2241
2677
|
startAdPlayback("native HLS ad playback");
|
|
2242
2678
|
} else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
|
|
@@ -2244,45 +2680,47 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2244
2680
|
adHls.destroy();
|
|
2245
2681
|
adHls = void 0;
|
|
2246
2682
|
}
|
|
2683
|
+
logFunnel("media_load", {
|
|
2684
|
+
pipeline: "progressive"
|
|
2685
|
+
});
|
|
2247
2686
|
adVideoElement.src = mediaFile.url;
|
|
2248
2687
|
adVideoElement.load();
|
|
2249
2688
|
startAdPlayback("progressive ad playback");
|
|
2250
2689
|
} else {
|
|
2690
|
+
clearMediaStartTimer();
|
|
2691
|
+
logFunnel("media_unsupported", {
|
|
2692
|
+
vastErrorCode: VAST_ERROR_NO_SUPPORTED_MEDIA
|
|
2693
|
+
});
|
|
2251
2694
|
throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
|
|
2252
2695
|
}
|
|
2253
2696
|
}
|
|
2254
2697
|
function advanceToNextPodAd() {
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
index: podIndex,
|
|
2277
|
-
total: podAds.length
|
|
2278
|
-
});
|
|
2279
|
-
return true;
|
|
2280
|
-
} catch (error) {
|
|
2281
|
-
console.error("[HlsAdPlayer] Failed to load next pod ad:", error);
|
|
2282
|
-
return false;
|
|
2698
|
+
clearMediaStartTimer();
|
|
2699
|
+
while(podIndex < podAds.length - 1){
|
|
2700
|
+
settleViewability();
|
|
2701
|
+
podIndex++;
|
|
2702
|
+
currentAd = podAds[podIndex];
|
|
2703
|
+
currentAdMediaFile = void 0;
|
|
2704
|
+
resetAdTracking();
|
|
2705
|
+
if (currentAd) {
|
|
2706
|
+
console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
|
|
2707
|
+
}
|
|
2708
|
+
resetVideoElementForNextSource();
|
|
2709
|
+
try {
|
|
2710
|
+
loadCurrentAdMedia();
|
|
2711
|
+
emit("pod_ad_started", {
|
|
2712
|
+
index: podIndex,
|
|
2713
|
+
total: podAds.length
|
|
2714
|
+
});
|
|
2715
|
+
return true;
|
|
2716
|
+
} catch (error) {
|
|
2717
|
+
console.error("[HlsAdPlayer] Failed to load next pod ad:", error);
|
|
2718
|
+
}
|
|
2283
2719
|
}
|
|
2720
|
+
return false;
|
|
2284
2721
|
}
|
|
2285
2722
|
function clearStallWatchdog() {
|
|
2723
|
+
clearMediaStartTimer();
|
|
2286
2724
|
if (stallWatchdogId != null) {
|
|
2287
2725
|
clearInterval(stallWatchdogId);
|
|
2288
2726
|
stallWatchdogId = void 0;
|
|
@@ -2298,11 +2736,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2298
2736
|
function handleAdStall() {
|
|
2299
2737
|
console.warn("[HlsAdPlayer] Ad playback stalled (no progress) - recovering to avoid a blank frame");
|
|
2300
2738
|
clearStallWatchdog();
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
handleAdError();
|
|
2739
|
+
logFunnel("stall", {
|
|
2740
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
2741
|
+
});
|
|
2742
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2306
2743
|
}
|
|
2307
2744
|
function getDecodedVideoFrameCount(video) {
|
|
2308
2745
|
try {
|
|
@@ -2364,11 +2801,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2364
2801
|
function handleVideoDecodeFailure() {
|
|
2365
2802
|
console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
|
|
2366
2803
|
clearStallWatchdog();
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
handleAdError();
|
|
2804
|
+
logFunnel("decode_failure", {
|
|
2805
|
+
vastErrorCode: VAST_ERROR_MEDIA_DISPLAY
|
|
2806
|
+
});
|
|
2807
|
+
recoverFromAdFailure(VAST_ERROR_MEDIA_DISPLAY);
|
|
2372
2808
|
}
|
|
2373
2809
|
function startStallWatchdog() {
|
|
2374
2810
|
clearStallWatchdog();
|
|
@@ -2492,6 +2928,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2492
2928
|
Promise.reject(new Error("Ad already playing"))
|
|
2493
2929
|
];
|
|
2494
2930
|
}
|
|
2931
|
+
if (destroyed) {
|
|
2932
|
+
return [
|
|
2933
|
+
2,
|
|
2934
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
2935
|
+
];
|
|
2936
|
+
}
|
|
2937
|
+
currentVastTagUrl = vastTagUrl;
|
|
2938
|
+
pendingRequestAbortReason = void 0;
|
|
2939
|
+
logFunnel("request_sent");
|
|
2495
2940
|
_state.label = 1;
|
|
2496
2941
|
case 1:
|
|
2497
2942
|
_state.trys.push([
|
|
@@ -2526,8 +2971,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2526
2971
|
ads = _state.sent();
|
|
2527
2972
|
_state.label = 4;
|
|
2528
2973
|
case 4:
|
|
2974
|
+
if (destroyed) {
|
|
2975
|
+
return [
|
|
2976
|
+
2,
|
|
2977
|
+
Promise.reject(new Error("Ad player destroyed"))
|
|
2978
|
+
];
|
|
2979
|
+
}
|
|
2980
|
+
if (!ads.length && pendingRequestAbortReason) {
|
|
2981
|
+
throw new Error(pendingRequestAbortReason);
|
|
2982
|
+
}
|
|
2529
2983
|
if (!ads.length) {
|
|
2530
2984
|
console.warn("[HlsAdPlayer] No ads available from VAST response");
|
|
2985
|
+
logFunnel("no_fill");
|
|
2531
2986
|
emit("ad_error");
|
|
2532
2987
|
return [
|
|
2533
2988
|
2,
|
|
@@ -2538,6 +2993,23 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2538
2993
|
podIndex = 0;
|
|
2539
2994
|
currentAd = ads[0];
|
|
2540
2995
|
currentAdMediaFile = void 0;
|
|
2996
|
+
logFunnel("vast_received", {
|
|
2997
|
+
adCount: ads.length,
|
|
2998
|
+
durations: ads.map(function(ad) {
|
|
2999
|
+
return ad.duration;
|
|
3000
|
+
}),
|
|
3001
|
+
impressionUrls: ads.map(function(ad) {
|
|
3002
|
+
return ad.trackingUrls.impression.length;
|
|
3003
|
+
})
|
|
3004
|
+
});
|
|
3005
|
+
ads.forEach(function(ad, index) {
|
|
3006
|
+
if (ad.trackingUrls.impression.length === 0) {
|
|
3007
|
+
logFunnel("vast_missing_impression", {
|
|
3008
|
+
adIndex: index,
|
|
3009
|
+
missingAdId: ad.id
|
|
3010
|
+
});
|
|
3011
|
+
}
|
|
3012
|
+
});
|
|
2541
3013
|
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"));
|
|
2542
3014
|
return [
|
|
2543
3015
|
2,
|
|
@@ -2546,6 +3018,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2546
3018
|
case 5:
|
|
2547
3019
|
error = _state.sent();
|
|
2548
3020
|
console.error("[HlsAdPlayer] Error requesting ads:", error);
|
|
3021
|
+
logFunnel("request_failed", {
|
|
3022
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3023
|
+
});
|
|
2549
3024
|
emit("ad_error");
|
|
2550
3025
|
return [
|
|
2551
3026
|
2,
|
|
@@ -2601,13 +3076,22 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2601
3076
|
adContainerEl.style.pointerEvents = "auto";
|
|
2602
3077
|
}
|
|
2603
3078
|
emit("content_pause");
|
|
2604
|
-
|
|
3079
|
+
try {
|
|
3080
|
+
loadCurrentAdMedia();
|
|
3081
|
+
} catch (loadError) {
|
|
3082
|
+
if (!(podIndex < podAds.length - 1 && advanceToNextPodAd())) {
|
|
3083
|
+
throw loadError;
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
2605
3086
|
return [
|
|
2606
3087
|
2,
|
|
2607
3088
|
Promise.resolve()
|
|
2608
3089
|
];
|
|
2609
3090
|
} catch (error) {
|
|
2610
3091
|
console.error("[HlsAdPlayer] Error playing ad:", error);
|
|
3092
|
+
logFunnel("play_failed", {
|
|
3093
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
3094
|
+
});
|
|
2611
3095
|
handleAdError();
|
|
2612
3096
|
return [
|
|
2613
3097
|
2,
|
|
@@ -2649,6 +3133,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2649
3133
|
var previousMutedState;
|
|
2650
3134
|
return _ts_generator(this, function(_state) {
|
|
2651
3135
|
console.log("[HlsAdPlayer] Stopping ad");
|
|
3136
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3137
|
+
logFunnel("stopped_before_start");
|
|
3138
|
+
}
|
|
2652
3139
|
settleViewability();
|
|
2653
3140
|
fireNotUsedForUnplayedAds();
|
|
2654
3141
|
clearStallWatchdog();
|
|
@@ -2681,15 +3168,18 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2681
3168
|
},
|
|
2682
3169
|
destroy: function destroy() {
|
|
2683
3170
|
console.log("[HlsAdPlayer] Destroying");
|
|
3171
|
+
if (adPlaying && currentAd && !trackingFired.impression) {
|
|
3172
|
+
logFunnel("stopped_before_start");
|
|
3173
|
+
}
|
|
2684
3174
|
settleViewability();
|
|
2685
3175
|
fireNotUsedForUnplayedAds();
|
|
2686
3176
|
destroyed = true;
|
|
2687
|
-
|
|
3177
|
+
pendingRequestAbortReason = "Ad player destroyed";
|
|
2688
3178
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2689
3179
|
try {
|
|
2690
|
-
for(var _iterator =
|
|
2691
|
-
var
|
|
2692
|
-
|
|
3180
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3181
|
+
var controller = _step.value;
|
|
3182
|
+
controller.abort();
|
|
2693
3183
|
}
|
|
2694
3184
|
} catch (err) {
|
|
2695
3185
|
_didIteratorError = true;
|
|
@@ -2705,6 +3195,28 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2705
3195
|
}
|
|
2706
3196
|
}
|
|
2707
3197
|
}
|
|
3198
|
+
pendingVastRequests.clear();
|
|
3199
|
+
clearStallWatchdog();
|
|
3200
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3201
|
+
try {
|
|
3202
|
+
for(var _iterator1 = pendingTimeouts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3203
|
+
var timeoutId = _step1.value;
|
|
3204
|
+
clearTimeout(timeoutId);
|
|
3205
|
+
}
|
|
3206
|
+
} catch (err) {
|
|
3207
|
+
_didIteratorError1 = true;
|
|
3208
|
+
_iteratorError1 = err;
|
|
3209
|
+
} finally{
|
|
3210
|
+
try {
|
|
3211
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
3212
|
+
_iterator1.return();
|
|
3213
|
+
}
|
|
3214
|
+
} finally{
|
|
3215
|
+
if (_didIteratorError1) {
|
|
3216
|
+
throw _iteratorError1;
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
2708
3220
|
pendingTimeouts = [];
|
|
2709
3221
|
adPlaying = false;
|
|
2710
3222
|
setAdPlayingFlag(false);
|
|
@@ -2724,6 +3236,35 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2724
3236
|
isAdPlaying: function isAdPlaying() {
|
|
2725
3237
|
return adPlaying;
|
|
2726
3238
|
},
|
|
3239
|
+
setFunnelContext: function setFunnelContext(context) {
|
|
3240
|
+
funnelContext = _object_spread({}, context);
|
|
3241
|
+
},
|
|
3242
|
+
abortPendingRequest: function abortPendingRequest() {
|
|
3243
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "VAST request aborted (timeout)";
|
|
3244
|
+
if (pendingVastRequests.size === 0) return;
|
|
3245
|
+
pendingRequestAbortReason = reason;
|
|
3246
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3247
|
+
try {
|
|
3248
|
+
for(var _iterator = Array.from(pendingVastRequests)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3249
|
+
var controller = _step.value;
|
|
3250
|
+
controller.abort();
|
|
3251
|
+
}
|
|
3252
|
+
} catch (err) {
|
|
3253
|
+
_didIteratorError = true;
|
|
3254
|
+
_iteratorError = err;
|
|
3255
|
+
} finally{
|
|
3256
|
+
try {
|
|
3257
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3258
|
+
_iterator.return();
|
|
3259
|
+
}
|
|
3260
|
+
} finally{
|
|
3261
|
+
if (_didIteratorError) {
|
|
3262
|
+
throw _iteratorError;
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3266
|
+
pendingVastRequests.clear();
|
|
3267
|
+
},
|
|
2727
3268
|
resize: function resize(width, height) {
|
|
2728
3269
|
console.log("[HlsAdPlayer] Resizing to ".concat(width, "x").concat(height));
|
|
2729
3270
|
if (adContainerEl) {
|
|
@@ -2759,6 +3300,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2759
3300
|
if (adVideoElement && adPlaying) {
|
|
2760
3301
|
var clamped = Math.max(0, Math.min(1, volume));
|
|
2761
3302
|
adVideoElement.volume = clamped;
|
|
3303
|
+
var userActivation = navigator.userActivation;
|
|
3304
|
+
if (clamped > 0 && forcedMuteByAutoplay && userActivation && !userActivation.isActive) {
|
|
3305
|
+
logFunnel("unmute_blocked_without_gesture", {
|
|
3306
|
+
requestedVolume: clamped
|
|
3307
|
+
});
|
|
3308
|
+
return;
|
|
3309
|
+
}
|
|
2762
3310
|
adVideoElement.muted = clamped === 0;
|
|
2763
3311
|
}
|
|
2764
3312
|
},
|
|
@@ -6822,7 +7370,7 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6822
7370
|
{
|
|
6823
7371
|
key: "adFitsRemainingBudget",
|
|
6824
7372
|
value: function adFitsRemainingBudget(durationMs) {
|
|
6825
|
-
if (durationMs <= 0) {
|
|
7373
|
+
if (durationMs <= 0 || this.expectedAdBreakDurationMs == null) {
|
|
6826
7374
|
return true;
|
|
6827
7375
|
}
|
|
6828
7376
|
return durationMs <= this.getDurationBudgetRemainingMs();
|
|
@@ -6881,6 +7429,11 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6881
7429
|
value: function markAdStarted() {
|
|
6882
7430
|
this.currentAdIndex++;
|
|
6883
7431
|
this.totalAdsInBreak = this.currentAdIndex;
|
|
7432
|
+
}
|
|
7433
|
+
},
|
|
7434
|
+
{
|
|
7435
|
+
key: "noteAdRequestSent",
|
|
7436
|
+
value: function noteAdRequestSent() {
|
|
6884
7437
|
this.totalAdRequestsInBreak++;
|
|
6885
7438
|
this.lastAdRequestTime = Date.now();
|
|
6886
7439
|
}
|
|
@@ -6932,6 +7485,9 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
6932
7485
|
if (message.includes("timeout")) {
|
|
6933
7486
|
return true;
|
|
6934
7487
|
}
|
|
7488
|
+
if (message.includes("ad player destroyed") || message.includes("aborted")) {
|
|
7489
|
+
return true;
|
|
7490
|
+
}
|
|
6935
7491
|
if (message.includes("rate limit") || message.includes("too many requests")) {
|
|
6936
7492
|
return true;
|
|
6937
7493
|
}
|
|
@@ -8065,6 +8621,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8065
8621
|
this.adDetectSentForCurrentBreak = false;
|
|
8066
8622
|
this.continuousFetchingActive = false;
|
|
8067
8623
|
this.continuousFetchLoopRunning = false;
|
|
8624
|
+
this.breakFunnel = {};
|
|
8625
|
+
this.controllerCallInFlight = false;
|
|
8626
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8627
|
+
this.opportunityEpoch = -1;
|
|
8068
8628
|
this.adRequestQueue = [];
|
|
8069
8629
|
this.adPodQueue = [];
|
|
8070
8630
|
this.maxPlaceholderDurationMs = 5e3;
|
|
@@ -8117,7 +8677,25 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8117
8677
|
adPlayer.on("ad_interaction", function(event) {
|
|
8118
8678
|
if (event) _this.host.onAdInteraction(event);
|
|
8119
8679
|
});
|
|
8680
|
+
adPlayer.on("ad_funnel", function(payload) {
|
|
8681
|
+
if (!(payload === null || payload === void 0 ? void 0 : payload.stage)) return;
|
|
8682
|
+
_this.countFunnelStage(payload.stage);
|
|
8683
|
+
if (payload.reason) {
|
|
8684
|
+
_this.countFunnelStage("".concat(payload.stage, ":").concat(payload.reason));
|
|
8685
|
+
}
|
|
8686
|
+
if (payload.stage === "impression_fired" && payload.pixelCount != null) {
|
|
8687
|
+
_this.countFunnelStage("impression_urls", payload.pixelCount);
|
|
8688
|
+
}
|
|
8689
|
+
if (payload.visibilityState === "hidden") {
|
|
8690
|
+
_this.countFunnelStage("while_hidden");
|
|
8691
|
+
}
|
|
8692
|
+
});
|
|
8120
8693
|
adPlayer.on("ad_impression", function() {
|
|
8694
|
+
_this.timing.consecutiveFailures = 0;
|
|
8695
|
+
if (!_this.playbackStartedForCurrentRequest) {
|
|
8696
|
+
_this.playbackStartedForCurrentRequest = true;
|
|
8697
|
+
_this.timing.markAdStarted();
|
|
8698
|
+
}
|
|
8121
8699
|
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
8122
8700
|
source: "hls",
|
|
8123
8701
|
adIndex: _this.timing.currentAdIndex
|
|
@@ -8161,6 +8739,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8161
8739
|
}
|
|
8162
8740
|
}
|
|
8163
8741
|
console.error("[AD-ERROR]", errorMessage, errorPayload || "");
|
|
8742
|
+
if (_this.controllerCallInFlight) {
|
|
8743
|
+
_this.timing.recordGamNoFill();
|
|
8744
|
+
return;
|
|
8745
|
+
}
|
|
8164
8746
|
_this.handleAdFailure();
|
|
8165
8747
|
});
|
|
8166
8748
|
adPlayer.on("content_pause", function() {
|
|
@@ -8232,6 +8814,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8232
8814
|
}
|
|
8233
8815
|
var preservedMutedState = adPlayer.getOriginalMutedState();
|
|
8234
8816
|
var preservedVolumeState = adPlayer.getOriginalVolume();
|
|
8817
|
+
this.playbackStartedForCurrentRequest = false;
|
|
8235
8818
|
if (adPlayer) {
|
|
8236
8819
|
try {
|
|
8237
8820
|
adPlayer.destroy();
|
|
@@ -8321,9 +8904,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8321
8904
|
if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
8322
8905
|
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
8323
8906
|
}
|
|
8907
|
+
this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
|
|
8324
8908
|
return [
|
|
8325
8909
|
4,
|
|
8326
|
-
this.startOptimizedPod(baseVastUrl, adBreakDurationMs
|
|
8910
|
+
this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
|
|
8327
8911
|
];
|
|
8328
8912
|
case 1:
|
|
8329
8913
|
podPlayed = _state.sent();
|
|
@@ -8357,7 +8941,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8357
8941
|
value: // ───────────────────────────────────────────────────────────────
|
|
8358
8942
|
// Optimized pod (single multi-ad request)
|
|
8359
8943
|
// ───────────────────────────────────────────────────────────────
|
|
8360
|
-
function startOptimizedPod(baseVastUrl, breakDurationMs
|
|
8944
|
+
function startOptimizedPod(baseVastUrl, breakDurationMs) {
|
|
8361
8945
|
return _async_to_generator(function() {
|
|
8362
8946
|
var podUrl, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
8363
8947
|
return _ts_generator(this, function(_state) {
|
|
@@ -8396,10 +8980,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8396
8980
|
case 2:
|
|
8397
8981
|
_state.sent();
|
|
8398
8982
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
8399
|
-
this.timing.
|
|
8983
|
+
this.timing.noteAdRequestSent();
|
|
8984
|
+
this.beginFunnelRequest(adPlayer, requestToken);
|
|
8400
8985
|
return [
|
|
8401
8986
|
4,
|
|
8402
|
-
|
|
8987
|
+
this.callController(function() {
|
|
8988
|
+
return adPlayer.requestAds(podUrl);
|
|
8989
|
+
})
|
|
8403
8990
|
];
|
|
8404
8991
|
case 3:
|
|
8405
8992
|
_state.sent();
|
|
@@ -8428,16 +9015,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8428
9015
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
8429
9016
|
return [
|
|
8430
9017
|
4,
|
|
8431
|
-
|
|
9018
|
+
this.callController(function() {
|
|
9019
|
+
return adPlayer.play();
|
|
9020
|
+
})
|
|
8432
9021
|
];
|
|
8433
9022
|
case 4:
|
|
8434
9023
|
_state.sent();
|
|
8435
|
-
this.timing.markAdStarted();
|
|
8436
9024
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
8437
9025
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
8438
9026
|
}
|
|
8439
|
-
adPlayer.setAdVolume(
|
|
8440
|
-
this.timing.consecutiveFailures = 0;
|
|
9027
|
+
adPlayer.setAdVolume(getAdAudioVolume(adPlayer));
|
|
8441
9028
|
this.continuousFetchingActive = true;
|
|
8442
9029
|
this.startContinuousFetching(baseVastUrl);
|
|
8443
9030
|
return [
|
|
@@ -8802,7 +9389,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8802
9389
|
];
|
|
8803
9390
|
case 3:
|
|
8804
9391
|
_state.sent();
|
|
8805
|
-
this.timing.consecutiveFailures = 0;
|
|
8806
9392
|
return [
|
|
8807
9393
|
3,
|
|
8808
9394
|
8
|
|
@@ -8815,6 +9401,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8815
9401
|
3,
|
|
8816
9402
|
6
|
|
8817
9403
|
];
|
|
9404
|
+
this.timing.consecutiveFailures++;
|
|
8818
9405
|
return [
|
|
8819
9406
|
4,
|
|
8820
9407
|
this.tryNextAvailableAdWithRateLimit()
|
|
@@ -8906,11 +9493,137 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8906
9493
|
}
|
|
8907
9494
|
}
|
|
8908
9495
|
},
|
|
9496
|
+
{
|
|
9497
|
+
key: "countFunnelStage",
|
|
9498
|
+
value: function countFunnelStage(stage) {
|
|
9499
|
+
var amount = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
|
|
9500
|
+
var _this_breakFunnel_stage;
|
|
9501
|
+
this.breakFunnel[stage] = ((_this_breakFunnel_stage = this.breakFunnel[stage]) !== null && _this_breakFunnel_stage !== void 0 ? _this_breakFunnel_stage : 0) + amount;
|
|
9502
|
+
}
|
|
9503
|
+
},
|
|
9504
|
+
{
|
|
9505
|
+
key: "logOrchestratorFunnel",
|
|
9506
|
+
value: function logOrchestratorFunnel(stage) {
|
|
9507
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
9508
|
+
this.countFunnelStage(stage);
|
|
9509
|
+
console.log("[AdBreak][FUNNEL] ".concat(stage), _object_spread({
|
|
9510
|
+
breakId: this.timing.adBreakEpoch,
|
|
9511
|
+
requestId: this.currentRequestId,
|
|
9512
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0
|
|
9513
|
+
}, extra));
|
|
9514
|
+
}
|
|
9515
|
+
},
|
|
9516
|
+
{
|
|
9517
|
+
key: "noteOpportunity",
|
|
9518
|
+
value: function noteOpportunity(source, breakKey) {
|
|
9519
|
+
if (breakKey && breakKey === this.opportunityBreakKey && this.opportunityEpoch === this.timing.adBreakEpoch) {
|
|
9520
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
9521
|
+
source: source,
|
|
9522
|
+
breakKey: breakKey
|
|
9523
|
+
});
|
|
9524
|
+
return;
|
|
9525
|
+
}
|
|
9526
|
+
this.opportunityBreakKey = breakKey;
|
|
9527
|
+
this.opportunityEpoch = this.timing.adBreakEpoch;
|
|
9528
|
+
this.logOrchestratorFunnel("opportunity_created", {
|
|
9529
|
+
source: source,
|
|
9530
|
+
breakKey: breakKey,
|
|
9531
|
+
expectedDurationMs: this.timing.expectedAdBreakDurationMs
|
|
9532
|
+
});
|
|
9533
|
+
}
|
|
9534
|
+
},
|
|
9535
|
+
{
|
|
9536
|
+
key: "beginFunnelRequest",
|
|
9537
|
+
value: function beginFunnelRequest(adPlayer, requestToken) {
|
|
9538
|
+
var _adPlayer_setFunnelContext;
|
|
9539
|
+
if (this.controllerCallInFlight) {
|
|
9540
|
+
this.logOrchestratorFunnel("duplicate_request_detected", {
|
|
9541
|
+
newRequestId: requestToken
|
|
9542
|
+
});
|
|
9543
|
+
}
|
|
9544
|
+
this.currentRequestId = requestToken;
|
|
9545
|
+
this.requestStartedAt = Date.now();
|
|
9546
|
+
(_adPlayer_setFunnelContext = adPlayer.setFunnelContext) === null || _adPlayer_setFunnelContext === void 0 ? void 0 : _adPlayer_setFunnelContext.call(adPlayer, {
|
|
9547
|
+
breakId: this.timing.adBreakEpoch,
|
|
9548
|
+
requestId: requestToken
|
|
9549
|
+
});
|
|
9550
|
+
}
|
|
9551
|
+
},
|
|
9552
|
+
{
|
|
9553
|
+
key: "isAdLoadingWithoutPlayback",
|
|
9554
|
+
value: function isAdLoadingWithoutPlayback() {
|
|
9555
|
+
return this.host.getAdPlayer().isAdPlaying() && !this.playbackStartedForCurrentRequest;
|
|
9556
|
+
}
|
|
9557
|
+
},
|
|
9558
|
+
{
|
|
9559
|
+
key: "noteStopBeforeStart",
|
|
9560
|
+
value: function noteStopBeforeStart(reason) {
|
|
9561
|
+
if (!this.isAdLoadingWithoutPlayback()) return;
|
|
9562
|
+
this.logOrchestratorFunnel("ad_stopped_before_start", {
|
|
9563
|
+
reason: reason,
|
|
9564
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
9565
|
+
});
|
|
9566
|
+
}
|
|
9567
|
+
},
|
|
9568
|
+
{
|
|
9569
|
+
key: "handleRequestWatchdogTimeout",
|
|
9570
|
+
value: function handleRequestWatchdogTimeout() {
|
|
9571
|
+
var adPlayer = this.host.getAdPlayer();
|
|
9572
|
+
if (this.controllerCallInFlight && adPlayer.abortPendingRequest) {
|
|
9573
|
+
this.logOrchestratorFunnel("request_aborted_timeout", {
|
|
9574
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
9575
|
+
});
|
|
9576
|
+
adPlayer.abortPendingRequest("VAST request aborted after request watchdog timeout");
|
|
9577
|
+
return;
|
|
9578
|
+
}
|
|
9579
|
+
this.handleAdFailure();
|
|
9580
|
+
}
|
|
9581
|
+
},
|
|
9582
|
+
{
|
|
9583
|
+
key: "callController",
|
|
9584
|
+
value: function callController(call) {
|
|
9585
|
+
return _async_to_generator(function() {
|
|
9586
|
+
return _ts_generator(this, function(_state) {
|
|
9587
|
+
switch(_state.label){
|
|
9588
|
+
case 0:
|
|
9589
|
+
this.controllerCallInFlight = true;
|
|
9590
|
+
_state.label = 1;
|
|
9591
|
+
case 1:
|
|
9592
|
+
_state.trys.push([
|
|
9593
|
+
1,
|
|
9594
|
+
,
|
|
9595
|
+
3,
|
|
9596
|
+
4
|
|
9597
|
+
]);
|
|
9598
|
+
return [
|
|
9599
|
+
4,
|
|
9600
|
+
call()
|
|
9601
|
+
];
|
|
9602
|
+
case 2:
|
|
9603
|
+
_state.sent();
|
|
9604
|
+
return [
|
|
9605
|
+
3,
|
|
9606
|
+
4
|
|
9607
|
+
];
|
|
9608
|
+
case 3:
|
|
9609
|
+
this.controllerCallInFlight = false;
|
|
9610
|
+
return [
|
|
9611
|
+
7
|
|
9612
|
+
];
|
|
9613
|
+
case 4:
|
|
9614
|
+
return [
|
|
9615
|
+
2
|
|
9616
|
+
];
|
|
9617
|
+
}
|
|
9618
|
+
});
|
|
9619
|
+
}).call(this);
|
|
9620
|
+
}
|
|
9621
|
+
},
|
|
8909
9622
|
{
|
|
8910
9623
|
key: "playSingleAd",
|
|
8911
9624
|
value: function playSingleAd(vastTagUrl) {
|
|
8912
9625
|
return _async_to_generator(function() {
|
|
8913
|
-
var adPlayer, requestToken, ap, requestUrl, playError, error, errorMessage;
|
|
9626
|
+
var adPlayer, requestToken, ap, requestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, playError, error, errorMessage;
|
|
8914
9627
|
return _ts_generator(this, function(_state) {
|
|
8915
9628
|
switch(_state.label){
|
|
8916
9629
|
case 0:
|
|
@@ -8952,13 +9665,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8952
9665
|
case 2:
|
|
8953
9666
|
_state.sent();
|
|
8954
9667
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
8955
|
-
this.timing.
|
|
9668
|
+
this.timing.noteAdRequestSent();
|
|
8956
9669
|
ap = this.host.getAdPlayer();
|
|
8957
9670
|
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
8958
9671
|
this.currentVastUrl = requestUrl;
|
|
9672
|
+
this.beginFunnelRequest(ap, requestToken);
|
|
8959
9673
|
return [
|
|
8960
9674
|
4,
|
|
8961
|
-
|
|
9675
|
+
this.callController(function() {
|
|
9676
|
+
return ap.requestAds(requestUrl);
|
|
9677
|
+
})
|
|
8962
9678
|
];
|
|
8963
9679
|
case 3:
|
|
8964
9680
|
_state.sent();
|
|
@@ -8972,6 +9688,14 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8972
9688
|
2
|
|
8973
9689
|
];
|
|
8974
9690
|
if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
|
|
9691
|
+
;
|
|
9692
|
+
adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
|
|
9693
|
+
remainingMs = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9694
|
+
this.logOrchestratorFunnel("discarded_budget", {
|
|
9695
|
+
vastUrl: requestUrl,
|
|
9696
|
+
adDurationMs: adDurationS != null ? adDurationS * 1e3 : void 0,
|
|
9697
|
+
remainingMs: remainingMs
|
|
9698
|
+
});
|
|
8975
9699
|
this.timing.rejectLoadedAdForDuration(ap);
|
|
8976
9700
|
this.recreateAdController();
|
|
8977
9701
|
throw new Error("ad_duration_exceeds_budget");
|
|
@@ -8987,16 +9711,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8987
9711
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
8988
9712
|
return [
|
|
8989
9713
|
4,
|
|
8990
|
-
|
|
9714
|
+
this.callController(function() {
|
|
9715
|
+
return ap.play();
|
|
9716
|
+
})
|
|
8991
9717
|
];
|
|
8992
9718
|
case 5:
|
|
8993
9719
|
_state.sent();
|
|
8994
|
-
this.timing.markAdStarted();
|
|
8995
9720
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
8996
9721
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
8997
9722
|
}
|
|
8998
9723
|
ap.setAdVolume(getAdAudioVolume(ap));
|
|
8999
|
-
this.timing.consecutiveFailures = 0;
|
|
9000
9724
|
this.timing.temporaryFailureUrls.delete(vastTagUrl);
|
|
9001
9725
|
return [
|
|
9002
9726
|
3,
|
|
@@ -9160,7 +9884,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9160
9884
|
];
|
|
9161
9885
|
case 5:
|
|
9162
9886
|
_state.sent();
|
|
9163
|
-
this.timing.consecutiveFailures = 0;
|
|
9164
9887
|
return [
|
|
9165
9888
|
3,
|
|
9166
9889
|
10
|
|
@@ -9172,6 +9895,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9172
9895
|
3,
|
|
9173
9896
|
8
|
|
9174
9897
|
];
|
|
9898
|
+
this.timing.consecutiveFailures++;
|
|
9175
9899
|
return [
|
|
9176
9900
|
4,
|
|
9177
9901
|
this.tryNextAvailableAdWithRateLimit()
|
|
@@ -9222,6 +9946,67 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9222
9946
|
// ───────────────────────────────────────────────────────────────
|
|
9223
9947
|
// Ad break completion
|
|
9224
9948
|
// ───────────────────────────────────────────────────────────────
|
|
9949
|
+
key: "logBreakFunnel",
|
|
9950
|
+
value: function logBreakFunnel() {
|
|
9951
|
+
var funnel = this.breakFunnel;
|
|
9952
|
+
this.breakFunnel = {};
|
|
9953
|
+
if (Object.keys(funnel).length === 0) return;
|
|
9954
|
+
var count = function count(stage) {
|
|
9955
|
+
var _funnel_stage;
|
|
9956
|
+
return (_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0;
|
|
9957
|
+
};
|
|
9958
|
+
var breakId = this.opportunityEpoch;
|
|
9959
|
+
if (count("request_sent") > 0 && count("impression_fired") === 0) {
|
|
9960
|
+
console.log("[AdBreak][FUNNEL] break_abandoned_before_start", {
|
|
9961
|
+
breakId: breakId,
|
|
9962
|
+
requests: count("request_sent")
|
|
9963
|
+
});
|
|
9964
|
+
}
|
|
9965
|
+
console.log("[AdBreak][FUNNEL] Break summary", {
|
|
9966
|
+
breakId: breakId,
|
|
9967
|
+
opportunities: count("opportunity_created"),
|
|
9968
|
+
requests: count("request_sent"),
|
|
9969
|
+
duplicates: count("duplicate_request_detected") + count("duplicate_break_start"),
|
|
9970
|
+
filled: count("vast_received"),
|
|
9971
|
+
noFill: count("no_fill"),
|
|
9972
|
+
requestFailed: count("request_failed"),
|
|
9973
|
+
requestAbortedTimeout: count("request_aborted_timeout"),
|
|
9974
|
+
credentialsRetries: count("vast_credentials_retry"),
|
|
9975
|
+
wrapperFailures: count("wrapper_fetch:failure"),
|
|
9976
|
+
noSupportedMedia: count("vast_no_supported_media"),
|
|
9977
|
+
vpaidOnly: count("vast_no_supported_media:vpaid_only"),
|
|
9978
|
+
missingImpression: count("vast_missing_impression"),
|
|
9979
|
+
discardedBudget: count("discarded_budget"),
|
|
9980
|
+
mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
|
|
9981
|
+
mediaRejected: count("media_candidate:rejected"),
|
|
9982
|
+
mediaFallbacks: count("media_fallback"),
|
|
9983
|
+
playCalled: count("play_called"),
|
|
9984
|
+
playRejected: count("play_rejected"),
|
|
9985
|
+
mutedRetry: count("muted_retry"),
|
|
9986
|
+
startTimeouts: count("play_resolved_but_never_started"),
|
|
9987
|
+
impressions: count("impression_fired"),
|
|
9988
|
+
impressionUrls: count("impression_urls"),
|
|
9989
|
+
trackingRequests: count("tracking_request_created"),
|
|
9990
|
+
trackingNotLoaded: count("tracking_request_settled:error") + count("tracking_request_settled:timeout"),
|
|
9991
|
+
trackingUnexpandedMacros: count("tracking_url_unexpanded_macro"),
|
|
9992
|
+
trackingInvalidUrls: count("tracking_url_invalid"),
|
|
9993
|
+
vastAdFallbacks: count("vast_ad_fallback"),
|
|
9994
|
+
mediaEvents: count("media_event"),
|
|
9995
|
+
quartile25: count("first_quartile"),
|
|
9996
|
+
quartile50: count("midpoint"),
|
|
9997
|
+
quartile75: count("third_quartile"),
|
|
9998
|
+
complete: count("complete"),
|
|
9999
|
+
stoppedBeforeStart: count("stopped_before_start"),
|
|
10000
|
+
stoppedBeforeStartByBreakEnd: count("ad_stopped_before_start"),
|
|
10001
|
+
unexpectedUnmutes: count("unexpected_unmute"),
|
|
10002
|
+
unmuteBlocked: count("unmute_blocked_without_gesture"),
|
|
10003
|
+
visibilityHidden: count("while_hidden"),
|
|
10004
|
+
playbackFailures: count("play_failed") + count("media_error") + count("hls_fatal") + count("stall") + count("decode_failure") + count("media_unsupported"),
|
|
10005
|
+
stages: funnel
|
|
10006
|
+
});
|
|
10007
|
+
}
|
|
10008
|
+
},
|
|
10009
|
+
{
|
|
9225
10010
|
key: "handleAdPodComplete",
|
|
9226
10011
|
value: function handleAdPodComplete() {
|
|
9227
10012
|
if (this.debug) {
|
|
@@ -9242,6 +10027,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9242
10027
|
this.adPodQueue = [];
|
|
9243
10028
|
this.showAds = false;
|
|
9244
10029
|
this.host.getAdPlayer().stop().catch(function() {});
|
|
10030
|
+
this.logBreakFunnel();
|
|
9245
10031
|
var restoredMuted = this.host.getAdPlayer().getOriginalMutedState();
|
|
9246
10032
|
var restoredVolume = this.host.getAdPlayer().getOriginalVolume();
|
|
9247
10033
|
if (this.host.video.muted !== restoredMuted) {
|
|
@@ -9593,7 +10379,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9593
10379
|
_this.startScte35AdBreak(marker, cueKey, marker.durationSeconds != null ? marker.durationSeconds * 1e3 : _this.timing.expectedAdBreakDurationMs);
|
|
9594
10380
|
},
|
|
9595
10381
|
onWatchdogTimeout: function onWatchdogTimeout() {
|
|
9596
|
-
return _this.adBreak.
|
|
10382
|
+
return _this.adBreak.handleRequestWatchdogTimeout();
|
|
9597
10383
|
},
|
|
9598
10384
|
onFailsafeTimeout: function onFailsafeTimeout() {
|
|
9599
10385
|
return _this.adBreak.handleAdFailure();
|
|
@@ -9698,6 +10484,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9698
10484
|
licenseKey: this.config.licenseKey
|
|
9699
10485
|
} : {}, ((_this_hlsEngine = this.hlsEngine) === null || _this_hlsEngine === void 0 ? void 0 : _this_hlsEngine.hls) ? {
|
|
9700
10486
|
mainHlsInstance: this.hlsEngine.hls
|
|
10487
|
+
} : {}, this.config.adMediaStartTimeoutMs != null ? {
|
|
10488
|
+
mediaStartTimeoutMs: this.config.adMediaStartTimeoutMs
|
|
9701
10489
|
} : {}));
|
|
9702
10490
|
}
|
|
9703
10491
|
},
|
|
@@ -10052,6 +10840,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10052
10840
|
this.timing.clearAdStartTimer();
|
|
10053
10841
|
this.timing.clearAdStopTimer();
|
|
10054
10842
|
if (adPlaying) {
|
|
10843
|
+
this.adBreak.noteStopBeforeStart("scte_end");
|
|
10055
10844
|
this.adPlayer.stop().catch(function() {});
|
|
10056
10845
|
}
|
|
10057
10846
|
this.adBreak.handleAdPodComplete();
|
|
@@ -10091,6 +10880,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10091
10880
|
console.log("[StormcloudVideoPlayer] Ad break boundary reached (overrun=".concat(overrunMs, "ms) - hard-stopping ads and resuming stream"));
|
|
10092
10881
|
}
|
|
10093
10882
|
if (adPlaying) {
|
|
10883
|
+
this.adBreak.noteStopBeforeStart("break_boundary");
|
|
10094
10884
|
this.adPlayer.stop().catch(function() {});
|
|
10095
10885
|
}
|
|
10096
10886
|
this.adBreak.handleAdPodComplete();
|
|
@@ -10219,6 +11009,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
10219
11009
|
this.adBreak.showAds = true;
|
|
10220
11010
|
this.adBreak.inAdBreak = true;
|
|
10221
11011
|
this.timing.currentAdBreakStartWallClockMs = Date.now();
|
|
11012
|
+
if (durationMs > 0) {
|
|
11013
|
+
this.timing.setAdBreakDurationBoundary(durationMs);
|
|
11014
|
+
}
|
|
11015
|
+
this.adBreak.noteOpportunity("vmap", key);
|
|
10222
11016
|
_state.label = 1;
|
|
10223
11017
|
case 1:
|
|
10224
11018
|
_state.trys.push([
|