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/players/index.cjs
CHANGED
|
@@ -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;
|
|
@@ -595,8 +581,6 @@ function createImaController(video, options) {
|
|
|
595
581
|
var originalMutedState = false;
|
|
596
582
|
var originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
597
583
|
var listeners = /* @__PURE__ */ new Map();
|
|
598
|
-
var preloadedVast = /* @__PURE__ */ new Map();
|
|
599
|
-
var preloadingVast = /* @__PURE__ */ new Map();
|
|
600
584
|
var adVideoElement;
|
|
601
585
|
function setAdPlayingFlag(isPlaying) {
|
|
602
586
|
if (isPlaying) {
|
|
@@ -746,10 +730,10 @@ function createImaController(video, options) {
|
|
|
746
730
|
var adsLoadedReject;
|
|
747
731
|
function makeAdsRequest(google, vastTagUrl) {
|
|
748
732
|
var adsRequest = new google.ima.AdsRequest();
|
|
749
|
-
console.log("[IMA] \uD83D\uDCE1 Requesting VAST
|
|
733
|
+
console.log("[IMA] \uD83D\uDCE1 Requesting VAST via IMA SDK:", vastTagUrl.substring(0, 80) + "...");
|
|
750
734
|
adsRequest.adTagUrl = vastTagUrl;
|
|
751
735
|
var videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
752
|
-
var videoHeight = video.offsetHeight || video.clientHeight ||
|
|
736
|
+
var videoHeight = video.offsetHeight || video.clientHeight || 480;
|
|
753
737
|
adsRequest.linearAdSlotWidth = videoWidth;
|
|
754
738
|
adsRequest.linearAdSlotHeight = videoHeight;
|
|
755
739
|
adsRequest.nonLinearAdSlotWidth = videoWidth;
|
|
@@ -795,36 +779,6 @@ function createImaController(video, options) {
|
|
|
795
779
|
(_video_parentElement = video.parentElement) === null || _video_parentElement === void 0 ? void 0 : _video_parentElement.appendChild(container);
|
|
796
780
|
adContainerEl = container;
|
|
797
781
|
}
|
|
798
|
-
function fetchVastDocument(vastTagUrl) {
|
|
799
|
-
return _async_to_generator(function() {
|
|
800
|
-
var response;
|
|
801
|
-
return _ts_generator(this, function(_state) {
|
|
802
|
-
switch(_state.label){
|
|
803
|
-
case 0:
|
|
804
|
-
return [
|
|
805
|
-
4,
|
|
806
|
-
fetch(vastTagUrl, {
|
|
807
|
-
mode: "cors",
|
|
808
|
-
credentials: "include",
|
|
809
|
-
headers: {
|
|
810
|
-
"Accept": "application/xml, text/xml, */*"
|
|
811
|
-
},
|
|
812
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
813
|
-
})
|
|
814
|
-
];
|
|
815
|
-
case 1:
|
|
816
|
-
response = _state.sent();
|
|
817
|
-
if (!response.ok) {
|
|
818
|
-
throw new Error("Failed to preload VAST: ".concat(response.status));
|
|
819
|
-
}
|
|
820
|
-
return [
|
|
821
|
-
2,
|
|
822
|
-
response.text()
|
|
823
|
-
];
|
|
824
|
-
}
|
|
825
|
-
});
|
|
826
|
-
})();
|
|
827
|
-
}
|
|
828
782
|
function destroyAdsManager() {
|
|
829
783
|
if (adsManager) {
|
|
830
784
|
try {
|
|
@@ -1139,47 +1093,6 @@ function createImaController(video, options) {
|
|
|
1139
1093
|
});
|
|
1140
1094
|
})();
|
|
1141
1095
|
},
|
|
1142
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1143
|
-
return _async_to_generator(function() {
|
|
1144
|
-
var inflight, preloadPromise;
|
|
1145
|
-
return _ts_generator(this, function(_state) {
|
|
1146
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1147
|
-
return [
|
|
1148
|
-
2,
|
|
1149
|
-
Promise.resolve()
|
|
1150
|
-
];
|
|
1151
|
-
}
|
|
1152
|
-
if (preloadedVast.has(vastTagUrl)) {
|
|
1153
|
-
return [
|
|
1154
|
-
2,
|
|
1155
|
-
Promise.resolve()
|
|
1156
|
-
];
|
|
1157
|
-
}
|
|
1158
|
-
inflight = preloadingVast.get(vastTagUrl);
|
|
1159
|
-
if (inflight) {
|
|
1160
|
-
return [
|
|
1161
|
-
2,
|
|
1162
|
-
inflight
|
|
1163
|
-
];
|
|
1164
|
-
}
|
|
1165
|
-
preloadPromise = fetchVastDocument(vastTagUrl).then(function(xml) {
|
|
1166
|
-
preloadedVast.set(vastTagUrl, xml);
|
|
1167
|
-
}).catch(function() {
|
|
1168
|
-
preloadedVast.delete(vastTagUrl);
|
|
1169
|
-
}).finally(function() {
|
|
1170
|
-
preloadingVast.delete(vastTagUrl);
|
|
1171
|
-
});
|
|
1172
|
-
preloadingVast.set(vastTagUrl, preloadPromise);
|
|
1173
|
-
return [
|
|
1174
|
-
2,
|
|
1175
|
-
preloadPromise
|
|
1176
|
-
];
|
|
1177
|
-
});
|
|
1178
|
-
})();
|
|
1179
|
-
},
|
|
1180
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1181
|
-
return preloadedVast.has(vastTagUrl);
|
|
1182
|
-
},
|
|
1183
1096
|
play: function play() {
|
|
1184
1097
|
return _async_to_generator(function() {
|
|
1185
1098
|
var _window_google, width, height, adVolume, _video_play;
|
|
@@ -1198,7 +1111,7 @@ function createImaController(video, options) {
|
|
|
1198
1111
|
}
|
|
1199
1112
|
try {
|
|
1200
1113
|
width = video.clientWidth || 640;
|
|
1201
|
-
height = video.clientHeight ||
|
|
1114
|
+
height = video.clientHeight || 480;
|
|
1202
1115
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
1203
1116
|
adPlaying = true;
|
|
1204
1117
|
adVolume = originalMutedState ? 0 : originalVolume;
|
|
@@ -1288,8 +1201,6 @@ function createImaController(video, options) {
|
|
|
1288
1201
|
adDisplayContainer = void 0;
|
|
1289
1202
|
adsLoader = void 0;
|
|
1290
1203
|
contentVideoHidden = false;
|
|
1291
|
-
preloadedVast.clear();
|
|
1292
|
-
preloadingVast.clear();
|
|
1293
1204
|
},
|
|
1294
1205
|
isAdPlaying: function isAdPlaying() {
|
|
1295
1206
|
return adPlaying;
|
|
@@ -1890,51 +1801,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1890
1801
|
});
|
|
1891
1802
|
})();
|
|
1892
1803
|
},
|
|
1893
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1894
|
-
return _async_to_generator(function() {
|
|
1895
|
-
var inflight, preloadPromise;
|
|
1896
|
-
return _ts_generator(this, function(_state) {
|
|
1897
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1898
|
-
return [
|
|
1899
|
-
2,
|
|
1900
|
-
Promise.resolve()
|
|
1901
|
-
];
|
|
1902
|
-
}
|
|
1903
|
-
if (preloadedAds.has(vastTagUrl)) {
|
|
1904
|
-
return [
|
|
1905
|
-
2,
|
|
1906
|
-
Promise.resolve()
|
|
1907
|
-
];
|
|
1908
|
-
}
|
|
1909
|
-
inflight = preloadingAds.get(vastTagUrl);
|
|
1910
|
-
if (inflight) {
|
|
1911
|
-
return [
|
|
1912
|
-
2,
|
|
1913
|
-
inflight
|
|
1914
|
-
];
|
|
1915
|
-
}
|
|
1916
|
-
preloadPromise = fetchAndParseVastAd(vastTagUrl).then(function(ad) {
|
|
1917
|
-
if (ad) {
|
|
1918
|
-
preloadedAds.set(vastTagUrl, ad);
|
|
1919
|
-
console.log("[HlsAdPlayer] Cached VAST response for preloading:", vastTagUrl);
|
|
1920
|
-
}
|
|
1921
|
-
}).catch(function(error) {
|
|
1922
|
-
console.warn("[HlsAdPlayer] Failed to preload VAST response:", error);
|
|
1923
|
-
preloadedAds.delete(vastTagUrl);
|
|
1924
|
-
}).finally(function() {
|
|
1925
|
-
preloadingAds.delete(vastTagUrl);
|
|
1926
|
-
});
|
|
1927
|
-
preloadingAds.set(vastTagUrl, preloadPromise);
|
|
1928
|
-
return [
|
|
1929
|
-
2,
|
|
1930
|
-
preloadPromise
|
|
1931
|
-
];
|
|
1932
|
-
});
|
|
1933
|
-
})();
|
|
1934
|
-
},
|
|
1935
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1936
|
-
return preloadedAds.has(vastTagUrl);
|
|
1937
|
-
},
|
|
1938
1804
|
play: function play() {
|
|
1939
1805
|
return _async_to_generator(function() {
|
|
1940
1806
|
var contentVolume, adVolume, mediaFile;
|
|
@@ -2826,32 +2692,17 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2826
2692
|
this.bufferedSegmentsCount = 0;
|
|
2827
2693
|
this.shouldAutoplayAfterBuffering = false;
|
|
2828
2694
|
this.hasInitialBufferCompleted = false;
|
|
2829
|
-
this.adPodAllUrls = [];
|
|
2830
|
-
this.preloadingAdUrls = /* @__PURE__ */ new Set();
|
|
2831
|
-
this.vastToMediaUrlMap = /* @__PURE__ */ new Map();
|
|
2832
|
-
this.preloadedMediaUrls = /* @__PURE__ */ new Set();
|
|
2833
|
-
this.preloadingMediaUrls = /* @__PURE__ */ new Set();
|
|
2834
2695
|
this.adRequestTokenCounter = 0;
|
|
2835
2696
|
this.activeAdRequestToken = null;
|
|
2836
2697
|
this.adRequestWatchdogToken = null;
|
|
2837
2698
|
this.adFailsafeToken = null;
|
|
2838
|
-
this.fetchedAdDurations = /* @__PURE__ */ new Map();
|
|
2839
|
-
this.targetAdBreakDurationMs = null;
|
|
2840
|
-
this.isAdaptiveMode = false;
|
|
2841
2699
|
this.failedVastUrls = /* @__PURE__ */ new Set();
|
|
2842
2700
|
this.continuousFetchingActive = false;
|
|
2843
2701
|
this.adRequestQueue = [];
|
|
2844
|
-
this.successfulAdRequests = [];
|
|
2845
2702
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2846
|
-
this.placeholderStartTimeMs = null;
|
|
2847
2703
|
this.isShowingPlaceholder = false;
|
|
2848
|
-
this.consecutiveEmptyResponses = 0;
|
|
2849
2704
|
this.totalAdRequestsInBreak = 0;
|
|
2850
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
2851
2705
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2852
|
-
this.maxConsecutiveEmptyResponses = 5;
|
|
2853
|
-
this.baseEmptyResponseDelayMs = 2e3;
|
|
2854
|
-
this.maxEmptyResponseDelayMs = 3e4;
|
|
2855
2706
|
initializePolyfills();
|
|
2856
2707
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2857
2708
|
this.config = _object_spread({}, config, browserOverrides);
|
|
@@ -3342,25 +3193,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3342
3193
|
}
|
|
3343
3194
|
});
|
|
3344
3195
|
this.ima.on("ad_error", function(errorPayload) {
|
|
3345
|
-
var remaining = _this.getRemainingAdMs();
|
|
3346
3196
|
console.error("[AD-ERROR] Ad playback failed", errorPayload || "");
|
|
3347
|
-
|
|
3348
|
-
if (remaining > 500 && _this.adPodQueue.length > 0) {
|
|
3349
|
-
var nextPreloaded = _this.findNextPreloadedAd();
|
|
3350
|
-
if (nextPreloaded) {
|
|
3351
|
-
_this.currentAdIndex++;
|
|
3352
|
-
_this.playSingleAd(nextPreloaded).catch(function() {
|
|
3353
|
-
_this.handleAdFailure();
|
|
3354
|
-
});
|
|
3355
|
-
} else {
|
|
3356
|
-
_this.handleAdFailure();
|
|
3357
|
-
}
|
|
3358
|
-
} else {
|
|
3359
|
-
_this.handleAdFailure();
|
|
3360
|
-
}
|
|
3361
|
-
} else {
|
|
3362
|
-
_this.handleAdFailure();
|
|
3363
|
-
}
|
|
3197
|
+
_this.handleAdFailure();
|
|
3364
3198
|
});
|
|
3365
3199
|
this.ima.on("content_pause", function() {
|
|
3366
3200
|
_this.clearAdFailsafeTimer();
|
|
@@ -4091,7 +3925,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4091
3925
|
key: "handleAdStart",
|
|
4092
3926
|
value: function handleAdStart(_marker) {
|
|
4093
3927
|
return _async_to_generator(function() {
|
|
4094
|
-
var scheduled, tags, baseVastUrl, adBreakDurationMs, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
3928
|
+
var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
4095
3929
|
return _ts_generator(this, function(_state) {
|
|
4096
3930
|
switch(_state.label){
|
|
4097
3931
|
case 0:
|
|
@@ -4107,35 +3941,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4107
3941
|
];
|
|
4108
3942
|
}
|
|
4109
3943
|
adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
|
|
4110
|
-
if (this.
|
|
4111
|
-
this.
|
|
4112
|
-
|
|
4113
|
-
this.fetchedAdDurations.clear();
|
|
4114
|
-
if (this.config.debugAdTiming) {
|
|
4115
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA LIVE MODE: Target duration=".concat(adBreakDurationMs, "ms | Will continuously fetch ads during break"));
|
|
4116
|
-
}
|
|
4117
|
-
} else {
|
|
4118
|
-
this.isAdaptiveMode = false;
|
|
4119
|
-
this.targetAdBreakDurationMs = null;
|
|
4120
|
-
this.fetchedAdDurations.clear();
|
|
4121
|
-
if (this.config.debugAdTiming) {
|
|
4122
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC VOD MODE: Using fixed ad strategy");
|
|
4123
|
-
}
|
|
3944
|
+
if (this.config.debugAdTiming) {
|
|
3945
|
+
mode = this.isLiveStream ? "LIVE" : "VOD";
|
|
3946
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
4124
3947
|
}
|
|
4125
|
-
this.adPodAllUrls = [];
|
|
4126
|
-
this.preloadingAdUrls.clear();
|
|
4127
|
-
this.vastToMediaUrlMap.clear();
|
|
4128
|
-
this.preloadedMediaUrls.clear();
|
|
4129
|
-
this.preloadingMediaUrls.clear();
|
|
4130
3948
|
this.failedVastUrls.clear();
|
|
4131
3949
|
this.adRequestQueue = [];
|
|
4132
|
-
this.successfulAdRequests = [];
|
|
4133
3950
|
this.continuousFetchingActive = true;
|
|
4134
3951
|
this.isShowingPlaceholder = false;
|
|
4135
|
-
this.placeholderStartTimeMs = null;
|
|
4136
|
-
this.consecutiveEmptyResponses = 0;
|
|
4137
3952
|
this.totalAdRequestsInBreak = 0;
|
|
4138
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
4139
3953
|
currentMuted = this.video.muted;
|
|
4140
3954
|
currentVolume = this.video.volume;
|
|
4141
3955
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
@@ -4181,7 +3995,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4181
3995
|
if (this.config.debugAdTiming) {
|
|
4182
3996
|
console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
|
|
4183
3997
|
}
|
|
4184
|
-
this.successfulAdRequests.push(firstAdUrl);
|
|
4185
3998
|
this.currentAdIndex++;
|
|
4186
3999
|
this.startContinuousFetching(baseVastUrl);
|
|
4187
4000
|
return [
|
|
@@ -4231,200 +4044,92 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4231
4044
|
key: "continuousFetchLoop",
|
|
4232
4045
|
value: function continuousFetchLoop(baseVastUrl) {
|
|
4233
4046
|
return _async_to_generator(function() {
|
|
4234
|
-
var
|
|
4047
|
+
var remaining, maxQueueSize, newAdUrl;
|
|
4235
4048
|
return _ts_generator(this, function(_state) {
|
|
4236
4049
|
switch(_state.label){
|
|
4237
4050
|
case 0:
|
|
4238
|
-
_loop = function() {
|
|
4239
|
-
var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
|
|
4240
|
-
return _ts_generator(this, function(_state) {
|
|
4241
|
-
switch(_state.label){
|
|
4242
|
-
case 0:
|
|
4243
|
-
remaining = _this.getRemainingAdMs();
|
|
4244
|
-
if (remaining <= 0) {
|
|
4245
|
-
if (_this.config.debugAdTiming) {
|
|
4246
|
-
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
|
|
4247
|
-
}
|
|
4248
|
-
return [
|
|
4249
|
-
2,
|
|
4250
|
-
"break"
|
|
4251
|
-
];
|
|
4252
|
-
}
|
|
4253
|
-
if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
|
|
4254
|
-
if (_this.config.debugAdTiming) {
|
|
4255
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
|
|
4256
|
-
}
|
|
4257
|
-
return [
|
|
4258
|
-
2,
|
|
4259
|
-
"break"
|
|
4260
|
-
];
|
|
4261
|
-
}
|
|
4262
|
-
if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
|
|
4263
|
-
if (_this.config.debugAdTiming) {
|
|
4264
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
|
|
4265
|
-
}
|
|
4266
|
-
return [
|
|
4267
|
-
2,
|
|
4268
|
-
"break"
|
|
4269
|
-
];
|
|
4270
|
-
}
|
|
4271
|
-
maxQueueSize = 3;
|
|
4272
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4273
|
-
3,
|
|
4274
|
-
2
|
|
4275
|
-
];
|
|
4276
|
-
if (_this.config.debugAdTiming) {
|
|
4277
|
-
console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
|
|
4278
|
-
}
|
|
4279
|
-
return [
|
|
4280
|
-
4,
|
|
4281
|
-
new Promise(function(resolve) {
|
|
4282
|
-
return setTimeout(resolve, 2e3);
|
|
4283
|
-
})
|
|
4284
|
-
];
|
|
4285
|
-
case 1:
|
|
4286
|
-
_state.sent();
|
|
4287
|
-
return [
|
|
4288
|
-
2,
|
|
4289
|
-
"continue"
|
|
4290
|
-
];
|
|
4291
|
-
case 2:
|
|
4292
|
-
newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4293
|
-
if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
|
|
4294
|
-
3,
|
|
4295
|
-
4
|
|
4296
|
-
];
|
|
4297
|
-
return [
|
|
4298
|
-
4,
|
|
4299
|
-
new Promise(function(resolve) {
|
|
4300
|
-
return setTimeout(resolve, 1e3);
|
|
4301
|
-
})
|
|
4302
|
-
];
|
|
4303
|
-
case 3:
|
|
4304
|
-
_state.sent();
|
|
4305
|
-
return [
|
|
4306
|
-
2,
|
|
4307
|
-
"continue"
|
|
4308
|
-
];
|
|
4309
|
-
case 4:
|
|
4310
|
-
_this.totalAdRequestsInBreak++;
|
|
4311
|
-
if (_this.config.debugAdTiming) {
|
|
4312
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
|
|
4313
|
-
}
|
|
4314
|
-
_state.label = 5;
|
|
4315
|
-
case 5:
|
|
4316
|
-
_state.trys.push([
|
|
4317
|
-
5,
|
|
4318
|
-
11,
|
|
4319
|
-
,
|
|
4320
|
-
13
|
|
4321
|
-
]);
|
|
4322
|
-
if (!_this.ima.preloadAds) return [
|
|
4323
|
-
3,
|
|
4324
|
-
7
|
|
4325
|
-
];
|
|
4326
|
-
return [
|
|
4327
|
-
4,
|
|
4328
|
-
_this.ima.preloadAds(newAdUrl)
|
|
4329
|
-
];
|
|
4330
|
-
case 6:
|
|
4331
|
-
_state.sent();
|
|
4332
|
-
_state.label = 7;
|
|
4333
|
-
case 7:
|
|
4334
|
-
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;
|
|
4335
|
-
if (!!hasPreloadedAd) return [
|
|
4336
|
-
3,
|
|
4337
|
-
9
|
|
4338
|
-
];
|
|
4339
|
-
_this.consecutiveEmptyResponses++;
|
|
4340
|
-
_this.lastEmptyResponseTimeMs = Date.now();
|
|
4341
|
-
backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4342
|
-
if (_this.config.debugAdTiming) {
|
|
4343
|
-
console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
|
|
4344
|
-
}
|
|
4345
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4346
|
-
return [
|
|
4347
|
-
4,
|
|
4348
|
-
new Promise(function(resolve) {
|
|
4349
|
-
return setTimeout(resolve, backoffDelay);
|
|
4350
|
-
})
|
|
4351
|
-
];
|
|
4352
|
-
case 8:
|
|
4353
|
-
_state.sent();
|
|
4354
|
-
return [
|
|
4355
|
-
2,
|
|
4356
|
-
"continue"
|
|
4357
|
-
];
|
|
4358
|
-
case 9:
|
|
4359
|
-
_this.consecutiveEmptyResponses = 0;
|
|
4360
|
-
if (_this.config.debugAdTiming) {
|
|
4361
|
-
console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
|
|
4362
|
-
}
|
|
4363
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
4364
|
-
_this.totalAdsInBreak++;
|
|
4365
|
-
return [
|
|
4366
|
-
4,
|
|
4367
|
-
new Promise(function(resolve) {
|
|
4368
|
-
return setTimeout(resolve, 500);
|
|
4369
|
-
})
|
|
4370
|
-
];
|
|
4371
|
-
case 10:
|
|
4372
|
-
_state.sent();
|
|
4373
|
-
return [
|
|
4374
|
-
3,
|
|
4375
|
-
13
|
|
4376
|
-
];
|
|
4377
|
-
case 11:
|
|
4378
|
-
error = _state.sent();
|
|
4379
|
-
if (_this.config.debugAdTiming) {
|
|
4380
|
-
console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
|
|
4381
|
-
}
|
|
4382
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4383
|
-
_this.consecutiveEmptyResponses++;
|
|
4384
|
-
backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4385
|
-
return [
|
|
4386
|
-
4,
|
|
4387
|
-
new Promise(function(resolve) {
|
|
4388
|
-
return setTimeout(resolve, backoffDelay1);
|
|
4389
|
-
})
|
|
4390
|
-
];
|
|
4391
|
-
case 12:
|
|
4392
|
-
_state.sent();
|
|
4393
|
-
return [
|
|
4394
|
-
3,
|
|
4395
|
-
13
|
|
4396
|
-
];
|
|
4397
|
-
case 13:
|
|
4398
|
-
return [
|
|
4399
|
-
2
|
|
4400
|
-
];
|
|
4401
|
-
}
|
|
4402
|
-
});
|
|
4403
|
-
};
|
|
4404
|
-
_state.label = 1;
|
|
4405
|
-
case 1:
|
|
4406
4051
|
if (!(this.continuousFetchingActive && this.inAdBreak)) return [
|
|
4407
4052
|
3,
|
|
4408
|
-
|
|
4053
|
+
6
|
|
4409
4054
|
];
|
|
4410
|
-
|
|
4055
|
+
remaining = this.getRemainingAdMs();
|
|
4056
|
+
if (remaining <= 0) {
|
|
4057
|
+
if (this.config.debugAdTiming) {
|
|
4058
|
+
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping URL generation");
|
|
4059
|
+
}
|
|
4060
|
+
return [
|
|
4061
|
+
3,
|
|
4062
|
+
6
|
|
4063
|
+
];
|
|
4064
|
+
}
|
|
4065
|
+
if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
|
|
4066
|
+
if (this.config.debugAdTiming) {
|
|
4067
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(this.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
4068
|
+
}
|
|
4069
|
+
return [
|
|
4070
|
+
3,
|
|
4071
|
+
6
|
|
4072
|
+
];
|
|
4073
|
+
}
|
|
4074
|
+
maxQueueSize = 5;
|
|
4075
|
+
if (!(this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4076
|
+
3,
|
|
4077
|
+
2
|
|
4078
|
+
];
|
|
4079
|
+
if (this.config.debugAdTiming) {
|
|
4080
|
+
console.log("[CONTINUOUS-FETCH] ⏸️ URL queue full (".concat(this.adRequestQueue.length, "), waiting..."));
|
|
4081
|
+
}
|
|
4411
4082
|
return [
|
|
4412
|
-
|
|
4413
|
-
|
|
4083
|
+
4,
|
|
4084
|
+
new Promise(function(resolve) {
|
|
4085
|
+
return setTimeout(resolve, 1e3);
|
|
4086
|
+
})
|
|
4087
|
+
];
|
|
4088
|
+
case 1:
|
|
4089
|
+
_state.sent();
|
|
4090
|
+
return [
|
|
4091
|
+
3,
|
|
4092
|
+
0
|
|
4414
4093
|
];
|
|
4415
4094
|
case 2:
|
|
4416
|
-
|
|
4417
|
-
if (
|
|
4095
|
+
newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4096
|
+
if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
|
|
4418
4097
|
3,
|
|
4419
|
-
|
|
4098
|
+
4
|
|
4420
4099
|
];
|
|
4421
4100
|
return [
|
|
4422
|
-
|
|
4423
|
-
|
|
4101
|
+
4,
|
|
4102
|
+
new Promise(function(resolve) {
|
|
4103
|
+
return setTimeout(resolve, 500);
|
|
4104
|
+
})
|
|
4424
4105
|
];
|
|
4425
4106
|
case 3:
|
|
4107
|
+
_state.sent();
|
|
4108
|
+
return [
|
|
4109
|
+
3,
|
|
4110
|
+
0
|
|
4111
|
+
];
|
|
4112
|
+
case 4:
|
|
4113
|
+
if (this.config.debugAdTiming) {
|
|
4114
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCDD Queued VAST URL (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
|
|
4115
|
+
}
|
|
4116
|
+
this.adRequestQueue.push(newAdUrl);
|
|
4117
|
+
this.totalAdsInBreak++;
|
|
4118
|
+
return [
|
|
4119
|
+
4,
|
|
4120
|
+
new Promise(function(resolve) {
|
|
4121
|
+
return setTimeout(resolve, 300);
|
|
4122
|
+
})
|
|
4123
|
+
];
|
|
4124
|
+
case 5:
|
|
4125
|
+
_state.sent();
|
|
4126
|
+
return [
|
|
4127
|
+
3,
|
|
4128
|
+
0
|
|
4129
|
+
];
|
|
4130
|
+
case 6:
|
|
4426
4131
|
if (this.config.debugAdTiming) {
|
|
4427
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1
|
|
4132
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"));
|
|
4428
4133
|
}
|
|
4429
4134
|
return [
|
|
4430
4135
|
2
|
|
@@ -4473,19 +4178,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4473
4178
|
2
|
|
4474
4179
|
];
|
|
4475
4180
|
if (this.config.debugAdTiming) {
|
|
4476
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC
|
|
4181
|
+
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)"));
|
|
4477
4182
|
}
|
|
4478
4183
|
currentMuted = this.video.muted;
|
|
4479
4184
|
currentVolume = this.video.volume;
|
|
4480
4185
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
4481
|
-
if (this.config.debugAdTiming) {
|
|
4482
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDD0A Updated ad audio state: muted=".concat(currentMuted, ", volume=").concat(currentVolume));
|
|
4483
|
-
}
|
|
4484
4186
|
this.currentAdIndex++;
|
|
4485
|
-
this.
|
|
4187
|
+
this.totalAdRequestsInBreak++;
|
|
4486
4188
|
return [
|
|
4487
4189
|
4,
|
|
4488
|
-
this.playSingleAd(nextAdUrl).catch(function() {
|
|
4190
|
+
this.playSingleAd(nextAdUrl).catch(function(error) {
|
|
4191
|
+
if (_this.config.debugAdTiming) {
|
|
4192
|
+
console.log("[CONTINUOUS-FETCH] \u274C Ad request failed:", error.message);
|
|
4193
|
+
}
|
|
4194
|
+
_this.failedVastUrls.add(nextAdUrl);
|
|
4489
4195
|
_this.tryNextAvailableAd(0);
|
|
4490
4196
|
})
|
|
4491
4197
|
];
|
|
@@ -4495,18 +4201,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4495
4201
|
2
|
|
4496
4202
|
];
|
|
4497
4203
|
case 2:
|
|
4498
|
-
maxRetries =
|
|
4204
|
+
maxRetries = 3;
|
|
4499
4205
|
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
4500
4206
|
3,
|
|
4501
4207
|
5
|
|
4502
4208
|
];
|
|
4503
4209
|
if (this.config.debugAdTiming) {
|
|
4504
|
-
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty
|
|
4210
|
+
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
4505
4211
|
}
|
|
4506
4212
|
return [
|
|
4507
4213
|
4,
|
|
4508
4214
|
new Promise(function(resolve) {
|
|
4509
|
-
return setTimeout(resolve,
|
|
4215
|
+
return setTimeout(resolve, 500);
|
|
4510
4216
|
})
|
|
4511
4217
|
];
|
|
4512
4218
|
case 3:
|
|
@@ -4555,12 +4261,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4555
4261
|
];
|
|
4556
4262
|
}
|
|
4557
4263
|
if (this.config.debugAdTiming) {
|
|
4558
|
-
console.log("[CONTINUOUS-FETCH] ⬛ Showing
|
|
4264
|
+
console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad URLs"));
|
|
4559
4265
|
}
|
|
4560
4266
|
this.isShowingPlaceholder = true;
|
|
4561
|
-
this.placeholderStartTimeMs = Date.now();
|
|
4562
4267
|
this.ima.showPlaceholder();
|
|
4563
|
-
checkInterval =
|
|
4268
|
+
checkInterval = 300;
|
|
4564
4269
|
maxChecks = Math.floor(waitTime / checkInterval);
|
|
4565
4270
|
i = 0;
|
|
4566
4271
|
_state.label = 1;
|
|
@@ -4587,10 +4292,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4587
4292
|
5
|
|
4588
4293
|
];
|
|
4589
4294
|
if (this.config.debugAdTiming) {
|
|
4590
|
-
console.log("[CONTINUOUS-FETCH] \u2705
|
|
4295
|
+
console.log("[CONTINUOUS-FETCH] \u2705 Ad URL available, requesting via IMA SDK");
|
|
4591
4296
|
}
|
|
4592
4297
|
this.isShowingPlaceholder = false;
|
|
4593
|
-
this.placeholderStartTimeMs = null;
|
|
4594
4298
|
this.ima.hidePlaceholder();
|
|
4595
4299
|
currentMuted = this.video.muted;
|
|
4596
4300
|
currentVolume = this.video.volume;
|
|
@@ -4601,7 +4305,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4601
4305
|
4
|
|
4602
4306
|
];
|
|
4603
4307
|
this.currentAdIndex++;
|
|
4604
|
-
this.
|
|
4308
|
+
this.totalAdRequestsInBreak++;
|
|
4605
4309
|
return [
|
|
4606
4310
|
4,
|
|
4607
4311
|
this.playSingleAd(nextAdUrl).catch(function() {
|
|
@@ -4623,10 +4327,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4623
4327
|
];
|
|
4624
4328
|
case 6:
|
|
4625
4329
|
if (this.config.debugAdTiming) {
|
|
4626
|
-
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout
|
|
4330
|
+
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
|
|
4627
4331
|
}
|
|
4628
4332
|
this.isShowingPlaceholder = false;
|
|
4629
|
-
this.placeholderStartTimeMs = null;
|
|
4630
4333
|
this.ima.hidePlaceholder();
|
|
4631
4334
|
this.handleAdPodComplete();
|
|
4632
4335
|
return [
|
|
@@ -4928,21 +4631,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4928
4631
|
if (this.isShowingPlaceholder) {
|
|
4929
4632
|
this.ima.hidePlaceholder();
|
|
4930
4633
|
this.isShowingPlaceholder = false;
|
|
4931
|
-
this.placeholderStartTimeMs = null;
|
|
4932
4634
|
}
|
|
4933
|
-
this.preloadingAdUrls.clear();
|
|
4934
|
-
this.vastToMediaUrlMap.clear();
|
|
4935
|
-
this.preloadedMediaUrls.clear();
|
|
4936
|
-
this.preloadingMediaUrls.clear();
|
|
4937
4635
|
this.adRequestQueue = [];
|
|
4938
|
-
this.successfulAdRequests = [];
|
|
4939
4636
|
this.inAdBreak = false;
|
|
4940
4637
|
this.expectedAdBreakDurationMs = void 0;
|
|
4941
4638
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
4942
4639
|
this.clearAdStartTimer();
|
|
4943
4640
|
this.clearAdStopTimer();
|
|
4944
4641
|
this.adPodQueue = [];
|
|
4945
|
-
this.adPodAllUrls = [];
|
|
4946
4642
|
this.showAds = false;
|
|
4947
4643
|
this.currentAdIndex = 0;
|
|
4948
4644
|
this.totalAdsInBreak = 0;
|
|
@@ -5097,651 +4793,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5097
4793
|
}, extra));
|
|
5098
4794
|
}
|
|
5099
4795
|
},
|
|
5100
|
-
{
|
|
5101
|
-
key: "fetchAndParseVastXml",
|
|
5102
|
-
value: function fetchAndParseVastXml(vastTagUrl) {
|
|
5103
|
-
return _async_to_generator(function() {
|
|
5104
|
-
var response, xmlText, error;
|
|
5105
|
-
return _ts_generator(this, function(_state) {
|
|
5106
|
-
switch(_state.label){
|
|
5107
|
-
case 0:
|
|
5108
|
-
_state.trys.push([
|
|
5109
|
-
0,
|
|
5110
|
-
3,
|
|
5111
|
-
,
|
|
5112
|
-
4
|
|
5113
|
-
]);
|
|
5114
|
-
return [
|
|
5115
|
-
4,
|
|
5116
|
-
fetch(vastTagUrl, {
|
|
5117
|
-
mode: "cors",
|
|
5118
|
-
credentials: "include",
|
|
5119
|
-
headers: {
|
|
5120
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5121
|
-
},
|
|
5122
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5123
|
-
})
|
|
5124
|
-
];
|
|
5125
|
-
case 1:
|
|
5126
|
-
response = _state.sent();
|
|
5127
|
-
if (!response.ok) {
|
|
5128
|
-
throw new Error("Failed to fetch VAST: ".concat(response.status));
|
|
5129
|
-
}
|
|
5130
|
-
return [
|
|
5131
|
-
4,
|
|
5132
|
-
response.text()
|
|
5133
|
-
];
|
|
5134
|
-
case 2:
|
|
5135
|
-
xmlText = _state.sent();
|
|
5136
|
-
return [
|
|
5137
|
-
2,
|
|
5138
|
-
this.extractMediaUrlsFromVast(xmlText)
|
|
5139
|
-
];
|
|
5140
|
-
case 3:
|
|
5141
|
-
error = _state.sent();
|
|
5142
|
-
if (this.config.debugAdTiming) {
|
|
5143
|
-
console.warn("[StormcloudVideoPlayer] Failed to fetch/parse VAST XML: ".concat(vastTagUrl), error);
|
|
5144
|
-
}
|
|
5145
|
-
return [
|
|
5146
|
-
2,
|
|
5147
|
-
[]
|
|
5148
|
-
];
|
|
5149
|
-
case 4:
|
|
5150
|
-
return [
|
|
5151
|
-
2
|
|
5152
|
-
];
|
|
5153
|
-
}
|
|
5154
|
-
});
|
|
5155
|
-
}).call(this);
|
|
5156
|
-
}
|
|
5157
|
-
},
|
|
5158
|
-
{
|
|
5159
|
-
key: "extractMediaUrlsFromVast",
|
|
5160
|
-
value: function extractMediaUrlsFromVast(xmlText) {
|
|
5161
|
-
var mediaUrls = [];
|
|
5162
|
-
try {
|
|
5163
|
-
var parser = new DOMParser();
|
|
5164
|
-
var xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5165
|
-
var mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
|
|
5166
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5167
|
-
try {
|
|
5168
|
-
for(var _iterator = Array.from(mediaFileElements)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5169
|
-
var mediaFile = _step.value;
|
|
5170
|
-
var _mediaFile_textContent;
|
|
5171
|
-
var url = (_mediaFile_textContent = mediaFile.textContent) === null || _mediaFile_textContent === void 0 ? void 0 : _mediaFile_textContent.trim();
|
|
5172
|
-
if (url) {
|
|
5173
|
-
var lowerUrl = url.toLowerCase();
|
|
5174
|
-
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")) {
|
|
5175
|
-
mediaUrls.push(url);
|
|
5176
|
-
}
|
|
5177
|
-
}
|
|
5178
|
-
}
|
|
5179
|
-
} catch (err) {
|
|
5180
|
-
_didIteratorError = true;
|
|
5181
|
-
_iteratorError = err;
|
|
5182
|
-
} finally{
|
|
5183
|
-
try {
|
|
5184
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5185
|
-
_iterator.return();
|
|
5186
|
-
}
|
|
5187
|
-
} finally{
|
|
5188
|
-
if (_didIteratorError) {
|
|
5189
|
-
throw _iteratorError;
|
|
5190
|
-
}
|
|
5191
|
-
}
|
|
5192
|
-
}
|
|
5193
|
-
if (this.config.debugAdTiming && mediaUrls.length > 0) {
|
|
5194
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs from VAST:"), mediaUrls);
|
|
5195
|
-
}
|
|
5196
|
-
} catch (error) {
|
|
5197
|
-
if (this.config.debugAdTiming) {
|
|
5198
|
-
console.warn("[StormcloudVideoPlayer] Failed to parse VAST XML:", error);
|
|
5199
|
-
}
|
|
5200
|
-
}
|
|
5201
|
-
return mediaUrls;
|
|
5202
|
-
}
|
|
5203
|
-
},
|
|
5204
|
-
{
|
|
5205
|
-
key: "fetchVastDuration",
|
|
5206
|
-
value: function fetchVastDuration(vastTagUrl) {
|
|
5207
|
-
return _async_to_generator(function() {
|
|
5208
|
-
var _xmlDoc_querySelector, response, xmlText, parser, xmlDoc, durationText, durationParts, durationSeconds, error;
|
|
5209
|
-
return _ts_generator(this, function(_state) {
|
|
5210
|
-
switch(_state.label){
|
|
5211
|
-
case 0:
|
|
5212
|
-
_state.trys.push([
|
|
5213
|
-
0,
|
|
5214
|
-
3,
|
|
5215
|
-
,
|
|
5216
|
-
4
|
|
5217
|
-
]);
|
|
5218
|
-
return [
|
|
5219
|
-
4,
|
|
5220
|
-
fetch(vastTagUrl, {
|
|
5221
|
-
mode: "cors",
|
|
5222
|
-
credentials: "include",
|
|
5223
|
-
headers: {
|
|
5224
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5225
|
-
},
|
|
5226
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5227
|
-
})
|
|
5228
|
-
];
|
|
5229
|
-
case 1:
|
|
5230
|
-
response = _state.sent();
|
|
5231
|
-
if (!response.ok) {
|
|
5232
|
-
if (this.config.debugAdTiming) {
|
|
5233
|
-
console.warn("[ADAPTIVE-POD] Failed to fetch VAST: ".concat(response.status));
|
|
5234
|
-
}
|
|
5235
|
-
return [
|
|
5236
|
-
2,
|
|
5237
|
-
null
|
|
5238
|
-
];
|
|
5239
|
-
}
|
|
5240
|
-
return [
|
|
5241
|
-
4,
|
|
5242
|
-
response.text()
|
|
5243
|
-
];
|
|
5244
|
-
case 2:
|
|
5245
|
-
xmlText = _state.sent();
|
|
5246
|
-
parser = new DOMParser();
|
|
5247
|
-
xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5248
|
-
durationText = (_xmlDoc_querySelector = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector === void 0 ? void 0 : _xmlDoc_querySelector.textContent;
|
|
5249
|
-
if (!durationText) {
|
|
5250
|
-
if (this.config.debugAdTiming) {
|
|
5251
|
-
console.warn("[ADAPTIVE-POD] No Duration element found in VAST");
|
|
5252
|
-
}
|
|
5253
|
-
return [
|
|
5254
|
-
2,
|
|
5255
|
-
null
|
|
5256
|
-
];
|
|
5257
|
-
}
|
|
5258
|
-
durationParts = durationText.split(":");
|
|
5259
|
-
durationSeconds = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
5260
|
-
return [
|
|
5261
|
-
2,
|
|
5262
|
-
durationSeconds
|
|
5263
|
-
];
|
|
5264
|
-
case 3:
|
|
5265
|
-
error = _state.sent();
|
|
5266
|
-
if (this.config.debugAdTiming) {
|
|
5267
|
-
console.warn("[ADAPTIVE-POD] Error fetching VAST duration from ".concat(vastTagUrl, ":"), error);
|
|
5268
|
-
}
|
|
5269
|
-
return [
|
|
5270
|
-
2,
|
|
5271
|
-
null
|
|
5272
|
-
];
|
|
5273
|
-
case 4:
|
|
5274
|
-
return [
|
|
5275
|
-
2
|
|
5276
|
-
];
|
|
5277
|
-
}
|
|
5278
|
-
});
|
|
5279
|
-
}).call(this);
|
|
5280
|
-
}
|
|
5281
|
-
},
|
|
5282
|
-
{
|
|
5283
|
-
key: "calculateAdditionalAdsNeeded",
|
|
5284
|
-
value: function calculateAdditionalAdsNeeded() {
|
|
5285
|
-
if (!this.isAdaptiveMode || this.targetAdBreakDurationMs === null) {
|
|
5286
|
-
return 0;
|
|
5287
|
-
}
|
|
5288
|
-
var totalFetchedDurationMs = 0;
|
|
5289
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5290
|
-
try {
|
|
5291
|
-
for(var _iterator = this.fetchedAdDurations.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5292
|
-
var duration = _step.value;
|
|
5293
|
-
totalFetchedDurationMs += duration * 1e3;
|
|
5294
|
-
}
|
|
5295
|
-
} catch (err) {
|
|
5296
|
-
_didIteratorError = true;
|
|
5297
|
-
_iteratorError = err;
|
|
5298
|
-
} finally{
|
|
5299
|
-
try {
|
|
5300
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5301
|
-
_iterator.return();
|
|
5302
|
-
}
|
|
5303
|
-
} finally{
|
|
5304
|
-
if (_didIteratorError) {
|
|
5305
|
-
throw _iteratorError;
|
|
5306
|
-
}
|
|
5307
|
-
}
|
|
5308
|
-
}
|
|
5309
|
-
var fetchedCount = this.fetchedAdDurations.size;
|
|
5310
|
-
var averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
5311
|
-
var queuedButNotFetched = this.adPodAllUrls.length - fetchedCount;
|
|
5312
|
-
var estimatedQueuedDurationMs = queuedButNotFetched * averageDurationMs;
|
|
5313
|
-
var estimatedTotalDurationMs = totalFetchedDurationMs + estimatedQueuedDurationMs;
|
|
5314
|
-
var remainingTimeMs = this.targetAdBreakDurationMs - estimatedTotalDurationMs;
|
|
5315
|
-
if (remainingTimeMs <= 0) {
|
|
5316
|
-
if (this.config.debugAdTiming) {
|
|
5317
|
-
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"));
|
|
5318
|
-
}
|
|
5319
|
-
return 0;
|
|
5320
|
-
}
|
|
5321
|
-
var additionalAds = Math.ceil(remainingTimeMs / averageDurationMs);
|
|
5322
|
-
if (this.config.debugAdTiming) {
|
|
5323
|
-
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"));
|
|
5324
|
-
}
|
|
5325
|
-
return additionalAds;
|
|
5326
|
-
}
|
|
5327
|
-
},
|
|
5328
|
-
{
|
|
5329
|
-
key: "addAdaptiveAdsToQueue",
|
|
5330
|
-
value: function addAdaptiveAdsToQueue() {
|
|
5331
|
-
return _async_to_generator(function() {
|
|
5332
|
-
var _this_adPodAllUrls, _this_adPodQueue, additionalAds, newUrls;
|
|
5333
|
-
return _ts_generator(this, function(_state) {
|
|
5334
|
-
if (!this.isAdaptiveMode || !this.apiVastTagUrl) {
|
|
5335
|
-
return [
|
|
5336
|
-
2
|
|
5337
|
-
];
|
|
5338
|
-
}
|
|
5339
|
-
additionalAds = this.calculateAdditionalAdsNeeded();
|
|
5340
|
-
if (additionalAds <= 0) {
|
|
5341
|
-
return [
|
|
5342
|
-
2
|
|
5343
|
-
];
|
|
5344
|
-
}
|
|
5345
|
-
newUrls = this.generateVastUrlsWithCorrelators(this.apiVastTagUrl, additionalAds);
|
|
5346
|
-
if (this.config.debugAdTiming) {
|
|
5347
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Adding ".concat(newUrls.length, " additional VAST URLs to queue (will be preloaded sequentially)"));
|
|
5348
|
-
}
|
|
5349
|
-
(_this_adPodAllUrls = this.adPodAllUrls).push.apply(_this_adPodAllUrls, _to_consumable_array(newUrls));
|
|
5350
|
-
(_this_adPodQueue = this.adPodQueue).push.apply(_this_adPodQueue, _to_consumable_array(newUrls));
|
|
5351
|
-
this.totalAdsInBreak += newUrls.length;
|
|
5352
|
-
return [
|
|
5353
|
-
2
|
|
5354
|
-
];
|
|
5355
|
-
});
|
|
5356
|
-
}).call(this);
|
|
5357
|
-
}
|
|
5358
|
-
},
|
|
5359
|
-
{
|
|
5360
|
-
key: "preloadMediaFile",
|
|
5361
|
-
value: function preloadMediaFile(mediaUrl) {
|
|
5362
|
-
return _async_to_generator(function() {
|
|
5363
|
-
var response, error;
|
|
5364
|
-
return _ts_generator(this, function(_state) {
|
|
5365
|
-
switch(_state.label){
|
|
5366
|
-
case 0:
|
|
5367
|
-
if (this.preloadedMediaUrls.has(mediaUrl)) {
|
|
5368
|
-
return [
|
|
5369
|
-
2
|
|
5370
|
-
];
|
|
5371
|
-
}
|
|
5372
|
-
if (this.preloadingMediaUrls.has(mediaUrl)) {
|
|
5373
|
-
return [
|
|
5374
|
-
2
|
|
5375
|
-
];
|
|
5376
|
-
}
|
|
5377
|
-
this.preloadingMediaUrls.add(mediaUrl);
|
|
5378
|
-
_state.label = 1;
|
|
5379
|
-
case 1:
|
|
5380
|
-
_state.trys.push([
|
|
5381
|
-
1,
|
|
5382
|
-
3,
|
|
5383
|
-
4,
|
|
5384
|
-
5
|
|
5385
|
-
]);
|
|
5386
|
-
if (this.config.debugAdTiming) {
|
|
5387
|
-
console.log("[StormcloudVideoPlayer] Preloading video file: ".concat(mediaUrl));
|
|
5388
|
-
}
|
|
5389
|
-
return [
|
|
5390
|
-
4,
|
|
5391
|
-
fetch(mediaUrl, {
|
|
5392
|
-
mode: "cors",
|
|
5393
|
-
credentials: "include",
|
|
5394
|
-
method: "GET",
|
|
5395
|
-
headers: {
|
|
5396
|
-
Range: "bytes=0-1048576"
|
|
5397
|
-
},
|
|
5398
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5399
|
-
})
|
|
5400
|
-
];
|
|
5401
|
-
case 2:
|
|
5402
|
-
response = _state.sent();
|
|
5403
|
-
if (response.ok || response.status === 206) {
|
|
5404
|
-
this.preloadedMediaUrls.add(mediaUrl);
|
|
5405
|
-
if (this.config.debugAdTiming) {
|
|
5406
|
-
console.log("[StormcloudVideoPlayer] Successfully preloaded video file: ".concat(mediaUrl));
|
|
5407
|
-
}
|
|
5408
|
-
}
|
|
5409
|
-
return [
|
|
5410
|
-
3,
|
|
5411
|
-
5
|
|
5412
|
-
];
|
|
5413
|
-
case 3:
|
|
5414
|
-
error = _state.sent();
|
|
5415
|
-
if (this.config.debugAdTiming) {
|
|
5416
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload video file: ".concat(mediaUrl), error);
|
|
5417
|
-
}
|
|
5418
|
-
return [
|
|
5419
|
-
3,
|
|
5420
|
-
5
|
|
5421
|
-
];
|
|
5422
|
-
case 4:
|
|
5423
|
-
this.preloadingMediaUrls.delete(mediaUrl);
|
|
5424
|
-
return [
|
|
5425
|
-
7
|
|
5426
|
-
];
|
|
5427
|
-
case 5:
|
|
5428
|
-
return [
|
|
5429
|
-
2
|
|
5430
|
-
];
|
|
5431
|
-
}
|
|
5432
|
-
});
|
|
5433
|
-
}).call(this);
|
|
5434
|
-
}
|
|
5435
|
-
},
|
|
5436
|
-
{
|
|
5437
|
-
key: "preloadAllAdsInBackground",
|
|
5438
|
-
value: function preloadAllAdsInBackground() {
|
|
5439
|
-
return _async_to_generator(function() {
|
|
5440
|
-
var _this, processedUrls, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, _this_ima_hasPreloadedAd, _this_ima, nextUrl, error, preloadPromises;
|
|
5441
|
-
return _ts_generator(this, function(_state) {
|
|
5442
|
-
switch(_state.label){
|
|
5443
|
-
case 0:
|
|
5444
|
-
_this = this;
|
|
5445
|
-
if (this.adPodAllUrls.length === 0) {
|
|
5446
|
-
return [
|
|
5447
|
-
2
|
|
5448
|
-
];
|
|
5449
|
-
}
|
|
5450
|
-
if (!this.isAdaptiveMode) return [
|
|
5451
|
-
3,
|
|
5452
|
-
7
|
|
5453
|
-
];
|
|
5454
|
-
if (this.config.debugAdTiming) {
|
|
5455
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Starting sequential preload of remaining ads");
|
|
5456
|
-
}
|
|
5457
|
-
processedUrls = /* @__PURE__ */ new Set();
|
|
5458
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5459
|
-
try {
|
|
5460
|
-
for(_iterator = this.adPodAllUrls[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5461
|
-
url = _step.value;
|
|
5462
|
-
;
|
|
5463
|
-
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)) {
|
|
5464
|
-
processedUrls.add(url);
|
|
5465
|
-
}
|
|
5466
|
-
}
|
|
5467
|
-
} catch (err) {
|
|
5468
|
-
_didIteratorError = true;
|
|
5469
|
-
_iteratorError = err;
|
|
5470
|
-
} finally{
|
|
5471
|
-
try {
|
|
5472
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5473
|
-
_iterator.return();
|
|
5474
|
-
}
|
|
5475
|
-
} finally{
|
|
5476
|
-
if (_didIteratorError) {
|
|
5477
|
-
throw _iteratorError;
|
|
5478
|
-
}
|
|
5479
|
-
}
|
|
5480
|
-
}
|
|
5481
|
-
if (this.config.debugAdTiming && processedUrls.size > 0) {
|
|
5482
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE6 Skipping ".concat(processedUrls.size, " already-preloaded ads"));
|
|
5483
|
-
}
|
|
5484
|
-
_state.label = 1;
|
|
5485
|
-
case 1:
|
|
5486
|
-
if (!true) return [
|
|
5487
|
-
3,
|
|
5488
|
-
6
|
|
5489
|
-
];
|
|
5490
|
-
nextUrl = this.adPodAllUrls.find(function(url) {
|
|
5491
|
-
return !processedUrls.has(url);
|
|
5492
|
-
});
|
|
5493
|
-
if (!nextUrl) {
|
|
5494
|
-
if (this.config.debugAdTiming) {
|
|
5495
|
-
console.log("[ADAPTIVE-POD] ✅ All queued ads processed (".concat(processedUrls.size, " total)"));
|
|
5496
|
-
}
|
|
5497
|
-
return [
|
|
5498
|
-
3,
|
|
5499
|
-
6
|
|
5500
|
-
];
|
|
5501
|
-
}
|
|
5502
|
-
processedUrls.add(nextUrl);
|
|
5503
|
-
if (this.config.debugAdTiming) {
|
|
5504
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE5 Preloading ad ".concat(processedUrls.size, "/").concat(this.adPodAllUrls.length, "..."));
|
|
5505
|
-
}
|
|
5506
|
-
_state.label = 2;
|
|
5507
|
-
case 2:
|
|
5508
|
-
_state.trys.push([
|
|
5509
|
-
2,
|
|
5510
|
-
4,
|
|
5511
|
-
,
|
|
5512
|
-
5
|
|
5513
|
-
]);
|
|
5514
|
-
return [
|
|
5515
|
-
4,
|
|
5516
|
-
this.preloadSingleAd(nextUrl)
|
|
5517
|
-
];
|
|
5518
|
-
case 3:
|
|
5519
|
-
_state.sent();
|
|
5520
|
-
return [
|
|
5521
|
-
3,
|
|
5522
|
-
5
|
|
5523
|
-
];
|
|
5524
|
-
case 4:
|
|
5525
|
-
error = _state.sent();
|
|
5526
|
-
if (this.config.debugAdTiming) {
|
|
5527
|
-
console.warn("[ADAPTIVE-POD] ⚠️ Preload failed for ad ".concat(processedUrls.size, ":"), error);
|
|
5528
|
-
}
|
|
5529
|
-
return [
|
|
5530
|
-
3,
|
|
5531
|
-
5
|
|
5532
|
-
];
|
|
5533
|
-
case 5:
|
|
5534
|
-
if (this.calculateAdditionalAdsNeeded() === 0) {
|
|
5535
|
-
if (this.config.debugAdTiming) {
|
|
5536
|
-
console.log("[ADAPTIVE-POD] ✅ Target duration reached (".concat(processedUrls.size, " ads preloaded), stopping"));
|
|
5537
|
-
}
|
|
5538
|
-
return [
|
|
5539
|
-
3,
|
|
5540
|
-
6
|
|
5541
|
-
];
|
|
5542
|
-
}
|
|
5543
|
-
return [
|
|
5544
|
-
3,
|
|
5545
|
-
1
|
|
5546
|
-
];
|
|
5547
|
-
case 6:
|
|
5548
|
-
if (this.config.debugAdTiming) {
|
|
5549
|
-
console.log("[ADAPTIVE-POD] ✅ Sequential preloading completed (".concat(processedUrls.size, " ads ready)"));
|
|
5550
|
-
}
|
|
5551
|
-
return [
|
|
5552
|
-
3,
|
|
5553
|
-
9
|
|
5554
|
-
];
|
|
5555
|
-
case 7:
|
|
5556
|
-
if (this.config.debugAdTiming) {
|
|
5557
|
-
console.log("[StormcloudVideoPlayer] Starting parallel preload of ".concat(this.adPodAllUrls.length, " ads"));
|
|
5558
|
-
}
|
|
5559
|
-
preloadPromises = this.adPodAllUrls.map(function(vastTagUrl) {
|
|
5560
|
-
return _this.preloadSingleAd(vastTagUrl).catch(function(error) {
|
|
5561
|
-
if (_this.config.debugAdTiming) {
|
|
5562
|
-
console.warn("[StormcloudVideoPlayer] Preload failed for ".concat(vastTagUrl, ":"), error);
|
|
5563
|
-
}
|
|
5564
|
-
});
|
|
5565
|
-
});
|
|
5566
|
-
return [
|
|
5567
|
-
4,
|
|
5568
|
-
Promise.all(preloadPromises)
|
|
5569
|
-
];
|
|
5570
|
-
case 8:
|
|
5571
|
-
_state.sent();
|
|
5572
|
-
if (this.config.debugAdTiming) {
|
|
5573
|
-
console.log("[StormcloudVideoPlayer] Background preloading completed for all ads");
|
|
5574
|
-
}
|
|
5575
|
-
_state.label = 9;
|
|
5576
|
-
case 9:
|
|
5577
|
-
return [
|
|
5578
|
-
2
|
|
5579
|
-
];
|
|
5580
|
-
}
|
|
5581
|
-
});
|
|
5582
|
-
}).call(this);
|
|
5583
|
-
}
|
|
5584
|
-
},
|
|
5585
|
-
{
|
|
5586
|
-
key: "preloadSingleAd",
|
|
5587
|
-
value: function preloadSingleAd(vastTagUrl) {
|
|
5588
|
-
return _async_to_generator(function() {
|
|
5589
|
-
var _this, duration, mediaUrls, primaryMediaUrl, error;
|
|
5590
|
-
return _ts_generator(this, function(_state) {
|
|
5591
|
-
switch(_state.label){
|
|
5592
|
-
case 0:
|
|
5593
|
-
_this = this;
|
|
5594
|
-
if (!vastTagUrl) return [
|
|
5595
|
-
2
|
|
5596
|
-
];
|
|
5597
|
-
_state.label = 1;
|
|
5598
|
-
case 1:
|
|
5599
|
-
_state.trys.push([
|
|
5600
|
-
1,
|
|
5601
|
-
11,
|
|
5602
|
-
,
|
|
5603
|
-
12
|
|
5604
|
-
]);
|
|
5605
|
-
if (!(this.isAdaptiveMode && !this.fetchedAdDurations.has(vastTagUrl))) return [
|
|
5606
|
-
3,
|
|
5607
|
-
4
|
|
5608
|
-
];
|
|
5609
|
-
return [
|
|
5610
|
-
4,
|
|
5611
|
-
this.fetchVastDuration(vastTagUrl)
|
|
5612
|
-
];
|
|
5613
|
-
case 2:
|
|
5614
|
-
duration = _state.sent();
|
|
5615
|
-
if (!(duration !== null)) return [
|
|
5616
|
-
3,
|
|
5617
|
-
4
|
|
5618
|
-
];
|
|
5619
|
-
this.fetchedAdDurations.set(vastTagUrl, duration);
|
|
5620
|
-
if (this.config.debugAdTiming) {
|
|
5621
|
-
console.log("[ADAPTIVE-POD] ✓ Fetched ad duration: ".concat(duration, "s (").concat(this.fetchedAdDurations.size, " ads fetched so far)"));
|
|
5622
|
-
}
|
|
5623
|
-
return [
|
|
5624
|
-
4,
|
|
5625
|
-
this.addAdaptiveAdsToQueue()
|
|
5626
|
-
];
|
|
5627
|
-
case 3:
|
|
5628
|
-
_state.sent();
|
|
5629
|
-
_state.label = 4;
|
|
5630
|
-
case 4:
|
|
5631
|
-
if (!(this.ima.preloadAds && !this.ima.hasPreloadedAd(vastTagUrl))) return [
|
|
5632
|
-
3,
|
|
5633
|
-
6
|
|
5634
|
-
];
|
|
5635
|
-
if (!!this.preloadingAdUrls.has(vastTagUrl)) return [
|
|
5636
|
-
3,
|
|
5637
|
-
6
|
|
5638
|
-
];
|
|
5639
|
-
if (this.config.debugAdTiming) {
|
|
5640
|
-
console.log("[StormcloudVideoPlayer] Preloading VAST: ".concat(vastTagUrl));
|
|
5641
|
-
}
|
|
5642
|
-
this.preloadingAdUrls.add(vastTagUrl);
|
|
5643
|
-
return [
|
|
5644
|
-
4,
|
|
5645
|
-
this.ima.preloadAds(vastTagUrl).then(function() {
|
|
5646
|
-
if (_this.config.debugAdTiming) {
|
|
5647
|
-
console.log("[StormcloudVideoPlayer] IMA VAST preload complete: ".concat(vastTagUrl));
|
|
5648
|
-
}
|
|
5649
|
-
}).catch(function(error) {
|
|
5650
|
-
if (_this.config.debugAdTiming) {
|
|
5651
|
-
console.warn("[StormcloudVideoPlayer] IMA VAST preload failed: ".concat(vastTagUrl), error);
|
|
5652
|
-
}
|
|
5653
|
-
}).finally(function() {
|
|
5654
|
-
_this.preloadingAdUrls.delete(vastTagUrl);
|
|
5655
|
-
})
|
|
5656
|
-
];
|
|
5657
|
-
case 5:
|
|
5658
|
-
_state.sent();
|
|
5659
|
-
_state.label = 6;
|
|
5660
|
-
case 6:
|
|
5661
|
-
mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5662
|
-
if (!!mediaUrls) return [
|
|
5663
|
-
3,
|
|
5664
|
-
8
|
|
5665
|
-
];
|
|
5666
|
-
if (this.config.debugAdTiming) {
|
|
5667
|
-
console.log("[StormcloudVideoPlayer] Fetching and parsing VAST to extract media URLs: ".concat(vastTagUrl));
|
|
5668
|
-
}
|
|
5669
|
-
return [
|
|
5670
|
-
4,
|
|
5671
|
-
this.fetchAndParseVastXml(vastTagUrl)
|
|
5672
|
-
];
|
|
5673
|
-
case 7:
|
|
5674
|
-
mediaUrls = _state.sent();
|
|
5675
|
-
if (this.config.debugAdTiming) {
|
|
5676
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs:"), mediaUrls);
|
|
5677
|
-
}
|
|
5678
|
-
if (mediaUrls.length > 0) {
|
|
5679
|
-
this.vastToMediaUrlMap.set(vastTagUrl, mediaUrls);
|
|
5680
|
-
}
|
|
5681
|
-
_state.label = 8;
|
|
5682
|
-
case 8:
|
|
5683
|
-
if (!(mediaUrls && mediaUrls.length > 0)) return [
|
|
5684
|
-
3,
|
|
5685
|
-
10
|
|
5686
|
-
];
|
|
5687
|
-
primaryMediaUrl = mediaUrls[0];
|
|
5688
|
-
if (!(primaryMediaUrl && !this.preloadedMediaUrls.has(primaryMediaUrl))) return [
|
|
5689
|
-
3,
|
|
5690
|
-
10
|
|
5691
|
-
];
|
|
5692
|
-
return [
|
|
5693
|
-
4,
|
|
5694
|
-
this.preloadMediaFile(primaryMediaUrl)
|
|
5695
|
-
];
|
|
5696
|
-
case 9:
|
|
5697
|
-
_state.sent();
|
|
5698
|
-
_state.label = 10;
|
|
5699
|
-
case 10:
|
|
5700
|
-
return [
|
|
5701
|
-
3,
|
|
5702
|
-
12
|
|
5703
|
-
];
|
|
5704
|
-
case 11:
|
|
5705
|
-
error = _state.sent();
|
|
5706
|
-
if (this.config.debugAdTiming) {
|
|
5707
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload ad: ".concat(vastTagUrl), error);
|
|
5708
|
-
}
|
|
5709
|
-
return [
|
|
5710
|
-
3,
|
|
5711
|
-
12
|
|
5712
|
-
];
|
|
5713
|
-
case 12:
|
|
5714
|
-
return [
|
|
5715
|
-
2
|
|
5716
|
-
];
|
|
5717
|
-
}
|
|
5718
|
-
});
|
|
5719
|
-
}).call(this);
|
|
5720
|
-
}
|
|
5721
|
-
},
|
|
5722
|
-
{
|
|
5723
|
-
key: "findNextPreloadedAd",
|
|
5724
|
-
value: function findNextPreloadedAd() {
|
|
5725
|
-
for(var i = 0; i < this.adPodQueue.length; i++){
|
|
5726
|
-
var _this_ima_hasPreloadedAd, _this_ima;
|
|
5727
|
-
var vastTagUrl = this.adPodQueue[i];
|
|
5728
|
-
if (!vastTagUrl) continue;
|
|
5729
|
-
if (this.failedVastUrls.has(vastTagUrl)) {
|
|
5730
|
-
console.warn("[AD-ERROR] Skipping failed URL in queue");
|
|
5731
|
-
continue;
|
|
5732
|
-
}
|
|
5733
|
-
var _this_ima_hasPreloadedAd1;
|
|
5734
|
-
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;
|
|
5735
|
-
var mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5736
|
-
var hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
|
|
5737
|
-
if (hasImaPreload || hasMediaPreload) {
|
|
5738
|
-
this.adPodQueue.splice(0, i + 1);
|
|
5739
|
-
return vastTagUrl;
|
|
5740
|
-
}
|
|
5741
|
-
}
|
|
5742
|
-
return void 0;
|
|
5743
|
-
}
|
|
5744
|
-
},
|
|
5745
4796
|
{
|
|
5746
4797
|
key: "getRemainingAdMs",
|
|
5747
4798
|
value: function getRemainingAdMs() {
|
|
@@ -5928,7 +4979,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5928
4979
|
}
|
|
5929
4980
|
if (this.ima && this.ima.isAdPlaying()) {
|
|
5930
4981
|
var width = this.video.clientWidth || 640;
|
|
5931
|
-
var height = this.video.clientHeight ||
|
|
4982
|
+
var height = this.video.clientHeight || 480;
|
|
5932
4983
|
if (this.config.debugAdTiming) {
|
|
5933
4984
|
console.log("[StormcloudVideoPlayer] Resizing ads manager to ".concat(width, "x").concat(height));
|
|
5934
4985
|
}
|
|
@@ -5959,13 +5010,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5959
5010
|
}
|
|
5960
5011
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5961
5012
|
(_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
|
|
5962
|
-
this.preloadingAdUrls.clear();
|
|
5963
|
-
this.vastToMediaUrlMap.clear();
|
|
5964
|
-
this.preloadedMediaUrls.clear();
|
|
5965
|
-
this.preloadingMediaUrls.clear();
|
|
5966
|
-
this.adPodAllUrls = [];
|
|
5967
5013
|
this.adRequestQueue = [];
|
|
5968
|
-
this.successfulAdRequests = [];
|
|
5969
5014
|
}
|
|
5970
5015
|
}
|
|
5971
5016
|
]);
|