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] : {};
|
|
@@ -180,9 +171,6 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
180
171
|
function _sliced_to_array(arr, i) {
|
|
181
172
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
182
173
|
}
|
|
183
|
-
function _to_consumable_array(arr) {
|
|
184
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
185
|
-
}
|
|
186
174
|
function _type_of(obj) {
|
|
187
175
|
"@swc/helpers - typeof";
|
|
188
176
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
@@ -286,20 +274,6 @@ function _ts_generator(thisArg, body) {
|
|
|
286
274
|
};
|
|
287
275
|
}
|
|
288
276
|
}
|
|
289
|
-
function _ts_values(o) {
|
|
290
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
291
|
-
if (m) return m.call(o);
|
|
292
|
-
if (o && typeof o.length === "number") return {
|
|
293
|
-
next: function() {
|
|
294
|
-
if (o && i >= o.length) o = void 0;
|
|
295
|
-
return {
|
|
296
|
-
value: o && o[i++],
|
|
297
|
-
done: !o
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
302
|
-
}
|
|
303
277
|
var __create = Object.create;
|
|
304
278
|
var __defProp = Object.defineProperty;
|
|
305
279
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -536,8 +510,6 @@ function createImaController(video, options) {
|
|
|
536
510
|
var originalMutedState = false;
|
|
537
511
|
var originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
538
512
|
var listeners = /* @__PURE__ */ new Map();
|
|
539
|
-
var preloadedVast = /* @__PURE__ */ new Map();
|
|
540
|
-
var preloadingVast = /* @__PURE__ */ new Map();
|
|
541
513
|
var adVideoElement;
|
|
542
514
|
function setAdPlayingFlag(isPlaying) {
|
|
543
515
|
if (isPlaying) {
|
|
@@ -687,10 +659,10 @@ function createImaController(video, options) {
|
|
|
687
659
|
var adsLoadedReject;
|
|
688
660
|
function makeAdsRequest(google, vastTagUrl) {
|
|
689
661
|
var adsRequest = new google.ima.AdsRequest();
|
|
690
|
-
console.log("[IMA] \uD83D\uDCE1 Requesting VAST
|
|
662
|
+
console.log("[IMA] \uD83D\uDCE1 Requesting VAST via IMA SDK:", vastTagUrl.substring(0, 80) + "...");
|
|
691
663
|
adsRequest.adTagUrl = vastTagUrl;
|
|
692
664
|
var videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
693
|
-
var videoHeight = video.offsetHeight || video.clientHeight ||
|
|
665
|
+
var videoHeight = video.offsetHeight || video.clientHeight || 480;
|
|
694
666
|
adsRequest.linearAdSlotWidth = videoWidth;
|
|
695
667
|
adsRequest.linearAdSlotHeight = videoHeight;
|
|
696
668
|
adsRequest.nonLinearAdSlotWidth = videoWidth;
|
|
@@ -736,36 +708,6 @@ function createImaController(video, options) {
|
|
|
736
708
|
(_video_parentElement = video.parentElement) === null || _video_parentElement === void 0 ? void 0 : _video_parentElement.appendChild(container);
|
|
737
709
|
adContainerEl = container;
|
|
738
710
|
}
|
|
739
|
-
function fetchVastDocument(vastTagUrl) {
|
|
740
|
-
return _async_to_generator(function() {
|
|
741
|
-
var response;
|
|
742
|
-
return _ts_generator(this, function(_state) {
|
|
743
|
-
switch(_state.label){
|
|
744
|
-
case 0:
|
|
745
|
-
return [
|
|
746
|
-
4,
|
|
747
|
-
fetch(vastTagUrl, {
|
|
748
|
-
mode: "cors",
|
|
749
|
-
credentials: "include",
|
|
750
|
-
headers: {
|
|
751
|
-
"Accept": "application/xml, text/xml, */*"
|
|
752
|
-
},
|
|
753
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
754
|
-
})
|
|
755
|
-
];
|
|
756
|
-
case 1:
|
|
757
|
-
response = _state.sent();
|
|
758
|
-
if (!response.ok) {
|
|
759
|
-
throw new Error("Failed to preload VAST: ".concat(response.status));
|
|
760
|
-
}
|
|
761
|
-
return [
|
|
762
|
-
2,
|
|
763
|
-
response.text()
|
|
764
|
-
];
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
})();
|
|
768
|
-
}
|
|
769
711
|
function destroyAdsManager() {
|
|
770
712
|
if (adsManager) {
|
|
771
713
|
try {
|
|
@@ -1080,47 +1022,6 @@ function createImaController(video, options) {
|
|
|
1080
1022
|
});
|
|
1081
1023
|
})();
|
|
1082
1024
|
},
|
|
1083
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1084
|
-
return _async_to_generator(function() {
|
|
1085
|
-
var inflight, preloadPromise;
|
|
1086
|
-
return _ts_generator(this, function(_state) {
|
|
1087
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1088
|
-
return [
|
|
1089
|
-
2,
|
|
1090
|
-
Promise.resolve()
|
|
1091
|
-
];
|
|
1092
|
-
}
|
|
1093
|
-
if (preloadedVast.has(vastTagUrl)) {
|
|
1094
|
-
return [
|
|
1095
|
-
2,
|
|
1096
|
-
Promise.resolve()
|
|
1097
|
-
];
|
|
1098
|
-
}
|
|
1099
|
-
inflight = preloadingVast.get(vastTagUrl);
|
|
1100
|
-
if (inflight) {
|
|
1101
|
-
return [
|
|
1102
|
-
2,
|
|
1103
|
-
inflight
|
|
1104
|
-
];
|
|
1105
|
-
}
|
|
1106
|
-
preloadPromise = fetchVastDocument(vastTagUrl).then(function(xml) {
|
|
1107
|
-
preloadedVast.set(vastTagUrl, xml);
|
|
1108
|
-
}).catch(function() {
|
|
1109
|
-
preloadedVast.delete(vastTagUrl);
|
|
1110
|
-
}).finally(function() {
|
|
1111
|
-
preloadingVast.delete(vastTagUrl);
|
|
1112
|
-
});
|
|
1113
|
-
preloadingVast.set(vastTagUrl, preloadPromise);
|
|
1114
|
-
return [
|
|
1115
|
-
2,
|
|
1116
|
-
preloadPromise
|
|
1117
|
-
];
|
|
1118
|
-
});
|
|
1119
|
-
})();
|
|
1120
|
-
},
|
|
1121
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1122
|
-
return preloadedVast.has(vastTagUrl);
|
|
1123
|
-
},
|
|
1124
1025
|
play: function play() {
|
|
1125
1026
|
return _async_to_generator(function() {
|
|
1126
1027
|
var _window_google, width, height, adVolume, _video_play;
|
|
@@ -1139,7 +1040,7 @@ function createImaController(video, options) {
|
|
|
1139
1040
|
}
|
|
1140
1041
|
try {
|
|
1141
1042
|
width = video.clientWidth || 640;
|
|
1142
|
-
height = video.clientHeight ||
|
|
1043
|
+
height = video.clientHeight || 480;
|
|
1143
1044
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
1144
1045
|
adPlaying = true;
|
|
1145
1046
|
adVolume = originalMutedState ? 0 : originalVolume;
|
|
@@ -1229,8 +1130,6 @@ function createImaController(video, options) {
|
|
|
1229
1130
|
adDisplayContainer = void 0;
|
|
1230
1131
|
adsLoader = void 0;
|
|
1231
1132
|
contentVideoHidden = false;
|
|
1232
|
-
preloadedVast.clear();
|
|
1233
|
-
preloadingVast.clear();
|
|
1234
1133
|
},
|
|
1235
1134
|
isAdPlaying: function isAdPlaying() {
|
|
1236
1135
|
return adPlaying;
|
|
@@ -1831,51 +1730,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1831
1730
|
});
|
|
1832
1731
|
})();
|
|
1833
1732
|
},
|
|
1834
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1835
|
-
return _async_to_generator(function() {
|
|
1836
|
-
var inflight, preloadPromise;
|
|
1837
|
-
return _ts_generator(this, function(_state) {
|
|
1838
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1839
|
-
return [
|
|
1840
|
-
2,
|
|
1841
|
-
Promise.resolve()
|
|
1842
|
-
];
|
|
1843
|
-
}
|
|
1844
|
-
if (preloadedAds.has(vastTagUrl)) {
|
|
1845
|
-
return [
|
|
1846
|
-
2,
|
|
1847
|
-
Promise.resolve()
|
|
1848
|
-
];
|
|
1849
|
-
}
|
|
1850
|
-
inflight = preloadingAds.get(vastTagUrl);
|
|
1851
|
-
if (inflight) {
|
|
1852
|
-
return [
|
|
1853
|
-
2,
|
|
1854
|
-
inflight
|
|
1855
|
-
];
|
|
1856
|
-
}
|
|
1857
|
-
preloadPromise = fetchAndParseVastAd(vastTagUrl).then(function(ad) {
|
|
1858
|
-
if (ad) {
|
|
1859
|
-
preloadedAds.set(vastTagUrl, ad);
|
|
1860
|
-
console.log("[HlsAdPlayer] Cached VAST response for preloading:", vastTagUrl);
|
|
1861
|
-
}
|
|
1862
|
-
}).catch(function(error) {
|
|
1863
|
-
console.warn("[HlsAdPlayer] Failed to preload VAST response:", error);
|
|
1864
|
-
preloadedAds.delete(vastTagUrl);
|
|
1865
|
-
}).finally(function() {
|
|
1866
|
-
preloadingAds.delete(vastTagUrl);
|
|
1867
|
-
});
|
|
1868
|
-
preloadingAds.set(vastTagUrl, preloadPromise);
|
|
1869
|
-
return [
|
|
1870
|
-
2,
|
|
1871
|
-
preloadPromise
|
|
1872
|
-
];
|
|
1873
|
-
});
|
|
1874
|
-
})();
|
|
1875
|
-
},
|
|
1876
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1877
|
-
return preloadedAds.has(vastTagUrl);
|
|
1878
|
-
},
|
|
1879
1733
|
play: function play() {
|
|
1880
1734
|
return _async_to_generator(function() {
|
|
1881
1735
|
var contentVolume, adVolume, mediaFile;
|
|
@@ -2767,32 +2621,17 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2767
2621
|
this.bufferedSegmentsCount = 0;
|
|
2768
2622
|
this.shouldAutoplayAfterBuffering = false;
|
|
2769
2623
|
this.hasInitialBufferCompleted = false;
|
|
2770
|
-
this.adPodAllUrls = [];
|
|
2771
|
-
this.preloadingAdUrls = /* @__PURE__ */ new Set();
|
|
2772
|
-
this.vastToMediaUrlMap = /* @__PURE__ */ new Map();
|
|
2773
|
-
this.preloadedMediaUrls = /* @__PURE__ */ new Set();
|
|
2774
|
-
this.preloadingMediaUrls = /* @__PURE__ */ new Set();
|
|
2775
2624
|
this.adRequestTokenCounter = 0;
|
|
2776
2625
|
this.activeAdRequestToken = null;
|
|
2777
2626
|
this.adRequestWatchdogToken = null;
|
|
2778
2627
|
this.adFailsafeToken = null;
|
|
2779
|
-
this.fetchedAdDurations = /* @__PURE__ */ new Map();
|
|
2780
|
-
this.targetAdBreakDurationMs = null;
|
|
2781
|
-
this.isAdaptiveMode = false;
|
|
2782
2628
|
this.failedVastUrls = /* @__PURE__ */ new Set();
|
|
2783
2629
|
this.continuousFetchingActive = false;
|
|
2784
2630
|
this.adRequestQueue = [];
|
|
2785
|
-
this.successfulAdRequests = [];
|
|
2786
2631
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2787
|
-
this.placeholderStartTimeMs = null;
|
|
2788
2632
|
this.isShowingPlaceholder = false;
|
|
2789
|
-
this.consecutiveEmptyResponses = 0;
|
|
2790
2633
|
this.totalAdRequestsInBreak = 0;
|
|
2791
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
2792
2634
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2793
|
-
this.maxConsecutiveEmptyResponses = 5;
|
|
2794
|
-
this.baseEmptyResponseDelayMs = 2e3;
|
|
2795
|
-
this.maxEmptyResponseDelayMs = 3e4;
|
|
2796
2635
|
initializePolyfills();
|
|
2797
2636
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2798
2637
|
this.config = _object_spread({}, config, browserOverrides);
|
|
@@ -3283,25 +3122,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3283
3122
|
}
|
|
3284
3123
|
});
|
|
3285
3124
|
this.ima.on("ad_error", function(errorPayload) {
|
|
3286
|
-
var remaining = _this.getRemainingAdMs();
|
|
3287
3125
|
console.error("[AD-ERROR] Ad playback failed", errorPayload || "");
|
|
3288
|
-
|
|
3289
|
-
if (remaining > 500 && _this.adPodQueue.length > 0) {
|
|
3290
|
-
var nextPreloaded = _this.findNextPreloadedAd();
|
|
3291
|
-
if (nextPreloaded) {
|
|
3292
|
-
_this.currentAdIndex++;
|
|
3293
|
-
_this.playSingleAd(nextPreloaded).catch(function() {
|
|
3294
|
-
_this.handleAdFailure();
|
|
3295
|
-
});
|
|
3296
|
-
} else {
|
|
3297
|
-
_this.handleAdFailure();
|
|
3298
|
-
}
|
|
3299
|
-
} else {
|
|
3300
|
-
_this.handleAdFailure();
|
|
3301
|
-
}
|
|
3302
|
-
} else {
|
|
3303
|
-
_this.handleAdFailure();
|
|
3304
|
-
}
|
|
3126
|
+
_this.handleAdFailure();
|
|
3305
3127
|
});
|
|
3306
3128
|
this.ima.on("content_pause", function() {
|
|
3307
3129
|
_this.clearAdFailsafeTimer();
|
|
@@ -4032,7 +3854,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4032
3854
|
key: "handleAdStart",
|
|
4033
3855
|
value: function handleAdStart(_marker) {
|
|
4034
3856
|
return _async_to_generator(function() {
|
|
4035
|
-
var scheduled, tags, baseVastUrl, adBreakDurationMs, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
3857
|
+
var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
4036
3858
|
return _ts_generator(this, function(_state) {
|
|
4037
3859
|
switch(_state.label){
|
|
4038
3860
|
case 0:
|
|
@@ -4048,35 +3870,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4048
3870
|
];
|
|
4049
3871
|
}
|
|
4050
3872
|
adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
|
|
4051
|
-
if (this.
|
|
4052
|
-
this.
|
|
4053
|
-
|
|
4054
|
-
this.fetchedAdDurations.clear();
|
|
4055
|
-
if (this.config.debugAdTiming) {
|
|
4056
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA LIVE MODE: Target duration=".concat(adBreakDurationMs, "ms | Will continuously fetch ads during break"));
|
|
4057
|
-
}
|
|
4058
|
-
} else {
|
|
4059
|
-
this.isAdaptiveMode = false;
|
|
4060
|
-
this.targetAdBreakDurationMs = null;
|
|
4061
|
-
this.fetchedAdDurations.clear();
|
|
4062
|
-
if (this.config.debugAdTiming) {
|
|
4063
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC VOD MODE: Using fixed ad strategy");
|
|
4064
|
-
}
|
|
3873
|
+
if (this.config.debugAdTiming) {
|
|
3874
|
+
mode = this.isLiveStream ? "LIVE" : "VOD";
|
|
3875
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
4065
3876
|
}
|
|
4066
|
-
this.adPodAllUrls = [];
|
|
4067
|
-
this.preloadingAdUrls.clear();
|
|
4068
|
-
this.vastToMediaUrlMap.clear();
|
|
4069
|
-
this.preloadedMediaUrls.clear();
|
|
4070
|
-
this.preloadingMediaUrls.clear();
|
|
4071
3877
|
this.failedVastUrls.clear();
|
|
4072
3878
|
this.adRequestQueue = [];
|
|
4073
|
-
this.successfulAdRequests = [];
|
|
4074
3879
|
this.continuousFetchingActive = true;
|
|
4075
3880
|
this.isShowingPlaceholder = false;
|
|
4076
|
-
this.placeholderStartTimeMs = null;
|
|
4077
|
-
this.consecutiveEmptyResponses = 0;
|
|
4078
3881
|
this.totalAdRequestsInBreak = 0;
|
|
4079
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
4080
3882
|
currentMuted = this.video.muted;
|
|
4081
3883
|
currentVolume = this.video.volume;
|
|
4082
3884
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
@@ -4122,7 +3924,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4122
3924
|
if (this.config.debugAdTiming) {
|
|
4123
3925
|
console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
|
|
4124
3926
|
}
|
|
4125
|
-
this.successfulAdRequests.push(firstAdUrl);
|
|
4126
3927
|
this.currentAdIndex++;
|
|
4127
3928
|
this.startContinuousFetching(baseVastUrl);
|
|
4128
3929
|
return [
|
|
@@ -4172,200 +3973,92 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4172
3973
|
key: "continuousFetchLoop",
|
|
4173
3974
|
value: function continuousFetchLoop(baseVastUrl) {
|
|
4174
3975
|
return _async_to_generator(function() {
|
|
4175
|
-
var
|
|
3976
|
+
var remaining, maxQueueSize, newAdUrl;
|
|
4176
3977
|
return _ts_generator(this, function(_state) {
|
|
4177
3978
|
switch(_state.label){
|
|
4178
3979
|
case 0:
|
|
4179
|
-
_loop = function() {
|
|
4180
|
-
var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
|
|
4181
|
-
return _ts_generator(this, function(_state) {
|
|
4182
|
-
switch(_state.label){
|
|
4183
|
-
case 0:
|
|
4184
|
-
remaining = _this.getRemainingAdMs();
|
|
4185
|
-
if (remaining <= 0) {
|
|
4186
|
-
if (_this.config.debugAdTiming) {
|
|
4187
|
-
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
|
|
4188
|
-
}
|
|
4189
|
-
return [
|
|
4190
|
-
2,
|
|
4191
|
-
"break"
|
|
4192
|
-
];
|
|
4193
|
-
}
|
|
4194
|
-
if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
|
|
4195
|
-
if (_this.config.debugAdTiming) {
|
|
4196
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
|
|
4197
|
-
}
|
|
4198
|
-
return [
|
|
4199
|
-
2,
|
|
4200
|
-
"break"
|
|
4201
|
-
];
|
|
4202
|
-
}
|
|
4203
|
-
if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
|
|
4204
|
-
if (_this.config.debugAdTiming) {
|
|
4205
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
|
|
4206
|
-
}
|
|
4207
|
-
return [
|
|
4208
|
-
2,
|
|
4209
|
-
"break"
|
|
4210
|
-
];
|
|
4211
|
-
}
|
|
4212
|
-
maxQueueSize = 3;
|
|
4213
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4214
|
-
3,
|
|
4215
|
-
2
|
|
4216
|
-
];
|
|
4217
|
-
if (_this.config.debugAdTiming) {
|
|
4218
|
-
console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
|
|
4219
|
-
}
|
|
4220
|
-
return [
|
|
4221
|
-
4,
|
|
4222
|
-
new Promise(function(resolve) {
|
|
4223
|
-
return setTimeout(resolve, 2e3);
|
|
4224
|
-
})
|
|
4225
|
-
];
|
|
4226
|
-
case 1:
|
|
4227
|
-
_state.sent();
|
|
4228
|
-
return [
|
|
4229
|
-
2,
|
|
4230
|
-
"continue"
|
|
4231
|
-
];
|
|
4232
|
-
case 2:
|
|
4233
|
-
newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4234
|
-
if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
|
|
4235
|
-
3,
|
|
4236
|
-
4
|
|
4237
|
-
];
|
|
4238
|
-
return [
|
|
4239
|
-
4,
|
|
4240
|
-
new Promise(function(resolve) {
|
|
4241
|
-
return setTimeout(resolve, 1e3);
|
|
4242
|
-
})
|
|
4243
|
-
];
|
|
4244
|
-
case 3:
|
|
4245
|
-
_state.sent();
|
|
4246
|
-
return [
|
|
4247
|
-
2,
|
|
4248
|
-
"continue"
|
|
4249
|
-
];
|
|
4250
|
-
case 4:
|
|
4251
|
-
_this.totalAdRequestsInBreak++;
|
|
4252
|
-
if (_this.config.debugAdTiming) {
|
|
4253
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
|
|
4254
|
-
}
|
|
4255
|
-
_state.label = 5;
|
|
4256
|
-
case 5:
|
|
4257
|
-
_state.trys.push([
|
|
4258
|
-
5,
|
|
4259
|
-
11,
|
|
4260
|
-
,
|
|
4261
|
-
13
|
|
4262
|
-
]);
|
|
4263
|
-
if (!_this.ima.preloadAds) return [
|
|
4264
|
-
3,
|
|
4265
|
-
7
|
|
4266
|
-
];
|
|
4267
|
-
return [
|
|
4268
|
-
4,
|
|
4269
|
-
_this.ima.preloadAds(newAdUrl)
|
|
4270
|
-
];
|
|
4271
|
-
case 6:
|
|
4272
|
-
_state.sent();
|
|
4273
|
-
_state.label = 7;
|
|
4274
|
-
case 7:
|
|
4275
|
-
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;
|
|
4276
|
-
if (!!hasPreloadedAd) return [
|
|
4277
|
-
3,
|
|
4278
|
-
9
|
|
4279
|
-
];
|
|
4280
|
-
_this.consecutiveEmptyResponses++;
|
|
4281
|
-
_this.lastEmptyResponseTimeMs = Date.now();
|
|
4282
|
-
backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4283
|
-
if (_this.config.debugAdTiming) {
|
|
4284
|
-
console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
|
|
4285
|
-
}
|
|
4286
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4287
|
-
return [
|
|
4288
|
-
4,
|
|
4289
|
-
new Promise(function(resolve) {
|
|
4290
|
-
return setTimeout(resolve, backoffDelay);
|
|
4291
|
-
})
|
|
4292
|
-
];
|
|
4293
|
-
case 8:
|
|
4294
|
-
_state.sent();
|
|
4295
|
-
return [
|
|
4296
|
-
2,
|
|
4297
|
-
"continue"
|
|
4298
|
-
];
|
|
4299
|
-
case 9:
|
|
4300
|
-
_this.consecutiveEmptyResponses = 0;
|
|
4301
|
-
if (_this.config.debugAdTiming) {
|
|
4302
|
-
console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
|
|
4303
|
-
}
|
|
4304
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
4305
|
-
_this.totalAdsInBreak++;
|
|
4306
|
-
return [
|
|
4307
|
-
4,
|
|
4308
|
-
new Promise(function(resolve) {
|
|
4309
|
-
return setTimeout(resolve, 500);
|
|
4310
|
-
})
|
|
4311
|
-
];
|
|
4312
|
-
case 10:
|
|
4313
|
-
_state.sent();
|
|
4314
|
-
return [
|
|
4315
|
-
3,
|
|
4316
|
-
13
|
|
4317
|
-
];
|
|
4318
|
-
case 11:
|
|
4319
|
-
error = _state.sent();
|
|
4320
|
-
if (_this.config.debugAdTiming) {
|
|
4321
|
-
console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
|
|
4322
|
-
}
|
|
4323
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4324
|
-
_this.consecutiveEmptyResponses++;
|
|
4325
|
-
backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4326
|
-
return [
|
|
4327
|
-
4,
|
|
4328
|
-
new Promise(function(resolve) {
|
|
4329
|
-
return setTimeout(resolve, backoffDelay1);
|
|
4330
|
-
})
|
|
4331
|
-
];
|
|
4332
|
-
case 12:
|
|
4333
|
-
_state.sent();
|
|
4334
|
-
return [
|
|
4335
|
-
3,
|
|
4336
|
-
13
|
|
4337
|
-
];
|
|
4338
|
-
case 13:
|
|
4339
|
-
return [
|
|
4340
|
-
2
|
|
4341
|
-
];
|
|
4342
|
-
}
|
|
4343
|
-
});
|
|
4344
|
-
};
|
|
4345
|
-
_state.label = 1;
|
|
4346
|
-
case 1:
|
|
4347
3980
|
if (!(this.continuousFetchingActive && this.inAdBreak)) return [
|
|
4348
3981
|
3,
|
|
4349
|
-
|
|
3982
|
+
6
|
|
3983
|
+
];
|
|
3984
|
+
remaining = this.getRemainingAdMs();
|
|
3985
|
+
if (remaining <= 0) {
|
|
3986
|
+
if (this.config.debugAdTiming) {
|
|
3987
|
+
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping URL generation");
|
|
3988
|
+
}
|
|
3989
|
+
return [
|
|
3990
|
+
3,
|
|
3991
|
+
6
|
|
3992
|
+
];
|
|
3993
|
+
}
|
|
3994
|
+
if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
|
|
3995
|
+
if (this.config.debugAdTiming) {
|
|
3996
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(this.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
3997
|
+
}
|
|
3998
|
+
return [
|
|
3999
|
+
3,
|
|
4000
|
+
6
|
|
4001
|
+
];
|
|
4002
|
+
}
|
|
4003
|
+
maxQueueSize = 5;
|
|
4004
|
+
if (!(this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4005
|
+
3,
|
|
4006
|
+
2
|
|
4350
4007
|
];
|
|
4351
|
-
|
|
4008
|
+
if (this.config.debugAdTiming) {
|
|
4009
|
+
console.log("[CONTINUOUS-FETCH] ⏸️ URL queue full (".concat(this.adRequestQueue.length, "), waiting..."));
|
|
4010
|
+
}
|
|
4352
4011
|
return [
|
|
4353
|
-
|
|
4354
|
-
|
|
4012
|
+
4,
|
|
4013
|
+
new Promise(function(resolve) {
|
|
4014
|
+
return setTimeout(resolve, 1e3);
|
|
4015
|
+
})
|
|
4016
|
+
];
|
|
4017
|
+
case 1:
|
|
4018
|
+
_state.sent();
|
|
4019
|
+
return [
|
|
4020
|
+
3,
|
|
4021
|
+
0
|
|
4355
4022
|
];
|
|
4356
4023
|
case 2:
|
|
4357
|
-
|
|
4358
|
-
if (
|
|
4024
|
+
newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4025
|
+
if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
|
|
4026
|
+
3,
|
|
4027
|
+
4
|
|
4028
|
+
];
|
|
4029
|
+
return [
|
|
4030
|
+
4,
|
|
4031
|
+
new Promise(function(resolve) {
|
|
4032
|
+
return setTimeout(resolve, 500);
|
|
4033
|
+
})
|
|
4034
|
+
];
|
|
4035
|
+
case 3:
|
|
4036
|
+
_state.sent();
|
|
4037
|
+
return [
|
|
4359
4038
|
3,
|
|
4360
|
-
|
|
4039
|
+
0
|
|
4040
|
+
];
|
|
4041
|
+
case 4:
|
|
4042
|
+
if (this.config.debugAdTiming) {
|
|
4043
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCDD Queued VAST URL (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
|
|
4044
|
+
}
|
|
4045
|
+
this.adRequestQueue.push(newAdUrl);
|
|
4046
|
+
this.totalAdsInBreak++;
|
|
4047
|
+
return [
|
|
4048
|
+
4,
|
|
4049
|
+
new Promise(function(resolve) {
|
|
4050
|
+
return setTimeout(resolve, 300);
|
|
4051
|
+
})
|
|
4361
4052
|
];
|
|
4053
|
+
case 5:
|
|
4054
|
+
_state.sent();
|
|
4362
4055
|
return [
|
|
4363
4056
|
3,
|
|
4364
|
-
|
|
4057
|
+
0
|
|
4365
4058
|
];
|
|
4366
|
-
case
|
|
4059
|
+
case 6:
|
|
4367
4060
|
if (this.config.debugAdTiming) {
|
|
4368
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1
|
|
4061
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"));
|
|
4369
4062
|
}
|
|
4370
4063
|
return [
|
|
4371
4064
|
2
|
|
@@ -4414,19 +4107,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4414
4107
|
2
|
|
4415
4108
|
];
|
|
4416
4109
|
if (this.config.debugAdTiming) {
|
|
4417
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC
|
|
4110
|
+
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)"));
|
|
4418
4111
|
}
|
|
4419
4112
|
currentMuted = this.video.muted;
|
|
4420
4113
|
currentVolume = this.video.volume;
|
|
4421
4114
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
4422
|
-
if (this.config.debugAdTiming) {
|
|
4423
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDD0A Updated ad audio state: muted=".concat(currentMuted, ", volume=").concat(currentVolume));
|
|
4424
|
-
}
|
|
4425
4115
|
this.currentAdIndex++;
|
|
4426
|
-
this.
|
|
4116
|
+
this.totalAdRequestsInBreak++;
|
|
4427
4117
|
return [
|
|
4428
4118
|
4,
|
|
4429
|
-
this.playSingleAd(nextAdUrl).catch(function() {
|
|
4119
|
+
this.playSingleAd(nextAdUrl).catch(function(error) {
|
|
4120
|
+
if (_this.config.debugAdTiming) {
|
|
4121
|
+
console.log("[CONTINUOUS-FETCH] \u274C Ad request failed:", error.message);
|
|
4122
|
+
}
|
|
4123
|
+
_this.failedVastUrls.add(nextAdUrl);
|
|
4430
4124
|
_this.tryNextAvailableAd(0);
|
|
4431
4125
|
})
|
|
4432
4126
|
];
|
|
@@ -4436,18 +4130,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4436
4130
|
2
|
|
4437
4131
|
];
|
|
4438
4132
|
case 2:
|
|
4439
|
-
maxRetries =
|
|
4133
|
+
maxRetries = 3;
|
|
4440
4134
|
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
4441
4135
|
3,
|
|
4442
4136
|
5
|
|
4443
4137
|
];
|
|
4444
4138
|
if (this.config.debugAdTiming) {
|
|
4445
|
-
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty
|
|
4139
|
+
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
4446
4140
|
}
|
|
4447
4141
|
return [
|
|
4448
4142
|
4,
|
|
4449
4143
|
new Promise(function(resolve) {
|
|
4450
|
-
return setTimeout(resolve,
|
|
4144
|
+
return setTimeout(resolve, 500);
|
|
4451
4145
|
})
|
|
4452
4146
|
];
|
|
4453
4147
|
case 3:
|
|
@@ -4496,12 +4190,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4496
4190
|
];
|
|
4497
4191
|
}
|
|
4498
4192
|
if (this.config.debugAdTiming) {
|
|
4499
|
-
console.log("[CONTINUOUS-FETCH] ⬛ Showing
|
|
4193
|
+
console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad URLs"));
|
|
4500
4194
|
}
|
|
4501
4195
|
this.isShowingPlaceholder = true;
|
|
4502
|
-
this.placeholderStartTimeMs = Date.now();
|
|
4503
4196
|
this.ima.showPlaceholder();
|
|
4504
|
-
checkInterval =
|
|
4197
|
+
checkInterval = 300;
|
|
4505
4198
|
maxChecks = Math.floor(waitTime / checkInterval);
|
|
4506
4199
|
i = 0;
|
|
4507
4200
|
_state.label = 1;
|
|
@@ -4528,10 +4221,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4528
4221
|
5
|
|
4529
4222
|
];
|
|
4530
4223
|
if (this.config.debugAdTiming) {
|
|
4531
|
-
console.log("[CONTINUOUS-FETCH] \u2705
|
|
4224
|
+
console.log("[CONTINUOUS-FETCH] \u2705 Ad URL available, requesting via IMA SDK");
|
|
4532
4225
|
}
|
|
4533
4226
|
this.isShowingPlaceholder = false;
|
|
4534
|
-
this.placeholderStartTimeMs = null;
|
|
4535
4227
|
this.ima.hidePlaceholder();
|
|
4536
4228
|
currentMuted = this.video.muted;
|
|
4537
4229
|
currentVolume = this.video.volume;
|
|
@@ -4542,7 +4234,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4542
4234
|
4
|
|
4543
4235
|
];
|
|
4544
4236
|
this.currentAdIndex++;
|
|
4545
|
-
this.
|
|
4237
|
+
this.totalAdRequestsInBreak++;
|
|
4546
4238
|
return [
|
|
4547
4239
|
4,
|
|
4548
4240
|
this.playSingleAd(nextAdUrl).catch(function() {
|
|
@@ -4564,10 +4256,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4564
4256
|
];
|
|
4565
4257
|
case 6:
|
|
4566
4258
|
if (this.config.debugAdTiming) {
|
|
4567
|
-
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout
|
|
4259
|
+
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
|
|
4568
4260
|
}
|
|
4569
4261
|
this.isShowingPlaceholder = false;
|
|
4570
|
-
this.placeholderStartTimeMs = null;
|
|
4571
4262
|
this.ima.hidePlaceholder();
|
|
4572
4263
|
this.handleAdPodComplete();
|
|
4573
4264
|
return [
|
|
@@ -4869,21 +4560,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4869
4560
|
if (this.isShowingPlaceholder) {
|
|
4870
4561
|
this.ima.hidePlaceholder();
|
|
4871
4562
|
this.isShowingPlaceholder = false;
|
|
4872
|
-
this.placeholderStartTimeMs = null;
|
|
4873
4563
|
}
|
|
4874
|
-
this.preloadingAdUrls.clear();
|
|
4875
|
-
this.vastToMediaUrlMap.clear();
|
|
4876
|
-
this.preloadedMediaUrls.clear();
|
|
4877
|
-
this.preloadingMediaUrls.clear();
|
|
4878
4564
|
this.adRequestQueue = [];
|
|
4879
|
-
this.successfulAdRequests = [];
|
|
4880
4565
|
this.inAdBreak = false;
|
|
4881
4566
|
this.expectedAdBreakDurationMs = void 0;
|
|
4882
4567
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
4883
4568
|
this.clearAdStartTimer();
|
|
4884
4569
|
this.clearAdStopTimer();
|
|
4885
4570
|
this.adPodQueue = [];
|
|
4886
|
-
this.adPodAllUrls = [];
|
|
4887
4571
|
this.showAds = false;
|
|
4888
4572
|
this.currentAdIndex = 0;
|
|
4889
4573
|
this.totalAdsInBreak = 0;
|
|
@@ -5038,651 +4722,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5038
4722
|
}, extra));
|
|
5039
4723
|
}
|
|
5040
4724
|
},
|
|
5041
|
-
{
|
|
5042
|
-
key: "fetchAndParseVastXml",
|
|
5043
|
-
value: function fetchAndParseVastXml(vastTagUrl) {
|
|
5044
|
-
return _async_to_generator(function() {
|
|
5045
|
-
var response, xmlText, error;
|
|
5046
|
-
return _ts_generator(this, function(_state) {
|
|
5047
|
-
switch(_state.label){
|
|
5048
|
-
case 0:
|
|
5049
|
-
_state.trys.push([
|
|
5050
|
-
0,
|
|
5051
|
-
3,
|
|
5052
|
-
,
|
|
5053
|
-
4
|
|
5054
|
-
]);
|
|
5055
|
-
return [
|
|
5056
|
-
4,
|
|
5057
|
-
fetch(vastTagUrl, {
|
|
5058
|
-
mode: "cors",
|
|
5059
|
-
credentials: "include",
|
|
5060
|
-
headers: {
|
|
5061
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5062
|
-
},
|
|
5063
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5064
|
-
})
|
|
5065
|
-
];
|
|
5066
|
-
case 1:
|
|
5067
|
-
response = _state.sent();
|
|
5068
|
-
if (!response.ok) {
|
|
5069
|
-
throw new Error("Failed to fetch VAST: ".concat(response.status));
|
|
5070
|
-
}
|
|
5071
|
-
return [
|
|
5072
|
-
4,
|
|
5073
|
-
response.text()
|
|
5074
|
-
];
|
|
5075
|
-
case 2:
|
|
5076
|
-
xmlText = _state.sent();
|
|
5077
|
-
return [
|
|
5078
|
-
2,
|
|
5079
|
-
this.extractMediaUrlsFromVast(xmlText)
|
|
5080
|
-
];
|
|
5081
|
-
case 3:
|
|
5082
|
-
error = _state.sent();
|
|
5083
|
-
if (this.config.debugAdTiming) {
|
|
5084
|
-
console.warn("[StormcloudVideoPlayer] Failed to fetch/parse VAST XML: ".concat(vastTagUrl), error);
|
|
5085
|
-
}
|
|
5086
|
-
return [
|
|
5087
|
-
2,
|
|
5088
|
-
[]
|
|
5089
|
-
];
|
|
5090
|
-
case 4:
|
|
5091
|
-
return [
|
|
5092
|
-
2
|
|
5093
|
-
];
|
|
5094
|
-
}
|
|
5095
|
-
});
|
|
5096
|
-
}).call(this);
|
|
5097
|
-
}
|
|
5098
|
-
},
|
|
5099
|
-
{
|
|
5100
|
-
key: "extractMediaUrlsFromVast",
|
|
5101
|
-
value: function extractMediaUrlsFromVast(xmlText) {
|
|
5102
|
-
var mediaUrls = [];
|
|
5103
|
-
try {
|
|
5104
|
-
var parser = new DOMParser();
|
|
5105
|
-
var xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5106
|
-
var mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
|
|
5107
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5108
|
-
try {
|
|
5109
|
-
for(var _iterator = Array.from(mediaFileElements)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5110
|
-
var mediaFile = _step.value;
|
|
5111
|
-
var _mediaFile_textContent;
|
|
5112
|
-
var url = (_mediaFile_textContent = mediaFile.textContent) === null || _mediaFile_textContent === void 0 ? void 0 : _mediaFile_textContent.trim();
|
|
5113
|
-
if (url) {
|
|
5114
|
-
var lowerUrl = url.toLowerCase();
|
|
5115
|
-
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")) {
|
|
5116
|
-
mediaUrls.push(url);
|
|
5117
|
-
}
|
|
5118
|
-
}
|
|
5119
|
-
}
|
|
5120
|
-
} catch (err) {
|
|
5121
|
-
_didIteratorError = true;
|
|
5122
|
-
_iteratorError = err;
|
|
5123
|
-
} finally{
|
|
5124
|
-
try {
|
|
5125
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5126
|
-
_iterator.return();
|
|
5127
|
-
}
|
|
5128
|
-
} finally{
|
|
5129
|
-
if (_didIteratorError) {
|
|
5130
|
-
throw _iteratorError;
|
|
5131
|
-
}
|
|
5132
|
-
}
|
|
5133
|
-
}
|
|
5134
|
-
if (this.config.debugAdTiming && mediaUrls.length > 0) {
|
|
5135
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs from VAST:"), mediaUrls);
|
|
5136
|
-
}
|
|
5137
|
-
} catch (error) {
|
|
5138
|
-
if (this.config.debugAdTiming) {
|
|
5139
|
-
console.warn("[StormcloudVideoPlayer] Failed to parse VAST XML:", error);
|
|
5140
|
-
}
|
|
5141
|
-
}
|
|
5142
|
-
return mediaUrls;
|
|
5143
|
-
}
|
|
5144
|
-
},
|
|
5145
|
-
{
|
|
5146
|
-
key: "fetchVastDuration",
|
|
5147
|
-
value: function fetchVastDuration(vastTagUrl) {
|
|
5148
|
-
return _async_to_generator(function() {
|
|
5149
|
-
var _xmlDoc_querySelector, response, xmlText, parser, xmlDoc, durationText, durationParts, durationSeconds, error;
|
|
5150
|
-
return _ts_generator(this, function(_state) {
|
|
5151
|
-
switch(_state.label){
|
|
5152
|
-
case 0:
|
|
5153
|
-
_state.trys.push([
|
|
5154
|
-
0,
|
|
5155
|
-
3,
|
|
5156
|
-
,
|
|
5157
|
-
4
|
|
5158
|
-
]);
|
|
5159
|
-
return [
|
|
5160
|
-
4,
|
|
5161
|
-
fetch(vastTagUrl, {
|
|
5162
|
-
mode: "cors",
|
|
5163
|
-
credentials: "include",
|
|
5164
|
-
headers: {
|
|
5165
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5166
|
-
},
|
|
5167
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5168
|
-
})
|
|
5169
|
-
];
|
|
5170
|
-
case 1:
|
|
5171
|
-
response = _state.sent();
|
|
5172
|
-
if (!response.ok) {
|
|
5173
|
-
if (this.config.debugAdTiming) {
|
|
5174
|
-
console.warn("[ADAPTIVE-POD] Failed to fetch VAST: ".concat(response.status));
|
|
5175
|
-
}
|
|
5176
|
-
return [
|
|
5177
|
-
2,
|
|
5178
|
-
null
|
|
5179
|
-
];
|
|
5180
|
-
}
|
|
5181
|
-
return [
|
|
5182
|
-
4,
|
|
5183
|
-
response.text()
|
|
5184
|
-
];
|
|
5185
|
-
case 2:
|
|
5186
|
-
xmlText = _state.sent();
|
|
5187
|
-
parser = new DOMParser();
|
|
5188
|
-
xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5189
|
-
durationText = (_xmlDoc_querySelector = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector === void 0 ? void 0 : _xmlDoc_querySelector.textContent;
|
|
5190
|
-
if (!durationText) {
|
|
5191
|
-
if (this.config.debugAdTiming) {
|
|
5192
|
-
console.warn("[ADAPTIVE-POD] No Duration element found in VAST");
|
|
5193
|
-
}
|
|
5194
|
-
return [
|
|
5195
|
-
2,
|
|
5196
|
-
null
|
|
5197
|
-
];
|
|
5198
|
-
}
|
|
5199
|
-
durationParts = durationText.split(":");
|
|
5200
|
-
durationSeconds = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
5201
|
-
return [
|
|
5202
|
-
2,
|
|
5203
|
-
durationSeconds
|
|
5204
|
-
];
|
|
5205
|
-
case 3:
|
|
5206
|
-
error = _state.sent();
|
|
5207
|
-
if (this.config.debugAdTiming) {
|
|
5208
|
-
console.warn("[ADAPTIVE-POD] Error fetching VAST duration from ".concat(vastTagUrl, ":"), error);
|
|
5209
|
-
}
|
|
5210
|
-
return [
|
|
5211
|
-
2,
|
|
5212
|
-
null
|
|
5213
|
-
];
|
|
5214
|
-
case 4:
|
|
5215
|
-
return [
|
|
5216
|
-
2
|
|
5217
|
-
];
|
|
5218
|
-
}
|
|
5219
|
-
});
|
|
5220
|
-
}).call(this);
|
|
5221
|
-
}
|
|
5222
|
-
},
|
|
5223
|
-
{
|
|
5224
|
-
key: "calculateAdditionalAdsNeeded",
|
|
5225
|
-
value: function calculateAdditionalAdsNeeded() {
|
|
5226
|
-
if (!this.isAdaptiveMode || this.targetAdBreakDurationMs === null) {
|
|
5227
|
-
return 0;
|
|
5228
|
-
}
|
|
5229
|
-
var totalFetchedDurationMs = 0;
|
|
5230
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5231
|
-
try {
|
|
5232
|
-
for(var _iterator = this.fetchedAdDurations.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5233
|
-
var duration = _step.value;
|
|
5234
|
-
totalFetchedDurationMs += duration * 1e3;
|
|
5235
|
-
}
|
|
5236
|
-
} catch (err) {
|
|
5237
|
-
_didIteratorError = true;
|
|
5238
|
-
_iteratorError = err;
|
|
5239
|
-
} finally{
|
|
5240
|
-
try {
|
|
5241
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5242
|
-
_iterator.return();
|
|
5243
|
-
}
|
|
5244
|
-
} finally{
|
|
5245
|
-
if (_didIteratorError) {
|
|
5246
|
-
throw _iteratorError;
|
|
5247
|
-
}
|
|
5248
|
-
}
|
|
5249
|
-
}
|
|
5250
|
-
var fetchedCount = this.fetchedAdDurations.size;
|
|
5251
|
-
var averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
5252
|
-
var queuedButNotFetched = this.adPodAllUrls.length - fetchedCount;
|
|
5253
|
-
var estimatedQueuedDurationMs = queuedButNotFetched * averageDurationMs;
|
|
5254
|
-
var estimatedTotalDurationMs = totalFetchedDurationMs + estimatedQueuedDurationMs;
|
|
5255
|
-
var remainingTimeMs = this.targetAdBreakDurationMs - estimatedTotalDurationMs;
|
|
5256
|
-
if (remainingTimeMs <= 0) {
|
|
5257
|
-
if (this.config.debugAdTiming) {
|
|
5258
|
-
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"));
|
|
5259
|
-
}
|
|
5260
|
-
return 0;
|
|
5261
|
-
}
|
|
5262
|
-
var additionalAds = Math.ceil(remainingTimeMs / averageDurationMs);
|
|
5263
|
-
if (this.config.debugAdTiming) {
|
|
5264
|
-
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"));
|
|
5265
|
-
}
|
|
5266
|
-
return additionalAds;
|
|
5267
|
-
}
|
|
5268
|
-
},
|
|
5269
|
-
{
|
|
5270
|
-
key: "addAdaptiveAdsToQueue",
|
|
5271
|
-
value: function addAdaptiveAdsToQueue() {
|
|
5272
|
-
return _async_to_generator(function() {
|
|
5273
|
-
var _this_adPodAllUrls, _this_adPodQueue, additionalAds, newUrls;
|
|
5274
|
-
return _ts_generator(this, function(_state) {
|
|
5275
|
-
if (!this.isAdaptiveMode || !this.apiVastTagUrl) {
|
|
5276
|
-
return [
|
|
5277
|
-
2
|
|
5278
|
-
];
|
|
5279
|
-
}
|
|
5280
|
-
additionalAds = this.calculateAdditionalAdsNeeded();
|
|
5281
|
-
if (additionalAds <= 0) {
|
|
5282
|
-
return [
|
|
5283
|
-
2
|
|
5284
|
-
];
|
|
5285
|
-
}
|
|
5286
|
-
newUrls = this.generateVastUrlsWithCorrelators(this.apiVastTagUrl, additionalAds);
|
|
5287
|
-
if (this.config.debugAdTiming) {
|
|
5288
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Adding ".concat(newUrls.length, " additional VAST URLs to queue (will be preloaded sequentially)"));
|
|
5289
|
-
}
|
|
5290
|
-
(_this_adPodAllUrls = this.adPodAllUrls).push.apply(_this_adPodAllUrls, _to_consumable_array(newUrls));
|
|
5291
|
-
(_this_adPodQueue = this.adPodQueue).push.apply(_this_adPodQueue, _to_consumable_array(newUrls));
|
|
5292
|
-
this.totalAdsInBreak += newUrls.length;
|
|
5293
|
-
return [
|
|
5294
|
-
2
|
|
5295
|
-
];
|
|
5296
|
-
});
|
|
5297
|
-
}).call(this);
|
|
5298
|
-
}
|
|
5299
|
-
},
|
|
5300
|
-
{
|
|
5301
|
-
key: "preloadMediaFile",
|
|
5302
|
-
value: function preloadMediaFile(mediaUrl) {
|
|
5303
|
-
return _async_to_generator(function() {
|
|
5304
|
-
var response, error;
|
|
5305
|
-
return _ts_generator(this, function(_state) {
|
|
5306
|
-
switch(_state.label){
|
|
5307
|
-
case 0:
|
|
5308
|
-
if (this.preloadedMediaUrls.has(mediaUrl)) {
|
|
5309
|
-
return [
|
|
5310
|
-
2
|
|
5311
|
-
];
|
|
5312
|
-
}
|
|
5313
|
-
if (this.preloadingMediaUrls.has(mediaUrl)) {
|
|
5314
|
-
return [
|
|
5315
|
-
2
|
|
5316
|
-
];
|
|
5317
|
-
}
|
|
5318
|
-
this.preloadingMediaUrls.add(mediaUrl);
|
|
5319
|
-
_state.label = 1;
|
|
5320
|
-
case 1:
|
|
5321
|
-
_state.trys.push([
|
|
5322
|
-
1,
|
|
5323
|
-
3,
|
|
5324
|
-
4,
|
|
5325
|
-
5
|
|
5326
|
-
]);
|
|
5327
|
-
if (this.config.debugAdTiming) {
|
|
5328
|
-
console.log("[StormcloudVideoPlayer] Preloading video file: ".concat(mediaUrl));
|
|
5329
|
-
}
|
|
5330
|
-
return [
|
|
5331
|
-
4,
|
|
5332
|
-
fetch(mediaUrl, {
|
|
5333
|
-
mode: "cors",
|
|
5334
|
-
credentials: "include",
|
|
5335
|
-
method: "GET",
|
|
5336
|
-
headers: {
|
|
5337
|
-
Range: "bytes=0-1048576"
|
|
5338
|
-
},
|
|
5339
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5340
|
-
})
|
|
5341
|
-
];
|
|
5342
|
-
case 2:
|
|
5343
|
-
response = _state.sent();
|
|
5344
|
-
if (response.ok || response.status === 206) {
|
|
5345
|
-
this.preloadedMediaUrls.add(mediaUrl);
|
|
5346
|
-
if (this.config.debugAdTiming) {
|
|
5347
|
-
console.log("[StormcloudVideoPlayer] Successfully preloaded video file: ".concat(mediaUrl));
|
|
5348
|
-
}
|
|
5349
|
-
}
|
|
5350
|
-
return [
|
|
5351
|
-
3,
|
|
5352
|
-
5
|
|
5353
|
-
];
|
|
5354
|
-
case 3:
|
|
5355
|
-
error = _state.sent();
|
|
5356
|
-
if (this.config.debugAdTiming) {
|
|
5357
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload video file: ".concat(mediaUrl), error);
|
|
5358
|
-
}
|
|
5359
|
-
return [
|
|
5360
|
-
3,
|
|
5361
|
-
5
|
|
5362
|
-
];
|
|
5363
|
-
case 4:
|
|
5364
|
-
this.preloadingMediaUrls.delete(mediaUrl);
|
|
5365
|
-
return [
|
|
5366
|
-
7
|
|
5367
|
-
];
|
|
5368
|
-
case 5:
|
|
5369
|
-
return [
|
|
5370
|
-
2
|
|
5371
|
-
];
|
|
5372
|
-
}
|
|
5373
|
-
});
|
|
5374
|
-
}).call(this);
|
|
5375
|
-
}
|
|
5376
|
-
},
|
|
5377
|
-
{
|
|
5378
|
-
key: "preloadAllAdsInBackground",
|
|
5379
|
-
value: function preloadAllAdsInBackground() {
|
|
5380
|
-
return _async_to_generator(function() {
|
|
5381
|
-
var _this, processedUrls, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, _this_ima_hasPreloadedAd, _this_ima, nextUrl, error, preloadPromises;
|
|
5382
|
-
return _ts_generator(this, function(_state) {
|
|
5383
|
-
switch(_state.label){
|
|
5384
|
-
case 0:
|
|
5385
|
-
_this = this;
|
|
5386
|
-
if (this.adPodAllUrls.length === 0) {
|
|
5387
|
-
return [
|
|
5388
|
-
2
|
|
5389
|
-
];
|
|
5390
|
-
}
|
|
5391
|
-
if (!this.isAdaptiveMode) return [
|
|
5392
|
-
3,
|
|
5393
|
-
7
|
|
5394
|
-
];
|
|
5395
|
-
if (this.config.debugAdTiming) {
|
|
5396
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Starting sequential preload of remaining ads");
|
|
5397
|
-
}
|
|
5398
|
-
processedUrls = /* @__PURE__ */ new Set();
|
|
5399
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5400
|
-
try {
|
|
5401
|
-
for(_iterator = this.adPodAllUrls[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5402
|
-
url = _step.value;
|
|
5403
|
-
;
|
|
5404
|
-
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)) {
|
|
5405
|
-
processedUrls.add(url);
|
|
5406
|
-
}
|
|
5407
|
-
}
|
|
5408
|
-
} catch (err) {
|
|
5409
|
-
_didIteratorError = true;
|
|
5410
|
-
_iteratorError = err;
|
|
5411
|
-
} finally{
|
|
5412
|
-
try {
|
|
5413
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5414
|
-
_iterator.return();
|
|
5415
|
-
}
|
|
5416
|
-
} finally{
|
|
5417
|
-
if (_didIteratorError) {
|
|
5418
|
-
throw _iteratorError;
|
|
5419
|
-
}
|
|
5420
|
-
}
|
|
5421
|
-
}
|
|
5422
|
-
if (this.config.debugAdTiming && processedUrls.size > 0) {
|
|
5423
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE6 Skipping ".concat(processedUrls.size, " already-preloaded ads"));
|
|
5424
|
-
}
|
|
5425
|
-
_state.label = 1;
|
|
5426
|
-
case 1:
|
|
5427
|
-
if (!true) return [
|
|
5428
|
-
3,
|
|
5429
|
-
6
|
|
5430
|
-
];
|
|
5431
|
-
nextUrl = this.adPodAllUrls.find(function(url) {
|
|
5432
|
-
return !processedUrls.has(url);
|
|
5433
|
-
});
|
|
5434
|
-
if (!nextUrl) {
|
|
5435
|
-
if (this.config.debugAdTiming) {
|
|
5436
|
-
console.log("[ADAPTIVE-POD] ✅ All queued ads processed (".concat(processedUrls.size, " total)"));
|
|
5437
|
-
}
|
|
5438
|
-
return [
|
|
5439
|
-
3,
|
|
5440
|
-
6
|
|
5441
|
-
];
|
|
5442
|
-
}
|
|
5443
|
-
processedUrls.add(nextUrl);
|
|
5444
|
-
if (this.config.debugAdTiming) {
|
|
5445
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE5 Preloading ad ".concat(processedUrls.size, "/").concat(this.adPodAllUrls.length, "..."));
|
|
5446
|
-
}
|
|
5447
|
-
_state.label = 2;
|
|
5448
|
-
case 2:
|
|
5449
|
-
_state.trys.push([
|
|
5450
|
-
2,
|
|
5451
|
-
4,
|
|
5452
|
-
,
|
|
5453
|
-
5
|
|
5454
|
-
]);
|
|
5455
|
-
return [
|
|
5456
|
-
4,
|
|
5457
|
-
this.preloadSingleAd(nextUrl)
|
|
5458
|
-
];
|
|
5459
|
-
case 3:
|
|
5460
|
-
_state.sent();
|
|
5461
|
-
return [
|
|
5462
|
-
3,
|
|
5463
|
-
5
|
|
5464
|
-
];
|
|
5465
|
-
case 4:
|
|
5466
|
-
error = _state.sent();
|
|
5467
|
-
if (this.config.debugAdTiming) {
|
|
5468
|
-
console.warn("[ADAPTIVE-POD] ⚠️ Preload failed for ad ".concat(processedUrls.size, ":"), error);
|
|
5469
|
-
}
|
|
5470
|
-
return [
|
|
5471
|
-
3,
|
|
5472
|
-
5
|
|
5473
|
-
];
|
|
5474
|
-
case 5:
|
|
5475
|
-
if (this.calculateAdditionalAdsNeeded() === 0) {
|
|
5476
|
-
if (this.config.debugAdTiming) {
|
|
5477
|
-
console.log("[ADAPTIVE-POD] ✅ Target duration reached (".concat(processedUrls.size, " ads preloaded), stopping"));
|
|
5478
|
-
}
|
|
5479
|
-
return [
|
|
5480
|
-
3,
|
|
5481
|
-
6
|
|
5482
|
-
];
|
|
5483
|
-
}
|
|
5484
|
-
return [
|
|
5485
|
-
3,
|
|
5486
|
-
1
|
|
5487
|
-
];
|
|
5488
|
-
case 6:
|
|
5489
|
-
if (this.config.debugAdTiming) {
|
|
5490
|
-
console.log("[ADAPTIVE-POD] ✅ Sequential preloading completed (".concat(processedUrls.size, " ads ready)"));
|
|
5491
|
-
}
|
|
5492
|
-
return [
|
|
5493
|
-
3,
|
|
5494
|
-
9
|
|
5495
|
-
];
|
|
5496
|
-
case 7:
|
|
5497
|
-
if (this.config.debugAdTiming) {
|
|
5498
|
-
console.log("[StormcloudVideoPlayer] Starting parallel preload of ".concat(this.adPodAllUrls.length, " ads"));
|
|
5499
|
-
}
|
|
5500
|
-
preloadPromises = this.adPodAllUrls.map(function(vastTagUrl) {
|
|
5501
|
-
return _this.preloadSingleAd(vastTagUrl).catch(function(error) {
|
|
5502
|
-
if (_this.config.debugAdTiming) {
|
|
5503
|
-
console.warn("[StormcloudVideoPlayer] Preload failed for ".concat(vastTagUrl, ":"), error);
|
|
5504
|
-
}
|
|
5505
|
-
});
|
|
5506
|
-
});
|
|
5507
|
-
return [
|
|
5508
|
-
4,
|
|
5509
|
-
Promise.all(preloadPromises)
|
|
5510
|
-
];
|
|
5511
|
-
case 8:
|
|
5512
|
-
_state.sent();
|
|
5513
|
-
if (this.config.debugAdTiming) {
|
|
5514
|
-
console.log("[StormcloudVideoPlayer] Background preloading completed for all ads");
|
|
5515
|
-
}
|
|
5516
|
-
_state.label = 9;
|
|
5517
|
-
case 9:
|
|
5518
|
-
return [
|
|
5519
|
-
2
|
|
5520
|
-
];
|
|
5521
|
-
}
|
|
5522
|
-
});
|
|
5523
|
-
}).call(this);
|
|
5524
|
-
}
|
|
5525
|
-
},
|
|
5526
|
-
{
|
|
5527
|
-
key: "preloadSingleAd",
|
|
5528
|
-
value: function preloadSingleAd(vastTagUrl) {
|
|
5529
|
-
return _async_to_generator(function() {
|
|
5530
|
-
var _this, duration, mediaUrls, primaryMediaUrl, error;
|
|
5531
|
-
return _ts_generator(this, function(_state) {
|
|
5532
|
-
switch(_state.label){
|
|
5533
|
-
case 0:
|
|
5534
|
-
_this = this;
|
|
5535
|
-
if (!vastTagUrl) return [
|
|
5536
|
-
2
|
|
5537
|
-
];
|
|
5538
|
-
_state.label = 1;
|
|
5539
|
-
case 1:
|
|
5540
|
-
_state.trys.push([
|
|
5541
|
-
1,
|
|
5542
|
-
11,
|
|
5543
|
-
,
|
|
5544
|
-
12
|
|
5545
|
-
]);
|
|
5546
|
-
if (!(this.isAdaptiveMode && !this.fetchedAdDurations.has(vastTagUrl))) return [
|
|
5547
|
-
3,
|
|
5548
|
-
4
|
|
5549
|
-
];
|
|
5550
|
-
return [
|
|
5551
|
-
4,
|
|
5552
|
-
this.fetchVastDuration(vastTagUrl)
|
|
5553
|
-
];
|
|
5554
|
-
case 2:
|
|
5555
|
-
duration = _state.sent();
|
|
5556
|
-
if (!(duration !== null)) return [
|
|
5557
|
-
3,
|
|
5558
|
-
4
|
|
5559
|
-
];
|
|
5560
|
-
this.fetchedAdDurations.set(vastTagUrl, duration);
|
|
5561
|
-
if (this.config.debugAdTiming) {
|
|
5562
|
-
console.log("[ADAPTIVE-POD] ✓ Fetched ad duration: ".concat(duration, "s (").concat(this.fetchedAdDurations.size, " ads fetched so far)"));
|
|
5563
|
-
}
|
|
5564
|
-
return [
|
|
5565
|
-
4,
|
|
5566
|
-
this.addAdaptiveAdsToQueue()
|
|
5567
|
-
];
|
|
5568
|
-
case 3:
|
|
5569
|
-
_state.sent();
|
|
5570
|
-
_state.label = 4;
|
|
5571
|
-
case 4:
|
|
5572
|
-
if (!(this.ima.preloadAds && !this.ima.hasPreloadedAd(vastTagUrl))) return [
|
|
5573
|
-
3,
|
|
5574
|
-
6
|
|
5575
|
-
];
|
|
5576
|
-
if (!!this.preloadingAdUrls.has(vastTagUrl)) return [
|
|
5577
|
-
3,
|
|
5578
|
-
6
|
|
5579
|
-
];
|
|
5580
|
-
if (this.config.debugAdTiming) {
|
|
5581
|
-
console.log("[StormcloudVideoPlayer] Preloading VAST: ".concat(vastTagUrl));
|
|
5582
|
-
}
|
|
5583
|
-
this.preloadingAdUrls.add(vastTagUrl);
|
|
5584
|
-
return [
|
|
5585
|
-
4,
|
|
5586
|
-
this.ima.preloadAds(vastTagUrl).then(function() {
|
|
5587
|
-
if (_this.config.debugAdTiming) {
|
|
5588
|
-
console.log("[StormcloudVideoPlayer] IMA VAST preload complete: ".concat(vastTagUrl));
|
|
5589
|
-
}
|
|
5590
|
-
}).catch(function(error) {
|
|
5591
|
-
if (_this.config.debugAdTiming) {
|
|
5592
|
-
console.warn("[StormcloudVideoPlayer] IMA VAST preload failed: ".concat(vastTagUrl), error);
|
|
5593
|
-
}
|
|
5594
|
-
}).finally(function() {
|
|
5595
|
-
_this.preloadingAdUrls.delete(vastTagUrl);
|
|
5596
|
-
})
|
|
5597
|
-
];
|
|
5598
|
-
case 5:
|
|
5599
|
-
_state.sent();
|
|
5600
|
-
_state.label = 6;
|
|
5601
|
-
case 6:
|
|
5602
|
-
mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5603
|
-
if (!!mediaUrls) return [
|
|
5604
|
-
3,
|
|
5605
|
-
8
|
|
5606
|
-
];
|
|
5607
|
-
if (this.config.debugAdTiming) {
|
|
5608
|
-
console.log("[StormcloudVideoPlayer] Fetching and parsing VAST to extract media URLs: ".concat(vastTagUrl));
|
|
5609
|
-
}
|
|
5610
|
-
return [
|
|
5611
|
-
4,
|
|
5612
|
-
this.fetchAndParseVastXml(vastTagUrl)
|
|
5613
|
-
];
|
|
5614
|
-
case 7:
|
|
5615
|
-
mediaUrls = _state.sent();
|
|
5616
|
-
if (this.config.debugAdTiming) {
|
|
5617
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs:"), mediaUrls);
|
|
5618
|
-
}
|
|
5619
|
-
if (mediaUrls.length > 0) {
|
|
5620
|
-
this.vastToMediaUrlMap.set(vastTagUrl, mediaUrls);
|
|
5621
|
-
}
|
|
5622
|
-
_state.label = 8;
|
|
5623
|
-
case 8:
|
|
5624
|
-
if (!(mediaUrls && mediaUrls.length > 0)) return [
|
|
5625
|
-
3,
|
|
5626
|
-
10
|
|
5627
|
-
];
|
|
5628
|
-
primaryMediaUrl = mediaUrls[0];
|
|
5629
|
-
if (!(primaryMediaUrl && !this.preloadedMediaUrls.has(primaryMediaUrl))) return [
|
|
5630
|
-
3,
|
|
5631
|
-
10
|
|
5632
|
-
];
|
|
5633
|
-
return [
|
|
5634
|
-
4,
|
|
5635
|
-
this.preloadMediaFile(primaryMediaUrl)
|
|
5636
|
-
];
|
|
5637
|
-
case 9:
|
|
5638
|
-
_state.sent();
|
|
5639
|
-
_state.label = 10;
|
|
5640
|
-
case 10:
|
|
5641
|
-
return [
|
|
5642
|
-
3,
|
|
5643
|
-
12
|
|
5644
|
-
];
|
|
5645
|
-
case 11:
|
|
5646
|
-
error = _state.sent();
|
|
5647
|
-
if (this.config.debugAdTiming) {
|
|
5648
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload ad: ".concat(vastTagUrl), error);
|
|
5649
|
-
}
|
|
5650
|
-
return [
|
|
5651
|
-
3,
|
|
5652
|
-
12
|
|
5653
|
-
];
|
|
5654
|
-
case 12:
|
|
5655
|
-
return [
|
|
5656
|
-
2
|
|
5657
|
-
];
|
|
5658
|
-
}
|
|
5659
|
-
});
|
|
5660
|
-
}).call(this);
|
|
5661
|
-
}
|
|
5662
|
-
},
|
|
5663
|
-
{
|
|
5664
|
-
key: "findNextPreloadedAd",
|
|
5665
|
-
value: function findNextPreloadedAd() {
|
|
5666
|
-
for(var i = 0; i < this.adPodQueue.length; i++){
|
|
5667
|
-
var _this_ima_hasPreloadedAd, _this_ima;
|
|
5668
|
-
var vastTagUrl = this.adPodQueue[i];
|
|
5669
|
-
if (!vastTagUrl) continue;
|
|
5670
|
-
if (this.failedVastUrls.has(vastTagUrl)) {
|
|
5671
|
-
console.warn("[AD-ERROR] Skipping failed URL in queue");
|
|
5672
|
-
continue;
|
|
5673
|
-
}
|
|
5674
|
-
var _this_ima_hasPreloadedAd1;
|
|
5675
|
-
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;
|
|
5676
|
-
var mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5677
|
-
var hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
|
|
5678
|
-
if (hasImaPreload || hasMediaPreload) {
|
|
5679
|
-
this.adPodQueue.splice(0, i + 1);
|
|
5680
|
-
return vastTagUrl;
|
|
5681
|
-
}
|
|
5682
|
-
}
|
|
5683
|
-
return void 0;
|
|
5684
|
-
}
|
|
5685
|
-
},
|
|
5686
4725
|
{
|
|
5687
4726
|
key: "getRemainingAdMs",
|
|
5688
4727
|
value: function getRemainingAdMs() {
|
|
@@ -5869,7 +4908,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5869
4908
|
}
|
|
5870
4909
|
if (this.ima && this.ima.isAdPlaying()) {
|
|
5871
4910
|
var width = this.video.clientWidth || 640;
|
|
5872
|
-
var height = this.video.clientHeight ||
|
|
4911
|
+
var height = this.video.clientHeight || 480;
|
|
5873
4912
|
if (this.config.debugAdTiming) {
|
|
5874
4913
|
console.log("[StormcloudVideoPlayer] Resizing ads manager to ".concat(width, "x").concat(height));
|
|
5875
4914
|
}
|
|
@@ -5900,13 +4939,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5900
4939
|
}
|
|
5901
4940
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5902
4941
|
(_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
|
|
5903
|
-
this.preloadingAdUrls.clear();
|
|
5904
|
-
this.vastToMediaUrlMap.clear();
|
|
5905
|
-
this.preloadedMediaUrls.clear();
|
|
5906
|
-
this.preloadingMediaUrls.clear();
|
|
5907
|
-
this.adPodAllUrls = [];
|
|
5908
4942
|
this.adRequestQueue = [];
|
|
5909
|
-
this.successfulAdRequests = [];
|
|
5910
4943
|
}
|
|
5911
4944
|
}
|
|
5912
4945
|
]);
|