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.cjs
CHANGED
|
@@ -336,20 +336,6 @@ function _ts_generator(thisArg, body) {
|
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
function _ts_values(o) {
|
|
340
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
341
|
-
if (m) return m.call(o);
|
|
342
|
-
if (o && typeof o.length === "number") return {
|
|
343
|
-
next: function() {
|
|
344
|
-
if (o && i >= o.length) o = void 0;
|
|
345
|
-
return {
|
|
346
|
-
value: o && o[i++],
|
|
347
|
-
done: !o
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
352
|
-
}
|
|
353
339
|
var __create = Object.create;
|
|
354
340
|
var __defProp = Object.defineProperty;
|
|
355
341
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -715,8 +701,6 @@ function createImaController(video, options) {
|
|
|
715
701
|
var originalMutedState = false;
|
|
716
702
|
var originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
717
703
|
var listeners = /* @__PURE__ */ new Map();
|
|
718
|
-
var preloadedVast = /* @__PURE__ */ new Map();
|
|
719
|
-
var preloadingVast = /* @__PURE__ */ new Map();
|
|
720
704
|
var adVideoElement;
|
|
721
705
|
function setAdPlayingFlag(isPlaying) {
|
|
722
706
|
if (isPlaying) {
|
|
@@ -866,10 +850,10 @@ function createImaController(video, options) {
|
|
|
866
850
|
var adsLoadedReject;
|
|
867
851
|
function makeAdsRequest(google, vastTagUrl) {
|
|
868
852
|
var adsRequest = new google.ima.AdsRequest();
|
|
869
|
-
console.log("[IMA] \uD83D\uDCE1 Requesting VAST
|
|
853
|
+
console.log("[IMA] \uD83D\uDCE1 Requesting VAST via IMA SDK:", vastTagUrl.substring(0, 80) + "...");
|
|
870
854
|
adsRequest.adTagUrl = vastTagUrl;
|
|
871
855
|
var videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
872
|
-
var videoHeight = video.offsetHeight || video.clientHeight ||
|
|
856
|
+
var videoHeight = video.offsetHeight || video.clientHeight || 480;
|
|
873
857
|
adsRequest.linearAdSlotWidth = videoWidth;
|
|
874
858
|
adsRequest.linearAdSlotHeight = videoHeight;
|
|
875
859
|
adsRequest.nonLinearAdSlotWidth = videoWidth;
|
|
@@ -915,36 +899,6 @@ function createImaController(video, options) {
|
|
|
915
899
|
(_video_parentElement = video.parentElement) === null || _video_parentElement === void 0 ? void 0 : _video_parentElement.appendChild(container);
|
|
916
900
|
adContainerEl = container;
|
|
917
901
|
}
|
|
918
|
-
function fetchVastDocument(vastTagUrl) {
|
|
919
|
-
return _async_to_generator(function() {
|
|
920
|
-
var response;
|
|
921
|
-
return _ts_generator(this, function(_state) {
|
|
922
|
-
switch(_state.label){
|
|
923
|
-
case 0:
|
|
924
|
-
return [
|
|
925
|
-
4,
|
|
926
|
-
fetch(vastTagUrl, {
|
|
927
|
-
mode: "cors",
|
|
928
|
-
credentials: "include",
|
|
929
|
-
headers: {
|
|
930
|
-
"Accept": "application/xml, text/xml, */*"
|
|
931
|
-
},
|
|
932
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
933
|
-
})
|
|
934
|
-
];
|
|
935
|
-
case 1:
|
|
936
|
-
response = _state.sent();
|
|
937
|
-
if (!response.ok) {
|
|
938
|
-
throw new Error("Failed to preload VAST: ".concat(response.status));
|
|
939
|
-
}
|
|
940
|
-
return [
|
|
941
|
-
2,
|
|
942
|
-
response.text()
|
|
943
|
-
];
|
|
944
|
-
}
|
|
945
|
-
});
|
|
946
|
-
})();
|
|
947
|
-
}
|
|
948
902
|
function destroyAdsManager() {
|
|
949
903
|
if (adsManager) {
|
|
950
904
|
try {
|
|
@@ -1259,47 +1213,6 @@ function createImaController(video, options) {
|
|
|
1259
1213
|
});
|
|
1260
1214
|
})();
|
|
1261
1215
|
},
|
|
1262
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1263
|
-
return _async_to_generator(function() {
|
|
1264
|
-
var inflight, preloadPromise;
|
|
1265
|
-
return _ts_generator(this, function(_state) {
|
|
1266
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1267
|
-
return [
|
|
1268
|
-
2,
|
|
1269
|
-
Promise.resolve()
|
|
1270
|
-
];
|
|
1271
|
-
}
|
|
1272
|
-
if (preloadedVast.has(vastTagUrl)) {
|
|
1273
|
-
return [
|
|
1274
|
-
2,
|
|
1275
|
-
Promise.resolve()
|
|
1276
|
-
];
|
|
1277
|
-
}
|
|
1278
|
-
inflight = preloadingVast.get(vastTagUrl);
|
|
1279
|
-
if (inflight) {
|
|
1280
|
-
return [
|
|
1281
|
-
2,
|
|
1282
|
-
inflight
|
|
1283
|
-
];
|
|
1284
|
-
}
|
|
1285
|
-
preloadPromise = fetchVastDocument(vastTagUrl).then(function(xml) {
|
|
1286
|
-
preloadedVast.set(vastTagUrl, xml);
|
|
1287
|
-
}).catch(function() {
|
|
1288
|
-
preloadedVast.delete(vastTagUrl);
|
|
1289
|
-
}).finally(function() {
|
|
1290
|
-
preloadingVast.delete(vastTagUrl);
|
|
1291
|
-
});
|
|
1292
|
-
preloadingVast.set(vastTagUrl, preloadPromise);
|
|
1293
|
-
return [
|
|
1294
|
-
2,
|
|
1295
|
-
preloadPromise
|
|
1296
|
-
];
|
|
1297
|
-
});
|
|
1298
|
-
})();
|
|
1299
|
-
},
|
|
1300
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1301
|
-
return preloadedVast.has(vastTagUrl);
|
|
1302
|
-
},
|
|
1303
1216
|
play: function play() {
|
|
1304
1217
|
return _async_to_generator(function() {
|
|
1305
1218
|
var _window_google, width, height, adVolume, _video_play;
|
|
@@ -1318,7 +1231,7 @@ function createImaController(video, options) {
|
|
|
1318
1231
|
}
|
|
1319
1232
|
try {
|
|
1320
1233
|
width = video.clientWidth || 640;
|
|
1321
|
-
height = video.clientHeight ||
|
|
1234
|
+
height = video.clientHeight || 480;
|
|
1322
1235
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
1323
1236
|
adPlaying = true;
|
|
1324
1237
|
adVolume = originalMutedState ? 0 : originalVolume;
|
|
@@ -1408,8 +1321,6 @@ function createImaController(video, options) {
|
|
|
1408
1321
|
adDisplayContainer = void 0;
|
|
1409
1322
|
adsLoader = void 0;
|
|
1410
1323
|
contentVideoHidden = false;
|
|
1411
|
-
preloadedVast.clear();
|
|
1412
|
-
preloadingVast.clear();
|
|
1413
1324
|
},
|
|
1414
1325
|
isAdPlaying: function isAdPlaying() {
|
|
1415
1326
|
return adPlaying;
|
|
@@ -2010,51 +1921,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2010
1921
|
});
|
|
2011
1922
|
})();
|
|
2012
1923
|
},
|
|
2013
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
2014
|
-
return _async_to_generator(function() {
|
|
2015
|
-
var inflight, preloadPromise;
|
|
2016
|
-
return _ts_generator(this, function(_state) {
|
|
2017
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
2018
|
-
return [
|
|
2019
|
-
2,
|
|
2020
|
-
Promise.resolve()
|
|
2021
|
-
];
|
|
2022
|
-
}
|
|
2023
|
-
if (preloadedAds.has(vastTagUrl)) {
|
|
2024
|
-
return [
|
|
2025
|
-
2,
|
|
2026
|
-
Promise.resolve()
|
|
2027
|
-
];
|
|
2028
|
-
}
|
|
2029
|
-
inflight = preloadingAds.get(vastTagUrl);
|
|
2030
|
-
if (inflight) {
|
|
2031
|
-
return [
|
|
2032
|
-
2,
|
|
2033
|
-
inflight
|
|
2034
|
-
];
|
|
2035
|
-
}
|
|
2036
|
-
preloadPromise = fetchAndParseVastAd(vastTagUrl).then(function(ad) {
|
|
2037
|
-
if (ad) {
|
|
2038
|
-
preloadedAds.set(vastTagUrl, ad);
|
|
2039
|
-
console.log("[HlsAdPlayer] Cached VAST response for preloading:", vastTagUrl);
|
|
2040
|
-
}
|
|
2041
|
-
}).catch(function(error) {
|
|
2042
|
-
console.warn("[HlsAdPlayer] Failed to preload VAST response:", error);
|
|
2043
|
-
preloadedAds.delete(vastTagUrl);
|
|
2044
|
-
}).finally(function() {
|
|
2045
|
-
preloadingAds.delete(vastTagUrl);
|
|
2046
|
-
});
|
|
2047
|
-
preloadingAds.set(vastTagUrl, preloadPromise);
|
|
2048
|
-
return [
|
|
2049
|
-
2,
|
|
2050
|
-
preloadPromise
|
|
2051
|
-
];
|
|
2052
|
-
});
|
|
2053
|
-
})();
|
|
2054
|
-
},
|
|
2055
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
2056
|
-
return preloadedAds.has(vastTagUrl);
|
|
2057
|
-
},
|
|
2058
1924
|
play: function play() {
|
|
2059
1925
|
return _async_to_generator(function() {
|
|
2060
1926
|
var contentVolume, adVolume, mediaFile;
|
|
@@ -2946,32 +2812,17 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2946
2812
|
this.bufferedSegmentsCount = 0;
|
|
2947
2813
|
this.shouldAutoplayAfterBuffering = false;
|
|
2948
2814
|
this.hasInitialBufferCompleted = false;
|
|
2949
|
-
this.adPodAllUrls = [];
|
|
2950
|
-
this.preloadingAdUrls = /* @__PURE__ */ new Set();
|
|
2951
|
-
this.vastToMediaUrlMap = /* @__PURE__ */ new Map();
|
|
2952
|
-
this.preloadedMediaUrls = /* @__PURE__ */ new Set();
|
|
2953
|
-
this.preloadingMediaUrls = /* @__PURE__ */ new Set();
|
|
2954
2815
|
this.adRequestTokenCounter = 0;
|
|
2955
2816
|
this.activeAdRequestToken = null;
|
|
2956
2817
|
this.adRequestWatchdogToken = null;
|
|
2957
2818
|
this.adFailsafeToken = null;
|
|
2958
|
-
this.fetchedAdDurations = /* @__PURE__ */ new Map();
|
|
2959
|
-
this.targetAdBreakDurationMs = null;
|
|
2960
|
-
this.isAdaptiveMode = false;
|
|
2961
2819
|
this.failedVastUrls = /* @__PURE__ */ new Set();
|
|
2962
2820
|
this.continuousFetchingActive = false;
|
|
2963
2821
|
this.adRequestQueue = [];
|
|
2964
|
-
this.successfulAdRequests = [];
|
|
2965
2822
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2966
|
-
this.placeholderStartTimeMs = null;
|
|
2967
2823
|
this.isShowingPlaceholder = false;
|
|
2968
|
-
this.consecutiveEmptyResponses = 0;
|
|
2969
2824
|
this.totalAdRequestsInBreak = 0;
|
|
2970
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
2971
2825
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2972
|
-
this.maxConsecutiveEmptyResponses = 5;
|
|
2973
|
-
this.baseEmptyResponseDelayMs = 2e3;
|
|
2974
|
-
this.maxEmptyResponseDelayMs = 3e4;
|
|
2975
2826
|
initializePolyfills();
|
|
2976
2827
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2977
2828
|
this.config = _object_spread({}, config, browserOverrides);
|
|
@@ -3462,25 +3313,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3462
3313
|
}
|
|
3463
3314
|
});
|
|
3464
3315
|
this.ima.on("ad_error", function(errorPayload) {
|
|
3465
|
-
var remaining = _this.getRemainingAdMs();
|
|
3466
3316
|
console.error("[AD-ERROR] Ad playback failed", errorPayload || "");
|
|
3467
|
-
|
|
3468
|
-
if (remaining > 500 && _this.adPodQueue.length > 0) {
|
|
3469
|
-
var nextPreloaded = _this.findNextPreloadedAd();
|
|
3470
|
-
if (nextPreloaded) {
|
|
3471
|
-
_this.currentAdIndex++;
|
|
3472
|
-
_this.playSingleAd(nextPreloaded).catch(function() {
|
|
3473
|
-
_this.handleAdFailure();
|
|
3474
|
-
});
|
|
3475
|
-
} else {
|
|
3476
|
-
_this.handleAdFailure();
|
|
3477
|
-
}
|
|
3478
|
-
} else {
|
|
3479
|
-
_this.handleAdFailure();
|
|
3480
|
-
}
|
|
3481
|
-
} else {
|
|
3482
|
-
_this.handleAdFailure();
|
|
3483
|
-
}
|
|
3317
|
+
_this.handleAdFailure();
|
|
3484
3318
|
});
|
|
3485
3319
|
this.ima.on("content_pause", function() {
|
|
3486
3320
|
_this.clearAdFailsafeTimer();
|
|
@@ -4211,7 +4045,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4211
4045
|
key: "handleAdStart",
|
|
4212
4046
|
value: function handleAdStart(_marker) {
|
|
4213
4047
|
return _async_to_generator(function() {
|
|
4214
|
-
var scheduled, tags, baseVastUrl, adBreakDurationMs, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
4048
|
+
var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
4215
4049
|
return _ts_generator(this, function(_state) {
|
|
4216
4050
|
switch(_state.label){
|
|
4217
4051
|
case 0:
|
|
@@ -4227,35 +4061,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4227
4061
|
];
|
|
4228
4062
|
}
|
|
4229
4063
|
adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
|
|
4230
|
-
if (this.
|
|
4231
|
-
this.
|
|
4232
|
-
|
|
4233
|
-
this.fetchedAdDurations.clear();
|
|
4234
|
-
if (this.config.debugAdTiming) {
|
|
4235
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA LIVE MODE: Target duration=".concat(adBreakDurationMs, "ms | Will continuously fetch ads during break"));
|
|
4236
|
-
}
|
|
4237
|
-
} else {
|
|
4238
|
-
this.isAdaptiveMode = false;
|
|
4239
|
-
this.targetAdBreakDurationMs = null;
|
|
4240
|
-
this.fetchedAdDurations.clear();
|
|
4241
|
-
if (this.config.debugAdTiming) {
|
|
4242
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC VOD MODE: Using fixed ad strategy");
|
|
4243
|
-
}
|
|
4064
|
+
if (this.config.debugAdTiming) {
|
|
4065
|
+
mode = this.isLiveStream ? "LIVE" : "VOD";
|
|
4066
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
4244
4067
|
}
|
|
4245
|
-
this.adPodAllUrls = [];
|
|
4246
|
-
this.preloadingAdUrls.clear();
|
|
4247
|
-
this.vastToMediaUrlMap.clear();
|
|
4248
|
-
this.preloadedMediaUrls.clear();
|
|
4249
|
-
this.preloadingMediaUrls.clear();
|
|
4250
4068
|
this.failedVastUrls.clear();
|
|
4251
4069
|
this.adRequestQueue = [];
|
|
4252
|
-
this.successfulAdRequests = [];
|
|
4253
4070
|
this.continuousFetchingActive = true;
|
|
4254
4071
|
this.isShowingPlaceholder = false;
|
|
4255
|
-
this.placeholderStartTimeMs = null;
|
|
4256
|
-
this.consecutiveEmptyResponses = 0;
|
|
4257
4072
|
this.totalAdRequestsInBreak = 0;
|
|
4258
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
4259
4073
|
currentMuted = this.video.muted;
|
|
4260
4074
|
currentVolume = this.video.volume;
|
|
4261
4075
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
@@ -4301,7 +4115,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4301
4115
|
if (this.config.debugAdTiming) {
|
|
4302
4116
|
console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
|
|
4303
4117
|
}
|
|
4304
|
-
this.successfulAdRequests.push(firstAdUrl);
|
|
4305
4118
|
this.currentAdIndex++;
|
|
4306
4119
|
this.startContinuousFetching(baseVastUrl);
|
|
4307
4120
|
return [
|
|
@@ -4351,200 +4164,92 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4351
4164
|
key: "continuousFetchLoop",
|
|
4352
4165
|
value: function continuousFetchLoop(baseVastUrl) {
|
|
4353
4166
|
return _async_to_generator(function() {
|
|
4354
|
-
var
|
|
4167
|
+
var remaining, maxQueueSize, newAdUrl;
|
|
4355
4168
|
return _ts_generator(this, function(_state) {
|
|
4356
4169
|
switch(_state.label){
|
|
4357
4170
|
case 0:
|
|
4358
|
-
_loop = function() {
|
|
4359
|
-
var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
|
|
4360
|
-
return _ts_generator(this, function(_state) {
|
|
4361
|
-
switch(_state.label){
|
|
4362
|
-
case 0:
|
|
4363
|
-
remaining = _this.getRemainingAdMs();
|
|
4364
|
-
if (remaining <= 0) {
|
|
4365
|
-
if (_this.config.debugAdTiming) {
|
|
4366
|
-
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
|
|
4367
|
-
}
|
|
4368
|
-
return [
|
|
4369
|
-
2,
|
|
4370
|
-
"break"
|
|
4371
|
-
];
|
|
4372
|
-
}
|
|
4373
|
-
if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
|
|
4374
|
-
if (_this.config.debugAdTiming) {
|
|
4375
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
|
|
4376
|
-
}
|
|
4377
|
-
return [
|
|
4378
|
-
2,
|
|
4379
|
-
"break"
|
|
4380
|
-
];
|
|
4381
|
-
}
|
|
4382
|
-
if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
|
|
4383
|
-
if (_this.config.debugAdTiming) {
|
|
4384
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
|
|
4385
|
-
}
|
|
4386
|
-
return [
|
|
4387
|
-
2,
|
|
4388
|
-
"break"
|
|
4389
|
-
];
|
|
4390
|
-
}
|
|
4391
|
-
maxQueueSize = 3;
|
|
4392
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4393
|
-
3,
|
|
4394
|
-
2
|
|
4395
|
-
];
|
|
4396
|
-
if (_this.config.debugAdTiming) {
|
|
4397
|
-
console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
|
|
4398
|
-
}
|
|
4399
|
-
return [
|
|
4400
|
-
4,
|
|
4401
|
-
new Promise(function(resolve) {
|
|
4402
|
-
return setTimeout(resolve, 2e3);
|
|
4403
|
-
})
|
|
4404
|
-
];
|
|
4405
|
-
case 1:
|
|
4406
|
-
_state.sent();
|
|
4407
|
-
return [
|
|
4408
|
-
2,
|
|
4409
|
-
"continue"
|
|
4410
|
-
];
|
|
4411
|
-
case 2:
|
|
4412
|
-
newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4413
|
-
if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
|
|
4414
|
-
3,
|
|
4415
|
-
4
|
|
4416
|
-
];
|
|
4417
|
-
return [
|
|
4418
|
-
4,
|
|
4419
|
-
new Promise(function(resolve) {
|
|
4420
|
-
return setTimeout(resolve, 1e3);
|
|
4421
|
-
})
|
|
4422
|
-
];
|
|
4423
|
-
case 3:
|
|
4424
|
-
_state.sent();
|
|
4425
|
-
return [
|
|
4426
|
-
2,
|
|
4427
|
-
"continue"
|
|
4428
|
-
];
|
|
4429
|
-
case 4:
|
|
4430
|
-
_this.totalAdRequestsInBreak++;
|
|
4431
|
-
if (_this.config.debugAdTiming) {
|
|
4432
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
|
|
4433
|
-
}
|
|
4434
|
-
_state.label = 5;
|
|
4435
|
-
case 5:
|
|
4436
|
-
_state.trys.push([
|
|
4437
|
-
5,
|
|
4438
|
-
11,
|
|
4439
|
-
,
|
|
4440
|
-
13
|
|
4441
|
-
]);
|
|
4442
|
-
if (!_this.ima.preloadAds) return [
|
|
4443
|
-
3,
|
|
4444
|
-
7
|
|
4445
|
-
];
|
|
4446
|
-
return [
|
|
4447
|
-
4,
|
|
4448
|
-
_this.ima.preloadAds(newAdUrl)
|
|
4449
|
-
];
|
|
4450
|
-
case 6:
|
|
4451
|
-
_state.sent();
|
|
4452
|
-
_state.label = 7;
|
|
4453
|
-
case 7:
|
|
4454
|
-
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;
|
|
4455
|
-
if (!!hasPreloadedAd) return [
|
|
4456
|
-
3,
|
|
4457
|
-
9
|
|
4458
|
-
];
|
|
4459
|
-
_this.consecutiveEmptyResponses++;
|
|
4460
|
-
_this.lastEmptyResponseTimeMs = Date.now();
|
|
4461
|
-
backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4462
|
-
if (_this.config.debugAdTiming) {
|
|
4463
|
-
console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
|
|
4464
|
-
}
|
|
4465
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4466
|
-
return [
|
|
4467
|
-
4,
|
|
4468
|
-
new Promise(function(resolve) {
|
|
4469
|
-
return setTimeout(resolve, backoffDelay);
|
|
4470
|
-
})
|
|
4471
|
-
];
|
|
4472
|
-
case 8:
|
|
4473
|
-
_state.sent();
|
|
4474
|
-
return [
|
|
4475
|
-
2,
|
|
4476
|
-
"continue"
|
|
4477
|
-
];
|
|
4478
|
-
case 9:
|
|
4479
|
-
_this.consecutiveEmptyResponses = 0;
|
|
4480
|
-
if (_this.config.debugAdTiming) {
|
|
4481
|
-
console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
|
|
4482
|
-
}
|
|
4483
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
4484
|
-
_this.totalAdsInBreak++;
|
|
4485
|
-
return [
|
|
4486
|
-
4,
|
|
4487
|
-
new Promise(function(resolve) {
|
|
4488
|
-
return setTimeout(resolve, 500);
|
|
4489
|
-
})
|
|
4490
|
-
];
|
|
4491
|
-
case 10:
|
|
4492
|
-
_state.sent();
|
|
4493
|
-
return [
|
|
4494
|
-
3,
|
|
4495
|
-
13
|
|
4496
|
-
];
|
|
4497
|
-
case 11:
|
|
4498
|
-
error = _state.sent();
|
|
4499
|
-
if (_this.config.debugAdTiming) {
|
|
4500
|
-
console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
|
|
4501
|
-
}
|
|
4502
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4503
|
-
_this.consecutiveEmptyResponses++;
|
|
4504
|
-
backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4505
|
-
return [
|
|
4506
|
-
4,
|
|
4507
|
-
new Promise(function(resolve) {
|
|
4508
|
-
return setTimeout(resolve, backoffDelay1);
|
|
4509
|
-
})
|
|
4510
|
-
];
|
|
4511
|
-
case 12:
|
|
4512
|
-
_state.sent();
|
|
4513
|
-
return [
|
|
4514
|
-
3,
|
|
4515
|
-
13
|
|
4516
|
-
];
|
|
4517
|
-
case 13:
|
|
4518
|
-
return [
|
|
4519
|
-
2
|
|
4520
|
-
];
|
|
4521
|
-
}
|
|
4522
|
-
});
|
|
4523
|
-
};
|
|
4524
|
-
_state.label = 1;
|
|
4525
|
-
case 1:
|
|
4526
4171
|
if (!(this.continuousFetchingActive && this.inAdBreak)) return [
|
|
4527
4172
|
3,
|
|
4528
|
-
|
|
4173
|
+
6
|
|
4529
4174
|
];
|
|
4530
|
-
|
|
4175
|
+
remaining = this.getRemainingAdMs();
|
|
4176
|
+
if (remaining <= 0) {
|
|
4177
|
+
if (this.config.debugAdTiming) {
|
|
4178
|
+
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping URL generation");
|
|
4179
|
+
}
|
|
4180
|
+
return [
|
|
4181
|
+
3,
|
|
4182
|
+
6
|
|
4183
|
+
];
|
|
4184
|
+
}
|
|
4185
|
+
if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
|
|
4186
|
+
if (this.config.debugAdTiming) {
|
|
4187
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(this.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
4188
|
+
}
|
|
4189
|
+
return [
|
|
4190
|
+
3,
|
|
4191
|
+
6
|
|
4192
|
+
];
|
|
4193
|
+
}
|
|
4194
|
+
maxQueueSize = 5;
|
|
4195
|
+
if (!(this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4196
|
+
3,
|
|
4197
|
+
2
|
|
4198
|
+
];
|
|
4199
|
+
if (this.config.debugAdTiming) {
|
|
4200
|
+
console.log("[CONTINUOUS-FETCH] ⏸️ URL queue full (".concat(this.adRequestQueue.length, "), waiting..."));
|
|
4201
|
+
}
|
|
4531
4202
|
return [
|
|
4532
|
-
|
|
4533
|
-
|
|
4203
|
+
4,
|
|
4204
|
+
new Promise(function(resolve) {
|
|
4205
|
+
return setTimeout(resolve, 1e3);
|
|
4206
|
+
})
|
|
4207
|
+
];
|
|
4208
|
+
case 1:
|
|
4209
|
+
_state.sent();
|
|
4210
|
+
return [
|
|
4211
|
+
3,
|
|
4212
|
+
0
|
|
4534
4213
|
];
|
|
4535
4214
|
case 2:
|
|
4536
|
-
|
|
4537
|
-
if (
|
|
4215
|
+
newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4216
|
+
if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
|
|
4538
4217
|
3,
|
|
4539
|
-
|
|
4218
|
+
4
|
|
4540
4219
|
];
|
|
4541
4220
|
return [
|
|
4542
|
-
|
|
4543
|
-
|
|
4221
|
+
4,
|
|
4222
|
+
new Promise(function(resolve) {
|
|
4223
|
+
return setTimeout(resolve, 500);
|
|
4224
|
+
})
|
|
4544
4225
|
];
|
|
4545
4226
|
case 3:
|
|
4227
|
+
_state.sent();
|
|
4228
|
+
return [
|
|
4229
|
+
3,
|
|
4230
|
+
0
|
|
4231
|
+
];
|
|
4232
|
+
case 4:
|
|
4233
|
+
if (this.config.debugAdTiming) {
|
|
4234
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCDD Queued VAST URL (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
|
|
4235
|
+
}
|
|
4236
|
+
this.adRequestQueue.push(newAdUrl);
|
|
4237
|
+
this.totalAdsInBreak++;
|
|
4238
|
+
return [
|
|
4239
|
+
4,
|
|
4240
|
+
new Promise(function(resolve) {
|
|
4241
|
+
return setTimeout(resolve, 300);
|
|
4242
|
+
})
|
|
4243
|
+
];
|
|
4244
|
+
case 5:
|
|
4245
|
+
_state.sent();
|
|
4246
|
+
return [
|
|
4247
|
+
3,
|
|
4248
|
+
0
|
|
4249
|
+
];
|
|
4250
|
+
case 6:
|
|
4546
4251
|
if (this.config.debugAdTiming) {
|
|
4547
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1
|
|
4252
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"));
|
|
4548
4253
|
}
|
|
4549
4254
|
return [
|
|
4550
4255
|
2
|
|
@@ -4593,19 +4298,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4593
4298
|
2
|
|
4594
4299
|
];
|
|
4595
4300
|
if (this.config.debugAdTiming) {
|
|
4596
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC
|
|
4301
|
+
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)"));
|
|
4597
4302
|
}
|
|
4598
4303
|
currentMuted = this.video.muted;
|
|
4599
4304
|
currentVolume = this.video.volume;
|
|
4600
4305
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
4601
|
-
if (this.config.debugAdTiming) {
|
|
4602
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDD0A Updated ad audio state: muted=".concat(currentMuted, ", volume=").concat(currentVolume));
|
|
4603
|
-
}
|
|
4604
4306
|
this.currentAdIndex++;
|
|
4605
|
-
this.
|
|
4307
|
+
this.totalAdRequestsInBreak++;
|
|
4606
4308
|
return [
|
|
4607
4309
|
4,
|
|
4608
|
-
this.playSingleAd(nextAdUrl).catch(function() {
|
|
4310
|
+
this.playSingleAd(nextAdUrl).catch(function(error) {
|
|
4311
|
+
if (_this.config.debugAdTiming) {
|
|
4312
|
+
console.log("[CONTINUOUS-FETCH] \u274C Ad request failed:", error.message);
|
|
4313
|
+
}
|
|
4314
|
+
_this.failedVastUrls.add(nextAdUrl);
|
|
4609
4315
|
_this.tryNextAvailableAd(0);
|
|
4610
4316
|
})
|
|
4611
4317
|
];
|
|
@@ -4615,18 +4321,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4615
4321
|
2
|
|
4616
4322
|
];
|
|
4617
4323
|
case 2:
|
|
4618
|
-
maxRetries =
|
|
4324
|
+
maxRetries = 3;
|
|
4619
4325
|
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
4620
4326
|
3,
|
|
4621
4327
|
5
|
|
4622
4328
|
];
|
|
4623
4329
|
if (this.config.debugAdTiming) {
|
|
4624
|
-
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty
|
|
4330
|
+
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
4625
4331
|
}
|
|
4626
4332
|
return [
|
|
4627
4333
|
4,
|
|
4628
4334
|
new Promise(function(resolve) {
|
|
4629
|
-
return setTimeout(resolve,
|
|
4335
|
+
return setTimeout(resolve, 500);
|
|
4630
4336
|
})
|
|
4631
4337
|
];
|
|
4632
4338
|
case 3:
|
|
@@ -4675,12 +4381,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4675
4381
|
];
|
|
4676
4382
|
}
|
|
4677
4383
|
if (this.config.debugAdTiming) {
|
|
4678
|
-
console.log("[CONTINUOUS-FETCH] ⬛ Showing
|
|
4384
|
+
console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad URLs"));
|
|
4679
4385
|
}
|
|
4680
4386
|
this.isShowingPlaceholder = true;
|
|
4681
|
-
this.placeholderStartTimeMs = Date.now();
|
|
4682
4387
|
this.ima.showPlaceholder();
|
|
4683
|
-
checkInterval =
|
|
4388
|
+
checkInterval = 300;
|
|
4684
4389
|
maxChecks = Math.floor(waitTime / checkInterval);
|
|
4685
4390
|
i = 0;
|
|
4686
4391
|
_state.label = 1;
|
|
@@ -4707,10 +4412,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4707
4412
|
5
|
|
4708
4413
|
];
|
|
4709
4414
|
if (this.config.debugAdTiming) {
|
|
4710
|
-
console.log("[CONTINUOUS-FETCH] \u2705
|
|
4415
|
+
console.log("[CONTINUOUS-FETCH] \u2705 Ad URL available, requesting via IMA SDK");
|
|
4711
4416
|
}
|
|
4712
4417
|
this.isShowingPlaceholder = false;
|
|
4713
|
-
this.placeholderStartTimeMs = null;
|
|
4714
4418
|
this.ima.hidePlaceholder();
|
|
4715
4419
|
currentMuted = this.video.muted;
|
|
4716
4420
|
currentVolume = this.video.volume;
|
|
@@ -4721,7 +4425,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4721
4425
|
4
|
|
4722
4426
|
];
|
|
4723
4427
|
this.currentAdIndex++;
|
|
4724
|
-
this.
|
|
4428
|
+
this.totalAdRequestsInBreak++;
|
|
4725
4429
|
return [
|
|
4726
4430
|
4,
|
|
4727
4431
|
this.playSingleAd(nextAdUrl).catch(function() {
|
|
@@ -4743,10 +4447,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4743
4447
|
];
|
|
4744
4448
|
case 6:
|
|
4745
4449
|
if (this.config.debugAdTiming) {
|
|
4746
|
-
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout
|
|
4450
|
+
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
|
|
4747
4451
|
}
|
|
4748
4452
|
this.isShowingPlaceholder = false;
|
|
4749
|
-
this.placeholderStartTimeMs = null;
|
|
4750
4453
|
this.ima.hidePlaceholder();
|
|
4751
4454
|
this.handleAdPodComplete();
|
|
4752
4455
|
return [
|
|
@@ -5048,21 +4751,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5048
4751
|
if (this.isShowingPlaceholder) {
|
|
5049
4752
|
this.ima.hidePlaceholder();
|
|
5050
4753
|
this.isShowingPlaceholder = false;
|
|
5051
|
-
this.placeholderStartTimeMs = null;
|
|
5052
4754
|
}
|
|
5053
|
-
this.preloadingAdUrls.clear();
|
|
5054
|
-
this.vastToMediaUrlMap.clear();
|
|
5055
|
-
this.preloadedMediaUrls.clear();
|
|
5056
|
-
this.preloadingMediaUrls.clear();
|
|
5057
4755
|
this.adRequestQueue = [];
|
|
5058
|
-
this.successfulAdRequests = [];
|
|
5059
4756
|
this.inAdBreak = false;
|
|
5060
4757
|
this.expectedAdBreakDurationMs = void 0;
|
|
5061
4758
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
5062
4759
|
this.clearAdStartTimer();
|
|
5063
4760
|
this.clearAdStopTimer();
|
|
5064
4761
|
this.adPodQueue = [];
|
|
5065
|
-
this.adPodAllUrls = [];
|
|
5066
4762
|
this.showAds = false;
|
|
5067
4763
|
this.currentAdIndex = 0;
|
|
5068
4764
|
this.totalAdsInBreak = 0;
|
|
@@ -5217,651 +4913,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5217
4913
|
}, extra));
|
|
5218
4914
|
}
|
|
5219
4915
|
},
|
|
5220
|
-
{
|
|
5221
|
-
key: "fetchAndParseVastXml",
|
|
5222
|
-
value: function fetchAndParseVastXml(vastTagUrl) {
|
|
5223
|
-
return _async_to_generator(function() {
|
|
5224
|
-
var response, xmlText, error;
|
|
5225
|
-
return _ts_generator(this, function(_state) {
|
|
5226
|
-
switch(_state.label){
|
|
5227
|
-
case 0:
|
|
5228
|
-
_state.trys.push([
|
|
5229
|
-
0,
|
|
5230
|
-
3,
|
|
5231
|
-
,
|
|
5232
|
-
4
|
|
5233
|
-
]);
|
|
5234
|
-
return [
|
|
5235
|
-
4,
|
|
5236
|
-
fetch(vastTagUrl, {
|
|
5237
|
-
mode: "cors",
|
|
5238
|
-
credentials: "include",
|
|
5239
|
-
headers: {
|
|
5240
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5241
|
-
},
|
|
5242
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5243
|
-
})
|
|
5244
|
-
];
|
|
5245
|
-
case 1:
|
|
5246
|
-
response = _state.sent();
|
|
5247
|
-
if (!response.ok) {
|
|
5248
|
-
throw new Error("Failed to fetch VAST: ".concat(response.status));
|
|
5249
|
-
}
|
|
5250
|
-
return [
|
|
5251
|
-
4,
|
|
5252
|
-
response.text()
|
|
5253
|
-
];
|
|
5254
|
-
case 2:
|
|
5255
|
-
xmlText = _state.sent();
|
|
5256
|
-
return [
|
|
5257
|
-
2,
|
|
5258
|
-
this.extractMediaUrlsFromVast(xmlText)
|
|
5259
|
-
];
|
|
5260
|
-
case 3:
|
|
5261
|
-
error = _state.sent();
|
|
5262
|
-
if (this.config.debugAdTiming) {
|
|
5263
|
-
console.warn("[StormcloudVideoPlayer] Failed to fetch/parse VAST XML: ".concat(vastTagUrl), error);
|
|
5264
|
-
}
|
|
5265
|
-
return [
|
|
5266
|
-
2,
|
|
5267
|
-
[]
|
|
5268
|
-
];
|
|
5269
|
-
case 4:
|
|
5270
|
-
return [
|
|
5271
|
-
2
|
|
5272
|
-
];
|
|
5273
|
-
}
|
|
5274
|
-
});
|
|
5275
|
-
}).call(this);
|
|
5276
|
-
}
|
|
5277
|
-
},
|
|
5278
|
-
{
|
|
5279
|
-
key: "extractMediaUrlsFromVast",
|
|
5280
|
-
value: function extractMediaUrlsFromVast(xmlText) {
|
|
5281
|
-
var mediaUrls = [];
|
|
5282
|
-
try {
|
|
5283
|
-
var parser = new DOMParser();
|
|
5284
|
-
var xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5285
|
-
var mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
|
|
5286
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5287
|
-
try {
|
|
5288
|
-
for(var _iterator = Array.from(mediaFileElements)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5289
|
-
var mediaFile = _step.value;
|
|
5290
|
-
var _mediaFile_textContent;
|
|
5291
|
-
var url = (_mediaFile_textContent = mediaFile.textContent) === null || _mediaFile_textContent === void 0 ? void 0 : _mediaFile_textContent.trim();
|
|
5292
|
-
if (url) {
|
|
5293
|
-
var lowerUrl = url.toLowerCase();
|
|
5294
|
-
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")) {
|
|
5295
|
-
mediaUrls.push(url);
|
|
5296
|
-
}
|
|
5297
|
-
}
|
|
5298
|
-
}
|
|
5299
|
-
} catch (err) {
|
|
5300
|
-
_didIteratorError = true;
|
|
5301
|
-
_iteratorError = err;
|
|
5302
|
-
} finally{
|
|
5303
|
-
try {
|
|
5304
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5305
|
-
_iterator.return();
|
|
5306
|
-
}
|
|
5307
|
-
} finally{
|
|
5308
|
-
if (_didIteratorError) {
|
|
5309
|
-
throw _iteratorError;
|
|
5310
|
-
}
|
|
5311
|
-
}
|
|
5312
|
-
}
|
|
5313
|
-
if (this.config.debugAdTiming && mediaUrls.length > 0) {
|
|
5314
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs from VAST:"), mediaUrls);
|
|
5315
|
-
}
|
|
5316
|
-
} catch (error) {
|
|
5317
|
-
if (this.config.debugAdTiming) {
|
|
5318
|
-
console.warn("[StormcloudVideoPlayer] Failed to parse VAST XML:", error);
|
|
5319
|
-
}
|
|
5320
|
-
}
|
|
5321
|
-
return mediaUrls;
|
|
5322
|
-
}
|
|
5323
|
-
},
|
|
5324
|
-
{
|
|
5325
|
-
key: "fetchVastDuration",
|
|
5326
|
-
value: function fetchVastDuration(vastTagUrl) {
|
|
5327
|
-
return _async_to_generator(function() {
|
|
5328
|
-
var _xmlDoc_querySelector, response, xmlText, parser, xmlDoc, durationText, durationParts, durationSeconds, error;
|
|
5329
|
-
return _ts_generator(this, function(_state) {
|
|
5330
|
-
switch(_state.label){
|
|
5331
|
-
case 0:
|
|
5332
|
-
_state.trys.push([
|
|
5333
|
-
0,
|
|
5334
|
-
3,
|
|
5335
|
-
,
|
|
5336
|
-
4
|
|
5337
|
-
]);
|
|
5338
|
-
return [
|
|
5339
|
-
4,
|
|
5340
|
-
fetch(vastTagUrl, {
|
|
5341
|
-
mode: "cors",
|
|
5342
|
-
credentials: "include",
|
|
5343
|
-
headers: {
|
|
5344
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5345
|
-
},
|
|
5346
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5347
|
-
})
|
|
5348
|
-
];
|
|
5349
|
-
case 1:
|
|
5350
|
-
response = _state.sent();
|
|
5351
|
-
if (!response.ok) {
|
|
5352
|
-
if (this.config.debugAdTiming) {
|
|
5353
|
-
console.warn("[ADAPTIVE-POD] Failed to fetch VAST: ".concat(response.status));
|
|
5354
|
-
}
|
|
5355
|
-
return [
|
|
5356
|
-
2,
|
|
5357
|
-
null
|
|
5358
|
-
];
|
|
5359
|
-
}
|
|
5360
|
-
return [
|
|
5361
|
-
4,
|
|
5362
|
-
response.text()
|
|
5363
|
-
];
|
|
5364
|
-
case 2:
|
|
5365
|
-
xmlText = _state.sent();
|
|
5366
|
-
parser = new DOMParser();
|
|
5367
|
-
xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5368
|
-
durationText = (_xmlDoc_querySelector = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector === void 0 ? void 0 : _xmlDoc_querySelector.textContent;
|
|
5369
|
-
if (!durationText) {
|
|
5370
|
-
if (this.config.debugAdTiming) {
|
|
5371
|
-
console.warn("[ADAPTIVE-POD] No Duration element found in VAST");
|
|
5372
|
-
}
|
|
5373
|
-
return [
|
|
5374
|
-
2,
|
|
5375
|
-
null
|
|
5376
|
-
];
|
|
5377
|
-
}
|
|
5378
|
-
durationParts = durationText.split(":");
|
|
5379
|
-
durationSeconds = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
5380
|
-
return [
|
|
5381
|
-
2,
|
|
5382
|
-
durationSeconds
|
|
5383
|
-
];
|
|
5384
|
-
case 3:
|
|
5385
|
-
error = _state.sent();
|
|
5386
|
-
if (this.config.debugAdTiming) {
|
|
5387
|
-
console.warn("[ADAPTIVE-POD] Error fetching VAST duration from ".concat(vastTagUrl, ":"), error);
|
|
5388
|
-
}
|
|
5389
|
-
return [
|
|
5390
|
-
2,
|
|
5391
|
-
null
|
|
5392
|
-
];
|
|
5393
|
-
case 4:
|
|
5394
|
-
return [
|
|
5395
|
-
2
|
|
5396
|
-
];
|
|
5397
|
-
}
|
|
5398
|
-
});
|
|
5399
|
-
}).call(this);
|
|
5400
|
-
}
|
|
5401
|
-
},
|
|
5402
|
-
{
|
|
5403
|
-
key: "calculateAdditionalAdsNeeded",
|
|
5404
|
-
value: function calculateAdditionalAdsNeeded() {
|
|
5405
|
-
if (!this.isAdaptiveMode || this.targetAdBreakDurationMs === null) {
|
|
5406
|
-
return 0;
|
|
5407
|
-
}
|
|
5408
|
-
var totalFetchedDurationMs = 0;
|
|
5409
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5410
|
-
try {
|
|
5411
|
-
for(var _iterator = this.fetchedAdDurations.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5412
|
-
var duration = _step.value;
|
|
5413
|
-
totalFetchedDurationMs += duration * 1e3;
|
|
5414
|
-
}
|
|
5415
|
-
} catch (err) {
|
|
5416
|
-
_didIteratorError = true;
|
|
5417
|
-
_iteratorError = err;
|
|
5418
|
-
} finally{
|
|
5419
|
-
try {
|
|
5420
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5421
|
-
_iterator.return();
|
|
5422
|
-
}
|
|
5423
|
-
} finally{
|
|
5424
|
-
if (_didIteratorError) {
|
|
5425
|
-
throw _iteratorError;
|
|
5426
|
-
}
|
|
5427
|
-
}
|
|
5428
|
-
}
|
|
5429
|
-
var fetchedCount = this.fetchedAdDurations.size;
|
|
5430
|
-
var averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
5431
|
-
var queuedButNotFetched = this.adPodAllUrls.length - fetchedCount;
|
|
5432
|
-
var estimatedQueuedDurationMs = queuedButNotFetched * averageDurationMs;
|
|
5433
|
-
var estimatedTotalDurationMs = totalFetchedDurationMs + estimatedQueuedDurationMs;
|
|
5434
|
-
var remainingTimeMs = this.targetAdBreakDurationMs - estimatedTotalDurationMs;
|
|
5435
|
-
if (remainingTimeMs <= 0) {
|
|
5436
|
-
if (this.config.debugAdTiming) {
|
|
5437
|
-
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"));
|
|
5438
|
-
}
|
|
5439
|
-
return 0;
|
|
5440
|
-
}
|
|
5441
|
-
var additionalAds = Math.ceil(remainingTimeMs / averageDurationMs);
|
|
5442
|
-
if (this.config.debugAdTiming) {
|
|
5443
|
-
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"));
|
|
5444
|
-
}
|
|
5445
|
-
return additionalAds;
|
|
5446
|
-
}
|
|
5447
|
-
},
|
|
5448
|
-
{
|
|
5449
|
-
key: "addAdaptiveAdsToQueue",
|
|
5450
|
-
value: function addAdaptiveAdsToQueue() {
|
|
5451
|
-
return _async_to_generator(function() {
|
|
5452
|
-
var _this_adPodAllUrls, _this_adPodQueue, additionalAds, newUrls;
|
|
5453
|
-
return _ts_generator(this, function(_state) {
|
|
5454
|
-
if (!this.isAdaptiveMode || !this.apiVastTagUrl) {
|
|
5455
|
-
return [
|
|
5456
|
-
2
|
|
5457
|
-
];
|
|
5458
|
-
}
|
|
5459
|
-
additionalAds = this.calculateAdditionalAdsNeeded();
|
|
5460
|
-
if (additionalAds <= 0) {
|
|
5461
|
-
return [
|
|
5462
|
-
2
|
|
5463
|
-
];
|
|
5464
|
-
}
|
|
5465
|
-
newUrls = this.generateVastUrlsWithCorrelators(this.apiVastTagUrl, additionalAds);
|
|
5466
|
-
if (this.config.debugAdTiming) {
|
|
5467
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Adding ".concat(newUrls.length, " additional VAST URLs to queue (will be preloaded sequentially)"));
|
|
5468
|
-
}
|
|
5469
|
-
(_this_adPodAllUrls = this.adPodAllUrls).push.apply(_this_adPodAllUrls, _to_consumable_array(newUrls));
|
|
5470
|
-
(_this_adPodQueue = this.adPodQueue).push.apply(_this_adPodQueue, _to_consumable_array(newUrls));
|
|
5471
|
-
this.totalAdsInBreak += newUrls.length;
|
|
5472
|
-
return [
|
|
5473
|
-
2
|
|
5474
|
-
];
|
|
5475
|
-
});
|
|
5476
|
-
}).call(this);
|
|
5477
|
-
}
|
|
5478
|
-
},
|
|
5479
|
-
{
|
|
5480
|
-
key: "preloadMediaFile",
|
|
5481
|
-
value: function preloadMediaFile(mediaUrl) {
|
|
5482
|
-
return _async_to_generator(function() {
|
|
5483
|
-
var response, error;
|
|
5484
|
-
return _ts_generator(this, function(_state) {
|
|
5485
|
-
switch(_state.label){
|
|
5486
|
-
case 0:
|
|
5487
|
-
if (this.preloadedMediaUrls.has(mediaUrl)) {
|
|
5488
|
-
return [
|
|
5489
|
-
2
|
|
5490
|
-
];
|
|
5491
|
-
}
|
|
5492
|
-
if (this.preloadingMediaUrls.has(mediaUrl)) {
|
|
5493
|
-
return [
|
|
5494
|
-
2
|
|
5495
|
-
];
|
|
5496
|
-
}
|
|
5497
|
-
this.preloadingMediaUrls.add(mediaUrl);
|
|
5498
|
-
_state.label = 1;
|
|
5499
|
-
case 1:
|
|
5500
|
-
_state.trys.push([
|
|
5501
|
-
1,
|
|
5502
|
-
3,
|
|
5503
|
-
4,
|
|
5504
|
-
5
|
|
5505
|
-
]);
|
|
5506
|
-
if (this.config.debugAdTiming) {
|
|
5507
|
-
console.log("[StormcloudVideoPlayer] Preloading video file: ".concat(mediaUrl));
|
|
5508
|
-
}
|
|
5509
|
-
return [
|
|
5510
|
-
4,
|
|
5511
|
-
fetch(mediaUrl, {
|
|
5512
|
-
mode: "cors",
|
|
5513
|
-
credentials: "include",
|
|
5514
|
-
method: "GET",
|
|
5515
|
-
headers: {
|
|
5516
|
-
Range: "bytes=0-1048576"
|
|
5517
|
-
},
|
|
5518
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5519
|
-
})
|
|
5520
|
-
];
|
|
5521
|
-
case 2:
|
|
5522
|
-
response = _state.sent();
|
|
5523
|
-
if (response.ok || response.status === 206) {
|
|
5524
|
-
this.preloadedMediaUrls.add(mediaUrl);
|
|
5525
|
-
if (this.config.debugAdTiming) {
|
|
5526
|
-
console.log("[StormcloudVideoPlayer] Successfully preloaded video file: ".concat(mediaUrl));
|
|
5527
|
-
}
|
|
5528
|
-
}
|
|
5529
|
-
return [
|
|
5530
|
-
3,
|
|
5531
|
-
5
|
|
5532
|
-
];
|
|
5533
|
-
case 3:
|
|
5534
|
-
error = _state.sent();
|
|
5535
|
-
if (this.config.debugAdTiming) {
|
|
5536
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload video file: ".concat(mediaUrl), error);
|
|
5537
|
-
}
|
|
5538
|
-
return [
|
|
5539
|
-
3,
|
|
5540
|
-
5
|
|
5541
|
-
];
|
|
5542
|
-
case 4:
|
|
5543
|
-
this.preloadingMediaUrls.delete(mediaUrl);
|
|
5544
|
-
return [
|
|
5545
|
-
7
|
|
5546
|
-
];
|
|
5547
|
-
case 5:
|
|
5548
|
-
return [
|
|
5549
|
-
2
|
|
5550
|
-
];
|
|
5551
|
-
}
|
|
5552
|
-
});
|
|
5553
|
-
}).call(this);
|
|
5554
|
-
}
|
|
5555
|
-
},
|
|
5556
|
-
{
|
|
5557
|
-
key: "preloadAllAdsInBackground",
|
|
5558
|
-
value: function preloadAllAdsInBackground() {
|
|
5559
|
-
return _async_to_generator(function() {
|
|
5560
|
-
var _this, processedUrls, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, _this_ima_hasPreloadedAd, _this_ima, nextUrl, error, preloadPromises;
|
|
5561
|
-
return _ts_generator(this, function(_state) {
|
|
5562
|
-
switch(_state.label){
|
|
5563
|
-
case 0:
|
|
5564
|
-
_this = this;
|
|
5565
|
-
if (this.adPodAllUrls.length === 0) {
|
|
5566
|
-
return [
|
|
5567
|
-
2
|
|
5568
|
-
];
|
|
5569
|
-
}
|
|
5570
|
-
if (!this.isAdaptiveMode) return [
|
|
5571
|
-
3,
|
|
5572
|
-
7
|
|
5573
|
-
];
|
|
5574
|
-
if (this.config.debugAdTiming) {
|
|
5575
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Starting sequential preload of remaining ads");
|
|
5576
|
-
}
|
|
5577
|
-
processedUrls = /* @__PURE__ */ new Set();
|
|
5578
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5579
|
-
try {
|
|
5580
|
-
for(_iterator = this.adPodAllUrls[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5581
|
-
url = _step.value;
|
|
5582
|
-
;
|
|
5583
|
-
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)) {
|
|
5584
|
-
processedUrls.add(url);
|
|
5585
|
-
}
|
|
5586
|
-
}
|
|
5587
|
-
} catch (err) {
|
|
5588
|
-
_didIteratorError = true;
|
|
5589
|
-
_iteratorError = err;
|
|
5590
|
-
} finally{
|
|
5591
|
-
try {
|
|
5592
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5593
|
-
_iterator.return();
|
|
5594
|
-
}
|
|
5595
|
-
} finally{
|
|
5596
|
-
if (_didIteratorError) {
|
|
5597
|
-
throw _iteratorError;
|
|
5598
|
-
}
|
|
5599
|
-
}
|
|
5600
|
-
}
|
|
5601
|
-
if (this.config.debugAdTiming && processedUrls.size > 0) {
|
|
5602
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE6 Skipping ".concat(processedUrls.size, " already-preloaded ads"));
|
|
5603
|
-
}
|
|
5604
|
-
_state.label = 1;
|
|
5605
|
-
case 1:
|
|
5606
|
-
if (!true) return [
|
|
5607
|
-
3,
|
|
5608
|
-
6
|
|
5609
|
-
];
|
|
5610
|
-
nextUrl = this.adPodAllUrls.find(function(url) {
|
|
5611
|
-
return !processedUrls.has(url);
|
|
5612
|
-
});
|
|
5613
|
-
if (!nextUrl) {
|
|
5614
|
-
if (this.config.debugAdTiming) {
|
|
5615
|
-
console.log("[ADAPTIVE-POD] ✅ All queued ads processed (".concat(processedUrls.size, " total)"));
|
|
5616
|
-
}
|
|
5617
|
-
return [
|
|
5618
|
-
3,
|
|
5619
|
-
6
|
|
5620
|
-
];
|
|
5621
|
-
}
|
|
5622
|
-
processedUrls.add(nextUrl);
|
|
5623
|
-
if (this.config.debugAdTiming) {
|
|
5624
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE5 Preloading ad ".concat(processedUrls.size, "/").concat(this.adPodAllUrls.length, "..."));
|
|
5625
|
-
}
|
|
5626
|
-
_state.label = 2;
|
|
5627
|
-
case 2:
|
|
5628
|
-
_state.trys.push([
|
|
5629
|
-
2,
|
|
5630
|
-
4,
|
|
5631
|
-
,
|
|
5632
|
-
5
|
|
5633
|
-
]);
|
|
5634
|
-
return [
|
|
5635
|
-
4,
|
|
5636
|
-
this.preloadSingleAd(nextUrl)
|
|
5637
|
-
];
|
|
5638
|
-
case 3:
|
|
5639
|
-
_state.sent();
|
|
5640
|
-
return [
|
|
5641
|
-
3,
|
|
5642
|
-
5
|
|
5643
|
-
];
|
|
5644
|
-
case 4:
|
|
5645
|
-
error = _state.sent();
|
|
5646
|
-
if (this.config.debugAdTiming) {
|
|
5647
|
-
console.warn("[ADAPTIVE-POD] ⚠️ Preload failed for ad ".concat(processedUrls.size, ":"), error);
|
|
5648
|
-
}
|
|
5649
|
-
return [
|
|
5650
|
-
3,
|
|
5651
|
-
5
|
|
5652
|
-
];
|
|
5653
|
-
case 5:
|
|
5654
|
-
if (this.calculateAdditionalAdsNeeded() === 0) {
|
|
5655
|
-
if (this.config.debugAdTiming) {
|
|
5656
|
-
console.log("[ADAPTIVE-POD] ✅ Target duration reached (".concat(processedUrls.size, " ads preloaded), stopping"));
|
|
5657
|
-
}
|
|
5658
|
-
return [
|
|
5659
|
-
3,
|
|
5660
|
-
6
|
|
5661
|
-
];
|
|
5662
|
-
}
|
|
5663
|
-
return [
|
|
5664
|
-
3,
|
|
5665
|
-
1
|
|
5666
|
-
];
|
|
5667
|
-
case 6:
|
|
5668
|
-
if (this.config.debugAdTiming) {
|
|
5669
|
-
console.log("[ADAPTIVE-POD] ✅ Sequential preloading completed (".concat(processedUrls.size, " ads ready)"));
|
|
5670
|
-
}
|
|
5671
|
-
return [
|
|
5672
|
-
3,
|
|
5673
|
-
9
|
|
5674
|
-
];
|
|
5675
|
-
case 7:
|
|
5676
|
-
if (this.config.debugAdTiming) {
|
|
5677
|
-
console.log("[StormcloudVideoPlayer] Starting parallel preload of ".concat(this.adPodAllUrls.length, " ads"));
|
|
5678
|
-
}
|
|
5679
|
-
preloadPromises = this.adPodAllUrls.map(function(vastTagUrl) {
|
|
5680
|
-
return _this.preloadSingleAd(vastTagUrl).catch(function(error) {
|
|
5681
|
-
if (_this.config.debugAdTiming) {
|
|
5682
|
-
console.warn("[StormcloudVideoPlayer] Preload failed for ".concat(vastTagUrl, ":"), error);
|
|
5683
|
-
}
|
|
5684
|
-
});
|
|
5685
|
-
});
|
|
5686
|
-
return [
|
|
5687
|
-
4,
|
|
5688
|
-
Promise.all(preloadPromises)
|
|
5689
|
-
];
|
|
5690
|
-
case 8:
|
|
5691
|
-
_state.sent();
|
|
5692
|
-
if (this.config.debugAdTiming) {
|
|
5693
|
-
console.log("[StormcloudVideoPlayer] Background preloading completed for all ads");
|
|
5694
|
-
}
|
|
5695
|
-
_state.label = 9;
|
|
5696
|
-
case 9:
|
|
5697
|
-
return [
|
|
5698
|
-
2
|
|
5699
|
-
];
|
|
5700
|
-
}
|
|
5701
|
-
});
|
|
5702
|
-
}).call(this);
|
|
5703
|
-
}
|
|
5704
|
-
},
|
|
5705
|
-
{
|
|
5706
|
-
key: "preloadSingleAd",
|
|
5707
|
-
value: function preloadSingleAd(vastTagUrl) {
|
|
5708
|
-
return _async_to_generator(function() {
|
|
5709
|
-
var _this, duration, mediaUrls, primaryMediaUrl, error;
|
|
5710
|
-
return _ts_generator(this, function(_state) {
|
|
5711
|
-
switch(_state.label){
|
|
5712
|
-
case 0:
|
|
5713
|
-
_this = this;
|
|
5714
|
-
if (!vastTagUrl) return [
|
|
5715
|
-
2
|
|
5716
|
-
];
|
|
5717
|
-
_state.label = 1;
|
|
5718
|
-
case 1:
|
|
5719
|
-
_state.trys.push([
|
|
5720
|
-
1,
|
|
5721
|
-
11,
|
|
5722
|
-
,
|
|
5723
|
-
12
|
|
5724
|
-
]);
|
|
5725
|
-
if (!(this.isAdaptiveMode && !this.fetchedAdDurations.has(vastTagUrl))) return [
|
|
5726
|
-
3,
|
|
5727
|
-
4
|
|
5728
|
-
];
|
|
5729
|
-
return [
|
|
5730
|
-
4,
|
|
5731
|
-
this.fetchVastDuration(vastTagUrl)
|
|
5732
|
-
];
|
|
5733
|
-
case 2:
|
|
5734
|
-
duration = _state.sent();
|
|
5735
|
-
if (!(duration !== null)) return [
|
|
5736
|
-
3,
|
|
5737
|
-
4
|
|
5738
|
-
];
|
|
5739
|
-
this.fetchedAdDurations.set(vastTagUrl, duration);
|
|
5740
|
-
if (this.config.debugAdTiming) {
|
|
5741
|
-
console.log("[ADAPTIVE-POD] ✓ Fetched ad duration: ".concat(duration, "s (").concat(this.fetchedAdDurations.size, " ads fetched so far)"));
|
|
5742
|
-
}
|
|
5743
|
-
return [
|
|
5744
|
-
4,
|
|
5745
|
-
this.addAdaptiveAdsToQueue()
|
|
5746
|
-
];
|
|
5747
|
-
case 3:
|
|
5748
|
-
_state.sent();
|
|
5749
|
-
_state.label = 4;
|
|
5750
|
-
case 4:
|
|
5751
|
-
if (!(this.ima.preloadAds && !this.ima.hasPreloadedAd(vastTagUrl))) return [
|
|
5752
|
-
3,
|
|
5753
|
-
6
|
|
5754
|
-
];
|
|
5755
|
-
if (!!this.preloadingAdUrls.has(vastTagUrl)) return [
|
|
5756
|
-
3,
|
|
5757
|
-
6
|
|
5758
|
-
];
|
|
5759
|
-
if (this.config.debugAdTiming) {
|
|
5760
|
-
console.log("[StormcloudVideoPlayer] Preloading VAST: ".concat(vastTagUrl));
|
|
5761
|
-
}
|
|
5762
|
-
this.preloadingAdUrls.add(vastTagUrl);
|
|
5763
|
-
return [
|
|
5764
|
-
4,
|
|
5765
|
-
this.ima.preloadAds(vastTagUrl).then(function() {
|
|
5766
|
-
if (_this.config.debugAdTiming) {
|
|
5767
|
-
console.log("[StormcloudVideoPlayer] IMA VAST preload complete: ".concat(vastTagUrl));
|
|
5768
|
-
}
|
|
5769
|
-
}).catch(function(error) {
|
|
5770
|
-
if (_this.config.debugAdTiming) {
|
|
5771
|
-
console.warn("[StormcloudVideoPlayer] IMA VAST preload failed: ".concat(vastTagUrl), error);
|
|
5772
|
-
}
|
|
5773
|
-
}).finally(function() {
|
|
5774
|
-
_this.preloadingAdUrls.delete(vastTagUrl);
|
|
5775
|
-
})
|
|
5776
|
-
];
|
|
5777
|
-
case 5:
|
|
5778
|
-
_state.sent();
|
|
5779
|
-
_state.label = 6;
|
|
5780
|
-
case 6:
|
|
5781
|
-
mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5782
|
-
if (!!mediaUrls) return [
|
|
5783
|
-
3,
|
|
5784
|
-
8
|
|
5785
|
-
];
|
|
5786
|
-
if (this.config.debugAdTiming) {
|
|
5787
|
-
console.log("[StormcloudVideoPlayer] Fetching and parsing VAST to extract media URLs: ".concat(vastTagUrl));
|
|
5788
|
-
}
|
|
5789
|
-
return [
|
|
5790
|
-
4,
|
|
5791
|
-
this.fetchAndParseVastXml(vastTagUrl)
|
|
5792
|
-
];
|
|
5793
|
-
case 7:
|
|
5794
|
-
mediaUrls = _state.sent();
|
|
5795
|
-
if (this.config.debugAdTiming) {
|
|
5796
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs:"), mediaUrls);
|
|
5797
|
-
}
|
|
5798
|
-
if (mediaUrls.length > 0) {
|
|
5799
|
-
this.vastToMediaUrlMap.set(vastTagUrl, mediaUrls);
|
|
5800
|
-
}
|
|
5801
|
-
_state.label = 8;
|
|
5802
|
-
case 8:
|
|
5803
|
-
if (!(mediaUrls && mediaUrls.length > 0)) return [
|
|
5804
|
-
3,
|
|
5805
|
-
10
|
|
5806
|
-
];
|
|
5807
|
-
primaryMediaUrl = mediaUrls[0];
|
|
5808
|
-
if (!(primaryMediaUrl && !this.preloadedMediaUrls.has(primaryMediaUrl))) return [
|
|
5809
|
-
3,
|
|
5810
|
-
10
|
|
5811
|
-
];
|
|
5812
|
-
return [
|
|
5813
|
-
4,
|
|
5814
|
-
this.preloadMediaFile(primaryMediaUrl)
|
|
5815
|
-
];
|
|
5816
|
-
case 9:
|
|
5817
|
-
_state.sent();
|
|
5818
|
-
_state.label = 10;
|
|
5819
|
-
case 10:
|
|
5820
|
-
return [
|
|
5821
|
-
3,
|
|
5822
|
-
12
|
|
5823
|
-
];
|
|
5824
|
-
case 11:
|
|
5825
|
-
error = _state.sent();
|
|
5826
|
-
if (this.config.debugAdTiming) {
|
|
5827
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload ad: ".concat(vastTagUrl), error);
|
|
5828
|
-
}
|
|
5829
|
-
return [
|
|
5830
|
-
3,
|
|
5831
|
-
12
|
|
5832
|
-
];
|
|
5833
|
-
case 12:
|
|
5834
|
-
return [
|
|
5835
|
-
2
|
|
5836
|
-
];
|
|
5837
|
-
}
|
|
5838
|
-
});
|
|
5839
|
-
}).call(this);
|
|
5840
|
-
}
|
|
5841
|
-
},
|
|
5842
|
-
{
|
|
5843
|
-
key: "findNextPreloadedAd",
|
|
5844
|
-
value: function findNextPreloadedAd() {
|
|
5845
|
-
for(var i = 0; i < this.adPodQueue.length; i++){
|
|
5846
|
-
var _this_ima_hasPreloadedAd, _this_ima;
|
|
5847
|
-
var vastTagUrl = this.adPodQueue[i];
|
|
5848
|
-
if (!vastTagUrl) continue;
|
|
5849
|
-
if (this.failedVastUrls.has(vastTagUrl)) {
|
|
5850
|
-
console.warn("[AD-ERROR] Skipping failed URL in queue");
|
|
5851
|
-
continue;
|
|
5852
|
-
}
|
|
5853
|
-
var _this_ima_hasPreloadedAd1;
|
|
5854
|
-
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;
|
|
5855
|
-
var mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5856
|
-
var hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
|
|
5857
|
-
if (hasImaPreload || hasMediaPreload) {
|
|
5858
|
-
this.adPodQueue.splice(0, i + 1);
|
|
5859
|
-
return vastTagUrl;
|
|
5860
|
-
}
|
|
5861
|
-
}
|
|
5862
|
-
return void 0;
|
|
5863
|
-
}
|
|
5864
|
-
},
|
|
5865
4916
|
{
|
|
5866
4917
|
key: "getRemainingAdMs",
|
|
5867
4918
|
value: function getRemainingAdMs() {
|
|
@@ -6048,7 +5099,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6048
5099
|
}
|
|
6049
5100
|
if (this.ima && this.ima.isAdPlaying()) {
|
|
6050
5101
|
var width = this.video.clientWidth || 640;
|
|
6051
|
-
var height = this.video.clientHeight ||
|
|
5102
|
+
var height = this.video.clientHeight || 480;
|
|
6052
5103
|
if (this.config.debugAdTiming) {
|
|
6053
5104
|
console.log("[StormcloudVideoPlayer] Resizing ads manager to ".concat(width, "x").concat(height));
|
|
6054
5105
|
}
|
|
@@ -6079,13 +5130,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6079
5130
|
}
|
|
6080
5131
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
6081
5132
|
(_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
|
|
6082
|
-
this.preloadingAdUrls.clear();
|
|
6083
|
-
this.vastToMediaUrlMap.clear();
|
|
6084
|
-
this.preloadedMediaUrls.clear();
|
|
6085
|
-
this.preloadingMediaUrls.clear();
|
|
6086
|
-
this.adPodAllUrls = [];
|
|
6087
5133
|
this.adRequestQueue = [];
|
|
6088
|
-
this.successfulAdRequests = [];
|
|
6089
5134
|
}
|
|
6090
5135
|
}
|
|
6091
5136
|
]);
|