stormcloud-video-player 0.3.20 → 0.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +95 -1050
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +0 -26
- package/lib/index.d.ts +0 -26
- package/lib/index.js +95 -1050
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +95 -1062
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -25
- package/lib/players/HlsPlayer.cjs +95 -1050
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +95 -1050
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +0 -45
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/sdk/ima.cjs +3 -78
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/sdk/ima.d.cts +1 -1
- package/lib/{types-CryTJVCC.d.cts → types-Bpq0mkLY.d.cts} +0 -2
- package/lib/ui/StormcloudVideoPlayer.cjs +95 -1062
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/package.json +1 -1
|
@@ -7,9 +7,6 @@ function _array_like_to_array(arr, len) {
|
|
|
7
7
|
function _array_with_holes(arr) {
|
|
8
8
|
if (Array.isArray(arr)) return arr;
|
|
9
9
|
}
|
|
10
|
-
function _array_without_holes(arr) {
|
|
11
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
12
|
-
}
|
|
13
10
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
14
11
|
try {
|
|
15
12
|
var info = gen[key](arg);
|
|
@@ -78,9 +75,6 @@ function _instanceof(left, right) {
|
|
|
78
75
|
return left instanceof right;
|
|
79
76
|
}
|
|
80
77
|
}
|
|
81
|
-
function _iterable_to_array(iter) {
|
|
82
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
83
|
-
}
|
|
84
78
|
function _iterable_to_array_limit(arr, i) {
|
|
85
79
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
86
80
|
if (_i == null) return;
|
|
@@ -108,9 +102,6 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
108
102
|
function _non_iterable_rest() {
|
|
109
103
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
110
104
|
}
|
|
111
|
-
function _non_iterable_spread() {
|
|
112
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
113
|
-
}
|
|
114
105
|
function _object_spread(target) {
|
|
115
106
|
for(var i = 1; i < arguments.length; i++){
|
|
116
107
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -153,9 +144,6 @@ function _object_spread_props(target, source) {
|
|
|
153
144
|
function _sliced_to_array(arr, i) {
|
|
154
145
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
155
146
|
}
|
|
156
|
-
function _to_consumable_array(arr) {
|
|
157
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
158
|
-
}
|
|
159
147
|
function _type_of(obj) {
|
|
160
148
|
"@swc/helpers - typeof";
|
|
161
149
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
@@ -259,20 +247,6 @@ function _ts_generator(thisArg, body) {
|
|
|
259
247
|
};
|
|
260
248
|
}
|
|
261
249
|
}
|
|
262
|
-
function _ts_values(o) {
|
|
263
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
264
|
-
if (m) return m.call(o);
|
|
265
|
-
if (o && typeof o.length === "number") return {
|
|
266
|
-
next: function() {
|
|
267
|
-
if (o && i >= o.length) o = void 0;
|
|
268
|
-
return {
|
|
269
|
-
value: o && o[i++],
|
|
270
|
-
done: !o
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
275
|
-
}
|
|
276
250
|
var __create = Object.create;
|
|
277
251
|
var __defProp = Object.defineProperty;
|
|
278
252
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -507,8 +481,6 @@ function createImaController(video, options) {
|
|
|
507
481
|
var originalMutedState = false;
|
|
508
482
|
var originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
509
483
|
var listeners = /* @__PURE__ */ new Map();
|
|
510
|
-
var preloadedVast = /* @__PURE__ */ new Map();
|
|
511
|
-
var preloadingVast = /* @__PURE__ */ new Map();
|
|
512
484
|
var adVideoElement;
|
|
513
485
|
function setAdPlayingFlag(isPlaying) {
|
|
514
486
|
if (isPlaying) {
|
|
@@ -658,10 +630,10 @@ function createImaController(video, options) {
|
|
|
658
630
|
var adsLoadedReject;
|
|
659
631
|
function makeAdsRequest(google, vastTagUrl) {
|
|
660
632
|
var adsRequest = new google.ima.AdsRequest();
|
|
661
|
-
console.log("[IMA] \uD83D\uDCE1 Requesting VAST
|
|
633
|
+
console.log("[IMA] \uD83D\uDCE1 Requesting VAST via IMA SDK:", vastTagUrl.substring(0, 80) + "...");
|
|
662
634
|
adsRequest.adTagUrl = vastTagUrl;
|
|
663
635
|
var videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
664
|
-
var videoHeight = video.offsetHeight || video.clientHeight ||
|
|
636
|
+
var videoHeight = video.offsetHeight || video.clientHeight || 480;
|
|
665
637
|
adsRequest.linearAdSlotWidth = videoWidth;
|
|
666
638
|
adsRequest.linearAdSlotHeight = videoHeight;
|
|
667
639
|
adsRequest.nonLinearAdSlotWidth = videoWidth;
|
|
@@ -707,36 +679,6 @@ function createImaController(video, options) {
|
|
|
707
679
|
(_video_parentElement = video.parentElement) === null || _video_parentElement === void 0 ? void 0 : _video_parentElement.appendChild(container);
|
|
708
680
|
adContainerEl = container;
|
|
709
681
|
}
|
|
710
|
-
function fetchVastDocument(vastTagUrl) {
|
|
711
|
-
return _async_to_generator(function() {
|
|
712
|
-
var response;
|
|
713
|
-
return _ts_generator(this, function(_state) {
|
|
714
|
-
switch(_state.label){
|
|
715
|
-
case 0:
|
|
716
|
-
return [
|
|
717
|
-
4,
|
|
718
|
-
fetch(vastTagUrl, {
|
|
719
|
-
mode: "cors",
|
|
720
|
-
credentials: "include",
|
|
721
|
-
headers: {
|
|
722
|
-
"Accept": "application/xml, text/xml, */*"
|
|
723
|
-
},
|
|
724
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
725
|
-
})
|
|
726
|
-
];
|
|
727
|
-
case 1:
|
|
728
|
-
response = _state.sent();
|
|
729
|
-
if (!response.ok) {
|
|
730
|
-
throw new Error("Failed to preload VAST: ".concat(response.status));
|
|
731
|
-
}
|
|
732
|
-
return [
|
|
733
|
-
2,
|
|
734
|
-
response.text()
|
|
735
|
-
];
|
|
736
|
-
}
|
|
737
|
-
});
|
|
738
|
-
})();
|
|
739
|
-
}
|
|
740
682
|
function destroyAdsManager() {
|
|
741
683
|
if (adsManager) {
|
|
742
684
|
try {
|
|
@@ -1051,47 +993,6 @@ function createImaController(video, options) {
|
|
|
1051
993
|
});
|
|
1052
994
|
})();
|
|
1053
995
|
},
|
|
1054
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1055
|
-
return _async_to_generator(function() {
|
|
1056
|
-
var inflight, preloadPromise;
|
|
1057
|
-
return _ts_generator(this, function(_state) {
|
|
1058
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1059
|
-
return [
|
|
1060
|
-
2,
|
|
1061
|
-
Promise.resolve()
|
|
1062
|
-
];
|
|
1063
|
-
}
|
|
1064
|
-
if (preloadedVast.has(vastTagUrl)) {
|
|
1065
|
-
return [
|
|
1066
|
-
2,
|
|
1067
|
-
Promise.resolve()
|
|
1068
|
-
];
|
|
1069
|
-
}
|
|
1070
|
-
inflight = preloadingVast.get(vastTagUrl);
|
|
1071
|
-
if (inflight) {
|
|
1072
|
-
return [
|
|
1073
|
-
2,
|
|
1074
|
-
inflight
|
|
1075
|
-
];
|
|
1076
|
-
}
|
|
1077
|
-
preloadPromise = fetchVastDocument(vastTagUrl).then(function(xml) {
|
|
1078
|
-
preloadedVast.set(vastTagUrl, xml);
|
|
1079
|
-
}).catch(function() {
|
|
1080
|
-
preloadedVast.delete(vastTagUrl);
|
|
1081
|
-
}).finally(function() {
|
|
1082
|
-
preloadingVast.delete(vastTagUrl);
|
|
1083
|
-
});
|
|
1084
|
-
preloadingVast.set(vastTagUrl, preloadPromise);
|
|
1085
|
-
return [
|
|
1086
|
-
2,
|
|
1087
|
-
preloadPromise
|
|
1088
|
-
];
|
|
1089
|
-
});
|
|
1090
|
-
})();
|
|
1091
|
-
},
|
|
1092
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1093
|
-
return preloadedVast.has(vastTagUrl);
|
|
1094
|
-
},
|
|
1095
996
|
play: function play() {
|
|
1096
997
|
return _async_to_generator(function() {
|
|
1097
998
|
var _window_google, width, height, adVolume, _video_play;
|
|
@@ -1110,7 +1011,7 @@ function createImaController(video, options) {
|
|
|
1110
1011
|
}
|
|
1111
1012
|
try {
|
|
1112
1013
|
width = video.clientWidth || 640;
|
|
1113
|
-
height = video.clientHeight ||
|
|
1014
|
+
height = video.clientHeight || 480;
|
|
1114
1015
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
1115
1016
|
adPlaying = true;
|
|
1116
1017
|
adVolume = originalMutedState ? 0 : originalVolume;
|
|
@@ -1200,8 +1101,6 @@ function createImaController(video, options) {
|
|
|
1200
1101
|
adDisplayContainer = void 0;
|
|
1201
1102
|
adsLoader = void 0;
|
|
1202
1103
|
contentVideoHidden = false;
|
|
1203
|
-
preloadedVast.clear();
|
|
1204
|
-
preloadingVast.clear();
|
|
1205
1104
|
},
|
|
1206
1105
|
isAdPlaying: function isAdPlaying() {
|
|
1207
1106
|
return adPlaying;
|
|
@@ -1802,51 +1701,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1802
1701
|
});
|
|
1803
1702
|
})();
|
|
1804
1703
|
},
|
|
1805
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1806
|
-
return _async_to_generator(function() {
|
|
1807
|
-
var inflight, preloadPromise;
|
|
1808
|
-
return _ts_generator(this, function(_state) {
|
|
1809
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1810
|
-
return [
|
|
1811
|
-
2,
|
|
1812
|
-
Promise.resolve()
|
|
1813
|
-
];
|
|
1814
|
-
}
|
|
1815
|
-
if (preloadedAds.has(vastTagUrl)) {
|
|
1816
|
-
return [
|
|
1817
|
-
2,
|
|
1818
|
-
Promise.resolve()
|
|
1819
|
-
];
|
|
1820
|
-
}
|
|
1821
|
-
inflight = preloadingAds.get(vastTagUrl);
|
|
1822
|
-
if (inflight) {
|
|
1823
|
-
return [
|
|
1824
|
-
2,
|
|
1825
|
-
inflight
|
|
1826
|
-
];
|
|
1827
|
-
}
|
|
1828
|
-
preloadPromise = fetchAndParseVastAd(vastTagUrl).then(function(ad) {
|
|
1829
|
-
if (ad) {
|
|
1830
|
-
preloadedAds.set(vastTagUrl, ad);
|
|
1831
|
-
console.log("[HlsAdPlayer] Cached VAST response for preloading:", vastTagUrl);
|
|
1832
|
-
}
|
|
1833
|
-
}).catch(function(error) {
|
|
1834
|
-
console.warn("[HlsAdPlayer] Failed to preload VAST response:", error);
|
|
1835
|
-
preloadedAds.delete(vastTagUrl);
|
|
1836
|
-
}).finally(function() {
|
|
1837
|
-
preloadingAds.delete(vastTagUrl);
|
|
1838
|
-
});
|
|
1839
|
-
preloadingAds.set(vastTagUrl, preloadPromise);
|
|
1840
|
-
return [
|
|
1841
|
-
2,
|
|
1842
|
-
preloadPromise
|
|
1843
|
-
];
|
|
1844
|
-
});
|
|
1845
|
-
})();
|
|
1846
|
-
},
|
|
1847
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1848
|
-
return preloadedAds.has(vastTagUrl);
|
|
1849
|
-
},
|
|
1850
1704
|
play: function play() {
|
|
1851
1705
|
return _async_to_generator(function() {
|
|
1852
1706
|
var contentVolume, adVolume, mediaFile;
|
|
@@ -2738,32 +2592,17 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2738
2592
|
this.bufferedSegmentsCount = 0;
|
|
2739
2593
|
this.shouldAutoplayAfterBuffering = false;
|
|
2740
2594
|
this.hasInitialBufferCompleted = false;
|
|
2741
|
-
this.adPodAllUrls = [];
|
|
2742
|
-
this.preloadingAdUrls = /* @__PURE__ */ new Set();
|
|
2743
|
-
this.vastToMediaUrlMap = /* @__PURE__ */ new Map();
|
|
2744
|
-
this.preloadedMediaUrls = /* @__PURE__ */ new Set();
|
|
2745
|
-
this.preloadingMediaUrls = /* @__PURE__ */ new Set();
|
|
2746
2595
|
this.adRequestTokenCounter = 0;
|
|
2747
2596
|
this.activeAdRequestToken = null;
|
|
2748
2597
|
this.adRequestWatchdogToken = null;
|
|
2749
2598
|
this.adFailsafeToken = null;
|
|
2750
|
-
this.fetchedAdDurations = /* @__PURE__ */ new Map();
|
|
2751
|
-
this.targetAdBreakDurationMs = null;
|
|
2752
|
-
this.isAdaptiveMode = false;
|
|
2753
2599
|
this.failedVastUrls = /* @__PURE__ */ new Set();
|
|
2754
2600
|
this.continuousFetchingActive = false;
|
|
2755
2601
|
this.adRequestQueue = [];
|
|
2756
|
-
this.successfulAdRequests = [];
|
|
2757
2602
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2758
|
-
this.placeholderStartTimeMs = null;
|
|
2759
2603
|
this.isShowingPlaceholder = false;
|
|
2760
|
-
this.consecutiveEmptyResponses = 0;
|
|
2761
2604
|
this.totalAdRequestsInBreak = 0;
|
|
2762
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
2763
2605
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2764
|
-
this.maxConsecutiveEmptyResponses = 5;
|
|
2765
|
-
this.baseEmptyResponseDelayMs = 2e3;
|
|
2766
|
-
this.maxEmptyResponseDelayMs = 3e4;
|
|
2767
2606
|
initializePolyfills();
|
|
2768
2607
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2769
2608
|
this.config = _object_spread({}, config, browserOverrides);
|
|
@@ -3254,25 +3093,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3254
3093
|
}
|
|
3255
3094
|
});
|
|
3256
3095
|
this.ima.on("ad_error", function(errorPayload) {
|
|
3257
|
-
var remaining = _this.getRemainingAdMs();
|
|
3258
3096
|
console.error("[AD-ERROR] Ad playback failed", errorPayload || "");
|
|
3259
|
-
|
|
3260
|
-
if (remaining > 500 && _this.adPodQueue.length > 0) {
|
|
3261
|
-
var nextPreloaded = _this.findNextPreloadedAd();
|
|
3262
|
-
if (nextPreloaded) {
|
|
3263
|
-
_this.currentAdIndex++;
|
|
3264
|
-
_this.playSingleAd(nextPreloaded).catch(function() {
|
|
3265
|
-
_this.handleAdFailure();
|
|
3266
|
-
});
|
|
3267
|
-
} else {
|
|
3268
|
-
_this.handleAdFailure();
|
|
3269
|
-
}
|
|
3270
|
-
} else {
|
|
3271
|
-
_this.handleAdFailure();
|
|
3272
|
-
}
|
|
3273
|
-
} else {
|
|
3274
|
-
_this.handleAdFailure();
|
|
3275
|
-
}
|
|
3097
|
+
_this.handleAdFailure();
|
|
3276
3098
|
});
|
|
3277
3099
|
this.ima.on("content_pause", function() {
|
|
3278
3100
|
_this.clearAdFailsafeTimer();
|
|
@@ -4003,7 +3825,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4003
3825
|
key: "handleAdStart",
|
|
4004
3826
|
value: function handleAdStart(_marker) {
|
|
4005
3827
|
return _async_to_generator(function() {
|
|
4006
|
-
var scheduled, tags, baseVastUrl, adBreakDurationMs, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
3828
|
+
var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
4007
3829
|
return _ts_generator(this, function(_state) {
|
|
4008
3830
|
switch(_state.label){
|
|
4009
3831
|
case 0:
|
|
@@ -4019,35 +3841,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4019
3841
|
];
|
|
4020
3842
|
}
|
|
4021
3843
|
adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
|
|
4022
|
-
if (this.
|
|
4023
|
-
this.
|
|
4024
|
-
|
|
4025
|
-
this.fetchedAdDurations.clear();
|
|
4026
|
-
if (this.config.debugAdTiming) {
|
|
4027
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA LIVE MODE: Target duration=".concat(adBreakDurationMs, "ms | Will continuously fetch ads during break"));
|
|
4028
|
-
}
|
|
4029
|
-
} else {
|
|
4030
|
-
this.isAdaptiveMode = false;
|
|
4031
|
-
this.targetAdBreakDurationMs = null;
|
|
4032
|
-
this.fetchedAdDurations.clear();
|
|
4033
|
-
if (this.config.debugAdTiming) {
|
|
4034
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC VOD MODE: Using fixed ad strategy");
|
|
4035
|
-
}
|
|
3844
|
+
if (this.config.debugAdTiming) {
|
|
3845
|
+
mode = this.isLiveStream ? "LIVE" : "VOD";
|
|
3846
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
4036
3847
|
}
|
|
4037
|
-
this.adPodAllUrls = [];
|
|
4038
|
-
this.preloadingAdUrls.clear();
|
|
4039
|
-
this.vastToMediaUrlMap.clear();
|
|
4040
|
-
this.preloadedMediaUrls.clear();
|
|
4041
|
-
this.preloadingMediaUrls.clear();
|
|
4042
3848
|
this.failedVastUrls.clear();
|
|
4043
3849
|
this.adRequestQueue = [];
|
|
4044
|
-
this.successfulAdRequests = [];
|
|
4045
3850
|
this.continuousFetchingActive = true;
|
|
4046
3851
|
this.isShowingPlaceholder = false;
|
|
4047
|
-
this.placeholderStartTimeMs = null;
|
|
4048
|
-
this.consecutiveEmptyResponses = 0;
|
|
4049
3852
|
this.totalAdRequestsInBreak = 0;
|
|
4050
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
4051
3853
|
currentMuted = this.video.muted;
|
|
4052
3854
|
currentVolume = this.video.volume;
|
|
4053
3855
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
@@ -4093,7 +3895,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4093
3895
|
if (this.config.debugAdTiming) {
|
|
4094
3896
|
console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
|
|
4095
3897
|
}
|
|
4096
|
-
this.successfulAdRequests.push(firstAdUrl);
|
|
4097
3898
|
this.currentAdIndex++;
|
|
4098
3899
|
this.startContinuousFetching(baseVastUrl);
|
|
4099
3900
|
return [
|
|
@@ -4143,200 +3944,92 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4143
3944
|
key: "continuousFetchLoop",
|
|
4144
3945
|
value: function continuousFetchLoop(baseVastUrl) {
|
|
4145
3946
|
return _async_to_generator(function() {
|
|
4146
|
-
var
|
|
3947
|
+
var remaining, maxQueueSize, newAdUrl;
|
|
4147
3948
|
return _ts_generator(this, function(_state) {
|
|
4148
3949
|
switch(_state.label){
|
|
4149
3950
|
case 0:
|
|
4150
|
-
_loop = function() {
|
|
4151
|
-
var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
|
|
4152
|
-
return _ts_generator(this, function(_state) {
|
|
4153
|
-
switch(_state.label){
|
|
4154
|
-
case 0:
|
|
4155
|
-
remaining = _this.getRemainingAdMs();
|
|
4156
|
-
if (remaining <= 0) {
|
|
4157
|
-
if (_this.config.debugAdTiming) {
|
|
4158
|
-
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
|
|
4159
|
-
}
|
|
4160
|
-
return [
|
|
4161
|
-
2,
|
|
4162
|
-
"break"
|
|
4163
|
-
];
|
|
4164
|
-
}
|
|
4165
|
-
if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
|
|
4166
|
-
if (_this.config.debugAdTiming) {
|
|
4167
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
|
|
4168
|
-
}
|
|
4169
|
-
return [
|
|
4170
|
-
2,
|
|
4171
|
-
"break"
|
|
4172
|
-
];
|
|
4173
|
-
}
|
|
4174
|
-
if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
|
|
4175
|
-
if (_this.config.debugAdTiming) {
|
|
4176
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
|
|
4177
|
-
}
|
|
4178
|
-
return [
|
|
4179
|
-
2,
|
|
4180
|
-
"break"
|
|
4181
|
-
];
|
|
4182
|
-
}
|
|
4183
|
-
maxQueueSize = 3;
|
|
4184
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4185
|
-
3,
|
|
4186
|
-
2
|
|
4187
|
-
];
|
|
4188
|
-
if (_this.config.debugAdTiming) {
|
|
4189
|
-
console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
|
|
4190
|
-
}
|
|
4191
|
-
return [
|
|
4192
|
-
4,
|
|
4193
|
-
new Promise(function(resolve) {
|
|
4194
|
-
return setTimeout(resolve, 2e3);
|
|
4195
|
-
})
|
|
4196
|
-
];
|
|
4197
|
-
case 1:
|
|
4198
|
-
_state.sent();
|
|
4199
|
-
return [
|
|
4200
|
-
2,
|
|
4201
|
-
"continue"
|
|
4202
|
-
];
|
|
4203
|
-
case 2:
|
|
4204
|
-
newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4205
|
-
if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
|
|
4206
|
-
3,
|
|
4207
|
-
4
|
|
4208
|
-
];
|
|
4209
|
-
return [
|
|
4210
|
-
4,
|
|
4211
|
-
new Promise(function(resolve) {
|
|
4212
|
-
return setTimeout(resolve, 1e3);
|
|
4213
|
-
})
|
|
4214
|
-
];
|
|
4215
|
-
case 3:
|
|
4216
|
-
_state.sent();
|
|
4217
|
-
return [
|
|
4218
|
-
2,
|
|
4219
|
-
"continue"
|
|
4220
|
-
];
|
|
4221
|
-
case 4:
|
|
4222
|
-
_this.totalAdRequestsInBreak++;
|
|
4223
|
-
if (_this.config.debugAdTiming) {
|
|
4224
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
|
|
4225
|
-
}
|
|
4226
|
-
_state.label = 5;
|
|
4227
|
-
case 5:
|
|
4228
|
-
_state.trys.push([
|
|
4229
|
-
5,
|
|
4230
|
-
11,
|
|
4231
|
-
,
|
|
4232
|
-
13
|
|
4233
|
-
]);
|
|
4234
|
-
if (!_this.ima.preloadAds) return [
|
|
4235
|
-
3,
|
|
4236
|
-
7
|
|
4237
|
-
];
|
|
4238
|
-
return [
|
|
4239
|
-
4,
|
|
4240
|
-
_this.ima.preloadAds(newAdUrl)
|
|
4241
|
-
];
|
|
4242
|
-
case 6:
|
|
4243
|
-
_state.sent();
|
|
4244
|
-
_state.label = 7;
|
|
4245
|
-
case 7:
|
|
4246
|
-
hasPreloadedAd = (_this_ima_hasPreloadedAd1 = (_this_ima_hasPreloadedAd = (_this_ima = _this.ima).hasPreloadedAd) === null || _this_ima_hasPreloadedAd === void 0 ? void 0 : _this_ima_hasPreloadedAd.call(_this_ima, newAdUrl)) !== null && _this_ima_hasPreloadedAd1 !== void 0 ? _this_ima_hasPreloadedAd1 : false;
|
|
4247
|
-
if (!!hasPreloadedAd) return [
|
|
4248
|
-
3,
|
|
4249
|
-
9
|
|
4250
|
-
];
|
|
4251
|
-
_this.consecutiveEmptyResponses++;
|
|
4252
|
-
_this.lastEmptyResponseTimeMs = Date.now();
|
|
4253
|
-
backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4254
|
-
if (_this.config.debugAdTiming) {
|
|
4255
|
-
console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
|
|
4256
|
-
}
|
|
4257
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4258
|
-
return [
|
|
4259
|
-
4,
|
|
4260
|
-
new Promise(function(resolve) {
|
|
4261
|
-
return setTimeout(resolve, backoffDelay);
|
|
4262
|
-
})
|
|
4263
|
-
];
|
|
4264
|
-
case 8:
|
|
4265
|
-
_state.sent();
|
|
4266
|
-
return [
|
|
4267
|
-
2,
|
|
4268
|
-
"continue"
|
|
4269
|
-
];
|
|
4270
|
-
case 9:
|
|
4271
|
-
_this.consecutiveEmptyResponses = 0;
|
|
4272
|
-
if (_this.config.debugAdTiming) {
|
|
4273
|
-
console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
|
|
4274
|
-
}
|
|
4275
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
4276
|
-
_this.totalAdsInBreak++;
|
|
4277
|
-
return [
|
|
4278
|
-
4,
|
|
4279
|
-
new Promise(function(resolve) {
|
|
4280
|
-
return setTimeout(resolve, 500);
|
|
4281
|
-
})
|
|
4282
|
-
];
|
|
4283
|
-
case 10:
|
|
4284
|
-
_state.sent();
|
|
4285
|
-
return [
|
|
4286
|
-
3,
|
|
4287
|
-
13
|
|
4288
|
-
];
|
|
4289
|
-
case 11:
|
|
4290
|
-
error = _state.sent();
|
|
4291
|
-
if (_this.config.debugAdTiming) {
|
|
4292
|
-
console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
|
|
4293
|
-
}
|
|
4294
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4295
|
-
_this.consecutiveEmptyResponses++;
|
|
4296
|
-
backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4297
|
-
return [
|
|
4298
|
-
4,
|
|
4299
|
-
new Promise(function(resolve) {
|
|
4300
|
-
return setTimeout(resolve, backoffDelay1);
|
|
4301
|
-
})
|
|
4302
|
-
];
|
|
4303
|
-
case 12:
|
|
4304
|
-
_state.sent();
|
|
4305
|
-
return [
|
|
4306
|
-
3,
|
|
4307
|
-
13
|
|
4308
|
-
];
|
|
4309
|
-
case 13:
|
|
4310
|
-
return [
|
|
4311
|
-
2
|
|
4312
|
-
];
|
|
4313
|
-
}
|
|
4314
|
-
});
|
|
4315
|
-
};
|
|
4316
|
-
_state.label = 1;
|
|
4317
|
-
case 1:
|
|
4318
3951
|
if (!(this.continuousFetchingActive && this.inAdBreak)) return [
|
|
4319
3952
|
3,
|
|
4320
|
-
|
|
3953
|
+
6
|
|
4321
3954
|
];
|
|
4322
|
-
|
|
3955
|
+
remaining = this.getRemainingAdMs();
|
|
3956
|
+
if (remaining <= 0) {
|
|
3957
|
+
if (this.config.debugAdTiming) {
|
|
3958
|
+
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping URL generation");
|
|
3959
|
+
}
|
|
3960
|
+
return [
|
|
3961
|
+
3,
|
|
3962
|
+
6
|
|
3963
|
+
];
|
|
3964
|
+
}
|
|
3965
|
+
if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
|
|
3966
|
+
if (this.config.debugAdTiming) {
|
|
3967
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(this.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
3968
|
+
}
|
|
3969
|
+
return [
|
|
3970
|
+
3,
|
|
3971
|
+
6
|
|
3972
|
+
];
|
|
3973
|
+
}
|
|
3974
|
+
maxQueueSize = 5;
|
|
3975
|
+
if (!(this.adRequestQueue.length >= maxQueueSize)) return [
|
|
3976
|
+
3,
|
|
3977
|
+
2
|
|
3978
|
+
];
|
|
3979
|
+
if (this.config.debugAdTiming) {
|
|
3980
|
+
console.log("[CONTINUOUS-FETCH] ⏸️ URL queue full (".concat(this.adRequestQueue.length, "), waiting..."));
|
|
3981
|
+
}
|
|
4323
3982
|
return [
|
|
4324
|
-
|
|
4325
|
-
|
|
3983
|
+
4,
|
|
3984
|
+
new Promise(function(resolve) {
|
|
3985
|
+
return setTimeout(resolve, 1e3);
|
|
3986
|
+
})
|
|
3987
|
+
];
|
|
3988
|
+
case 1:
|
|
3989
|
+
_state.sent();
|
|
3990
|
+
return [
|
|
3991
|
+
3,
|
|
3992
|
+
0
|
|
4326
3993
|
];
|
|
4327
3994
|
case 2:
|
|
4328
|
-
|
|
4329
|
-
if (
|
|
3995
|
+
newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
3996
|
+
if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
|
|
4330
3997
|
3,
|
|
4331
|
-
|
|
3998
|
+
4
|
|
4332
3999
|
];
|
|
4333
4000
|
return [
|
|
4334
|
-
|
|
4335
|
-
|
|
4001
|
+
4,
|
|
4002
|
+
new Promise(function(resolve) {
|
|
4003
|
+
return setTimeout(resolve, 500);
|
|
4004
|
+
})
|
|
4336
4005
|
];
|
|
4337
4006
|
case 3:
|
|
4007
|
+
_state.sent();
|
|
4008
|
+
return [
|
|
4009
|
+
3,
|
|
4010
|
+
0
|
|
4011
|
+
];
|
|
4012
|
+
case 4:
|
|
4013
|
+
if (this.config.debugAdTiming) {
|
|
4014
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCDD Queued VAST URL (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
|
|
4015
|
+
}
|
|
4016
|
+
this.adRequestQueue.push(newAdUrl);
|
|
4017
|
+
this.totalAdsInBreak++;
|
|
4018
|
+
return [
|
|
4019
|
+
4,
|
|
4020
|
+
new Promise(function(resolve) {
|
|
4021
|
+
return setTimeout(resolve, 300);
|
|
4022
|
+
})
|
|
4023
|
+
];
|
|
4024
|
+
case 5:
|
|
4025
|
+
_state.sent();
|
|
4026
|
+
return [
|
|
4027
|
+
3,
|
|
4028
|
+
0
|
|
4029
|
+
];
|
|
4030
|
+
case 6:
|
|
4338
4031
|
if (this.config.debugAdTiming) {
|
|
4339
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1
|
|
4032
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"));
|
|
4340
4033
|
}
|
|
4341
4034
|
return [
|
|
4342
4035
|
2
|
|
@@ -4385,19 +4078,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4385
4078
|
2
|
|
4386
4079
|
];
|
|
4387
4080
|
if (this.config.debugAdTiming) {
|
|
4388
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC
|
|
4081
|
+
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC Requesting next ad via IMA SDK (".concat(this.currentAdIndex + 1, "/").concat(this.totalAdsInBreak, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
|
|
4389
4082
|
}
|
|
4390
4083
|
currentMuted = this.video.muted;
|
|
4391
4084
|
currentVolume = this.video.volume;
|
|
4392
4085
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
4393
|
-
if (this.config.debugAdTiming) {
|
|
4394
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDD0A Updated ad audio state: muted=".concat(currentMuted, ", volume=").concat(currentVolume));
|
|
4395
|
-
}
|
|
4396
4086
|
this.currentAdIndex++;
|
|
4397
|
-
this.
|
|
4087
|
+
this.totalAdRequestsInBreak++;
|
|
4398
4088
|
return [
|
|
4399
4089
|
4,
|
|
4400
|
-
this.playSingleAd(nextAdUrl).catch(function() {
|
|
4090
|
+
this.playSingleAd(nextAdUrl).catch(function(error) {
|
|
4091
|
+
if (_this.config.debugAdTiming) {
|
|
4092
|
+
console.log("[CONTINUOUS-FETCH] \u274C Ad request failed:", error.message);
|
|
4093
|
+
}
|
|
4094
|
+
_this.failedVastUrls.add(nextAdUrl);
|
|
4401
4095
|
_this.tryNextAvailableAd(0);
|
|
4402
4096
|
})
|
|
4403
4097
|
];
|
|
@@ -4407,18 +4101,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4407
4101
|
2
|
|
4408
4102
|
];
|
|
4409
4103
|
case 2:
|
|
4410
|
-
maxRetries =
|
|
4104
|
+
maxRetries = 3;
|
|
4411
4105
|
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
4412
4106
|
3,
|
|
4413
4107
|
5
|
|
4414
4108
|
];
|
|
4415
4109
|
if (this.config.debugAdTiming) {
|
|
4416
|
-
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty
|
|
4110
|
+
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
4417
4111
|
}
|
|
4418
4112
|
return [
|
|
4419
4113
|
4,
|
|
4420
4114
|
new Promise(function(resolve) {
|
|
4421
|
-
return setTimeout(resolve,
|
|
4115
|
+
return setTimeout(resolve, 500);
|
|
4422
4116
|
})
|
|
4423
4117
|
];
|
|
4424
4118
|
case 3:
|
|
@@ -4467,12 +4161,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4467
4161
|
];
|
|
4468
4162
|
}
|
|
4469
4163
|
if (this.config.debugAdTiming) {
|
|
4470
|
-
console.log("[CONTINUOUS-FETCH] ⬛ Showing
|
|
4164
|
+
console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad URLs"));
|
|
4471
4165
|
}
|
|
4472
4166
|
this.isShowingPlaceholder = true;
|
|
4473
|
-
this.placeholderStartTimeMs = Date.now();
|
|
4474
4167
|
this.ima.showPlaceholder();
|
|
4475
|
-
checkInterval =
|
|
4168
|
+
checkInterval = 300;
|
|
4476
4169
|
maxChecks = Math.floor(waitTime / checkInterval);
|
|
4477
4170
|
i = 0;
|
|
4478
4171
|
_state.label = 1;
|
|
@@ -4499,10 +4192,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4499
4192
|
5
|
|
4500
4193
|
];
|
|
4501
4194
|
if (this.config.debugAdTiming) {
|
|
4502
|
-
console.log("[CONTINUOUS-FETCH] \u2705
|
|
4195
|
+
console.log("[CONTINUOUS-FETCH] \u2705 Ad URL available, requesting via IMA SDK");
|
|
4503
4196
|
}
|
|
4504
4197
|
this.isShowingPlaceholder = false;
|
|
4505
|
-
this.placeholderStartTimeMs = null;
|
|
4506
4198
|
this.ima.hidePlaceholder();
|
|
4507
4199
|
currentMuted = this.video.muted;
|
|
4508
4200
|
currentVolume = this.video.volume;
|
|
@@ -4513,7 +4205,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4513
4205
|
4
|
|
4514
4206
|
];
|
|
4515
4207
|
this.currentAdIndex++;
|
|
4516
|
-
this.
|
|
4208
|
+
this.totalAdRequestsInBreak++;
|
|
4517
4209
|
return [
|
|
4518
4210
|
4,
|
|
4519
4211
|
this.playSingleAd(nextAdUrl).catch(function() {
|
|
@@ -4535,10 +4227,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4535
4227
|
];
|
|
4536
4228
|
case 6:
|
|
4537
4229
|
if (this.config.debugAdTiming) {
|
|
4538
|
-
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout
|
|
4230
|
+
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
|
|
4539
4231
|
}
|
|
4540
4232
|
this.isShowingPlaceholder = false;
|
|
4541
|
-
this.placeholderStartTimeMs = null;
|
|
4542
4233
|
this.ima.hidePlaceholder();
|
|
4543
4234
|
this.handleAdPodComplete();
|
|
4544
4235
|
return [
|
|
@@ -4840,21 +4531,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4840
4531
|
if (this.isShowingPlaceholder) {
|
|
4841
4532
|
this.ima.hidePlaceholder();
|
|
4842
4533
|
this.isShowingPlaceholder = false;
|
|
4843
|
-
this.placeholderStartTimeMs = null;
|
|
4844
4534
|
}
|
|
4845
|
-
this.preloadingAdUrls.clear();
|
|
4846
|
-
this.vastToMediaUrlMap.clear();
|
|
4847
|
-
this.preloadedMediaUrls.clear();
|
|
4848
|
-
this.preloadingMediaUrls.clear();
|
|
4849
4535
|
this.adRequestQueue = [];
|
|
4850
|
-
this.successfulAdRequests = [];
|
|
4851
4536
|
this.inAdBreak = false;
|
|
4852
4537
|
this.expectedAdBreakDurationMs = void 0;
|
|
4853
4538
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
4854
4539
|
this.clearAdStartTimer();
|
|
4855
4540
|
this.clearAdStopTimer();
|
|
4856
4541
|
this.adPodQueue = [];
|
|
4857
|
-
this.adPodAllUrls = [];
|
|
4858
4542
|
this.showAds = false;
|
|
4859
4543
|
this.currentAdIndex = 0;
|
|
4860
4544
|
this.totalAdsInBreak = 0;
|
|
@@ -5009,651 +4693,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5009
4693
|
}, extra));
|
|
5010
4694
|
}
|
|
5011
4695
|
},
|
|
5012
|
-
{
|
|
5013
|
-
key: "fetchAndParseVastXml",
|
|
5014
|
-
value: function fetchAndParseVastXml(vastTagUrl) {
|
|
5015
|
-
return _async_to_generator(function() {
|
|
5016
|
-
var response, xmlText, error;
|
|
5017
|
-
return _ts_generator(this, function(_state) {
|
|
5018
|
-
switch(_state.label){
|
|
5019
|
-
case 0:
|
|
5020
|
-
_state.trys.push([
|
|
5021
|
-
0,
|
|
5022
|
-
3,
|
|
5023
|
-
,
|
|
5024
|
-
4
|
|
5025
|
-
]);
|
|
5026
|
-
return [
|
|
5027
|
-
4,
|
|
5028
|
-
fetch(vastTagUrl, {
|
|
5029
|
-
mode: "cors",
|
|
5030
|
-
credentials: "include",
|
|
5031
|
-
headers: {
|
|
5032
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5033
|
-
},
|
|
5034
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5035
|
-
})
|
|
5036
|
-
];
|
|
5037
|
-
case 1:
|
|
5038
|
-
response = _state.sent();
|
|
5039
|
-
if (!response.ok) {
|
|
5040
|
-
throw new Error("Failed to fetch VAST: ".concat(response.status));
|
|
5041
|
-
}
|
|
5042
|
-
return [
|
|
5043
|
-
4,
|
|
5044
|
-
response.text()
|
|
5045
|
-
];
|
|
5046
|
-
case 2:
|
|
5047
|
-
xmlText = _state.sent();
|
|
5048
|
-
return [
|
|
5049
|
-
2,
|
|
5050
|
-
this.extractMediaUrlsFromVast(xmlText)
|
|
5051
|
-
];
|
|
5052
|
-
case 3:
|
|
5053
|
-
error = _state.sent();
|
|
5054
|
-
if (this.config.debugAdTiming) {
|
|
5055
|
-
console.warn("[StormcloudVideoPlayer] Failed to fetch/parse VAST XML: ".concat(vastTagUrl), error);
|
|
5056
|
-
}
|
|
5057
|
-
return [
|
|
5058
|
-
2,
|
|
5059
|
-
[]
|
|
5060
|
-
];
|
|
5061
|
-
case 4:
|
|
5062
|
-
return [
|
|
5063
|
-
2
|
|
5064
|
-
];
|
|
5065
|
-
}
|
|
5066
|
-
});
|
|
5067
|
-
}).call(this);
|
|
5068
|
-
}
|
|
5069
|
-
},
|
|
5070
|
-
{
|
|
5071
|
-
key: "extractMediaUrlsFromVast",
|
|
5072
|
-
value: function extractMediaUrlsFromVast(xmlText) {
|
|
5073
|
-
var mediaUrls = [];
|
|
5074
|
-
try {
|
|
5075
|
-
var parser = new DOMParser();
|
|
5076
|
-
var xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5077
|
-
var mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
|
|
5078
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5079
|
-
try {
|
|
5080
|
-
for(var _iterator = Array.from(mediaFileElements)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5081
|
-
var mediaFile = _step.value;
|
|
5082
|
-
var _mediaFile_textContent;
|
|
5083
|
-
var url = (_mediaFile_textContent = mediaFile.textContent) === null || _mediaFile_textContent === void 0 ? void 0 : _mediaFile_textContent.trim();
|
|
5084
|
-
if (url) {
|
|
5085
|
-
var lowerUrl = url.toLowerCase();
|
|
5086
|
-
if (lowerUrl.endsWith(".mp4") || lowerUrl.endsWith(".webm") || lowerUrl.endsWith(".mov") || lowerUrl.endsWith(".avi") || lowerUrl.includes(".mp4?") || lowerUrl.includes(".webm?") || lowerUrl.includes("/mp4/") || lowerUrl.includes("type=video")) {
|
|
5087
|
-
mediaUrls.push(url);
|
|
5088
|
-
}
|
|
5089
|
-
}
|
|
5090
|
-
}
|
|
5091
|
-
} catch (err) {
|
|
5092
|
-
_didIteratorError = true;
|
|
5093
|
-
_iteratorError = err;
|
|
5094
|
-
} finally{
|
|
5095
|
-
try {
|
|
5096
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5097
|
-
_iterator.return();
|
|
5098
|
-
}
|
|
5099
|
-
} finally{
|
|
5100
|
-
if (_didIteratorError) {
|
|
5101
|
-
throw _iteratorError;
|
|
5102
|
-
}
|
|
5103
|
-
}
|
|
5104
|
-
}
|
|
5105
|
-
if (this.config.debugAdTiming && mediaUrls.length > 0) {
|
|
5106
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs from VAST:"), mediaUrls);
|
|
5107
|
-
}
|
|
5108
|
-
} catch (error) {
|
|
5109
|
-
if (this.config.debugAdTiming) {
|
|
5110
|
-
console.warn("[StormcloudVideoPlayer] Failed to parse VAST XML:", error);
|
|
5111
|
-
}
|
|
5112
|
-
}
|
|
5113
|
-
return mediaUrls;
|
|
5114
|
-
}
|
|
5115
|
-
},
|
|
5116
|
-
{
|
|
5117
|
-
key: "fetchVastDuration",
|
|
5118
|
-
value: function fetchVastDuration(vastTagUrl) {
|
|
5119
|
-
return _async_to_generator(function() {
|
|
5120
|
-
var _xmlDoc_querySelector, response, xmlText, parser, xmlDoc, durationText, durationParts, durationSeconds, error;
|
|
5121
|
-
return _ts_generator(this, function(_state) {
|
|
5122
|
-
switch(_state.label){
|
|
5123
|
-
case 0:
|
|
5124
|
-
_state.trys.push([
|
|
5125
|
-
0,
|
|
5126
|
-
3,
|
|
5127
|
-
,
|
|
5128
|
-
4
|
|
5129
|
-
]);
|
|
5130
|
-
return [
|
|
5131
|
-
4,
|
|
5132
|
-
fetch(vastTagUrl, {
|
|
5133
|
-
mode: "cors",
|
|
5134
|
-
credentials: "include",
|
|
5135
|
-
headers: {
|
|
5136
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5137
|
-
},
|
|
5138
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5139
|
-
})
|
|
5140
|
-
];
|
|
5141
|
-
case 1:
|
|
5142
|
-
response = _state.sent();
|
|
5143
|
-
if (!response.ok) {
|
|
5144
|
-
if (this.config.debugAdTiming) {
|
|
5145
|
-
console.warn("[ADAPTIVE-POD] Failed to fetch VAST: ".concat(response.status));
|
|
5146
|
-
}
|
|
5147
|
-
return [
|
|
5148
|
-
2,
|
|
5149
|
-
null
|
|
5150
|
-
];
|
|
5151
|
-
}
|
|
5152
|
-
return [
|
|
5153
|
-
4,
|
|
5154
|
-
response.text()
|
|
5155
|
-
];
|
|
5156
|
-
case 2:
|
|
5157
|
-
xmlText = _state.sent();
|
|
5158
|
-
parser = new DOMParser();
|
|
5159
|
-
xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5160
|
-
durationText = (_xmlDoc_querySelector = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector === void 0 ? void 0 : _xmlDoc_querySelector.textContent;
|
|
5161
|
-
if (!durationText) {
|
|
5162
|
-
if (this.config.debugAdTiming) {
|
|
5163
|
-
console.warn("[ADAPTIVE-POD] No Duration element found in VAST");
|
|
5164
|
-
}
|
|
5165
|
-
return [
|
|
5166
|
-
2,
|
|
5167
|
-
null
|
|
5168
|
-
];
|
|
5169
|
-
}
|
|
5170
|
-
durationParts = durationText.split(":");
|
|
5171
|
-
durationSeconds = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
5172
|
-
return [
|
|
5173
|
-
2,
|
|
5174
|
-
durationSeconds
|
|
5175
|
-
];
|
|
5176
|
-
case 3:
|
|
5177
|
-
error = _state.sent();
|
|
5178
|
-
if (this.config.debugAdTiming) {
|
|
5179
|
-
console.warn("[ADAPTIVE-POD] Error fetching VAST duration from ".concat(vastTagUrl, ":"), error);
|
|
5180
|
-
}
|
|
5181
|
-
return [
|
|
5182
|
-
2,
|
|
5183
|
-
null
|
|
5184
|
-
];
|
|
5185
|
-
case 4:
|
|
5186
|
-
return [
|
|
5187
|
-
2
|
|
5188
|
-
];
|
|
5189
|
-
}
|
|
5190
|
-
});
|
|
5191
|
-
}).call(this);
|
|
5192
|
-
}
|
|
5193
|
-
},
|
|
5194
|
-
{
|
|
5195
|
-
key: "calculateAdditionalAdsNeeded",
|
|
5196
|
-
value: function calculateAdditionalAdsNeeded() {
|
|
5197
|
-
if (!this.isAdaptiveMode || this.targetAdBreakDurationMs === null) {
|
|
5198
|
-
return 0;
|
|
5199
|
-
}
|
|
5200
|
-
var totalFetchedDurationMs = 0;
|
|
5201
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5202
|
-
try {
|
|
5203
|
-
for(var _iterator = this.fetchedAdDurations.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5204
|
-
var duration = _step.value;
|
|
5205
|
-
totalFetchedDurationMs += duration * 1e3;
|
|
5206
|
-
}
|
|
5207
|
-
} catch (err) {
|
|
5208
|
-
_didIteratorError = true;
|
|
5209
|
-
_iteratorError = err;
|
|
5210
|
-
} finally{
|
|
5211
|
-
try {
|
|
5212
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5213
|
-
_iterator.return();
|
|
5214
|
-
}
|
|
5215
|
-
} finally{
|
|
5216
|
-
if (_didIteratorError) {
|
|
5217
|
-
throw _iteratorError;
|
|
5218
|
-
}
|
|
5219
|
-
}
|
|
5220
|
-
}
|
|
5221
|
-
var fetchedCount = this.fetchedAdDurations.size;
|
|
5222
|
-
var averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
5223
|
-
var queuedButNotFetched = this.adPodAllUrls.length - fetchedCount;
|
|
5224
|
-
var estimatedQueuedDurationMs = queuedButNotFetched * averageDurationMs;
|
|
5225
|
-
var estimatedTotalDurationMs = totalFetchedDurationMs + estimatedQueuedDurationMs;
|
|
5226
|
-
var remainingTimeMs = this.targetAdBreakDurationMs - estimatedTotalDurationMs;
|
|
5227
|
-
if (remainingTimeMs <= 0) {
|
|
5228
|
-
if (this.config.debugAdTiming) {
|
|
5229
|
-
console.log("[ADAPTIVE-POD] ✅ Target duration met: Fetched=".concat(totalFetchedDurationMs, "ms + Queued(").concat(queuedButNotFetched, " ads)=").concat(estimatedQueuedDurationMs, "ms = ").concat(estimatedTotalDurationMs, "ms / Target=").concat(this.targetAdBreakDurationMs, "ms"));
|
|
5230
|
-
}
|
|
5231
|
-
return 0;
|
|
5232
|
-
}
|
|
5233
|
-
var additionalAds = Math.ceil(remainingTimeMs / averageDurationMs);
|
|
5234
|
-
if (this.config.debugAdTiming) {
|
|
5235
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCCA Need ".concat(additionalAds, " more ads | Fetched: ").concat(totalFetchedDurationMs, "ms (").concat(fetchedCount, " ads) | Queued: ").concat(estimatedQueuedDurationMs, "ms (").concat(queuedButNotFetched, " ads) | Target: ").concat(this.targetAdBreakDurationMs, "ms | Remaining: ").concat(remainingTimeMs, "ms | Avg duration: ").concat(averageDurationMs, "ms"));
|
|
5236
|
-
}
|
|
5237
|
-
return additionalAds;
|
|
5238
|
-
}
|
|
5239
|
-
},
|
|
5240
|
-
{
|
|
5241
|
-
key: "addAdaptiveAdsToQueue",
|
|
5242
|
-
value: function addAdaptiveAdsToQueue() {
|
|
5243
|
-
return _async_to_generator(function() {
|
|
5244
|
-
var _this_adPodAllUrls, _this_adPodQueue, additionalAds, newUrls;
|
|
5245
|
-
return _ts_generator(this, function(_state) {
|
|
5246
|
-
if (!this.isAdaptiveMode || !this.apiVastTagUrl) {
|
|
5247
|
-
return [
|
|
5248
|
-
2
|
|
5249
|
-
];
|
|
5250
|
-
}
|
|
5251
|
-
additionalAds = this.calculateAdditionalAdsNeeded();
|
|
5252
|
-
if (additionalAds <= 0) {
|
|
5253
|
-
return [
|
|
5254
|
-
2
|
|
5255
|
-
];
|
|
5256
|
-
}
|
|
5257
|
-
newUrls = this.generateVastUrlsWithCorrelators(this.apiVastTagUrl, additionalAds);
|
|
5258
|
-
if (this.config.debugAdTiming) {
|
|
5259
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Adding ".concat(newUrls.length, " additional VAST URLs to queue (will be preloaded sequentially)"));
|
|
5260
|
-
}
|
|
5261
|
-
(_this_adPodAllUrls = this.adPodAllUrls).push.apply(_this_adPodAllUrls, _to_consumable_array(newUrls));
|
|
5262
|
-
(_this_adPodQueue = this.adPodQueue).push.apply(_this_adPodQueue, _to_consumable_array(newUrls));
|
|
5263
|
-
this.totalAdsInBreak += newUrls.length;
|
|
5264
|
-
return [
|
|
5265
|
-
2
|
|
5266
|
-
];
|
|
5267
|
-
});
|
|
5268
|
-
}).call(this);
|
|
5269
|
-
}
|
|
5270
|
-
},
|
|
5271
|
-
{
|
|
5272
|
-
key: "preloadMediaFile",
|
|
5273
|
-
value: function preloadMediaFile(mediaUrl) {
|
|
5274
|
-
return _async_to_generator(function() {
|
|
5275
|
-
var response, error;
|
|
5276
|
-
return _ts_generator(this, function(_state) {
|
|
5277
|
-
switch(_state.label){
|
|
5278
|
-
case 0:
|
|
5279
|
-
if (this.preloadedMediaUrls.has(mediaUrl)) {
|
|
5280
|
-
return [
|
|
5281
|
-
2
|
|
5282
|
-
];
|
|
5283
|
-
}
|
|
5284
|
-
if (this.preloadingMediaUrls.has(mediaUrl)) {
|
|
5285
|
-
return [
|
|
5286
|
-
2
|
|
5287
|
-
];
|
|
5288
|
-
}
|
|
5289
|
-
this.preloadingMediaUrls.add(mediaUrl);
|
|
5290
|
-
_state.label = 1;
|
|
5291
|
-
case 1:
|
|
5292
|
-
_state.trys.push([
|
|
5293
|
-
1,
|
|
5294
|
-
3,
|
|
5295
|
-
4,
|
|
5296
|
-
5
|
|
5297
|
-
]);
|
|
5298
|
-
if (this.config.debugAdTiming) {
|
|
5299
|
-
console.log("[StormcloudVideoPlayer] Preloading video file: ".concat(mediaUrl));
|
|
5300
|
-
}
|
|
5301
|
-
return [
|
|
5302
|
-
4,
|
|
5303
|
-
fetch(mediaUrl, {
|
|
5304
|
-
mode: "cors",
|
|
5305
|
-
credentials: "include",
|
|
5306
|
-
method: "GET",
|
|
5307
|
-
headers: {
|
|
5308
|
-
Range: "bytes=0-1048576"
|
|
5309
|
-
},
|
|
5310
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5311
|
-
})
|
|
5312
|
-
];
|
|
5313
|
-
case 2:
|
|
5314
|
-
response = _state.sent();
|
|
5315
|
-
if (response.ok || response.status === 206) {
|
|
5316
|
-
this.preloadedMediaUrls.add(mediaUrl);
|
|
5317
|
-
if (this.config.debugAdTiming) {
|
|
5318
|
-
console.log("[StormcloudVideoPlayer] Successfully preloaded video file: ".concat(mediaUrl));
|
|
5319
|
-
}
|
|
5320
|
-
}
|
|
5321
|
-
return [
|
|
5322
|
-
3,
|
|
5323
|
-
5
|
|
5324
|
-
];
|
|
5325
|
-
case 3:
|
|
5326
|
-
error = _state.sent();
|
|
5327
|
-
if (this.config.debugAdTiming) {
|
|
5328
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload video file: ".concat(mediaUrl), error);
|
|
5329
|
-
}
|
|
5330
|
-
return [
|
|
5331
|
-
3,
|
|
5332
|
-
5
|
|
5333
|
-
];
|
|
5334
|
-
case 4:
|
|
5335
|
-
this.preloadingMediaUrls.delete(mediaUrl);
|
|
5336
|
-
return [
|
|
5337
|
-
7
|
|
5338
|
-
];
|
|
5339
|
-
case 5:
|
|
5340
|
-
return [
|
|
5341
|
-
2
|
|
5342
|
-
];
|
|
5343
|
-
}
|
|
5344
|
-
});
|
|
5345
|
-
}).call(this);
|
|
5346
|
-
}
|
|
5347
|
-
},
|
|
5348
|
-
{
|
|
5349
|
-
key: "preloadAllAdsInBackground",
|
|
5350
|
-
value: function preloadAllAdsInBackground() {
|
|
5351
|
-
return _async_to_generator(function() {
|
|
5352
|
-
var _this, processedUrls, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, _this_ima_hasPreloadedAd, _this_ima, nextUrl, error, preloadPromises;
|
|
5353
|
-
return _ts_generator(this, function(_state) {
|
|
5354
|
-
switch(_state.label){
|
|
5355
|
-
case 0:
|
|
5356
|
-
_this = this;
|
|
5357
|
-
if (this.adPodAllUrls.length === 0) {
|
|
5358
|
-
return [
|
|
5359
|
-
2
|
|
5360
|
-
];
|
|
5361
|
-
}
|
|
5362
|
-
if (!this.isAdaptiveMode) return [
|
|
5363
|
-
3,
|
|
5364
|
-
7
|
|
5365
|
-
];
|
|
5366
|
-
if (this.config.debugAdTiming) {
|
|
5367
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Starting sequential preload of remaining ads");
|
|
5368
|
-
}
|
|
5369
|
-
processedUrls = /* @__PURE__ */ new Set();
|
|
5370
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5371
|
-
try {
|
|
5372
|
-
for(_iterator = this.adPodAllUrls[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5373
|
-
url = _step.value;
|
|
5374
|
-
;
|
|
5375
|
-
if (((_this_ima_hasPreloadedAd = (_this_ima = this.ima).hasPreloadedAd) === null || _this_ima_hasPreloadedAd === void 0 ? void 0 : _this_ima_hasPreloadedAd.call(_this_ima, url)) || this.fetchedAdDurations.has(url)) {
|
|
5376
|
-
processedUrls.add(url);
|
|
5377
|
-
}
|
|
5378
|
-
}
|
|
5379
|
-
} catch (err) {
|
|
5380
|
-
_didIteratorError = true;
|
|
5381
|
-
_iteratorError = err;
|
|
5382
|
-
} finally{
|
|
5383
|
-
try {
|
|
5384
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5385
|
-
_iterator.return();
|
|
5386
|
-
}
|
|
5387
|
-
} finally{
|
|
5388
|
-
if (_didIteratorError) {
|
|
5389
|
-
throw _iteratorError;
|
|
5390
|
-
}
|
|
5391
|
-
}
|
|
5392
|
-
}
|
|
5393
|
-
if (this.config.debugAdTiming && processedUrls.size > 0) {
|
|
5394
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE6 Skipping ".concat(processedUrls.size, " already-preloaded ads"));
|
|
5395
|
-
}
|
|
5396
|
-
_state.label = 1;
|
|
5397
|
-
case 1:
|
|
5398
|
-
if (!true) return [
|
|
5399
|
-
3,
|
|
5400
|
-
6
|
|
5401
|
-
];
|
|
5402
|
-
nextUrl = this.adPodAllUrls.find(function(url) {
|
|
5403
|
-
return !processedUrls.has(url);
|
|
5404
|
-
});
|
|
5405
|
-
if (!nextUrl) {
|
|
5406
|
-
if (this.config.debugAdTiming) {
|
|
5407
|
-
console.log("[ADAPTIVE-POD] ✅ All queued ads processed (".concat(processedUrls.size, " total)"));
|
|
5408
|
-
}
|
|
5409
|
-
return [
|
|
5410
|
-
3,
|
|
5411
|
-
6
|
|
5412
|
-
];
|
|
5413
|
-
}
|
|
5414
|
-
processedUrls.add(nextUrl);
|
|
5415
|
-
if (this.config.debugAdTiming) {
|
|
5416
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE5 Preloading ad ".concat(processedUrls.size, "/").concat(this.adPodAllUrls.length, "..."));
|
|
5417
|
-
}
|
|
5418
|
-
_state.label = 2;
|
|
5419
|
-
case 2:
|
|
5420
|
-
_state.trys.push([
|
|
5421
|
-
2,
|
|
5422
|
-
4,
|
|
5423
|
-
,
|
|
5424
|
-
5
|
|
5425
|
-
]);
|
|
5426
|
-
return [
|
|
5427
|
-
4,
|
|
5428
|
-
this.preloadSingleAd(nextUrl)
|
|
5429
|
-
];
|
|
5430
|
-
case 3:
|
|
5431
|
-
_state.sent();
|
|
5432
|
-
return [
|
|
5433
|
-
3,
|
|
5434
|
-
5
|
|
5435
|
-
];
|
|
5436
|
-
case 4:
|
|
5437
|
-
error = _state.sent();
|
|
5438
|
-
if (this.config.debugAdTiming) {
|
|
5439
|
-
console.warn("[ADAPTIVE-POD] ⚠️ Preload failed for ad ".concat(processedUrls.size, ":"), error);
|
|
5440
|
-
}
|
|
5441
|
-
return [
|
|
5442
|
-
3,
|
|
5443
|
-
5
|
|
5444
|
-
];
|
|
5445
|
-
case 5:
|
|
5446
|
-
if (this.calculateAdditionalAdsNeeded() === 0) {
|
|
5447
|
-
if (this.config.debugAdTiming) {
|
|
5448
|
-
console.log("[ADAPTIVE-POD] ✅ Target duration reached (".concat(processedUrls.size, " ads preloaded), stopping"));
|
|
5449
|
-
}
|
|
5450
|
-
return [
|
|
5451
|
-
3,
|
|
5452
|
-
6
|
|
5453
|
-
];
|
|
5454
|
-
}
|
|
5455
|
-
return [
|
|
5456
|
-
3,
|
|
5457
|
-
1
|
|
5458
|
-
];
|
|
5459
|
-
case 6:
|
|
5460
|
-
if (this.config.debugAdTiming) {
|
|
5461
|
-
console.log("[ADAPTIVE-POD] ✅ Sequential preloading completed (".concat(processedUrls.size, " ads ready)"));
|
|
5462
|
-
}
|
|
5463
|
-
return [
|
|
5464
|
-
3,
|
|
5465
|
-
9
|
|
5466
|
-
];
|
|
5467
|
-
case 7:
|
|
5468
|
-
if (this.config.debugAdTiming) {
|
|
5469
|
-
console.log("[StormcloudVideoPlayer] Starting parallel preload of ".concat(this.adPodAllUrls.length, " ads"));
|
|
5470
|
-
}
|
|
5471
|
-
preloadPromises = this.adPodAllUrls.map(function(vastTagUrl) {
|
|
5472
|
-
return _this.preloadSingleAd(vastTagUrl).catch(function(error) {
|
|
5473
|
-
if (_this.config.debugAdTiming) {
|
|
5474
|
-
console.warn("[StormcloudVideoPlayer] Preload failed for ".concat(vastTagUrl, ":"), error);
|
|
5475
|
-
}
|
|
5476
|
-
});
|
|
5477
|
-
});
|
|
5478
|
-
return [
|
|
5479
|
-
4,
|
|
5480
|
-
Promise.all(preloadPromises)
|
|
5481
|
-
];
|
|
5482
|
-
case 8:
|
|
5483
|
-
_state.sent();
|
|
5484
|
-
if (this.config.debugAdTiming) {
|
|
5485
|
-
console.log("[StormcloudVideoPlayer] Background preloading completed for all ads");
|
|
5486
|
-
}
|
|
5487
|
-
_state.label = 9;
|
|
5488
|
-
case 9:
|
|
5489
|
-
return [
|
|
5490
|
-
2
|
|
5491
|
-
];
|
|
5492
|
-
}
|
|
5493
|
-
});
|
|
5494
|
-
}).call(this);
|
|
5495
|
-
}
|
|
5496
|
-
},
|
|
5497
|
-
{
|
|
5498
|
-
key: "preloadSingleAd",
|
|
5499
|
-
value: function preloadSingleAd(vastTagUrl) {
|
|
5500
|
-
return _async_to_generator(function() {
|
|
5501
|
-
var _this, duration, mediaUrls, primaryMediaUrl, error;
|
|
5502
|
-
return _ts_generator(this, function(_state) {
|
|
5503
|
-
switch(_state.label){
|
|
5504
|
-
case 0:
|
|
5505
|
-
_this = this;
|
|
5506
|
-
if (!vastTagUrl) return [
|
|
5507
|
-
2
|
|
5508
|
-
];
|
|
5509
|
-
_state.label = 1;
|
|
5510
|
-
case 1:
|
|
5511
|
-
_state.trys.push([
|
|
5512
|
-
1,
|
|
5513
|
-
11,
|
|
5514
|
-
,
|
|
5515
|
-
12
|
|
5516
|
-
]);
|
|
5517
|
-
if (!(this.isAdaptiveMode && !this.fetchedAdDurations.has(vastTagUrl))) return [
|
|
5518
|
-
3,
|
|
5519
|
-
4
|
|
5520
|
-
];
|
|
5521
|
-
return [
|
|
5522
|
-
4,
|
|
5523
|
-
this.fetchVastDuration(vastTagUrl)
|
|
5524
|
-
];
|
|
5525
|
-
case 2:
|
|
5526
|
-
duration = _state.sent();
|
|
5527
|
-
if (!(duration !== null)) return [
|
|
5528
|
-
3,
|
|
5529
|
-
4
|
|
5530
|
-
];
|
|
5531
|
-
this.fetchedAdDurations.set(vastTagUrl, duration);
|
|
5532
|
-
if (this.config.debugAdTiming) {
|
|
5533
|
-
console.log("[ADAPTIVE-POD] ✓ Fetched ad duration: ".concat(duration, "s (").concat(this.fetchedAdDurations.size, " ads fetched so far)"));
|
|
5534
|
-
}
|
|
5535
|
-
return [
|
|
5536
|
-
4,
|
|
5537
|
-
this.addAdaptiveAdsToQueue()
|
|
5538
|
-
];
|
|
5539
|
-
case 3:
|
|
5540
|
-
_state.sent();
|
|
5541
|
-
_state.label = 4;
|
|
5542
|
-
case 4:
|
|
5543
|
-
if (!(this.ima.preloadAds && !this.ima.hasPreloadedAd(vastTagUrl))) return [
|
|
5544
|
-
3,
|
|
5545
|
-
6
|
|
5546
|
-
];
|
|
5547
|
-
if (!!this.preloadingAdUrls.has(vastTagUrl)) return [
|
|
5548
|
-
3,
|
|
5549
|
-
6
|
|
5550
|
-
];
|
|
5551
|
-
if (this.config.debugAdTiming) {
|
|
5552
|
-
console.log("[StormcloudVideoPlayer] Preloading VAST: ".concat(vastTagUrl));
|
|
5553
|
-
}
|
|
5554
|
-
this.preloadingAdUrls.add(vastTagUrl);
|
|
5555
|
-
return [
|
|
5556
|
-
4,
|
|
5557
|
-
this.ima.preloadAds(vastTagUrl).then(function() {
|
|
5558
|
-
if (_this.config.debugAdTiming) {
|
|
5559
|
-
console.log("[StormcloudVideoPlayer] IMA VAST preload complete: ".concat(vastTagUrl));
|
|
5560
|
-
}
|
|
5561
|
-
}).catch(function(error) {
|
|
5562
|
-
if (_this.config.debugAdTiming) {
|
|
5563
|
-
console.warn("[StormcloudVideoPlayer] IMA VAST preload failed: ".concat(vastTagUrl), error);
|
|
5564
|
-
}
|
|
5565
|
-
}).finally(function() {
|
|
5566
|
-
_this.preloadingAdUrls.delete(vastTagUrl);
|
|
5567
|
-
})
|
|
5568
|
-
];
|
|
5569
|
-
case 5:
|
|
5570
|
-
_state.sent();
|
|
5571
|
-
_state.label = 6;
|
|
5572
|
-
case 6:
|
|
5573
|
-
mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5574
|
-
if (!!mediaUrls) return [
|
|
5575
|
-
3,
|
|
5576
|
-
8
|
|
5577
|
-
];
|
|
5578
|
-
if (this.config.debugAdTiming) {
|
|
5579
|
-
console.log("[StormcloudVideoPlayer] Fetching and parsing VAST to extract media URLs: ".concat(vastTagUrl));
|
|
5580
|
-
}
|
|
5581
|
-
return [
|
|
5582
|
-
4,
|
|
5583
|
-
this.fetchAndParseVastXml(vastTagUrl)
|
|
5584
|
-
];
|
|
5585
|
-
case 7:
|
|
5586
|
-
mediaUrls = _state.sent();
|
|
5587
|
-
if (this.config.debugAdTiming) {
|
|
5588
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs:"), mediaUrls);
|
|
5589
|
-
}
|
|
5590
|
-
if (mediaUrls.length > 0) {
|
|
5591
|
-
this.vastToMediaUrlMap.set(vastTagUrl, mediaUrls);
|
|
5592
|
-
}
|
|
5593
|
-
_state.label = 8;
|
|
5594
|
-
case 8:
|
|
5595
|
-
if (!(mediaUrls && mediaUrls.length > 0)) return [
|
|
5596
|
-
3,
|
|
5597
|
-
10
|
|
5598
|
-
];
|
|
5599
|
-
primaryMediaUrl = mediaUrls[0];
|
|
5600
|
-
if (!(primaryMediaUrl && !this.preloadedMediaUrls.has(primaryMediaUrl))) return [
|
|
5601
|
-
3,
|
|
5602
|
-
10
|
|
5603
|
-
];
|
|
5604
|
-
return [
|
|
5605
|
-
4,
|
|
5606
|
-
this.preloadMediaFile(primaryMediaUrl)
|
|
5607
|
-
];
|
|
5608
|
-
case 9:
|
|
5609
|
-
_state.sent();
|
|
5610
|
-
_state.label = 10;
|
|
5611
|
-
case 10:
|
|
5612
|
-
return [
|
|
5613
|
-
3,
|
|
5614
|
-
12
|
|
5615
|
-
];
|
|
5616
|
-
case 11:
|
|
5617
|
-
error = _state.sent();
|
|
5618
|
-
if (this.config.debugAdTiming) {
|
|
5619
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload ad: ".concat(vastTagUrl), error);
|
|
5620
|
-
}
|
|
5621
|
-
return [
|
|
5622
|
-
3,
|
|
5623
|
-
12
|
|
5624
|
-
];
|
|
5625
|
-
case 12:
|
|
5626
|
-
return [
|
|
5627
|
-
2
|
|
5628
|
-
];
|
|
5629
|
-
}
|
|
5630
|
-
});
|
|
5631
|
-
}).call(this);
|
|
5632
|
-
}
|
|
5633
|
-
},
|
|
5634
|
-
{
|
|
5635
|
-
key: "findNextPreloadedAd",
|
|
5636
|
-
value: function findNextPreloadedAd() {
|
|
5637
|
-
for(var i = 0; i < this.adPodQueue.length; i++){
|
|
5638
|
-
var _this_ima_hasPreloadedAd, _this_ima;
|
|
5639
|
-
var vastTagUrl = this.adPodQueue[i];
|
|
5640
|
-
if (!vastTagUrl) continue;
|
|
5641
|
-
if (this.failedVastUrls.has(vastTagUrl)) {
|
|
5642
|
-
console.warn("[AD-ERROR] Skipping failed URL in queue");
|
|
5643
|
-
continue;
|
|
5644
|
-
}
|
|
5645
|
-
var _this_ima_hasPreloadedAd1;
|
|
5646
|
-
var hasImaPreload = (_this_ima_hasPreloadedAd1 = (_this_ima_hasPreloadedAd = (_this_ima = this.ima).hasPreloadedAd) === null || _this_ima_hasPreloadedAd === void 0 ? void 0 : _this_ima_hasPreloadedAd.call(_this_ima, vastTagUrl)) !== null && _this_ima_hasPreloadedAd1 !== void 0 ? _this_ima_hasPreloadedAd1 : false;
|
|
5647
|
-
var mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5648
|
-
var hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
|
|
5649
|
-
if (hasImaPreload || hasMediaPreload) {
|
|
5650
|
-
this.adPodQueue.splice(0, i + 1);
|
|
5651
|
-
return vastTagUrl;
|
|
5652
|
-
}
|
|
5653
|
-
}
|
|
5654
|
-
return void 0;
|
|
5655
|
-
}
|
|
5656
|
-
},
|
|
5657
4696
|
{
|
|
5658
4697
|
key: "getRemainingAdMs",
|
|
5659
4698
|
value: function getRemainingAdMs() {
|
|
@@ -5840,7 +4879,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5840
4879
|
}
|
|
5841
4880
|
if (this.ima && this.ima.isAdPlaying()) {
|
|
5842
4881
|
var width = this.video.clientWidth || 640;
|
|
5843
|
-
var height = this.video.clientHeight ||
|
|
4882
|
+
var height = this.video.clientHeight || 480;
|
|
5844
4883
|
if (this.config.debugAdTiming) {
|
|
5845
4884
|
console.log("[StormcloudVideoPlayer] Resizing ads manager to ".concat(width, "x").concat(height));
|
|
5846
4885
|
}
|
|
@@ -5871,13 +4910,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5871
4910
|
}
|
|
5872
4911
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5873
4912
|
(_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
|
|
5874
|
-
this.preloadingAdUrls.clear();
|
|
5875
|
-
this.vastToMediaUrlMap.clear();
|
|
5876
|
-
this.preloadedMediaUrls.clear();
|
|
5877
|
-
this.preloadingMediaUrls.clear();
|
|
5878
|
-
this.adPodAllUrls = [];
|
|
5879
4913
|
this.adRequestQueue = [];
|
|
5880
|
-
this.successfulAdRequests = [];
|
|
5881
4914
|
}
|
|
5882
4915
|
}
|
|
5883
4916
|
]);
|