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
package/lib/index.js
CHANGED
|
@@ -335,20 +335,6 @@ function _ts_generator(thisArg, body) {
|
|
|
335
335
|
};
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
|
-
function _ts_values(o) {
|
|
339
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
340
|
-
if (m) return m.call(o);
|
|
341
|
-
if (o && typeof o.length === "number") return {
|
|
342
|
-
next: function() {
|
|
343
|
-
if (o && i >= o.length) o = void 0;
|
|
344
|
-
return {
|
|
345
|
-
value: o && o[i++],
|
|
346
|
-
done: !o
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
351
|
-
}
|
|
352
338
|
// src/ui/StormcloudVideoPlayer.tsx
|
|
353
339
|
import React, { useEffect, useRef, useMemo } from "react";
|
|
354
340
|
// src/player/StormcloudVideoPlayer.ts
|
|
@@ -549,8 +535,6 @@ function createImaController(video, options) {
|
|
|
549
535
|
var originalMutedState = false;
|
|
550
536
|
var originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
551
537
|
var listeners = /* @__PURE__ */ new Map();
|
|
552
|
-
var preloadedVast = /* @__PURE__ */ new Map();
|
|
553
|
-
var preloadingVast = /* @__PURE__ */ new Map();
|
|
554
538
|
var adVideoElement;
|
|
555
539
|
function setAdPlayingFlag(isPlaying) {
|
|
556
540
|
if (isPlaying) {
|
|
@@ -700,10 +684,10 @@ function createImaController(video, options) {
|
|
|
700
684
|
var adsLoadedReject;
|
|
701
685
|
function makeAdsRequest(google, vastTagUrl) {
|
|
702
686
|
var adsRequest = new google.ima.AdsRequest();
|
|
703
|
-
console.log("[IMA] \uD83D\uDCE1 Requesting VAST
|
|
687
|
+
console.log("[IMA] \uD83D\uDCE1 Requesting VAST via IMA SDK:", vastTagUrl.substring(0, 80) + "...");
|
|
704
688
|
adsRequest.adTagUrl = vastTagUrl;
|
|
705
689
|
var videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
706
|
-
var videoHeight = video.offsetHeight || video.clientHeight ||
|
|
690
|
+
var videoHeight = video.offsetHeight || video.clientHeight || 480;
|
|
707
691
|
adsRequest.linearAdSlotWidth = videoWidth;
|
|
708
692
|
adsRequest.linearAdSlotHeight = videoHeight;
|
|
709
693
|
adsRequest.nonLinearAdSlotWidth = videoWidth;
|
|
@@ -749,36 +733,6 @@ function createImaController(video, options) {
|
|
|
749
733
|
(_video_parentElement = video.parentElement) === null || _video_parentElement === void 0 ? void 0 : _video_parentElement.appendChild(container);
|
|
750
734
|
adContainerEl = container;
|
|
751
735
|
}
|
|
752
|
-
function fetchVastDocument(vastTagUrl) {
|
|
753
|
-
return _async_to_generator(function() {
|
|
754
|
-
var response;
|
|
755
|
-
return _ts_generator(this, function(_state) {
|
|
756
|
-
switch(_state.label){
|
|
757
|
-
case 0:
|
|
758
|
-
return [
|
|
759
|
-
4,
|
|
760
|
-
fetch(vastTagUrl, {
|
|
761
|
-
mode: "cors",
|
|
762
|
-
credentials: "include",
|
|
763
|
-
headers: {
|
|
764
|
-
"Accept": "application/xml, text/xml, */*"
|
|
765
|
-
},
|
|
766
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
767
|
-
})
|
|
768
|
-
];
|
|
769
|
-
case 1:
|
|
770
|
-
response = _state.sent();
|
|
771
|
-
if (!response.ok) {
|
|
772
|
-
throw new Error("Failed to preload VAST: ".concat(response.status));
|
|
773
|
-
}
|
|
774
|
-
return [
|
|
775
|
-
2,
|
|
776
|
-
response.text()
|
|
777
|
-
];
|
|
778
|
-
}
|
|
779
|
-
});
|
|
780
|
-
})();
|
|
781
|
-
}
|
|
782
736
|
function destroyAdsManager() {
|
|
783
737
|
if (adsManager) {
|
|
784
738
|
try {
|
|
@@ -1093,47 +1047,6 @@ function createImaController(video, options) {
|
|
|
1093
1047
|
});
|
|
1094
1048
|
})();
|
|
1095
1049
|
},
|
|
1096
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1097
|
-
return _async_to_generator(function() {
|
|
1098
|
-
var inflight, preloadPromise;
|
|
1099
|
-
return _ts_generator(this, function(_state) {
|
|
1100
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1101
|
-
return [
|
|
1102
|
-
2,
|
|
1103
|
-
Promise.resolve()
|
|
1104
|
-
];
|
|
1105
|
-
}
|
|
1106
|
-
if (preloadedVast.has(vastTagUrl)) {
|
|
1107
|
-
return [
|
|
1108
|
-
2,
|
|
1109
|
-
Promise.resolve()
|
|
1110
|
-
];
|
|
1111
|
-
}
|
|
1112
|
-
inflight = preloadingVast.get(vastTagUrl);
|
|
1113
|
-
if (inflight) {
|
|
1114
|
-
return [
|
|
1115
|
-
2,
|
|
1116
|
-
inflight
|
|
1117
|
-
];
|
|
1118
|
-
}
|
|
1119
|
-
preloadPromise = fetchVastDocument(vastTagUrl).then(function(xml) {
|
|
1120
|
-
preloadedVast.set(vastTagUrl, xml);
|
|
1121
|
-
}).catch(function() {
|
|
1122
|
-
preloadedVast.delete(vastTagUrl);
|
|
1123
|
-
}).finally(function() {
|
|
1124
|
-
preloadingVast.delete(vastTagUrl);
|
|
1125
|
-
});
|
|
1126
|
-
preloadingVast.set(vastTagUrl, preloadPromise);
|
|
1127
|
-
return [
|
|
1128
|
-
2,
|
|
1129
|
-
preloadPromise
|
|
1130
|
-
];
|
|
1131
|
-
});
|
|
1132
|
-
})();
|
|
1133
|
-
},
|
|
1134
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1135
|
-
return preloadedVast.has(vastTagUrl);
|
|
1136
|
-
},
|
|
1137
1050
|
play: function play() {
|
|
1138
1051
|
return _async_to_generator(function() {
|
|
1139
1052
|
var _window_google, width, height, adVolume, _video_play;
|
|
@@ -1152,7 +1065,7 @@ function createImaController(video, options) {
|
|
|
1152
1065
|
}
|
|
1153
1066
|
try {
|
|
1154
1067
|
width = video.clientWidth || 640;
|
|
1155
|
-
height = video.clientHeight ||
|
|
1068
|
+
height = video.clientHeight || 480;
|
|
1156
1069
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
1157
1070
|
adPlaying = true;
|
|
1158
1071
|
adVolume = originalMutedState ? 0 : originalVolume;
|
|
@@ -1242,8 +1155,6 @@ function createImaController(video, options) {
|
|
|
1242
1155
|
adDisplayContainer = void 0;
|
|
1243
1156
|
adsLoader = void 0;
|
|
1244
1157
|
contentVideoHidden = false;
|
|
1245
|
-
preloadedVast.clear();
|
|
1246
|
-
preloadingVast.clear();
|
|
1247
1158
|
},
|
|
1248
1159
|
isAdPlaying: function isAdPlaying() {
|
|
1249
1160
|
return adPlaying;
|
|
@@ -1844,51 +1755,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1844
1755
|
});
|
|
1845
1756
|
})();
|
|
1846
1757
|
},
|
|
1847
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1848
|
-
return _async_to_generator(function() {
|
|
1849
|
-
var inflight, preloadPromise;
|
|
1850
|
-
return _ts_generator(this, function(_state) {
|
|
1851
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1852
|
-
return [
|
|
1853
|
-
2,
|
|
1854
|
-
Promise.resolve()
|
|
1855
|
-
];
|
|
1856
|
-
}
|
|
1857
|
-
if (preloadedAds.has(vastTagUrl)) {
|
|
1858
|
-
return [
|
|
1859
|
-
2,
|
|
1860
|
-
Promise.resolve()
|
|
1861
|
-
];
|
|
1862
|
-
}
|
|
1863
|
-
inflight = preloadingAds.get(vastTagUrl);
|
|
1864
|
-
if (inflight) {
|
|
1865
|
-
return [
|
|
1866
|
-
2,
|
|
1867
|
-
inflight
|
|
1868
|
-
];
|
|
1869
|
-
}
|
|
1870
|
-
preloadPromise = fetchAndParseVastAd(vastTagUrl).then(function(ad) {
|
|
1871
|
-
if (ad) {
|
|
1872
|
-
preloadedAds.set(vastTagUrl, ad);
|
|
1873
|
-
console.log("[HlsAdPlayer] Cached VAST response for preloading:", vastTagUrl);
|
|
1874
|
-
}
|
|
1875
|
-
}).catch(function(error) {
|
|
1876
|
-
console.warn("[HlsAdPlayer] Failed to preload VAST response:", error);
|
|
1877
|
-
preloadedAds.delete(vastTagUrl);
|
|
1878
|
-
}).finally(function() {
|
|
1879
|
-
preloadingAds.delete(vastTagUrl);
|
|
1880
|
-
});
|
|
1881
|
-
preloadingAds.set(vastTagUrl, preloadPromise);
|
|
1882
|
-
return [
|
|
1883
|
-
2,
|
|
1884
|
-
preloadPromise
|
|
1885
|
-
];
|
|
1886
|
-
});
|
|
1887
|
-
})();
|
|
1888
|
-
},
|
|
1889
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1890
|
-
return preloadedAds.has(vastTagUrl);
|
|
1891
|
-
},
|
|
1892
1758
|
play: function play() {
|
|
1893
1759
|
return _async_to_generator(function() {
|
|
1894
1760
|
var contentVolume, adVolume, mediaFile;
|
|
@@ -2783,32 +2649,17 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2783
2649
|
this.bufferedSegmentsCount = 0;
|
|
2784
2650
|
this.shouldAutoplayAfterBuffering = false;
|
|
2785
2651
|
this.hasInitialBufferCompleted = false;
|
|
2786
|
-
this.adPodAllUrls = [];
|
|
2787
|
-
this.preloadingAdUrls = /* @__PURE__ */ new Set();
|
|
2788
|
-
this.vastToMediaUrlMap = /* @__PURE__ */ new Map();
|
|
2789
|
-
this.preloadedMediaUrls = /* @__PURE__ */ new Set();
|
|
2790
|
-
this.preloadingMediaUrls = /* @__PURE__ */ new Set();
|
|
2791
2652
|
this.adRequestTokenCounter = 0;
|
|
2792
2653
|
this.activeAdRequestToken = null;
|
|
2793
2654
|
this.adRequestWatchdogToken = null;
|
|
2794
2655
|
this.adFailsafeToken = null;
|
|
2795
|
-
this.fetchedAdDurations = /* @__PURE__ */ new Map();
|
|
2796
|
-
this.targetAdBreakDurationMs = null;
|
|
2797
|
-
this.isAdaptiveMode = false;
|
|
2798
2656
|
this.failedVastUrls = /* @__PURE__ */ new Set();
|
|
2799
2657
|
this.continuousFetchingActive = false;
|
|
2800
2658
|
this.adRequestQueue = [];
|
|
2801
|
-
this.successfulAdRequests = [];
|
|
2802
2659
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2803
|
-
this.placeholderStartTimeMs = null;
|
|
2804
2660
|
this.isShowingPlaceholder = false;
|
|
2805
|
-
this.consecutiveEmptyResponses = 0;
|
|
2806
2661
|
this.totalAdRequestsInBreak = 0;
|
|
2807
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
2808
2662
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2809
|
-
this.maxConsecutiveEmptyResponses = 5;
|
|
2810
|
-
this.baseEmptyResponseDelayMs = 2e3;
|
|
2811
|
-
this.maxEmptyResponseDelayMs = 3e4;
|
|
2812
2663
|
initializePolyfills();
|
|
2813
2664
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2814
2665
|
this.config = _object_spread({}, config, browserOverrides);
|
|
@@ -3299,25 +3150,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3299
3150
|
}
|
|
3300
3151
|
});
|
|
3301
3152
|
this.ima.on("ad_error", function(errorPayload) {
|
|
3302
|
-
var remaining = _this.getRemainingAdMs();
|
|
3303
3153
|
console.error("[AD-ERROR] Ad playback failed", errorPayload || "");
|
|
3304
|
-
|
|
3305
|
-
if (remaining > 500 && _this.adPodQueue.length > 0) {
|
|
3306
|
-
var nextPreloaded = _this.findNextPreloadedAd();
|
|
3307
|
-
if (nextPreloaded) {
|
|
3308
|
-
_this.currentAdIndex++;
|
|
3309
|
-
_this.playSingleAd(nextPreloaded).catch(function() {
|
|
3310
|
-
_this.handleAdFailure();
|
|
3311
|
-
});
|
|
3312
|
-
} else {
|
|
3313
|
-
_this.handleAdFailure();
|
|
3314
|
-
}
|
|
3315
|
-
} else {
|
|
3316
|
-
_this.handleAdFailure();
|
|
3317
|
-
}
|
|
3318
|
-
} else {
|
|
3319
|
-
_this.handleAdFailure();
|
|
3320
|
-
}
|
|
3154
|
+
_this.handleAdFailure();
|
|
3321
3155
|
});
|
|
3322
3156
|
this.ima.on("content_pause", function() {
|
|
3323
3157
|
_this.clearAdFailsafeTimer();
|
|
@@ -4048,7 +3882,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4048
3882
|
key: "handleAdStart",
|
|
4049
3883
|
value: function handleAdStart(_marker) {
|
|
4050
3884
|
return _async_to_generator(function() {
|
|
4051
|
-
var scheduled, tags, baseVastUrl, adBreakDurationMs, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
3885
|
+
var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
4052
3886
|
return _ts_generator(this, function(_state) {
|
|
4053
3887
|
switch(_state.label){
|
|
4054
3888
|
case 0:
|
|
@@ -4064,35 +3898,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4064
3898
|
];
|
|
4065
3899
|
}
|
|
4066
3900
|
adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
|
|
4067
|
-
if (this.
|
|
4068
|
-
this.
|
|
4069
|
-
|
|
4070
|
-
this.fetchedAdDurations.clear();
|
|
4071
|
-
if (this.config.debugAdTiming) {
|
|
4072
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA LIVE MODE: Target duration=".concat(adBreakDurationMs, "ms | Will continuously fetch ads during break"));
|
|
4073
|
-
}
|
|
4074
|
-
} else {
|
|
4075
|
-
this.isAdaptiveMode = false;
|
|
4076
|
-
this.targetAdBreakDurationMs = null;
|
|
4077
|
-
this.fetchedAdDurations.clear();
|
|
4078
|
-
if (this.config.debugAdTiming) {
|
|
4079
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC VOD MODE: Using fixed ad strategy");
|
|
4080
|
-
}
|
|
3901
|
+
if (this.config.debugAdTiming) {
|
|
3902
|
+
mode = this.isLiveStream ? "LIVE" : "VOD";
|
|
3903
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
4081
3904
|
}
|
|
4082
|
-
this.adPodAllUrls = [];
|
|
4083
|
-
this.preloadingAdUrls.clear();
|
|
4084
|
-
this.vastToMediaUrlMap.clear();
|
|
4085
|
-
this.preloadedMediaUrls.clear();
|
|
4086
|
-
this.preloadingMediaUrls.clear();
|
|
4087
3905
|
this.failedVastUrls.clear();
|
|
4088
3906
|
this.adRequestQueue = [];
|
|
4089
|
-
this.successfulAdRequests = [];
|
|
4090
3907
|
this.continuousFetchingActive = true;
|
|
4091
3908
|
this.isShowingPlaceholder = false;
|
|
4092
|
-
this.placeholderStartTimeMs = null;
|
|
4093
|
-
this.consecutiveEmptyResponses = 0;
|
|
4094
3909
|
this.totalAdRequestsInBreak = 0;
|
|
4095
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
4096
3910
|
currentMuted = this.video.muted;
|
|
4097
3911
|
currentVolume = this.video.volume;
|
|
4098
3912
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
@@ -4138,7 +3952,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4138
3952
|
if (this.config.debugAdTiming) {
|
|
4139
3953
|
console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
|
|
4140
3954
|
}
|
|
4141
|
-
this.successfulAdRequests.push(firstAdUrl);
|
|
4142
3955
|
this.currentAdIndex++;
|
|
4143
3956
|
this.startContinuousFetching(baseVastUrl);
|
|
4144
3957
|
return [
|
|
@@ -4188,200 +4001,92 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4188
4001
|
key: "continuousFetchLoop",
|
|
4189
4002
|
value: function continuousFetchLoop(baseVastUrl) {
|
|
4190
4003
|
return _async_to_generator(function() {
|
|
4191
|
-
var
|
|
4004
|
+
var remaining, maxQueueSize, newAdUrl;
|
|
4192
4005
|
return _ts_generator(this, function(_state) {
|
|
4193
4006
|
switch(_state.label){
|
|
4194
4007
|
case 0:
|
|
4195
|
-
_loop = function() {
|
|
4196
|
-
var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
|
|
4197
|
-
return _ts_generator(this, function(_state) {
|
|
4198
|
-
switch(_state.label){
|
|
4199
|
-
case 0:
|
|
4200
|
-
remaining = _this.getRemainingAdMs();
|
|
4201
|
-
if (remaining <= 0) {
|
|
4202
|
-
if (_this.config.debugAdTiming) {
|
|
4203
|
-
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
|
|
4204
|
-
}
|
|
4205
|
-
return [
|
|
4206
|
-
2,
|
|
4207
|
-
"break"
|
|
4208
|
-
];
|
|
4209
|
-
}
|
|
4210
|
-
if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
|
|
4211
|
-
if (_this.config.debugAdTiming) {
|
|
4212
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
|
|
4213
|
-
}
|
|
4214
|
-
return [
|
|
4215
|
-
2,
|
|
4216
|
-
"break"
|
|
4217
|
-
];
|
|
4218
|
-
}
|
|
4219
|
-
if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
|
|
4220
|
-
if (_this.config.debugAdTiming) {
|
|
4221
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
|
|
4222
|
-
}
|
|
4223
|
-
return [
|
|
4224
|
-
2,
|
|
4225
|
-
"break"
|
|
4226
|
-
];
|
|
4227
|
-
}
|
|
4228
|
-
maxQueueSize = 3;
|
|
4229
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4230
|
-
3,
|
|
4231
|
-
2
|
|
4232
|
-
];
|
|
4233
|
-
if (_this.config.debugAdTiming) {
|
|
4234
|
-
console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
|
|
4235
|
-
}
|
|
4236
|
-
return [
|
|
4237
|
-
4,
|
|
4238
|
-
new Promise(function(resolve) {
|
|
4239
|
-
return setTimeout(resolve, 2e3);
|
|
4240
|
-
})
|
|
4241
|
-
];
|
|
4242
|
-
case 1:
|
|
4243
|
-
_state.sent();
|
|
4244
|
-
return [
|
|
4245
|
-
2,
|
|
4246
|
-
"continue"
|
|
4247
|
-
];
|
|
4248
|
-
case 2:
|
|
4249
|
-
newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4250
|
-
if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
|
|
4251
|
-
3,
|
|
4252
|
-
4
|
|
4253
|
-
];
|
|
4254
|
-
return [
|
|
4255
|
-
4,
|
|
4256
|
-
new Promise(function(resolve) {
|
|
4257
|
-
return setTimeout(resolve, 1e3);
|
|
4258
|
-
})
|
|
4259
|
-
];
|
|
4260
|
-
case 3:
|
|
4261
|
-
_state.sent();
|
|
4262
|
-
return [
|
|
4263
|
-
2,
|
|
4264
|
-
"continue"
|
|
4265
|
-
];
|
|
4266
|
-
case 4:
|
|
4267
|
-
_this.totalAdRequestsInBreak++;
|
|
4268
|
-
if (_this.config.debugAdTiming) {
|
|
4269
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
|
|
4270
|
-
}
|
|
4271
|
-
_state.label = 5;
|
|
4272
|
-
case 5:
|
|
4273
|
-
_state.trys.push([
|
|
4274
|
-
5,
|
|
4275
|
-
11,
|
|
4276
|
-
,
|
|
4277
|
-
13
|
|
4278
|
-
]);
|
|
4279
|
-
if (!_this.ima.preloadAds) return [
|
|
4280
|
-
3,
|
|
4281
|
-
7
|
|
4282
|
-
];
|
|
4283
|
-
return [
|
|
4284
|
-
4,
|
|
4285
|
-
_this.ima.preloadAds(newAdUrl)
|
|
4286
|
-
];
|
|
4287
|
-
case 6:
|
|
4288
|
-
_state.sent();
|
|
4289
|
-
_state.label = 7;
|
|
4290
|
-
case 7:
|
|
4291
|
-
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;
|
|
4292
|
-
if (!!hasPreloadedAd) return [
|
|
4293
|
-
3,
|
|
4294
|
-
9
|
|
4295
|
-
];
|
|
4296
|
-
_this.consecutiveEmptyResponses++;
|
|
4297
|
-
_this.lastEmptyResponseTimeMs = Date.now();
|
|
4298
|
-
backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4299
|
-
if (_this.config.debugAdTiming) {
|
|
4300
|
-
console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
|
|
4301
|
-
}
|
|
4302
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4303
|
-
return [
|
|
4304
|
-
4,
|
|
4305
|
-
new Promise(function(resolve) {
|
|
4306
|
-
return setTimeout(resolve, backoffDelay);
|
|
4307
|
-
})
|
|
4308
|
-
];
|
|
4309
|
-
case 8:
|
|
4310
|
-
_state.sent();
|
|
4311
|
-
return [
|
|
4312
|
-
2,
|
|
4313
|
-
"continue"
|
|
4314
|
-
];
|
|
4315
|
-
case 9:
|
|
4316
|
-
_this.consecutiveEmptyResponses = 0;
|
|
4317
|
-
if (_this.config.debugAdTiming) {
|
|
4318
|
-
console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
|
|
4319
|
-
}
|
|
4320
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
4321
|
-
_this.totalAdsInBreak++;
|
|
4322
|
-
return [
|
|
4323
|
-
4,
|
|
4324
|
-
new Promise(function(resolve) {
|
|
4325
|
-
return setTimeout(resolve, 500);
|
|
4326
|
-
})
|
|
4327
|
-
];
|
|
4328
|
-
case 10:
|
|
4329
|
-
_state.sent();
|
|
4330
|
-
return [
|
|
4331
|
-
3,
|
|
4332
|
-
13
|
|
4333
|
-
];
|
|
4334
|
-
case 11:
|
|
4335
|
-
error = _state.sent();
|
|
4336
|
-
if (_this.config.debugAdTiming) {
|
|
4337
|
-
console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
|
|
4338
|
-
}
|
|
4339
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4340
|
-
_this.consecutiveEmptyResponses++;
|
|
4341
|
-
backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4342
|
-
return [
|
|
4343
|
-
4,
|
|
4344
|
-
new Promise(function(resolve) {
|
|
4345
|
-
return setTimeout(resolve, backoffDelay1);
|
|
4346
|
-
})
|
|
4347
|
-
];
|
|
4348
|
-
case 12:
|
|
4349
|
-
_state.sent();
|
|
4350
|
-
return [
|
|
4351
|
-
3,
|
|
4352
|
-
13
|
|
4353
|
-
];
|
|
4354
|
-
case 13:
|
|
4355
|
-
return [
|
|
4356
|
-
2
|
|
4357
|
-
];
|
|
4358
|
-
}
|
|
4359
|
-
});
|
|
4360
|
-
};
|
|
4361
|
-
_state.label = 1;
|
|
4362
|
-
case 1:
|
|
4363
4008
|
if (!(this.continuousFetchingActive && this.inAdBreak)) return [
|
|
4364
4009
|
3,
|
|
4365
|
-
|
|
4010
|
+
6
|
|
4366
4011
|
];
|
|
4367
|
-
|
|
4012
|
+
remaining = this.getRemainingAdMs();
|
|
4013
|
+
if (remaining <= 0) {
|
|
4014
|
+
if (this.config.debugAdTiming) {
|
|
4015
|
+
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping URL generation");
|
|
4016
|
+
}
|
|
4017
|
+
return [
|
|
4018
|
+
3,
|
|
4019
|
+
6
|
|
4020
|
+
];
|
|
4021
|
+
}
|
|
4022
|
+
if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
|
|
4023
|
+
if (this.config.debugAdTiming) {
|
|
4024
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(this.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
4025
|
+
}
|
|
4026
|
+
return [
|
|
4027
|
+
3,
|
|
4028
|
+
6
|
|
4029
|
+
];
|
|
4030
|
+
}
|
|
4031
|
+
maxQueueSize = 5;
|
|
4032
|
+
if (!(this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4033
|
+
3,
|
|
4034
|
+
2
|
|
4035
|
+
];
|
|
4036
|
+
if (this.config.debugAdTiming) {
|
|
4037
|
+
console.log("[CONTINUOUS-FETCH] ⏸️ URL queue full (".concat(this.adRequestQueue.length, "), waiting..."));
|
|
4038
|
+
}
|
|
4368
4039
|
return [
|
|
4369
|
-
|
|
4370
|
-
|
|
4040
|
+
4,
|
|
4041
|
+
new Promise(function(resolve) {
|
|
4042
|
+
return setTimeout(resolve, 1e3);
|
|
4043
|
+
})
|
|
4044
|
+
];
|
|
4045
|
+
case 1:
|
|
4046
|
+
_state.sent();
|
|
4047
|
+
return [
|
|
4048
|
+
3,
|
|
4049
|
+
0
|
|
4371
4050
|
];
|
|
4372
4051
|
case 2:
|
|
4373
|
-
|
|
4374
|
-
if (
|
|
4052
|
+
newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4053
|
+
if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
|
|
4375
4054
|
3,
|
|
4376
|
-
|
|
4055
|
+
4
|
|
4377
4056
|
];
|
|
4378
4057
|
return [
|
|
4379
|
-
|
|
4380
|
-
|
|
4058
|
+
4,
|
|
4059
|
+
new Promise(function(resolve) {
|
|
4060
|
+
return setTimeout(resolve, 500);
|
|
4061
|
+
})
|
|
4381
4062
|
];
|
|
4382
4063
|
case 3:
|
|
4064
|
+
_state.sent();
|
|
4065
|
+
return [
|
|
4066
|
+
3,
|
|
4067
|
+
0
|
|
4068
|
+
];
|
|
4069
|
+
case 4:
|
|
4070
|
+
if (this.config.debugAdTiming) {
|
|
4071
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCDD Queued VAST URL (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
|
|
4072
|
+
}
|
|
4073
|
+
this.adRequestQueue.push(newAdUrl);
|
|
4074
|
+
this.totalAdsInBreak++;
|
|
4075
|
+
return [
|
|
4076
|
+
4,
|
|
4077
|
+
new Promise(function(resolve) {
|
|
4078
|
+
return setTimeout(resolve, 300);
|
|
4079
|
+
})
|
|
4080
|
+
];
|
|
4081
|
+
case 5:
|
|
4082
|
+
_state.sent();
|
|
4083
|
+
return [
|
|
4084
|
+
3,
|
|
4085
|
+
0
|
|
4086
|
+
];
|
|
4087
|
+
case 6:
|
|
4383
4088
|
if (this.config.debugAdTiming) {
|
|
4384
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1
|
|
4089
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"));
|
|
4385
4090
|
}
|
|
4386
4091
|
return [
|
|
4387
4092
|
2
|
|
@@ -4430,19 +4135,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4430
4135
|
2
|
|
4431
4136
|
];
|
|
4432
4137
|
if (this.config.debugAdTiming) {
|
|
4433
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC
|
|
4138
|
+
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)"));
|
|
4434
4139
|
}
|
|
4435
4140
|
currentMuted = this.video.muted;
|
|
4436
4141
|
currentVolume = this.video.volume;
|
|
4437
4142
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
4438
|
-
if (this.config.debugAdTiming) {
|
|
4439
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDD0A Updated ad audio state: muted=".concat(currentMuted, ", volume=").concat(currentVolume));
|
|
4440
|
-
}
|
|
4441
4143
|
this.currentAdIndex++;
|
|
4442
|
-
this.
|
|
4144
|
+
this.totalAdRequestsInBreak++;
|
|
4443
4145
|
return [
|
|
4444
4146
|
4,
|
|
4445
|
-
this.playSingleAd(nextAdUrl).catch(function() {
|
|
4147
|
+
this.playSingleAd(nextAdUrl).catch(function(error) {
|
|
4148
|
+
if (_this.config.debugAdTiming) {
|
|
4149
|
+
console.log("[CONTINUOUS-FETCH] \u274C Ad request failed:", error.message);
|
|
4150
|
+
}
|
|
4151
|
+
_this.failedVastUrls.add(nextAdUrl);
|
|
4446
4152
|
_this.tryNextAvailableAd(0);
|
|
4447
4153
|
})
|
|
4448
4154
|
];
|
|
@@ -4452,18 +4158,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4452
4158
|
2
|
|
4453
4159
|
];
|
|
4454
4160
|
case 2:
|
|
4455
|
-
maxRetries =
|
|
4161
|
+
maxRetries = 3;
|
|
4456
4162
|
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
4457
4163
|
3,
|
|
4458
4164
|
5
|
|
4459
4165
|
];
|
|
4460
4166
|
if (this.config.debugAdTiming) {
|
|
4461
|
-
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty
|
|
4167
|
+
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
4462
4168
|
}
|
|
4463
4169
|
return [
|
|
4464
4170
|
4,
|
|
4465
4171
|
new Promise(function(resolve) {
|
|
4466
|
-
return setTimeout(resolve,
|
|
4172
|
+
return setTimeout(resolve, 500);
|
|
4467
4173
|
})
|
|
4468
4174
|
];
|
|
4469
4175
|
case 3:
|
|
@@ -4512,12 +4218,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4512
4218
|
];
|
|
4513
4219
|
}
|
|
4514
4220
|
if (this.config.debugAdTiming) {
|
|
4515
|
-
console.log("[CONTINUOUS-FETCH] ⬛ Showing
|
|
4221
|
+
console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad URLs"));
|
|
4516
4222
|
}
|
|
4517
4223
|
this.isShowingPlaceholder = true;
|
|
4518
|
-
this.placeholderStartTimeMs = Date.now();
|
|
4519
4224
|
this.ima.showPlaceholder();
|
|
4520
|
-
checkInterval =
|
|
4225
|
+
checkInterval = 300;
|
|
4521
4226
|
maxChecks = Math.floor(waitTime / checkInterval);
|
|
4522
4227
|
i = 0;
|
|
4523
4228
|
_state.label = 1;
|
|
@@ -4544,10 +4249,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4544
4249
|
5
|
|
4545
4250
|
];
|
|
4546
4251
|
if (this.config.debugAdTiming) {
|
|
4547
|
-
console.log("[CONTINUOUS-FETCH] \u2705
|
|
4252
|
+
console.log("[CONTINUOUS-FETCH] \u2705 Ad URL available, requesting via IMA SDK");
|
|
4548
4253
|
}
|
|
4549
4254
|
this.isShowingPlaceholder = false;
|
|
4550
|
-
this.placeholderStartTimeMs = null;
|
|
4551
4255
|
this.ima.hidePlaceholder();
|
|
4552
4256
|
currentMuted = this.video.muted;
|
|
4553
4257
|
currentVolume = this.video.volume;
|
|
@@ -4558,7 +4262,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4558
4262
|
4
|
|
4559
4263
|
];
|
|
4560
4264
|
this.currentAdIndex++;
|
|
4561
|
-
this.
|
|
4265
|
+
this.totalAdRequestsInBreak++;
|
|
4562
4266
|
return [
|
|
4563
4267
|
4,
|
|
4564
4268
|
this.playSingleAd(nextAdUrl).catch(function() {
|
|
@@ -4580,10 +4284,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4580
4284
|
];
|
|
4581
4285
|
case 6:
|
|
4582
4286
|
if (this.config.debugAdTiming) {
|
|
4583
|
-
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout
|
|
4287
|
+
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
|
|
4584
4288
|
}
|
|
4585
4289
|
this.isShowingPlaceholder = false;
|
|
4586
|
-
this.placeholderStartTimeMs = null;
|
|
4587
4290
|
this.ima.hidePlaceholder();
|
|
4588
4291
|
this.handleAdPodComplete();
|
|
4589
4292
|
return [
|
|
@@ -4885,21 +4588,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4885
4588
|
if (this.isShowingPlaceholder) {
|
|
4886
4589
|
this.ima.hidePlaceholder();
|
|
4887
4590
|
this.isShowingPlaceholder = false;
|
|
4888
|
-
this.placeholderStartTimeMs = null;
|
|
4889
4591
|
}
|
|
4890
|
-
this.preloadingAdUrls.clear();
|
|
4891
|
-
this.vastToMediaUrlMap.clear();
|
|
4892
|
-
this.preloadedMediaUrls.clear();
|
|
4893
|
-
this.preloadingMediaUrls.clear();
|
|
4894
4592
|
this.adRequestQueue = [];
|
|
4895
|
-
this.successfulAdRequests = [];
|
|
4896
4593
|
this.inAdBreak = false;
|
|
4897
4594
|
this.expectedAdBreakDurationMs = void 0;
|
|
4898
4595
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
4899
4596
|
this.clearAdStartTimer();
|
|
4900
4597
|
this.clearAdStopTimer();
|
|
4901
4598
|
this.adPodQueue = [];
|
|
4902
|
-
this.adPodAllUrls = [];
|
|
4903
4599
|
this.showAds = false;
|
|
4904
4600
|
this.currentAdIndex = 0;
|
|
4905
4601
|
this.totalAdsInBreak = 0;
|
|
@@ -5054,651 +4750,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5054
4750
|
}, extra));
|
|
5055
4751
|
}
|
|
5056
4752
|
},
|
|
5057
|
-
{
|
|
5058
|
-
key: "fetchAndParseVastXml",
|
|
5059
|
-
value: function fetchAndParseVastXml(vastTagUrl) {
|
|
5060
|
-
return _async_to_generator(function() {
|
|
5061
|
-
var response, xmlText, error;
|
|
5062
|
-
return _ts_generator(this, function(_state) {
|
|
5063
|
-
switch(_state.label){
|
|
5064
|
-
case 0:
|
|
5065
|
-
_state.trys.push([
|
|
5066
|
-
0,
|
|
5067
|
-
3,
|
|
5068
|
-
,
|
|
5069
|
-
4
|
|
5070
|
-
]);
|
|
5071
|
-
return [
|
|
5072
|
-
4,
|
|
5073
|
-
fetch(vastTagUrl, {
|
|
5074
|
-
mode: "cors",
|
|
5075
|
-
credentials: "include",
|
|
5076
|
-
headers: {
|
|
5077
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5078
|
-
},
|
|
5079
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5080
|
-
})
|
|
5081
|
-
];
|
|
5082
|
-
case 1:
|
|
5083
|
-
response = _state.sent();
|
|
5084
|
-
if (!response.ok) {
|
|
5085
|
-
throw new Error("Failed to fetch VAST: ".concat(response.status));
|
|
5086
|
-
}
|
|
5087
|
-
return [
|
|
5088
|
-
4,
|
|
5089
|
-
response.text()
|
|
5090
|
-
];
|
|
5091
|
-
case 2:
|
|
5092
|
-
xmlText = _state.sent();
|
|
5093
|
-
return [
|
|
5094
|
-
2,
|
|
5095
|
-
this.extractMediaUrlsFromVast(xmlText)
|
|
5096
|
-
];
|
|
5097
|
-
case 3:
|
|
5098
|
-
error = _state.sent();
|
|
5099
|
-
if (this.config.debugAdTiming) {
|
|
5100
|
-
console.warn("[StormcloudVideoPlayer] Failed to fetch/parse VAST XML: ".concat(vastTagUrl), error);
|
|
5101
|
-
}
|
|
5102
|
-
return [
|
|
5103
|
-
2,
|
|
5104
|
-
[]
|
|
5105
|
-
];
|
|
5106
|
-
case 4:
|
|
5107
|
-
return [
|
|
5108
|
-
2
|
|
5109
|
-
];
|
|
5110
|
-
}
|
|
5111
|
-
});
|
|
5112
|
-
}).call(this);
|
|
5113
|
-
}
|
|
5114
|
-
},
|
|
5115
|
-
{
|
|
5116
|
-
key: "extractMediaUrlsFromVast",
|
|
5117
|
-
value: function extractMediaUrlsFromVast(xmlText) {
|
|
5118
|
-
var mediaUrls = [];
|
|
5119
|
-
try {
|
|
5120
|
-
var parser = new DOMParser();
|
|
5121
|
-
var xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5122
|
-
var mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
|
|
5123
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5124
|
-
try {
|
|
5125
|
-
for(var _iterator = Array.from(mediaFileElements)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5126
|
-
var mediaFile = _step.value;
|
|
5127
|
-
var _mediaFile_textContent;
|
|
5128
|
-
var url = (_mediaFile_textContent = mediaFile.textContent) === null || _mediaFile_textContent === void 0 ? void 0 : _mediaFile_textContent.trim();
|
|
5129
|
-
if (url) {
|
|
5130
|
-
var lowerUrl = url.toLowerCase();
|
|
5131
|
-
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")) {
|
|
5132
|
-
mediaUrls.push(url);
|
|
5133
|
-
}
|
|
5134
|
-
}
|
|
5135
|
-
}
|
|
5136
|
-
} catch (err) {
|
|
5137
|
-
_didIteratorError = true;
|
|
5138
|
-
_iteratorError = err;
|
|
5139
|
-
} finally{
|
|
5140
|
-
try {
|
|
5141
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5142
|
-
_iterator.return();
|
|
5143
|
-
}
|
|
5144
|
-
} finally{
|
|
5145
|
-
if (_didIteratorError) {
|
|
5146
|
-
throw _iteratorError;
|
|
5147
|
-
}
|
|
5148
|
-
}
|
|
5149
|
-
}
|
|
5150
|
-
if (this.config.debugAdTiming && mediaUrls.length > 0) {
|
|
5151
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs from VAST:"), mediaUrls);
|
|
5152
|
-
}
|
|
5153
|
-
} catch (error) {
|
|
5154
|
-
if (this.config.debugAdTiming) {
|
|
5155
|
-
console.warn("[StormcloudVideoPlayer] Failed to parse VAST XML:", error);
|
|
5156
|
-
}
|
|
5157
|
-
}
|
|
5158
|
-
return mediaUrls;
|
|
5159
|
-
}
|
|
5160
|
-
},
|
|
5161
|
-
{
|
|
5162
|
-
key: "fetchVastDuration",
|
|
5163
|
-
value: function fetchVastDuration(vastTagUrl) {
|
|
5164
|
-
return _async_to_generator(function() {
|
|
5165
|
-
var _xmlDoc_querySelector, response, xmlText, parser, xmlDoc, durationText, durationParts, durationSeconds, error;
|
|
5166
|
-
return _ts_generator(this, function(_state) {
|
|
5167
|
-
switch(_state.label){
|
|
5168
|
-
case 0:
|
|
5169
|
-
_state.trys.push([
|
|
5170
|
-
0,
|
|
5171
|
-
3,
|
|
5172
|
-
,
|
|
5173
|
-
4
|
|
5174
|
-
]);
|
|
5175
|
-
return [
|
|
5176
|
-
4,
|
|
5177
|
-
fetch(vastTagUrl, {
|
|
5178
|
-
mode: "cors",
|
|
5179
|
-
credentials: "include",
|
|
5180
|
-
headers: {
|
|
5181
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5182
|
-
},
|
|
5183
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5184
|
-
})
|
|
5185
|
-
];
|
|
5186
|
-
case 1:
|
|
5187
|
-
response = _state.sent();
|
|
5188
|
-
if (!response.ok) {
|
|
5189
|
-
if (this.config.debugAdTiming) {
|
|
5190
|
-
console.warn("[ADAPTIVE-POD] Failed to fetch VAST: ".concat(response.status));
|
|
5191
|
-
}
|
|
5192
|
-
return [
|
|
5193
|
-
2,
|
|
5194
|
-
null
|
|
5195
|
-
];
|
|
5196
|
-
}
|
|
5197
|
-
return [
|
|
5198
|
-
4,
|
|
5199
|
-
response.text()
|
|
5200
|
-
];
|
|
5201
|
-
case 2:
|
|
5202
|
-
xmlText = _state.sent();
|
|
5203
|
-
parser = new DOMParser();
|
|
5204
|
-
xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5205
|
-
durationText = (_xmlDoc_querySelector = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector === void 0 ? void 0 : _xmlDoc_querySelector.textContent;
|
|
5206
|
-
if (!durationText) {
|
|
5207
|
-
if (this.config.debugAdTiming) {
|
|
5208
|
-
console.warn("[ADAPTIVE-POD] No Duration element found in VAST");
|
|
5209
|
-
}
|
|
5210
|
-
return [
|
|
5211
|
-
2,
|
|
5212
|
-
null
|
|
5213
|
-
];
|
|
5214
|
-
}
|
|
5215
|
-
durationParts = durationText.split(":");
|
|
5216
|
-
durationSeconds = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
5217
|
-
return [
|
|
5218
|
-
2,
|
|
5219
|
-
durationSeconds
|
|
5220
|
-
];
|
|
5221
|
-
case 3:
|
|
5222
|
-
error = _state.sent();
|
|
5223
|
-
if (this.config.debugAdTiming) {
|
|
5224
|
-
console.warn("[ADAPTIVE-POD] Error fetching VAST duration from ".concat(vastTagUrl, ":"), error);
|
|
5225
|
-
}
|
|
5226
|
-
return [
|
|
5227
|
-
2,
|
|
5228
|
-
null
|
|
5229
|
-
];
|
|
5230
|
-
case 4:
|
|
5231
|
-
return [
|
|
5232
|
-
2
|
|
5233
|
-
];
|
|
5234
|
-
}
|
|
5235
|
-
});
|
|
5236
|
-
}).call(this);
|
|
5237
|
-
}
|
|
5238
|
-
},
|
|
5239
|
-
{
|
|
5240
|
-
key: "calculateAdditionalAdsNeeded",
|
|
5241
|
-
value: function calculateAdditionalAdsNeeded() {
|
|
5242
|
-
if (!this.isAdaptiveMode || this.targetAdBreakDurationMs === null) {
|
|
5243
|
-
return 0;
|
|
5244
|
-
}
|
|
5245
|
-
var totalFetchedDurationMs = 0;
|
|
5246
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5247
|
-
try {
|
|
5248
|
-
for(var _iterator = this.fetchedAdDurations.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5249
|
-
var duration = _step.value;
|
|
5250
|
-
totalFetchedDurationMs += duration * 1e3;
|
|
5251
|
-
}
|
|
5252
|
-
} catch (err) {
|
|
5253
|
-
_didIteratorError = true;
|
|
5254
|
-
_iteratorError = err;
|
|
5255
|
-
} finally{
|
|
5256
|
-
try {
|
|
5257
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5258
|
-
_iterator.return();
|
|
5259
|
-
}
|
|
5260
|
-
} finally{
|
|
5261
|
-
if (_didIteratorError) {
|
|
5262
|
-
throw _iteratorError;
|
|
5263
|
-
}
|
|
5264
|
-
}
|
|
5265
|
-
}
|
|
5266
|
-
var fetchedCount = this.fetchedAdDurations.size;
|
|
5267
|
-
var averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
5268
|
-
var queuedButNotFetched = this.adPodAllUrls.length - fetchedCount;
|
|
5269
|
-
var estimatedQueuedDurationMs = queuedButNotFetched * averageDurationMs;
|
|
5270
|
-
var estimatedTotalDurationMs = totalFetchedDurationMs + estimatedQueuedDurationMs;
|
|
5271
|
-
var remainingTimeMs = this.targetAdBreakDurationMs - estimatedTotalDurationMs;
|
|
5272
|
-
if (remainingTimeMs <= 0) {
|
|
5273
|
-
if (this.config.debugAdTiming) {
|
|
5274
|
-
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"));
|
|
5275
|
-
}
|
|
5276
|
-
return 0;
|
|
5277
|
-
}
|
|
5278
|
-
var additionalAds = Math.ceil(remainingTimeMs / averageDurationMs);
|
|
5279
|
-
if (this.config.debugAdTiming) {
|
|
5280
|
-
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"));
|
|
5281
|
-
}
|
|
5282
|
-
return additionalAds;
|
|
5283
|
-
}
|
|
5284
|
-
},
|
|
5285
|
-
{
|
|
5286
|
-
key: "addAdaptiveAdsToQueue",
|
|
5287
|
-
value: function addAdaptiveAdsToQueue() {
|
|
5288
|
-
return _async_to_generator(function() {
|
|
5289
|
-
var _this_adPodAllUrls, _this_adPodQueue, additionalAds, newUrls;
|
|
5290
|
-
return _ts_generator(this, function(_state) {
|
|
5291
|
-
if (!this.isAdaptiveMode || !this.apiVastTagUrl) {
|
|
5292
|
-
return [
|
|
5293
|
-
2
|
|
5294
|
-
];
|
|
5295
|
-
}
|
|
5296
|
-
additionalAds = this.calculateAdditionalAdsNeeded();
|
|
5297
|
-
if (additionalAds <= 0) {
|
|
5298
|
-
return [
|
|
5299
|
-
2
|
|
5300
|
-
];
|
|
5301
|
-
}
|
|
5302
|
-
newUrls = this.generateVastUrlsWithCorrelators(this.apiVastTagUrl, additionalAds);
|
|
5303
|
-
if (this.config.debugAdTiming) {
|
|
5304
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Adding ".concat(newUrls.length, " additional VAST URLs to queue (will be preloaded sequentially)"));
|
|
5305
|
-
}
|
|
5306
|
-
(_this_adPodAllUrls = this.adPodAllUrls).push.apply(_this_adPodAllUrls, _to_consumable_array(newUrls));
|
|
5307
|
-
(_this_adPodQueue = this.adPodQueue).push.apply(_this_adPodQueue, _to_consumable_array(newUrls));
|
|
5308
|
-
this.totalAdsInBreak += newUrls.length;
|
|
5309
|
-
return [
|
|
5310
|
-
2
|
|
5311
|
-
];
|
|
5312
|
-
});
|
|
5313
|
-
}).call(this);
|
|
5314
|
-
}
|
|
5315
|
-
},
|
|
5316
|
-
{
|
|
5317
|
-
key: "preloadMediaFile",
|
|
5318
|
-
value: function preloadMediaFile(mediaUrl) {
|
|
5319
|
-
return _async_to_generator(function() {
|
|
5320
|
-
var response, error;
|
|
5321
|
-
return _ts_generator(this, function(_state) {
|
|
5322
|
-
switch(_state.label){
|
|
5323
|
-
case 0:
|
|
5324
|
-
if (this.preloadedMediaUrls.has(mediaUrl)) {
|
|
5325
|
-
return [
|
|
5326
|
-
2
|
|
5327
|
-
];
|
|
5328
|
-
}
|
|
5329
|
-
if (this.preloadingMediaUrls.has(mediaUrl)) {
|
|
5330
|
-
return [
|
|
5331
|
-
2
|
|
5332
|
-
];
|
|
5333
|
-
}
|
|
5334
|
-
this.preloadingMediaUrls.add(mediaUrl);
|
|
5335
|
-
_state.label = 1;
|
|
5336
|
-
case 1:
|
|
5337
|
-
_state.trys.push([
|
|
5338
|
-
1,
|
|
5339
|
-
3,
|
|
5340
|
-
4,
|
|
5341
|
-
5
|
|
5342
|
-
]);
|
|
5343
|
-
if (this.config.debugAdTiming) {
|
|
5344
|
-
console.log("[StormcloudVideoPlayer] Preloading video file: ".concat(mediaUrl));
|
|
5345
|
-
}
|
|
5346
|
-
return [
|
|
5347
|
-
4,
|
|
5348
|
-
fetch(mediaUrl, {
|
|
5349
|
-
mode: "cors",
|
|
5350
|
-
credentials: "include",
|
|
5351
|
-
method: "GET",
|
|
5352
|
-
headers: {
|
|
5353
|
-
Range: "bytes=0-1048576"
|
|
5354
|
-
},
|
|
5355
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5356
|
-
})
|
|
5357
|
-
];
|
|
5358
|
-
case 2:
|
|
5359
|
-
response = _state.sent();
|
|
5360
|
-
if (response.ok || response.status === 206) {
|
|
5361
|
-
this.preloadedMediaUrls.add(mediaUrl);
|
|
5362
|
-
if (this.config.debugAdTiming) {
|
|
5363
|
-
console.log("[StormcloudVideoPlayer] Successfully preloaded video file: ".concat(mediaUrl));
|
|
5364
|
-
}
|
|
5365
|
-
}
|
|
5366
|
-
return [
|
|
5367
|
-
3,
|
|
5368
|
-
5
|
|
5369
|
-
];
|
|
5370
|
-
case 3:
|
|
5371
|
-
error = _state.sent();
|
|
5372
|
-
if (this.config.debugAdTiming) {
|
|
5373
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload video file: ".concat(mediaUrl), error);
|
|
5374
|
-
}
|
|
5375
|
-
return [
|
|
5376
|
-
3,
|
|
5377
|
-
5
|
|
5378
|
-
];
|
|
5379
|
-
case 4:
|
|
5380
|
-
this.preloadingMediaUrls.delete(mediaUrl);
|
|
5381
|
-
return [
|
|
5382
|
-
7
|
|
5383
|
-
];
|
|
5384
|
-
case 5:
|
|
5385
|
-
return [
|
|
5386
|
-
2
|
|
5387
|
-
];
|
|
5388
|
-
}
|
|
5389
|
-
});
|
|
5390
|
-
}).call(this);
|
|
5391
|
-
}
|
|
5392
|
-
},
|
|
5393
|
-
{
|
|
5394
|
-
key: "preloadAllAdsInBackground",
|
|
5395
|
-
value: function preloadAllAdsInBackground() {
|
|
5396
|
-
return _async_to_generator(function() {
|
|
5397
|
-
var _this, processedUrls, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, _this_ima_hasPreloadedAd, _this_ima, nextUrl, error, preloadPromises;
|
|
5398
|
-
return _ts_generator(this, function(_state) {
|
|
5399
|
-
switch(_state.label){
|
|
5400
|
-
case 0:
|
|
5401
|
-
_this = this;
|
|
5402
|
-
if (this.adPodAllUrls.length === 0) {
|
|
5403
|
-
return [
|
|
5404
|
-
2
|
|
5405
|
-
];
|
|
5406
|
-
}
|
|
5407
|
-
if (!this.isAdaptiveMode) return [
|
|
5408
|
-
3,
|
|
5409
|
-
7
|
|
5410
|
-
];
|
|
5411
|
-
if (this.config.debugAdTiming) {
|
|
5412
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Starting sequential preload of remaining ads");
|
|
5413
|
-
}
|
|
5414
|
-
processedUrls = /* @__PURE__ */ new Set();
|
|
5415
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5416
|
-
try {
|
|
5417
|
-
for(_iterator = this.adPodAllUrls[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5418
|
-
url = _step.value;
|
|
5419
|
-
;
|
|
5420
|
-
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)) {
|
|
5421
|
-
processedUrls.add(url);
|
|
5422
|
-
}
|
|
5423
|
-
}
|
|
5424
|
-
} catch (err) {
|
|
5425
|
-
_didIteratorError = true;
|
|
5426
|
-
_iteratorError = err;
|
|
5427
|
-
} finally{
|
|
5428
|
-
try {
|
|
5429
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5430
|
-
_iterator.return();
|
|
5431
|
-
}
|
|
5432
|
-
} finally{
|
|
5433
|
-
if (_didIteratorError) {
|
|
5434
|
-
throw _iteratorError;
|
|
5435
|
-
}
|
|
5436
|
-
}
|
|
5437
|
-
}
|
|
5438
|
-
if (this.config.debugAdTiming && processedUrls.size > 0) {
|
|
5439
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE6 Skipping ".concat(processedUrls.size, " already-preloaded ads"));
|
|
5440
|
-
}
|
|
5441
|
-
_state.label = 1;
|
|
5442
|
-
case 1:
|
|
5443
|
-
if (!true) return [
|
|
5444
|
-
3,
|
|
5445
|
-
6
|
|
5446
|
-
];
|
|
5447
|
-
nextUrl = this.adPodAllUrls.find(function(url) {
|
|
5448
|
-
return !processedUrls.has(url);
|
|
5449
|
-
});
|
|
5450
|
-
if (!nextUrl) {
|
|
5451
|
-
if (this.config.debugAdTiming) {
|
|
5452
|
-
console.log("[ADAPTIVE-POD] ✅ All queued ads processed (".concat(processedUrls.size, " total)"));
|
|
5453
|
-
}
|
|
5454
|
-
return [
|
|
5455
|
-
3,
|
|
5456
|
-
6
|
|
5457
|
-
];
|
|
5458
|
-
}
|
|
5459
|
-
processedUrls.add(nextUrl);
|
|
5460
|
-
if (this.config.debugAdTiming) {
|
|
5461
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE5 Preloading ad ".concat(processedUrls.size, "/").concat(this.adPodAllUrls.length, "..."));
|
|
5462
|
-
}
|
|
5463
|
-
_state.label = 2;
|
|
5464
|
-
case 2:
|
|
5465
|
-
_state.trys.push([
|
|
5466
|
-
2,
|
|
5467
|
-
4,
|
|
5468
|
-
,
|
|
5469
|
-
5
|
|
5470
|
-
]);
|
|
5471
|
-
return [
|
|
5472
|
-
4,
|
|
5473
|
-
this.preloadSingleAd(nextUrl)
|
|
5474
|
-
];
|
|
5475
|
-
case 3:
|
|
5476
|
-
_state.sent();
|
|
5477
|
-
return [
|
|
5478
|
-
3,
|
|
5479
|
-
5
|
|
5480
|
-
];
|
|
5481
|
-
case 4:
|
|
5482
|
-
error = _state.sent();
|
|
5483
|
-
if (this.config.debugAdTiming) {
|
|
5484
|
-
console.warn("[ADAPTIVE-POD] ⚠️ Preload failed for ad ".concat(processedUrls.size, ":"), error);
|
|
5485
|
-
}
|
|
5486
|
-
return [
|
|
5487
|
-
3,
|
|
5488
|
-
5
|
|
5489
|
-
];
|
|
5490
|
-
case 5:
|
|
5491
|
-
if (this.calculateAdditionalAdsNeeded() === 0) {
|
|
5492
|
-
if (this.config.debugAdTiming) {
|
|
5493
|
-
console.log("[ADAPTIVE-POD] ✅ Target duration reached (".concat(processedUrls.size, " ads preloaded), stopping"));
|
|
5494
|
-
}
|
|
5495
|
-
return [
|
|
5496
|
-
3,
|
|
5497
|
-
6
|
|
5498
|
-
];
|
|
5499
|
-
}
|
|
5500
|
-
return [
|
|
5501
|
-
3,
|
|
5502
|
-
1
|
|
5503
|
-
];
|
|
5504
|
-
case 6:
|
|
5505
|
-
if (this.config.debugAdTiming) {
|
|
5506
|
-
console.log("[ADAPTIVE-POD] ✅ Sequential preloading completed (".concat(processedUrls.size, " ads ready)"));
|
|
5507
|
-
}
|
|
5508
|
-
return [
|
|
5509
|
-
3,
|
|
5510
|
-
9
|
|
5511
|
-
];
|
|
5512
|
-
case 7:
|
|
5513
|
-
if (this.config.debugAdTiming) {
|
|
5514
|
-
console.log("[StormcloudVideoPlayer] Starting parallel preload of ".concat(this.adPodAllUrls.length, " ads"));
|
|
5515
|
-
}
|
|
5516
|
-
preloadPromises = this.adPodAllUrls.map(function(vastTagUrl) {
|
|
5517
|
-
return _this.preloadSingleAd(vastTagUrl).catch(function(error) {
|
|
5518
|
-
if (_this.config.debugAdTiming) {
|
|
5519
|
-
console.warn("[StormcloudVideoPlayer] Preload failed for ".concat(vastTagUrl, ":"), error);
|
|
5520
|
-
}
|
|
5521
|
-
});
|
|
5522
|
-
});
|
|
5523
|
-
return [
|
|
5524
|
-
4,
|
|
5525
|
-
Promise.all(preloadPromises)
|
|
5526
|
-
];
|
|
5527
|
-
case 8:
|
|
5528
|
-
_state.sent();
|
|
5529
|
-
if (this.config.debugAdTiming) {
|
|
5530
|
-
console.log("[StormcloudVideoPlayer] Background preloading completed for all ads");
|
|
5531
|
-
}
|
|
5532
|
-
_state.label = 9;
|
|
5533
|
-
case 9:
|
|
5534
|
-
return [
|
|
5535
|
-
2
|
|
5536
|
-
];
|
|
5537
|
-
}
|
|
5538
|
-
});
|
|
5539
|
-
}).call(this);
|
|
5540
|
-
}
|
|
5541
|
-
},
|
|
5542
|
-
{
|
|
5543
|
-
key: "preloadSingleAd",
|
|
5544
|
-
value: function preloadSingleAd(vastTagUrl) {
|
|
5545
|
-
return _async_to_generator(function() {
|
|
5546
|
-
var _this, duration, mediaUrls, primaryMediaUrl, error;
|
|
5547
|
-
return _ts_generator(this, function(_state) {
|
|
5548
|
-
switch(_state.label){
|
|
5549
|
-
case 0:
|
|
5550
|
-
_this = this;
|
|
5551
|
-
if (!vastTagUrl) return [
|
|
5552
|
-
2
|
|
5553
|
-
];
|
|
5554
|
-
_state.label = 1;
|
|
5555
|
-
case 1:
|
|
5556
|
-
_state.trys.push([
|
|
5557
|
-
1,
|
|
5558
|
-
11,
|
|
5559
|
-
,
|
|
5560
|
-
12
|
|
5561
|
-
]);
|
|
5562
|
-
if (!(this.isAdaptiveMode && !this.fetchedAdDurations.has(vastTagUrl))) return [
|
|
5563
|
-
3,
|
|
5564
|
-
4
|
|
5565
|
-
];
|
|
5566
|
-
return [
|
|
5567
|
-
4,
|
|
5568
|
-
this.fetchVastDuration(vastTagUrl)
|
|
5569
|
-
];
|
|
5570
|
-
case 2:
|
|
5571
|
-
duration = _state.sent();
|
|
5572
|
-
if (!(duration !== null)) return [
|
|
5573
|
-
3,
|
|
5574
|
-
4
|
|
5575
|
-
];
|
|
5576
|
-
this.fetchedAdDurations.set(vastTagUrl, duration);
|
|
5577
|
-
if (this.config.debugAdTiming) {
|
|
5578
|
-
console.log("[ADAPTIVE-POD] ✓ Fetched ad duration: ".concat(duration, "s (").concat(this.fetchedAdDurations.size, " ads fetched so far)"));
|
|
5579
|
-
}
|
|
5580
|
-
return [
|
|
5581
|
-
4,
|
|
5582
|
-
this.addAdaptiveAdsToQueue()
|
|
5583
|
-
];
|
|
5584
|
-
case 3:
|
|
5585
|
-
_state.sent();
|
|
5586
|
-
_state.label = 4;
|
|
5587
|
-
case 4:
|
|
5588
|
-
if (!(this.ima.preloadAds && !this.ima.hasPreloadedAd(vastTagUrl))) return [
|
|
5589
|
-
3,
|
|
5590
|
-
6
|
|
5591
|
-
];
|
|
5592
|
-
if (!!this.preloadingAdUrls.has(vastTagUrl)) return [
|
|
5593
|
-
3,
|
|
5594
|
-
6
|
|
5595
|
-
];
|
|
5596
|
-
if (this.config.debugAdTiming) {
|
|
5597
|
-
console.log("[StormcloudVideoPlayer] Preloading VAST: ".concat(vastTagUrl));
|
|
5598
|
-
}
|
|
5599
|
-
this.preloadingAdUrls.add(vastTagUrl);
|
|
5600
|
-
return [
|
|
5601
|
-
4,
|
|
5602
|
-
this.ima.preloadAds(vastTagUrl).then(function() {
|
|
5603
|
-
if (_this.config.debugAdTiming) {
|
|
5604
|
-
console.log("[StormcloudVideoPlayer] IMA VAST preload complete: ".concat(vastTagUrl));
|
|
5605
|
-
}
|
|
5606
|
-
}).catch(function(error) {
|
|
5607
|
-
if (_this.config.debugAdTiming) {
|
|
5608
|
-
console.warn("[StormcloudVideoPlayer] IMA VAST preload failed: ".concat(vastTagUrl), error);
|
|
5609
|
-
}
|
|
5610
|
-
}).finally(function() {
|
|
5611
|
-
_this.preloadingAdUrls.delete(vastTagUrl);
|
|
5612
|
-
})
|
|
5613
|
-
];
|
|
5614
|
-
case 5:
|
|
5615
|
-
_state.sent();
|
|
5616
|
-
_state.label = 6;
|
|
5617
|
-
case 6:
|
|
5618
|
-
mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5619
|
-
if (!!mediaUrls) return [
|
|
5620
|
-
3,
|
|
5621
|
-
8
|
|
5622
|
-
];
|
|
5623
|
-
if (this.config.debugAdTiming) {
|
|
5624
|
-
console.log("[StormcloudVideoPlayer] Fetching and parsing VAST to extract media URLs: ".concat(vastTagUrl));
|
|
5625
|
-
}
|
|
5626
|
-
return [
|
|
5627
|
-
4,
|
|
5628
|
-
this.fetchAndParseVastXml(vastTagUrl)
|
|
5629
|
-
];
|
|
5630
|
-
case 7:
|
|
5631
|
-
mediaUrls = _state.sent();
|
|
5632
|
-
if (this.config.debugAdTiming) {
|
|
5633
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs:"), mediaUrls);
|
|
5634
|
-
}
|
|
5635
|
-
if (mediaUrls.length > 0) {
|
|
5636
|
-
this.vastToMediaUrlMap.set(vastTagUrl, mediaUrls);
|
|
5637
|
-
}
|
|
5638
|
-
_state.label = 8;
|
|
5639
|
-
case 8:
|
|
5640
|
-
if (!(mediaUrls && mediaUrls.length > 0)) return [
|
|
5641
|
-
3,
|
|
5642
|
-
10
|
|
5643
|
-
];
|
|
5644
|
-
primaryMediaUrl = mediaUrls[0];
|
|
5645
|
-
if (!(primaryMediaUrl && !this.preloadedMediaUrls.has(primaryMediaUrl))) return [
|
|
5646
|
-
3,
|
|
5647
|
-
10
|
|
5648
|
-
];
|
|
5649
|
-
return [
|
|
5650
|
-
4,
|
|
5651
|
-
this.preloadMediaFile(primaryMediaUrl)
|
|
5652
|
-
];
|
|
5653
|
-
case 9:
|
|
5654
|
-
_state.sent();
|
|
5655
|
-
_state.label = 10;
|
|
5656
|
-
case 10:
|
|
5657
|
-
return [
|
|
5658
|
-
3,
|
|
5659
|
-
12
|
|
5660
|
-
];
|
|
5661
|
-
case 11:
|
|
5662
|
-
error = _state.sent();
|
|
5663
|
-
if (this.config.debugAdTiming) {
|
|
5664
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload ad: ".concat(vastTagUrl), error);
|
|
5665
|
-
}
|
|
5666
|
-
return [
|
|
5667
|
-
3,
|
|
5668
|
-
12
|
|
5669
|
-
];
|
|
5670
|
-
case 12:
|
|
5671
|
-
return [
|
|
5672
|
-
2
|
|
5673
|
-
];
|
|
5674
|
-
}
|
|
5675
|
-
});
|
|
5676
|
-
}).call(this);
|
|
5677
|
-
}
|
|
5678
|
-
},
|
|
5679
|
-
{
|
|
5680
|
-
key: "findNextPreloadedAd",
|
|
5681
|
-
value: function findNextPreloadedAd() {
|
|
5682
|
-
for(var i = 0; i < this.adPodQueue.length; i++){
|
|
5683
|
-
var _this_ima_hasPreloadedAd, _this_ima;
|
|
5684
|
-
var vastTagUrl = this.adPodQueue[i];
|
|
5685
|
-
if (!vastTagUrl) continue;
|
|
5686
|
-
if (this.failedVastUrls.has(vastTagUrl)) {
|
|
5687
|
-
console.warn("[AD-ERROR] Skipping failed URL in queue");
|
|
5688
|
-
continue;
|
|
5689
|
-
}
|
|
5690
|
-
var _this_ima_hasPreloadedAd1;
|
|
5691
|
-
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;
|
|
5692
|
-
var mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5693
|
-
var hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
|
|
5694
|
-
if (hasImaPreload || hasMediaPreload) {
|
|
5695
|
-
this.adPodQueue.splice(0, i + 1);
|
|
5696
|
-
return vastTagUrl;
|
|
5697
|
-
}
|
|
5698
|
-
}
|
|
5699
|
-
return void 0;
|
|
5700
|
-
}
|
|
5701
|
-
},
|
|
5702
4753
|
{
|
|
5703
4754
|
key: "getRemainingAdMs",
|
|
5704
4755
|
value: function getRemainingAdMs() {
|
|
@@ -5885,7 +4936,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5885
4936
|
}
|
|
5886
4937
|
if (this.ima && this.ima.isAdPlaying()) {
|
|
5887
4938
|
var width = this.video.clientWidth || 640;
|
|
5888
|
-
var height = this.video.clientHeight ||
|
|
4939
|
+
var height = this.video.clientHeight || 480;
|
|
5889
4940
|
if (this.config.debugAdTiming) {
|
|
5890
4941
|
console.log("[StormcloudVideoPlayer] Resizing ads manager to ".concat(width, "x").concat(height));
|
|
5891
4942
|
}
|
|
@@ -5916,13 +4967,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5916
4967
|
}
|
|
5917
4968
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5918
4969
|
(_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
|
|
5919
|
-
this.preloadingAdUrls.clear();
|
|
5920
|
-
this.vastToMediaUrlMap.clear();
|
|
5921
|
-
this.preloadedMediaUrls.clear();
|
|
5922
|
-
this.preloadingMediaUrls.clear();
|
|
5923
|
-
this.adPodAllUrls = [];
|
|
5924
4970
|
this.adRequestQueue = [];
|
|
5925
|
-
this.successfulAdRequests = [];
|
|
5926
4971
|
}
|
|
5927
4972
|
}
|
|
5928
4973
|
]);
|