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
|
@@ -309,20 +309,6 @@ function _ts_generator(thisArg, body) {
|
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
-
function _ts_values(o) {
|
|
313
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
314
|
-
if (m) return m.call(o);
|
|
315
|
-
if (o && typeof o.length === "number") return {
|
|
316
|
-
next: function() {
|
|
317
|
-
if (o && i >= o.length) o = void 0;
|
|
318
|
-
return {
|
|
319
|
-
value: o && o[i++],
|
|
320
|
-
done: !o
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
325
|
-
}
|
|
326
312
|
var __create = Object.create;
|
|
327
313
|
var __defProp = Object.defineProperty;
|
|
328
314
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -559,8 +545,6 @@ function createImaController(video, options) {
|
|
|
559
545
|
var originalMutedState = false;
|
|
560
546
|
var originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
561
547
|
var listeners = /* @__PURE__ */ new Map();
|
|
562
|
-
var preloadedVast = /* @__PURE__ */ new Map();
|
|
563
|
-
var preloadingVast = /* @__PURE__ */ new Map();
|
|
564
548
|
var adVideoElement;
|
|
565
549
|
function setAdPlayingFlag(isPlaying) {
|
|
566
550
|
if (isPlaying) {
|
|
@@ -710,10 +694,10 @@ function createImaController(video, options) {
|
|
|
710
694
|
var adsLoadedReject;
|
|
711
695
|
function makeAdsRequest(google, vastTagUrl) {
|
|
712
696
|
var adsRequest = new google.ima.AdsRequest();
|
|
713
|
-
console.log("[IMA] \uD83D\uDCE1 Requesting VAST
|
|
697
|
+
console.log("[IMA] \uD83D\uDCE1 Requesting VAST via IMA SDK:", vastTagUrl.substring(0, 80) + "...");
|
|
714
698
|
adsRequest.adTagUrl = vastTagUrl;
|
|
715
699
|
var videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
716
|
-
var videoHeight = video.offsetHeight || video.clientHeight ||
|
|
700
|
+
var videoHeight = video.offsetHeight || video.clientHeight || 480;
|
|
717
701
|
adsRequest.linearAdSlotWidth = videoWidth;
|
|
718
702
|
adsRequest.linearAdSlotHeight = videoHeight;
|
|
719
703
|
adsRequest.nonLinearAdSlotWidth = videoWidth;
|
|
@@ -759,36 +743,6 @@ function createImaController(video, options) {
|
|
|
759
743
|
(_video_parentElement = video.parentElement) === null || _video_parentElement === void 0 ? void 0 : _video_parentElement.appendChild(container);
|
|
760
744
|
adContainerEl = container;
|
|
761
745
|
}
|
|
762
|
-
function fetchVastDocument(vastTagUrl) {
|
|
763
|
-
return _async_to_generator(function() {
|
|
764
|
-
var response;
|
|
765
|
-
return _ts_generator(this, function(_state) {
|
|
766
|
-
switch(_state.label){
|
|
767
|
-
case 0:
|
|
768
|
-
return [
|
|
769
|
-
4,
|
|
770
|
-
fetch(vastTagUrl, {
|
|
771
|
-
mode: "cors",
|
|
772
|
-
credentials: "include",
|
|
773
|
-
headers: {
|
|
774
|
-
"Accept": "application/xml, text/xml, */*"
|
|
775
|
-
},
|
|
776
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
777
|
-
})
|
|
778
|
-
];
|
|
779
|
-
case 1:
|
|
780
|
-
response = _state.sent();
|
|
781
|
-
if (!response.ok) {
|
|
782
|
-
throw new Error("Failed to preload VAST: ".concat(response.status));
|
|
783
|
-
}
|
|
784
|
-
return [
|
|
785
|
-
2,
|
|
786
|
-
response.text()
|
|
787
|
-
];
|
|
788
|
-
}
|
|
789
|
-
});
|
|
790
|
-
})();
|
|
791
|
-
}
|
|
792
746
|
function destroyAdsManager() {
|
|
793
747
|
if (adsManager) {
|
|
794
748
|
try {
|
|
@@ -1103,47 +1057,6 @@ function createImaController(video, options) {
|
|
|
1103
1057
|
});
|
|
1104
1058
|
})();
|
|
1105
1059
|
},
|
|
1106
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1107
|
-
return _async_to_generator(function() {
|
|
1108
|
-
var inflight, preloadPromise;
|
|
1109
|
-
return _ts_generator(this, function(_state) {
|
|
1110
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1111
|
-
return [
|
|
1112
|
-
2,
|
|
1113
|
-
Promise.resolve()
|
|
1114
|
-
];
|
|
1115
|
-
}
|
|
1116
|
-
if (preloadedVast.has(vastTagUrl)) {
|
|
1117
|
-
return [
|
|
1118
|
-
2,
|
|
1119
|
-
Promise.resolve()
|
|
1120
|
-
];
|
|
1121
|
-
}
|
|
1122
|
-
inflight = preloadingVast.get(vastTagUrl);
|
|
1123
|
-
if (inflight) {
|
|
1124
|
-
return [
|
|
1125
|
-
2,
|
|
1126
|
-
inflight
|
|
1127
|
-
];
|
|
1128
|
-
}
|
|
1129
|
-
preloadPromise = fetchVastDocument(vastTagUrl).then(function(xml) {
|
|
1130
|
-
preloadedVast.set(vastTagUrl, xml);
|
|
1131
|
-
}).catch(function() {
|
|
1132
|
-
preloadedVast.delete(vastTagUrl);
|
|
1133
|
-
}).finally(function() {
|
|
1134
|
-
preloadingVast.delete(vastTagUrl);
|
|
1135
|
-
});
|
|
1136
|
-
preloadingVast.set(vastTagUrl, preloadPromise);
|
|
1137
|
-
return [
|
|
1138
|
-
2,
|
|
1139
|
-
preloadPromise
|
|
1140
|
-
];
|
|
1141
|
-
});
|
|
1142
|
-
})();
|
|
1143
|
-
},
|
|
1144
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1145
|
-
return preloadedVast.has(vastTagUrl);
|
|
1146
|
-
},
|
|
1147
1060
|
play: function play() {
|
|
1148
1061
|
return _async_to_generator(function() {
|
|
1149
1062
|
var _window_google, width, height, adVolume, _video_play;
|
|
@@ -1162,7 +1075,7 @@ function createImaController(video, options) {
|
|
|
1162
1075
|
}
|
|
1163
1076
|
try {
|
|
1164
1077
|
width = video.clientWidth || 640;
|
|
1165
|
-
height = video.clientHeight ||
|
|
1078
|
+
height = video.clientHeight || 480;
|
|
1166
1079
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
1167
1080
|
adPlaying = true;
|
|
1168
1081
|
adVolume = originalMutedState ? 0 : originalVolume;
|
|
@@ -1252,8 +1165,6 @@ function createImaController(video, options) {
|
|
|
1252
1165
|
adDisplayContainer = void 0;
|
|
1253
1166
|
adsLoader = void 0;
|
|
1254
1167
|
contentVideoHidden = false;
|
|
1255
|
-
preloadedVast.clear();
|
|
1256
|
-
preloadingVast.clear();
|
|
1257
1168
|
},
|
|
1258
1169
|
isAdPlaying: function isAdPlaying() {
|
|
1259
1170
|
return adPlaying;
|
|
@@ -1854,51 +1765,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1854
1765
|
});
|
|
1855
1766
|
})();
|
|
1856
1767
|
},
|
|
1857
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1858
|
-
return _async_to_generator(function() {
|
|
1859
|
-
var inflight, preloadPromise;
|
|
1860
|
-
return _ts_generator(this, function(_state) {
|
|
1861
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1862
|
-
return [
|
|
1863
|
-
2,
|
|
1864
|
-
Promise.resolve()
|
|
1865
|
-
];
|
|
1866
|
-
}
|
|
1867
|
-
if (preloadedAds.has(vastTagUrl)) {
|
|
1868
|
-
return [
|
|
1869
|
-
2,
|
|
1870
|
-
Promise.resolve()
|
|
1871
|
-
];
|
|
1872
|
-
}
|
|
1873
|
-
inflight = preloadingAds.get(vastTagUrl);
|
|
1874
|
-
if (inflight) {
|
|
1875
|
-
return [
|
|
1876
|
-
2,
|
|
1877
|
-
inflight
|
|
1878
|
-
];
|
|
1879
|
-
}
|
|
1880
|
-
preloadPromise = fetchAndParseVastAd(vastTagUrl).then(function(ad) {
|
|
1881
|
-
if (ad) {
|
|
1882
|
-
preloadedAds.set(vastTagUrl, ad);
|
|
1883
|
-
console.log("[HlsAdPlayer] Cached VAST response for preloading:", vastTagUrl);
|
|
1884
|
-
}
|
|
1885
|
-
}).catch(function(error) {
|
|
1886
|
-
console.warn("[HlsAdPlayer] Failed to preload VAST response:", error);
|
|
1887
|
-
preloadedAds.delete(vastTagUrl);
|
|
1888
|
-
}).finally(function() {
|
|
1889
|
-
preloadingAds.delete(vastTagUrl);
|
|
1890
|
-
});
|
|
1891
|
-
preloadingAds.set(vastTagUrl, preloadPromise);
|
|
1892
|
-
return [
|
|
1893
|
-
2,
|
|
1894
|
-
preloadPromise
|
|
1895
|
-
];
|
|
1896
|
-
});
|
|
1897
|
-
})();
|
|
1898
|
-
},
|
|
1899
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1900
|
-
return preloadedAds.has(vastTagUrl);
|
|
1901
|
-
},
|
|
1902
1768
|
play: function play() {
|
|
1903
1769
|
return _async_to_generator(function() {
|
|
1904
1770
|
var contentVolume, adVolume, mediaFile;
|
|
@@ -2790,32 +2656,17 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2790
2656
|
this.bufferedSegmentsCount = 0;
|
|
2791
2657
|
this.shouldAutoplayAfterBuffering = false;
|
|
2792
2658
|
this.hasInitialBufferCompleted = false;
|
|
2793
|
-
this.adPodAllUrls = [];
|
|
2794
|
-
this.preloadingAdUrls = /* @__PURE__ */ new Set();
|
|
2795
|
-
this.vastToMediaUrlMap = /* @__PURE__ */ new Map();
|
|
2796
|
-
this.preloadedMediaUrls = /* @__PURE__ */ new Set();
|
|
2797
|
-
this.preloadingMediaUrls = /* @__PURE__ */ new Set();
|
|
2798
2659
|
this.adRequestTokenCounter = 0;
|
|
2799
2660
|
this.activeAdRequestToken = null;
|
|
2800
2661
|
this.adRequestWatchdogToken = null;
|
|
2801
2662
|
this.adFailsafeToken = null;
|
|
2802
|
-
this.fetchedAdDurations = /* @__PURE__ */ new Map();
|
|
2803
|
-
this.targetAdBreakDurationMs = null;
|
|
2804
|
-
this.isAdaptiveMode = false;
|
|
2805
2663
|
this.failedVastUrls = /* @__PURE__ */ new Set();
|
|
2806
2664
|
this.continuousFetchingActive = false;
|
|
2807
2665
|
this.adRequestQueue = [];
|
|
2808
|
-
this.successfulAdRequests = [];
|
|
2809
2666
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2810
|
-
this.placeholderStartTimeMs = null;
|
|
2811
2667
|
this.isShowingPlaceholder = false;
|
|
2812
|
-
this.consecutiveEmptyResponses = 0;
|
|
2813
2668
|
this.totalAdRequestsInBreak = 0;
|
|
2814
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
2815
2669
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2816
|
-
this.maxConsecutiveEmptyResponses = 5;
|
|
2817
|
-
this.baseEmptyResponseDelayMs = 2e3;
|
|
2818
|
-
this.maxEmptyResponseDelayMs = 3e4;
|
|
2819
2670
|
initializePolyfills();
|
|
2820
2671
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2821
2672
|
this.config = _object_spread({}, config, browserOverrides);
|
|
@@ -3306,25 +3157,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3306
3157
|
}
|
|
3307
3158
|
});
|
|
3308
3159
|
this.ima.on("ad_error", function(errorPayload) {
|
|
3309
|
-
var remaining = _this.getRemainingAdMs();
|
|
3310
3160
|
console.error("[AD-ERROR] Ad playback failed", errorPayload || "");
|
|
3311
|
-
|
|
3312
|
-
if (remaining > 500 && _this.adPodQueue.length > 0) {
|
|
3313
|
-
var nextPreloaded = _this.findNextPreloadedAd();
|
|
3314
|
-
if (nextPreloaded) {
|
|
3315
|
-
_this.currentAdIndex++;
|
|
3316
|
-
_this.playSingleAd(nextPreloaded).catch(function() {
|
|
3317
|
-
_this.handleAdFailure();
|
|
3318
|
-
});
|
|
3319
|
-
} else {
|
|
3320
|
-
_this.handleAdFailure();
|
|
3321
|
-
}
|
|
3322
|
-
} else {
|
|
3323
|
-
_this.handleAdFailure();
|
|
3324
|
-
}
|
|
3325
|
-
} else {
|
|
3326
|
-
_this.handleAdFailure();
|
|
3327
|
-
}
|
|
3161
|
+
_this.handleAdFailure();
|
|
3328
3162
|
});
|
|
3329
3163
|
this.ima.on("content_pause", function() {
|
|
3330
3164
|
_this.clearAdFailsafeTimer();
|
|
@@ -4055,7 +3889,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4055
3889
|
key: "handleAdStart",
|
|
4056
3890
|
value: function handleAdStart(_marker) {
|
|
4057
3891
|
return _async_to_generator(function() {
|
|
4058
|
-
var scheduled, tags, baseVastUrl, adBreakDurationMs, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
3892
|
+
var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
4059
3893
|
return _ts_generator(this, function(_state) {
|
|
4060
3894
|
switch(_state.label){
|
|
4061
3895
|
case 0:
|
|
@@ -4071,35 +3905,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4071
3905
|
];
|
|
4072
3906
|
}
|
|
4073
3907
|
adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
|
|
4074
|
-
if (this.
|
|
4075
|
-
this.
|
|
4076
|
-
|
|
4077
|
-
this.fetchedAdDurations.clear();
|
|
4078
|
-
if (this.config.debugAdTiming) {
|
|
4079
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA LIVE MODE: Target duration=".concat(adBreakDurationMs, "ms | Will continuously fetch ads during break"));
|
|
4080
|
-
}
|
|
4081
|
-
} else {
|
|
4082
|
-
this.isAdaptiveMode = false;
|
|
4083
|
-
this.targetAdBreakDurationMs = null;
|
|
4084
|
-
this.fetchedAdDurations.clear();
|
|
4085
|
-
if (this.config.debugAdTiming) {
|
|
4086
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC VOD MODE: Using fixed ad strategy");
|
|
4087
|
-
}
|
|
3908
|
+
if (this.config.debugAdTiming) {
|
|
3909
|
+
mode = this.isLiveStream ? "LIVE" : "VOD";
|
|
3910
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
4088
3911
|
}
|
|
4089
|
-
this.adPodAllUrls = [];
|
|
4090
|
-
this.preloadingAdUrls.clear();
|
|
4091
|
-
this.vastToMediaUrlMap.clear();
|
|
4092
|
-
this.preloadedMediaUrls.clear();
|
|
4093
|
-
this.preloadingMediaUrls.clear();
|
|
4094
3912
|
this.failedVastUrls.clear();
|
|
4095
3913
|
this.adRequestQueue = [];
|
|
4096
|
-
this.successfulAdRequests = [];
|
|
4097
3914
|
this.continuousFetchingActive = true;
|
|
4098
3915
|
this.isShowingPlaceholder = false;
|
|
4099
|
-
this.placeholderStartTimeMs = null;
|
|
4100
|
-
this.consecutiveEmptyResponses = 0;
|
|
4101
3916
|
this.totalAdRequestsInBreak = 0;
|
|
4102
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
4103
3917
|
currentMuted = this.video.muted;
|
|
4104
3918
|
currentVolume = this.video.volume;
|
|
4105
3919
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
@@ -4145,7 +3959,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4145
3959
|
if (this.config.debugAdTiming) {
|
|
4146
3960
|
console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
|
|
4147
3961
|
}
|
|
4148
|
-
this.successfulAdRequests.push(firstAdUrl);
|
|
4149
3962
|
this.currentAdIndex++;
|
|
4150
3963
|
this.startContinuousFetching(baseVastUrl);
|
|
4151
3964
|
return [
|
|
@@ -4195,200 +4008,92 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4195
4008
|
key: "continuousFetchLoop",
|
|
4196
4009
|
value: function continuousFetchLoop(baseVastUrl) {
|
|
4197
4010
|
return _async_to_generator(function() {
|
|
4198
|
-
var
|
|
4011
|
+
var remaining, maxQueueSize, newAdUrl;
|
|
4199
4012
|
return _ts_generator(this, function(_state) {
|
|
4200
4013
|
switch(_state.label){
|
|
4201
4014
|
case 0:
|
|
4202
|
-
_loop = function() {
|
|
4203
|
-
var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
|
|
4204
|
-
return _ts_generator(this, function(_state) {
|
|
4205
|
-
switch(_state.label){
|
|
4206
|
-
case 0:
|
|
4207
|
-
remaining = _this.getRemainingAdMs();
|
|
4208
|
-
if (remaining <= 0) {
|
|
4209
|
-
if (_this.config.debugAdTiming) {
|
|
4210
|
-
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
|
|
4211
|
-
}
|
|
4212
|
-
return [
|
|
4213
|
-
2,
|
|
4214
|
-
"break"
|
|
4215
|
-
];
|
|
4216
|
-
}
|
|
4217
|
-
if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
|
|
4218
|
-
if (_this.config.debugAdTiming) {
|
|
4219
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
|
|
4220
|
-
}
|
|
4221
|
-
return [
|
|
4222
|
-
2,
|
|
4223
|
-
"break"
|
|
4224
|
-
];
|
|
4225
|
-
}
|
|
4226
|
-
if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
|
|
4227
|
-
if (_this.config.debugAdTiming) {
|
|
4228
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
|
|
4229
|
-
}
|
|
4230
|
-
return [
|
|
4231
|
-
2,
|
|
4232
|
-
"break"
|
|
4233
|
-
];
|
|
4234
|
-
}
|
|
4235
|
-
maxQueueSize = 3;
|
|
4236
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4237
|
-
3,
|
|
4238
|
-
2
|
|
4239
|
-
];
|
|
4240
|
-
if (_this.config.debugAdTiming) {
|
|
4241
|
-
console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
|
|
4242
|
-
}
|
|
4243
|
-
return [
|
|
4244
|
-
4,
|
|
4245
|
-
new Promise(function(resolve) {
|
|
4246
|
-
return setTimeout(resolve, 2e3);
|
|
4247
|
-
})
|
|
4248
|
-
];
|
|
4249
|
-
case 1:
|
|
4250
|
-
_state.sent();
|
|
4251
|
-
return [
|
|
4252
|
-
2,
|
|
4253
|
-
"continue"
|
|
4254
|
-
];
|
|
4255
|
-
case 2:
|
|
4256
|
-
newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4257
|
-
if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
|
|
4258
|
-
3,
|
|
4259
|
-
4
|
|
4260
|
-
];
|
|
4261
|
-
return [
|
|
4262
|
-
4,
|
|
4263
|
-
new Promise(function(resolve) {
|
|
4264
|
-
return setTimeout(resolve, 1e3);
|
|
4265
|
-
})
|
|
4266
|
-
];
|
|
4267
|
-
case 3:
|
|
4268
|
-
_state.sent();
|
|
4269
|
-
return [
|
|
4270
|
-
2,
|
|
4271
|
-
"continue"
|
|
4272
|
-
];
|
|
4273
|
-
case 4:
|
|
4274
|
-
_this.totalAdRequestsInBreak++;
|
|
4275
|
-
if (_this.config.debugAdTiming) {
|
|
4276
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
|
|
4277
|
-
}
|
|
4278
|
-
_state.label = 5;
|
|
4279
|
-
case 5:
|
|
4280
|
-
_state.trys.push([
|
|
4281
|
-
5,
|
|
4282
|
-
11,
|
|
4283
|
-
,
|
|
4284
|
-
13
|
|
4285
|
-
]);
|
|
4286
|
-
if (!_this.ima.preloadAds) return [
|
|
4287
|
-
3,
|
|
4288
|
-
7
|
|
4289
|
-
];
|
|
4290
|
-
return [
|
|
4291
|
-
4,
|
|
4292
|
-
_this.ima.preloadAds(newAdUrl)
|
|
4293
|
-
];
|
|
4294
|
-
case 6:
|
|
4295
|
-
_state.sent();
|
|
4296
|
-
_state.label = 7;
|
|
4297
|
-
case 7:
|
|
4298
|
-
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;
|
|
4299
|
-
if (!!hasPreloadedAd) return [
|
|
4300
|
-
3,
|
|
4301
|
-
9
|
|
4302
|
-
];
|
|
4303
|
-
_this.consecutiveEmptyResponses++;
|
|
4304
|
-
_this.lastEmptyResponseTimeMs = Date.now();
|
|
4305
|
-
backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4306
|
-
if (_this.config.debugAdTiming) {
|
|
4307
|
-
console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
|
|
4308
|
-
}
|
|
4309
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4310
|
-
return [
|
|
4311
|
-
4,
|
|
4312
|
-
new Promise(function(resolve) {
|
|
4313
|
-
return setTimeout(resolve, backoffDelay);
|
|
4314
|
-
})
|
|
4315
|
-
];
|
|
4316
|
-
case 8:
|
|
4317
|
-
_state.sent();
|
|
4318
|
-
return [
|
|
4319
|
-
2,
|
|
4320
|
-
"continue"
|
|
4321
|
-
];
|
|
4322
|
-
case 9:
|
|
4323
|
-
_this.consecutiveEmptyResponses = 0;
|
|
4324
|
-
if (_this.config.debugAdTiming) {
|
|
4325
|
-
console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
|
|
4326
|
-
}
|
|
4327
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
4328
|
-
_this.totalAdsInBreak++;
|
|
4329
|
-
return [
|
|
4330
|
-
4,
|
|
4331
|
-
new Promise(function(resolve) {
|
|
4332
|
-
return setTimeout(resolve, 500);
|
|
4333
|
-
})
|
|
4334
|
-
];
|
|
4335
|
-
case 10:
|
|
4336
|
-
_state.sent();
|
|
4337
|
-
return [
|
|
4338
|
-
3,
|
|
4339
|
-
13
|
|
4340
|
-
];
|
|
4341
|
-
case 11:
|
|
4342
|
-
error = _state.sent();
|
|
4343
|
-
if (_this.config.debugAdTiming) {
|
|
4344
|
-
console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
|
|
4345
|
-
}
|
|
4346
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4347
|
-
_this.consecutiveEmptyResponses++;
|
|
4348
|
-
backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4349
|
-
return [
|
|
4350
|
-
4,
|
|
4351
|
-
new Promise(function(resolve) {
|
|
4352
|
-
return setTimeout(resolve, backoffDelay1);
|
|
4353
|
-
})
|
|
4354
|
-
];
|
|
4355
|
-
case 12:
|
|
4356
|
-
_state.sent();
|
|
4357
|
-
return [
|
|
4358
|
-
3,
|
|
4359
|
-
13
|
|
4360
|
-
];
|
|
4361
|
-
case 13:
|
|
4362
|
-
return [
|
|
4363
|
-
2
|
|
4364
|
-
];
|
|
4365
|
-
}
|
|
4366
|
-
});
|
|
4367
|
-
};
|
|
4368
|
-
_state.label = 1;
|
|
4369
|
-
case 1:
|
|
4370
4015
|
if (!(this.continuousFetchingActive && this.inAdBreak)) return [
|
|
4371
4016
|
3,
|
|
4372
|
-
|
|
4017
|
+
6
|
|
4373
4018
|
];
|
|
4374
|
-
|
|
4019
|
+
remaining = this.getRemainingAdMs();
|
|
4020
|
+
if (remaining <= 0) {
|
|
4021
|
+
if (this.config.debugAdTiming) {
|
|
4022
|
+
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping URL generation");
|
|
4023
|
+
}
|
|
4024
|
+
return [
|
|
4025
|
+
3,
|
|
4026
|
+
6
|
|
4027
|
+
];
|
|
4028
|
+
}
|
|
4029
|
+
if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
|
|
4030
|
+
if (this.config.debugAdTiming) {
|
|
4031
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(this.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
4032
|
+
}
|
|
4033
|
+
return [
|
|
4034
|
+
3,
|
|
4035
|
+
6
|
|
4036
|
+
];
|
|
4037
|
+
}
|
|
4038
|
+
maxQueueSize = 5;
|
|
4039
|
+
if (!(this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4040
|
+
3,
|
|
4041
|
+
2
|
|
4042
|
+
];
|
|
4043
|
+
if (this.config.debugAdTiming) {
|
|
4044
|
+
console.log("[CONTINUOUS-FETCH] ⏸️ URL queue full (".concat(this.adRequestQueue.length, "), waiting..."));
|
|
4045
|
+
}
|
|
4375
4046
|
return [
|
|
4376
|
-
|
|
4377
|
-
|
|
4047
|
+
4,
|
|
4048
|
+
new Promise(function(resolve) {
|
|
4049
|
+
return setTimeout(resolve, 1e3);
|
|
4050
|
+
})
|
|
4051
|
+
];
|
|
4052
|
+
case 1:
|
|
4053
|
+
_state.sent();
|
|
4054
|
+
return [
|
|
4055
|
+
3,
|
|
4056
|
+
0
|
|
4378
4057
|
];
|
|
4379
4058
|
case 2:
|
|
4380
|
-
|
|
4381
|
-
if (
|
|
4059
|
+
newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4060
|
+
if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
|
|
4382
4061
|
3,
|
|
4383
|
-
|
|
4062
|
+
4
|
|
4384
4063
|
];
|
|
4385
4064
|
return [
|
|
4386
|
-
|
|
4387
|
-
|
|
4065
|
+
4,
|
|
4066
|
+
new Promise(function(resolve) {
|
|
4067
|
+
return setTimeout(resolve, 500);
|
|
4068
|
+
})
|
|
4388
4069
|
];
|
|
4389
4070
|
case 3:
|
|
4071
|
+
_state.sent();
|
|
4072
|
+
return [
|
|
4073
|
+
3,
|
|
4074
|
+
0
|
|
4075
|
+
];
|
|
4076
|
+
case 4:
|
|
4077
|
+
if (this.config.debugAdTiming) {
|
|
4078
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCDD Queued VAST URL (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
|
|
4079
|
+
}
|
|
4080
|
+
this.adRequestQueue.push(newAdUrl);
|
|
4081
|
+
this.totalAdsInBreak++;
|
|
4082
|
+
return [
|
|
4083
|
+
4,
|
|
4084
|
+
new Promise(function(resolve) {
|
|
4085
|
+
return setTimeout(resolve, 300);
|
|
4086
|
+
})
|
|
4087
|
+
];
|
|
4088
|
+
case 5:
|
|
4089
|
+
_state.sent();
|
|
4090
|
+
return [
|
|
4091
|
+
3,
|
|
4092
|
+
0
|
|
4093
|
+
];
|
|
4094
|
+
case 6:
|
|
4390
4095
|
if (this.config.debugAdTiming) {
|
|
4391
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1
|
|
4096
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"));
|
|
4392
4097
|
}
|
|
4393
4098
|
return [
|
|
4394
4099
|
2
|
|
@@ -4437,19 +4142,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4437
4142
|
2
|
|
4438
4143
|
];
|
|
4439
4144
|
if (this.config.debugAdTiming) {
|
|
4440
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC
|
|
4145
|
+
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)"));
|
|
4441
4146
|
}
|
|
4442
4147
|
currentMuted = this.video.muted;
|
|
4443
4148
|
currentVolume = this.video.volume;
|
|
4444
4149
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
4445
|
-
if (this.config.debugAdTiming) {
|
|
4446
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDD0A Updated ad audio state: muted=".concat(currentMuted, ", volume=").concat(currentVolume));
|
|
4447
|
-
}
|
|
4448
4150
|
this.currentAdIndex++;
|
|
4449
|
-
this.
|
|
4151
|
+
this.totalAdRequestsInBreak++;
|
|
4450
4152
|
return [
|
|
4451
4153
|
4,
|
|
4452
|
-
this.playSingleAd(nextAdUrl).catch(function() {
|
|
4154
|
+
this.playSingleAd(nextAdUrl).catch(function(error) {
|
|
4155
|
+
if (_this.config.debugAdTiming) {
|
|
4156
|
+
console.log("[CONTINUOUS-FETCH] \u274C Ad request failed:", error.message);
|
|
4157
|
+
}
|
|
4158
|
+
_this.failedVastUrls.add(nextAdUrl);
|
|
4453
4159
|
_this.tryNextAvailableAd(0);
|
|
4454
4160
|
})
|
|
4455
4161
|
];
|
|
@@ -4459,18 +4165,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4459
4165
|
2
|
|
4460
4166
|
];
|
|
4461
4167
|
case 2:
|
|
4462
|
-
maxRetries =
|
|
4168
|
+
maxRetries = 3;
|
|
4463
4169
|
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
4464
4170
|
3,
|
|
4465
4171
|
5
|
|
4466
4172
|
];
|
|
4467
4173
|
if (this.config.debugAdTiming) {
|
|
4468
|
-
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty
|
|
4174
|
+
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
4469
4175
|
}
|
|
4470
4176
|
return [
|
|
4471
4177
|
4,
|
|
4472
4178
|
new Promise(function(resolve) {
|
|
4473
|
-
return setTimeout(resolve,
|
|
4179
|
+
return setTimeout(resolve, 500);
|
|
4474
4180
|
})
|
|
4475
4181
|
];
|
|
4476
4182
|
case 3:
|
|
@@ -4519,12 +4225,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4519
4225
|
];
|
|
4520
4226
|
}
|
|
4521
4227
|
if (this.config.debugAdTiming) {
|
|
4522
|
-
console.log("[CONTINUOUS-FETCH] ⬛ Showing
|
|
4228
|
+
console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad URLs"));
|
|
4523
4229
|
}
|
|
4524
4230
|
this.isShowingPlaceholder = true;
|
|
4525
|
-
this.placeholderStartTimeMs = Date.now();
|
|
4526
4231
|
this.ima.showPlaceholder();
|
|
4527
|
-
checkInterval =
|
|
4232
|
+
checkInterval = 300;
|
|
4528
4233
|
maxChecks = Math.floor(waitTime / checkInterval);
|
|
4529
4234
|
i = 0;
|
|
4530
4235
|
_state.label = 1;
|
|
@@ -4551,10 +4256,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4551
4256
|
5
|
|
4552
4257
|
];
|
|
4553
4258
|
if (this.config.debugAdTiming) {
|
|
4554
|
-
console.log("[CONTINUOUS-FETCH] \u2705
|
|
4259
|
+
console.log("[CONTINUOUS-FETCH] \u2705 Ad URL available, requesting via IMA SDK");
|
|
4555
4260
|
}
|
|
4556
4261
|
this.isShowingPlaceholder = false;
|
|
4557
|
-
this.placeholderStartTimeMs = null;
|
|
4558
4262
|
this.ima.hidePlaceholder();
|
|
4559
4263
|
currentMuted = this.video.muted;
|
|
4560
4264
|
currentVolume = this.video.volume;
|
|
@@ -4565,7 +4269,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4565
4269
|
4
|
|
4566
4270
|
];
|
|
4567
4271
|
this.currentAdIndex++;
|
|
4568
|
-
this.
|
|
4272
|
+
this.totalAdRequestsInBreak++;
|
|
4569
4273
|
return [
|
|
4570
4274
|
4,
|
|
4571
4275
|
this.playSingleAd(nextAdUrl).catch(function() {
|
|
@@ -4587,10 +4291,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4587
4291
|
];
|
|
4588
4292
|
case 6:
|
|
4589
4293
|
if (this.config.debugAdTiming) {
|
|
4590
|
-
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout
|
|
4294
|
+
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
|
|
4591
4295
|
}
|
|
4592
4296
|
this.isShowingPlaceholder = false;
|
|
4593
|
-
this.placeholderStartTimeMs = null;
|
|
4594
4297
|
this.ima.hidePlaceholder();
|
|
4595
4298
|
this.handleAdPodComplete();
|
|
4596
4299
|
return [
|
|
@@ -4892,21 +4595,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4892
4595
|
if (this.isShowingPlaceholder) {
|
|
4893
4596
|
this.ima.hidePlaceholder();
|
|
4894
4597
|
this.isShowingPlaceholder = false;
|
|
4895
|
-
this.placeholderStartTimeMs = null;
|
|
4896
4598
|
}
|
|
4897
|
-
this.preloadingAdUrls.clear();
|
|
4898
|
-
this.vastToMediaUrlMap.clear();
|
|
4899
|
-
this.preloadedMediaUrls.clear();
|
|
4900
|
-
this.preloadingMediaUrls.clear();
|
|
4901
4599
|
this.adRequestQueue = [];
|
|
4902
|
-
this.successfulAdRequests = [];
|
|
4903
4600
|
this.inAdBreak = false;
|
|
4904
4601
|
this.expectedAdBreakDurationMs = void 0;
|
|
4905
4602
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
4906
4603
|
this.clearAdStartTimer();
|
|
4907
4604
|
this.clearAdStopTimer();
|
|
4908
4605
|
this.adPodQueue = [];
|
|
4909
|
-
this.adPodAllUrls = [];
|
|
4910
4606
|
this.showAds = false;
|
|
4911
4607
|
this.currentAdIndex = 0;
|
|
4912
4608
|
this.totalAdsInBreak = 0;
|
|
@@ -5061,651 +4757,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5061
4757
|
}, extra));
|
|
5062
4758
|
}
|
|
5063
4759
|
},
|
|
5064
|
-
{
|
|
5065
|
-
key: "fetchAndParseVastXml",
|
|
5066
|
-
value: function fetchAndParseVastXml(vastTagUrl) {
|
|
5067
|
-
return _async_to_generator(function() {
|
|
5068
|
-
var response, xmlText, error;
|
|
5069
|
-
return _ts_generator(this, function(_state) {
|
|
5070
|
-
switch(_state.label){
|
|
5071
|
-
case 0:
|
|
5072
|
-
_state.trys.push([
|
|
5073
|
-
0,
|
|
5074
|
-
3,
|
|
5075
|
-
,
|
|
5076
|
-
4
|
|
5077
|
-
]);
|
|
5078
|
-
return [
|
|
5079
|
-
4,
|
|
5080
|
-
fetch(vastTagUrl, {
|
|
5081
|
-
mode: "cors",
|
|
5082
|
-
credentials: "include",
|
|
5083
|
-
headers: {
|
|
5084
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5085
|
-
},
|
|
5086
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5087
|
-
})
|
|
5088
|
-
];
|
|
5089
|
-
case 1:
|
|
5090
|
-
response = _state.sent();
|
|
5091
|
-
if (!response.ok) {
|
|
5092
|
-
throw new Error("Failed to fetch VAST: ".concat(response.status));
|
|
5093
|
-
}
|
|
5094
|
-
return [
|
|
5095
|
-
4,
|
|
5096
|
-
response.text()
|
|
5097
|
-
];
|
|
5098
|
-
case 2:
|
|
5099
|
-
xmlText = _state.sent();
|
|
5100
|
-
return [
|
|
5101
|
-
2,
|
|
5102
|
-
this.extractMediaUrlsFromVast(xmlText)
|
|
5103
|
-
];
|
|
5104
|
-
case 3:
|
|
5105
|
-
error = _state.sent();
|
|
5106
|
-
if (this.config.debugAdTiming) {
|
|
5107
|
-
console.warn("[StormcloudVideoPlayer] Failed to fetch/parse VAST XML: ".concat(vastTagUrl), error);
|
|
5108
|
-
}
|
|
5109
|
-
return [
|
|
5110
|
-
2,
|
|
5111
|
-
[]
|
|
5112
|
-
];
|
|
5113
|
-
case 4:
|
|
5114
|
-
return [
|
|
5115
|
-
2
|
|
5116
|
-
];
|
|
5117
|
-
}
|
|
5118
|
-
});
|
|
5119
|
-
}).call(this);
|
|
5120
|
-
}
|
|
5121
|
-
},
|
|
5122
|
-
{
|
|
5123
|
-
key: "extractMediaUrlsFromVast",
|
|
5124
|
-
value: function extractMediaUrlsFromVast(xmlText) {
|
|
5125
|
-
var mediaUrls = [];
|
|
5126
|
-
try {
|
|
5127
|
-
var parser = new DOMParser();
|
|
5128
|
-
var xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5129
|
-
var mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
|
|
5130
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5131
|
-
try {
|
|
5132
|
-
for(var _iterator = Array.from(mediaFileElements)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5133
|
-
var mediaFile = _step.value;
|
|
5134
|
-
var _mediaFile_textContent;
|
|
5135
|
-
var url = (_mediaFile_textContent = mediaFile.textContent) === null || _mediaFile_textContent === void 0 ? void 0 : _mediaFile_textContent.trim();
|
|
5136
|
-
if (url) {
|
|
5137
|
-
var lowerUrl = url.toLowerCase();
|
|
5138
|
-
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")) {
|
|
5139
|
-
mediaUrls.push(url);
|
|
5140
|
-
}
|
|
5141
|
-
}
|
|
5142
|
-
}
|
|
5143
|
-
} catch (err) {
|
|
5144
|
-
_didIteratorError = true;
|
|
5145
|
-
_iteratorError = err;
|
|
5146
|
-
} finally{
|
|
5147
|
-
try {
|
|
5148
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5149
|
-
_iterator.return();
|
|
5150
|
-
}
|
|
5151
|
-
} finally{
|
|
5152
|
-
if (_didIteratorError) {
|
|
5153
|
-
throw _iteratorError;
|
|
5154
|
-
}
|
|
5155
|
-
}
|
|
5156
|
-
}
|
|
5157
|
-
if (this.config.debugAdTiming && mediaUrls.length > 0) {
|
|
5158
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs from VAST:"), mediaUrls);
|
|
5159
|
-
}
|
|
5160
|
-
} catch (error) {
|
|
5161
|
-
if (this.config.debugAdTiming) {
|
|
5162
|
-
console.warn("[StormcloudVideoPlayer] Failed to parse VAST XML:", error);
|
|
5163
|
-
}
|
|
5164
|
-
}
|
|
5165
|
-
return mediaUrls;
|
|
5166
|
-
}
|
|
5167
|
-
},
|
|
5168
|
-
{
|
|
5169
|
-
key: "fetchVastDuration",
|
|
5170
|
-
value: function fetchVastDuration(vastTagUrl) {
|
|
5171
|
-
return _async_to_generator(function() {
|
|
5172
|
-
var _xmlDoc_querySelector, response, xmlText, parser, xmlDoc, durationText, durationParts, durationSeconds, error;
|
|
5173
|
-
return _ts_generator(this, function(_state) {
|
|
5174
|
-
switch(_state.label){
|
|
5175
|
-
case 0:
|
|
5176
|
-
_state.trys.push([
|
|
5177
|
-
0,
|
|
5178
|
-
3,
|
|
5179
|
-
,
|
|
5180
|
-
4
|
|
5181
|
-
]);
|
|
5182
|
-
return [
|
|
5183
|
-
4,
|
|
5184
|
-
fetch(vastTagUrl, {
|
|
5185
|
-
mode: "cors",
|
|
5186
|
-
credentials: "include",
|
|
5187
|
-
headers: {
|
|
5188
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5189
|
-
},
|
|
5190
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5191
|
-
})
|
|
5192
|
-
];
|
|
5193
|
-
case 1:
|
|
5194
|
-
response = _state.sent();
|
|
5195
|
-
if (!response.ok) {
|
|
5196
|
-
if (this.config.debugAdTiming) {
|
|
5197
|
-
console.warn("[ADAPTIVE-POD] Failed to fetch VAST: ".concat(response.status));
|
|
5198
|
-
}
|
|
5199
|
-
return [
|
|
5200
|
-
2,
|
|
5201
|
-
null
|
|
5202
|
-
];
|
|
5203
|
-
}
|
|
5204
|
-
return [
|
|
5205
|
-
4,
|
|
5206
|
-
response.text()
|
|
5207
|
-
];
|
|
5208
|
-
case 2:
|
|
5209
|
-
xmlText = _state.sent();
|
|
5210
|
-
parser = new DOMParser();
|
|
5211
|
-
xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5212
|
-
durationText = (_xmlDoc_querySelector = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector === void 0 ? void 0 : _xmlDoc_querySelector.textContent;
|
|
5213
|
-
if (!durationText) {
|
|
5214
|
-
if (this.config.debugAdTiming) {
|
|
5215
|
-
console.warn("[ADAPTIVE-POD] No Duration element found in VAST");
|
|
5216
|
-
}
|
|
5217
|
-
return [
|
|
5218
|
-
2,
|
|
5219
|
-
null
|
|
5220
|
-
];
|
|
5221
|
-
}
|
|
5222
|
-
durationParts = durationText.split(":");
|
|
5223
|
-
durationSeconds = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
5224
|
-
return [
|
|
5225
|
-
2,
|
|
5226
|
-
durationSeconds
|
|
5227
|
-
];
|
|
5228
|
-
case 3:
|
|
5229
|
-
error = _state.sent();
|
|
5230
|
-
if (this.config.debugAdTiming) {
|
|
5231
|
-
console.warn("[ADAPTIVE-POD] Error fetching VAST duration from ".concat(vastTagUrl, ":"), error);
|
|
5232
|
-
}
|
|
5233
|
-
return [
|
|
5234
|
-
2,
|
|
5235
|
-
null
|
|
5236
|
-
];
|
|
5237
|
-
case 4:
|
|
5238
|
-
return [
|
|
5239
|
-
2
|
|
5240
|
-
];
|
|
5241
|
-
}
|
|
5242
|
-
});
|
|
5243
|
-
}).call(this);
|
|
5244
|
-
}
|
|
5245
|
-
},
|
|
5246
|
-
{
|
|
5247
|
-
key: "calculateAdditionalAdsNeeded",
|
|
5248
|
-
value: function calculateAdditionalAdsNeeded() {
|
|
5249
|
-
if (!this.isAdaptiveMode || this.targetAdBreakDurationMs === null) {
|
|
5250
|
-
return 0;
|
|
5251
|
-
}
|
|
5252
|
-
var totalFetchedDurationMs = 0;
|
|
5253
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5254
|
-
try {
|
|
5255
|
-
for(var _iterator = this.fetchedAdDurations.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5256
|
-
var duration = _step.value;
|
|
5257
|
-
totalFetchedDurationMs += duration * 1e3;
|
|
5258
|
-
}
|
|
5259
|
-
} catch (err) {
|
|
5260
|
-
_didIteratorError = true;
|
|
5261
|
-
_iteratorError = err;
|
|
5262
|
-
} finally{
|
|
5263
|
-
try {
|
|
5264
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5265
|
-
_iterator.return();
|
|
5266
|
-
}
|
|
5267
|
-
} finally{
|
|
5268
|
-
if (_didIteratorError) {
|
|
5269
|
-
throw _iteratorError;
|
|
5270
|
-
}
|
|
5271
|
-
}
|
|
5272
|
-
}
|
|
5273
|
-
var fetchedCount = this.fetchedAdDurations.size;
|
|
5274
|
-
var averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
5275
|
-
var queuedButNotFetched = this.adPodAllUrls.length - fetchedCount;
|
|
5276
|
-
var estimatedQueuedDurationMs = queuedButNotFetched * averageDurationMs;
|
|
5277
|
-
var estimatedTotalDurationMs = totalFetchedDurationMs + estimatedQueuedDurationMs;
|
|
5278
|
-
var remainingTimeMs = this.targetAdBreakDurationMs - estimatedTotalDurationMs;
|
|
5279
|
-
if (remainingTimeMs <= 0) {
|
|
5280
|
-
if (this.config.debugAdTiming) {
|
|
5281
|
-
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"));
|
|
5282
|
-
}
|
|
5283
|
-
return 0;
|
|
5284
|
-
}
|
|
5285
|
-
var additionalAds = Math.ceil(remainingTimeMs / averageDurationMs);
|
|
5286
|
-
if (this.config.debugAdTiming) {
|
|
5287
|
-
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"));
|
|
5288
|
-
}
|
|
5289
|
-
return additionalAds;
|
|
5290
|
-
}
|
|
5291
|
-
},
|
|
5292
|
-
{
|
|
5293
|
-
key: "addAdaptiveAdsToQueue",
|
|
5294
|
-
value: function addAdaptiveAdsToQueue() {
|
|
5295
|
-
return _async_to_generator(function() {
|
|
5296
|
-
var _this_adPodAllUrls, _this_adPodQueue, additionalAds, newUrls;
|
|
5297
|
-
return _ts_generator(this, function(_state) {
|
|
5298
|
-
if (!this.isAdaptiveMode || !this.apiVastTagUrl) {
|
|
5299
|
-
return [
|
|
5300
|
-
2
|
|
5301
|
-
];
|
|
5302
|
-
}
|
|
5303
|
-
additionalAds = this.calculateAdditionalAdsNeeded();
|
|
5304
|
-
if (additionalAds <= 0) {
|
|
5305
|
-
return [
|
|
5306
|
-
2
|
|
5307
|
-
];
|
|
5308
|
-
}
|
|
5309
|
-
newUrls = this.generateVastUrlsWithCorrelators(this.apiVastTagUrl, additionalAds);
|
|
5310
|
-
if (this.config.debugAdTiming) {
|
|
5311
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Adding ".concat(newUrls.length, " additional VAST URLs to queue (will be preloaded sequentially)"));
|
|
5312
|
-
}
|
|
5313
|
-
(_this_adPodAllUrls = this.adPodAllUrls).push.apply(_this_adPodAllUrls, _to_consumable_array(newUrls));
|
|
5314
|
-
(_this_adPodQueue = this.adPodQueue).push.apply(_this_adPodQueue, _to_consumable_array(newUrls));
|
|
5315
|
-
this.totalAdsInBreak += newUrls.length;
|
|
5316
|
-
return [
|
|
5317
|
-
2
|
|
5318
|
-
];
|
|
5319
|
-
});
|
|
5320
|
-
}).call(this);
|
|
5321
|
-
}
|
|
5322
|
-
},
|
|
5323
|
-
{
|
|
5324
|
-
key: "preloadMediaFile",
|
|
5325
|
-
value: function preloadMediaFile(mediaUrl) {
|
|
5326
|
-
return _async_to_generator(function() {
|
|
5327
|
-
var response, error;
|
|
5328
|
-
return _ts_generator(this, function(_state) {
|
|
5329
|
-
switch(_state.label){
|
|
5330
|
-
case 0:
|
|
5331
|
-
if (this.preloadedMediaUrls.has(mediaUrl)) {
|
|
5332
|
-
return [
|
|
5333
|
-
2
|
|
5334
|
-
];
|
|
5335
|
-
}
|
|
5336
|
-
if (this.preloadingMediaUrls.has(mediaUrl)) {
|
|
5337
|
-
return [
|
|
5338
|
-
2
|
|
5339
|
-
];
|
|
5340
|
-
}
|
|
5341
|
-
this.preloadingMediaUrls.add(mediaUrl);
|
|
5342
|
-
_state.label = 1;
|
|
5343
|
-
case 1:
|
|
5344
|
-
_state.trys.push([
|
|
5345
|
-
1,
|
|
5346
|
-
3,
|
|
5347
|
-
4,
|
|
5348
|
-
5
|
|
5349
|
-
]);
|
|
5350
|
-
if (this.config.debugAdTiming) {
|
|
5351
|
-
console.log("[StormcloudVideoPlayer] Preloading video file: ".concat(mediaUrl));
|
|
5352
|
-
}
|
|
5353
|
-
return [
|
|
5354
|
-
4,
|
|
5355
|
-
fetch(mediaUrl, {
|
|
5356
|
-
mode: "cors",
|
|
5357
|
-
credentials: "include",
|
|
5358
|
-
method: "GET",
|
|
5359
|
-
headers: {
|
|
5360
|
-
Range: "bytes=0-1048576"
|
|
5361
|
-
},
|
|
5362
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5363
|
-
})
|
|
5364
|
-
];
|
|
5365
|
-
case 2:
|
|
5366
|
-
response = _state.sent();
|
|
5367
|
-
if (response.ok || response.status === 206) {
|
|
5368
|
-
this.preloadedMediaUrls.add(mediaUrl);
|
|
5369
|
-
if (this.config.debugAdTiming) {
|
|
5370
|
-
console.log("[StormcloudVideoPlayer] Successfully preloaded video file: ".concat(mediaUrl));
|
|
5371
|
-
}
|
|
5372
|
-
}
|
|
5373
|
-
return [
|
|
5374
|
-
3,
|
|
5375
|
-
5
|
|
5376
|
-
];
|
|
5377
|
-
case 3:
|
|
5378
|
-
error = _state.sent();
|
|
5379
|
-
if (this.config.debugAdTiming) {
|
|
5380
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload video file: ".concat(mediaUrl), error);
|
|
5381
|
-
}
|
|
5382
|
-
return [
|
|
5383
|
-
3,
|
|
5384
|
-
5
|
|
5385
|
-
];
|
|
5386
|
-
case 4:
|
|
5387
|
-
this.preloadingMediaUrls.delete(mediaUrl);
|
|
5388
|
-
return [
|
|
5389
|
-
7
|
|
5390
|
-
];
|
|
5391
|
-
case 5:
|
|
5392
|
-
return [
|
|
5393
|
-
2
|
|
5394
|
-
];
|
|
5395
|
-
}
|
|
5396
|
-
});
|
|
5397
|
-
}).call(this);
|
|
5398
|
-
}
|
|
5399
|
-
},
|
|
5400
|
-
{
|
|
5401
|
-
key: "preloadAllAdsInBackground",
|
|
5402
|
-
value: function preloadAllAdsInBackground() {
|
|
5403
|
-
return _async_to_generator(function() {
|
|
5404
|
-
var _this, processedUrls, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, _this_ima_hasPreloadedAd, _this_ima, nextUrl, error, preloadPromises;
|
|
5405
|
-
return _ts_generator(this, function(_state) {
|
|
5406
|
-
switch(_state.label){
|
|
5407
|
-
case 0:
|
|
5408
|
-
_this = this;
|
|
5409
|
-
if (this.adPodAllUrls.length === 0) {
|
|
5410
|
-
return [
|
|
5411
|
-
2
|
|
5412
|
-
];
|
|
5413
|
-
}
|
|
5414
|
-
if (!this.isAdaptiveMode) return [
|
|
5415
|
-
3,
|
|
5416
|
-
7
|
|
5417
|
-
];
|
|
5418
|
-
if (this.config.debugAdTiming) {
|
|
5419
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Starting sequential preload of remaining ads");
|
|
5420
|
-
}
|
|
5421
|
-
processedUrls = /* @__PURE__ */ new Set();
|
|
5422
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5423
|
-
try {
|
|
5424
|
-
for(_iterator = this.adPodAllUrls[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5425
|
-
url = _step.value;
|
|
5426
|
-
;
|
|
5427
|
-
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)) {
|
|
5428
|
-
processedUrls.add(url);
|
|
5429
|
-
}
|
|
5430
|
-
}
|
|
5431
|
-
} catch (err) {
|
|
5432
|
-
_didIteratorError = true;
|
|
5433
|
-
_iteratorError = err;
|
|
5434
|
-
} finally{
|
|
5435
|
-
try {
|
|
5436
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5437
|
-
_iterator.return();
|
|
5438
|
-
}
|
|
5439
|
-
} finally{
|
|
5440
|
-
if (_didIteratorError) {
|
|
5441
|
-
throw _iteratorError;
|
|
5442
|
-
}
|
|
5443
|
-
}
|
|
5444
|
-
}
|
|
5445
|
-
if (this.config.debugAdTiming && processedUrls.size > 0) {
|
|
5446
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE6 Skipping ".concat(processedUrls.size, " already-preloaded ads"));
|
|
5447
|
-
}
|
|
5448
|
-
_state.label = 1;
|
|
5449
|
-
case 1:
|
|
5450
|
-
if (!true) return [
|
|
5451
|
-
3,
|
|
5452
|
-
6
|
|
5453
|
-
];
|
|
5454
|
-
nextUrl = this.adPodAllUrls.find(function(url) {
|
|
5455
|
-
return !processedUrls.has(url);
|
|
5456
|
-
});
|
|
5457
|
-
if (!nextUrl) {
|
|
5458
|
-
if (this.config.debugAdTiming) {
|
|
5459
|
-
console.log("[ADAPTIVE-POD] ✅ All queued ads processed (".concat(processedUrls.size, " total)"));
|
|
5460
|
-
}
|
|
5461
|
-
return [
|
|
5462
|
-
3,
|
|
5463
|
-
6
|
|
5464
|
-
];
|
|
5465
|
-
}
|
|
5466
|
-
processedUrls.add(nextUrl);
|
|
5467
|
-
if (this.config.debugAdTiming) {
|
|
5468
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE5 Preloading ad ".concat(processedUrls.size, "/").concat(this.adPodAllUrls.length, "..."));
|
|
5469
|
-
}
|
|
5470
|
-
_state.label = 2;
|
|
5471
|
-
case 2:
|
|
5472
|
-
_state.trys.push([
|
|
5473
|
-
2,
|
|
5474
|
-
4,
|
|
5475
|
-
,
|
|
5476
|
-
5
|
|
5477
|
-
]);
|
|
5478
|
-
return [
|
|
5479
|
-
4,
|
|
5480
|
-
this.preloadSingleAd(nextUrl)
|
|
5481
|
-
];
|
|
5482
|
-
case 3:
|
|
5483
|
-
_state.sent();
|
|
5484
|
-
return [
|
|
5485
|
-
3,
|
|
5486
|
-
5
|
|
5487
|
-
];
|
|
5488
|
-
case 4:
|
|
5489
|
-
error = _state.sent();
|
|
5490
|
-
if (this.config.debugAdTiming) {
|
|
5491
|
-
console.warn("[ADAPTIVE-POD] ⚠️ Preload failed for ad ".concat(processedUrls.size, ":"), error);
|
|
5492
|
-
}
|
|
5493
|
-
return [
|
|
5494
|
-
3,
|
|
5495
|
-
5
|
|
5496
|
-
];
|
|
5497
|
-
case 5:
|
|
5498
|
-
if (this.calculateAdditionalAdsNeeded() === 0) {
|
|
5499
|
-
if (this.config.debugAdTiming) {
|
|
5500
|
-
console.log("[ADAPTIVE-POD] ✅ Target duration reached (".concat(processedUrls.size, " ads preloaded), stopping"));
|
|
5501
|
-
}
|
|
5502
|
-
return [
|
|
5503
|
-
3,
|
|
5504
|
-
6
|
|
5505
|
-
];
|
|
5506
|
-
}
|
|
5507
|
-
return [
|
|
5508
|
-
3,
|
|
5509
|
-
1
|
|
5510
|
-
];
|
|
5511
|
-
case 6:
|
|
5512
|
-
if (this.config.debugAdTiming) {
|
|
5513
|
-
console.log("[ADAPTIVE-POD] ✅ Sequential preloading completed (".concat(processedUrls.size, " ads ready)"));
|
|
5514
|
-
}
|
|
5515
|
-
return [
|
|
5516
|
-
3,
|
|
5517
|
-
9
|
|
5518
|
-
];
|
|
5519
|
-
case 7:
|
|
5520
|
-
if (this.config.debugAdTiming) {
|
|
5521
|
-
console.log("[StormcloudVideoPlayer] Starting parallel preload of ".concat(this.adPodAllUrls.length, " ads"));
|
|
5522
|
-
}
|
|
5523
|
-
preloadPromises = this.adPodAllUrls.map(function(vastTagUrl) {
|
|
5524
|
-
return _this.preloadSingleAd(vastTagUrl).catch(function(error) {
|
|
5525
|
-
if (_this.config.debugAdTiming) {
|
|
5526
|
-
console.warn("[StormcloudVideoPlayer] Preload failed for ".concat(vastTagUrl, ":"), error);
|
|
5527
|
-
}
|
|
5528
|
-
});
|
|
5529
|
-
});
|
|
5530
|
-
return [
|
|
5531
|
-
4,
|
|
5532
|
-
Promise.all(preloadPromises)
|
|
5533
|
-
];
|
|
5534
|
-
case 8:
|
|
5535
|
-
_state.sent();
|
|
5536
|
-
if (this.config.debugAdTiming) {
|
|
5537
|
-
console.log("[StormcloudVideoPlayer] Background preloading completed for all ads");
|
|
5538
|
-
}
|
|
5539
|
-
_state.label = 9;
|
|
5540
|
-
case 9:
|
|
5541
|
-
return [
|
|
5542
|
-
2
|
|
5543
|
-
];
|
|
5544
|
-
}
|
|
5545
|
-
});
|
|
5546
|
-
}).call(this);
|
|
5547
|
-
}
|
|
5548
|
-
},
|
|
5549
|
-
{
|
|
5550
|
-
key: "preloadSingleAd",
|
|
5551
|
-
value: function preloadSingleAd(vastTagUrl) {
|
|
5552
|
-
return _async_to_generator(function() {
|
|
5553
|
-
var _this, duration, mediaUrls, primaryMediaUrl, error;
|
|
5554
|
-
return _ts_generator(this, function(_state) {
|
|
5555
|
-
switch(_state.label){
|
|
5556
|
-
case 0:
|
|
5557
|
-
_this = this;
|
|
5558
|
-
if (!vastTagUrl) return [
|
|
5559
|
-
2
|
|
5560
|
-
];
|
|
5561
|
-
_state.label = 1;
|
|
5562
|
-
case 1:
|
|
5563
|
-
_state.trys.push([
|
|
5564
|
-
1,
|
|
5565
|
-
11,
|
|
5566
|
-
,
|
|
5567
|
-
12
|
|
5568
|
-
]);
|
|
5569
|
-
if (!(this.isAdaptiveMode && !this.fetchedAdDurations.has(vastTagUrl))) return [
|
|
5570
|
-
3,
|
|
5571
|
-
4
|
|
5572
|
-
];
|
|
5573
|
-
return [
|
|
5574
|
-
4,
|
|
5575
|
-
this.fetchVastDuration(vastTagUrl)
|
|
5576
|
-
];
|
|
5577
|
-
case 2:
|
|
5578
|
-
duration = _state.sent();
|
|
5579
|
-
if (!(duration !== null)) return [
|
|
5580
|
-
3,
|
|
5581
|
-
4
|
|
5582
|
-
];
|
|
5583
|
-
this.fetchedAdDurations.set(vastTagUrl, duration);
|
|
5584
|
-
if (this.config.debugAdTiming) {
|
|
5585
|
-
console.log("[ADAPTIVE-POD] ✓ Fetched ad duration: ".concat(duration, "s (").concat(this.fetchedAdDurations.size, " ads fetched so far)"));
|
|
5586
|
-
}
|
|
5587
|
-
return [
|
|
5588
|
-
4,
|
|
5589
|
-
this.addAdaptiveAdsToQueue()
|
|
5590
|
-
];
|
|
5591
|
-
case 3:
|
|
5592
|
-
_state.sent();
|
|
5593
|
-
_state.label = 4;
|
|
5594
|
-
case 4:
|
|
5595
|
-
if (!(this.ima.preloadAds && !this.ima.hasPreloadedAd(vastTagUrl))) return [
|
|
5596
|
-
3,
|
|
5597
|
-
6
|
|
5598
|
-
];
|
|
5599
|
-
if (!!this.preloadingAdUrls.has(vastTagUrl)) return [
|
|
5600
|
-
3,
|
|
5601
|
-
6
|
|
5602
|
-
];
|
|
5603
|
-
if (this.config.debugAdTiming) {
|
|
5604
|
-
console.log("[StormcloudVideoPlayer] Preloading VAST: ".concat(vastTagUrl));
|
|
5605
|
-
}
|
|
5606
|
-
this.preloadingAdUrls.add(vastTagUrl);
|
|
5607
|
-
return [
|
|
5608
|
-
4,
|
|
5609
|
-
this.ima.preloadAds(vastTagUrl).then(function() {
|
|
5610
|
-
if (_this.config.debugAdTiming) {
|
|
5611
|
-
console.log("[StormcloudVideoPlayer] IMA VAST preload complete: ".concat(vastTagUrl));
|
|
5612
|
-
}
|
|
5613
|
-
}).catch(function(error) {
|
|
5614
|
-
if (_this.config.debugAdTiming) {
|
|
5615
|
-
console.warn("[StormcloudVideoPlayer] IMA VAST preload failed: ".concat(vastTagUrl), error);
|
|
5616
|
-
}
|
|
5617
|
-
}).finally(function() {
|
|
5618
|
-
_this.preloadingAdUrls.delete(vastTagUrl);
|
|
5619
|
-
})
|
|
5620
|
-
];
|
|
5621
|
-
case 5:
|
|
5622
|
-
_state.sent();
|
|
5623
|
-
_state.label = 6;
|
|
5624
|
-
case 6:
|
|
5625
|
-
mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5626
|
-
if (!!mediaUrls) return [
|
|
5627
|
-
3,
|
|
5628
|
-
8
|
|
5629
|
-
];
|
|
5630
|
-
if (this.config.debugAdTiming) {
|
|
5631
|
-
console.log("[StormcloudVideoPlayer] Fetching and parsing VAST to extract media URLs: ".concat(vastTagUrl));
|
|
5632
|
-
}
|
|
5633
|
-
return [
|
|
5634
|
-
4,
|
|
5635
|
-
this.fetchAndParseVastXml(vastTagUrl)
|
|
5636
|
-
];
|
|
5637
|
-
case 7:
|
|
5638
|
-
mediaUrls = _state.sent();
|
|
5639
|
-
if (this.config.debugAdTiming) {
|
|
5640
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs:"), mediaUrls);
|
|
5641
|
-
}
|
|
5642
|
-
if (mediaUrls.length > 0) {
|
|
5643
|
-
this.vastToMediaUrlMap.set(vastTagUrl, mediaUrls);
|
|
5644
|
-
}
|
|
5645
|
-
_state.label = 8;
|
|
5646
|
-
case 8:
|
|
5647
|
-
if (!(mediaUrls && mediaUrls.length > 0)) return [
|
|
5648
|
-
3,
|
|
5649
|
-
10
|
|
5650
|
-
];
|
|
5651
|
-
primaryMediaUrl = mediaUrls[0];
|
|
5652
|
-
if (!(primaryMediaUrl && !this.preloadedMediaUrls.has(primaryMediaUrl))) return [
|
|
5653
|
-
3,
|
|
5654
|
-
10
|
|
5655
|
-
];
|
|
5656
|
-
return [
|
|
5657
|
-
4,
|
|
5658
|
-
this.preloadMediaFile(primaryMediaUrl)
|
|
5659
|
-
];
|
|
5660
|
-
case 9:
|
|
5661
|
-
_state.sent();
|
|
5662
|
-
_state.label = 10;
|
|
5663
|
-
case 10:
|
|
5664
|
-
return [
|
|
5665
|
-
3,
|
|
5666
|
-
12
|
|
5667
|
-
];
|
|
5668
|
-
case 11:
|
|
5669
|
-
error = _state.sent();
|
|
5670
|
-
if (this.config.debugAdTiming) {
|
|
5671
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload ad: ".concat(vastTagUrl), error);
|
|
5672
|
-
}
|
|
5673
|
-
return [
|
|
5674
|
-
3,
|
|
5675
|
-
12
|
|
5676
|
-
];
|
|
5677
|
-
case 12:
|
|
5678
|
-
return [
|
|
5679
|
-
2
|
|
5680
|
-
];
|
|
5681
|
-
}
|
|
5682
|
-
});
|
|
5683
|
-
}).call(this);
|
|
5684
|
-
}
|
|
5685
|
-
},
|
|
5686
|
-
{
|
|
5687
|
-
key: "findNextPreloadedAd",
|
|
5688
|
-
value: function findNextPreloadedAd() {
|
|
5689
|
-
for(var i = 0; i < this.adPodQueue.length; i++){
|
|
5690
|
-
var _this_ima_hasPreloadedAd, _this_ima;
|
|
5691
|
-
var vastTagUrl = this.adPodQueue[i];
|
|
5692
|
-
if (!vastTagUrl) continue;
|
|
5693
|
-
if (this.failedVastUrls.has(vastTagUrl)) {
|
|
5694
|
-
console.warn("[AD-ERROR] Skipping failed URL in queue");
|
|
5695
|
-
continue;
|
|
5696
|
-
}
|
|
5697
|
-
var _this_ima_hasPreloadedAd1;
|
|
5698
|
-
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;
|
|
5699
|
-
var mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5700
|
-
var hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
|
|
5701
|
-
if (hasImaPreload || hasMediaPreload) {
|
|
5702
|
-
this.adPodQueue.splice(0, i + 1);
|
|
5703
|
-
return vastTagUrl;
|
|
5704
|
-
}
|
|
5705
|
-
}
|
|
5706
|
-
return void 0;
|
|
5707
|
-
}
|
|
5708
|
-
},
|
|
5709
4760
|
{
|
|
5710
4761
|
key: "getRemainingAdMs",
|
|
5711
4762
|
value: function getRemainingAdMs() {
|
|
@@ -5892,7 +4943,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5892
4943
|
}
|
|
5893
4944
|
if (this.ima && this.ima.isAdPlaying()) {
|
|
5894
4945
|
var width = this.video.clientWidth || 640;
|
|
5895
|
-
var height = this.video.clientHeight ||
|
|
4946
|
+
var height = this.video.clientHeight || 480;
|
|
5896
4947
|
if (this.config.debugAdTiming) {
|
|
5897
4948
|
console.log("[StormcloudVideoPlayer] Resizing ads manager to ".concat(width, "x").concat(height));
|
|
5898
4949
|
}
|
|
@@ -5923,13 +4974,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5923
4974
|
}
|
|
5924
4975
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5925
4976
|
(_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
|
|
5926
|
-
this.preloadingAdUrls.clear();
|
|
5927
|
-
this.vastToMediaUrlMap.clear();
|
|
5928
|
-
this.preloadedMediaUrls.clear();
|
|
5929
|
-
this.preloadingMediaUrls.clear();
|
|
5930
|
-
this.adPodAllUrls = [];
|
|
5931
4977
|
this.adRequestQueue = [];
|
|
5932
|
-
this.successfulAdRequests = [];
|
|
5933
4978
|
}
|
|
5934
4979
|
}
|
|
5935
4980
|
]);
|