stormcloud-video-player 0.3.21 → 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 +88 -354
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +0 -9
- package/lib/index.d.ts +0 -9
- package/lib/index.js +88 -354
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +88 -354
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -8
- package/lib/players/FilePlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +88 -354
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +88 -354
- 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 +2 -84
- 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 +88 -354
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/browserCompat.cjs.map +1 -1
- package/lib/utils/polyfills.cjs.map +1 -1
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/package.json +1 -1
|
@@ -309,20 +309,6 @@ function _ts_generator(thisArg, body) {
|
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
-
function _ts_values(o) {
|
|
313
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
314
|
-
if (m) return m.call(o);
|
|
315
|
-
if (o && typeof o.length === "number") return {
|
|
316
|
-
next: function() {
|
|
317
|
-
if (o && i >= o.length) o = void 0;
|
|
318
|
-
return {
|
|
319
|
-
value: o && o[i++],
|
|
320
|
-
done: !o
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
325
|
-
}
|
|
326
312
|
var __create = Object.create;
|
|
327
313
|
var __defProp = Object.defineProperty;
|
|
328
314
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -559,8 +545,6 @@ function createImaController(video, options) {
|
|
|
559
545
|
var originalMutedState = false;
|
|
560
546
|
var originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
561
547
|
var listeners = /* @__PURE__ */ new Map();
|
|
562
|
-
var preloadedVast = /* @__PURE__ */ new Map();
|
|
563
|
-
var preloadingVast = /* @__PURE__ */ new Map();
|
|
564
548
|
var adVideoElement;
|
|
565
549
|
function setAdPlayingFlag(isPlaying) {
|
|
566
550
|
if (isPlaying) {
|
|
@@ -710,15 +694,8 @@ function createImaController(video, options) {
|
|
|
710
694
|
var adsLoadedReject;
|
|
711
695
|
function makeAdsRequest(google, vastTagUrl) {
|
|
712
696
|
var adsRequest = new google.ima.AdsRequest();
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
console.log("[IMA] \uD83D\uDCE6 Using preloaded VAST response");
|
|
716
|
-
adsRequest.adsResponse = preloadedXml;
|
|
717
|
-
preloadedVast.delete(vastTagUrl);
|
|
718
|
-
} else {
|
|
719
|
-
console.log("[IMA] \uD83D\uDCE1 Requesting VAST from URL (letting IMA fetch fresh)");
|
|
720
|
-
adsRequest.adTagUrl = vastTagUrl;
|
|
721
|
-
}
|
|
697
|
+
console.log("[IMA] \uD83D\uDCE1 Requesting VAST via IMA SDK:", vastTagUrl.substring(0, 80) + "...");
|
|
698
|
+
adsRequest.adTagUrl = vastTagUrl;
|
|
722
699
|
var videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
723
700
|
var videoHeight = video.offsetHeight || video.clientHeight || 480;
|
|
724
701
|
adsRequest.linearAdSlotWidth = videoWidth;
|
|
@@ -766,36 +743,6 @@ function createImaController(video, options) {
|
|
|
766
743
|
(_video_parentElement = video.parentElement) === null || _video_parentElement === void 0 ? void 0 : _video_parentElement.appendChild(container);
|
|
767
744
|
adContainerEl = container;
|
|
768
745
|
}
|
|
769
|
-
function fetchVastDocument(vastTagUrl) {
|
|
770
|
-
return _async_to_generator(function() {
|
|
771
|
-
var response;
|
|
772
|
-
return _ts_generator(this, function(_state) {
|
|
773
|
-
switch(_state.label){
|
|
774
|
-
case 0:
|
|
775
|
-
return [
|
|
776
|
-
4,
|
|
777
|
-
fetch(vastTagUrl, {
|
|
778
|
-
mode: "cors",
|
|
779
|
-
credentials: "include",
|
|
780
|
-
headers: {
|
|
781
|
-
"Accept": "application/xml, text/xml, */*"
|
|
782
|
-
},
|
|
783
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
784
|
-
})
|
|
785
|
-
];
|
|
786
|
-
case 1:
|
|
787
|
-
response = _state.sent();
|
|
788
|
-
if (!response.ok) {
|
|
789
|
-
throw new Error("Failed to preload VAST: ".concat(response.status));
|
|
790
|
-
}
|
|
791
|
-
return [
|
|
792
|
-
2,
|
|
793
|
-
response.text()
|
|
794
|
-
];
|
|
795
|
-
}
|
|
796
|
-
});
|
|
797
|
-
})();
|
|
798
|
-
}
|
|
799
746
|
function destroyAdsManager() {
|
|
800
747
|
if (adsManager) {
|
|
801
748
|
try {
|
|
@@ -1110,47 +1057,6 @@ function createImaController(video, options) {
|
|
|
1110
1057
|
});
|
|
1111
1058
|
})();
|
|
1112
1059
|
},
|
|
1113
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1114
|
-
return _async_to_generator(function() {
|
|
1115
|
-
var inflight, preloadPromise;
|
|
1116
|
-
return _ts_generator(this, function(_state) {
|
|
1117
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1118
|
-
return [
|
|
1119
|
-
2,
|
|
1120
|
-
Promise.resolve()
|
|
1121
|
-
];
|
|
1122
|
-
}
|
|
1123
|
-
if (preloadedVast.has(vastTagUrl)) {
|
|
1124
|
-
return [
|
|
1125
|
-
2,
|
|
1126
|
-
Promise.resolve()
|
|
1127
|
-
];
|
|
1128
|
-
}
|
|
1129
|
-
inflight = preloadingVast.get(vastTagUrl);
|
|
1130
|
-
if (inflight) {
|
|
1131
|
-
return [
|
|
1132
|
-
2,
|
|
1133
|
-
inflight
|
|
1134
|
-
];
|
|
1135
|
-
}
|
|
1136
|
-
preloadPromise = fetchVastDocument(vastTagUrl).then(function(xml) {
|
|
1137
|
-
preloadedVast.set(vastTagUrl, xml);
|
|
1138
|
-
}).catch(function() {
|
|
1139
|
-
preloadedVast.delete(vastTagUrl);
|
|
1140
|
-
}).finally(function() {
|
|
1141
|
-
preloadingVast.delete(vastTagUrl);
|
|
1142
|
-
});
|
|
1143
|
-
preloadingVast.set(vastTagUrl, preloadPromise);
|
|
1144
|
-
return [
|
|
1145
|
-
2,
|
|
1146
|
-
preloadPromise
|
|
1147
|
-
];
|
|
1148
|
-
});
|
|
1149
|
-
})();
|
|
1150
|
-
},
|
|
1151
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1152
|
-
return preloadedVast.has(vastTagUrl);
|
|
1153
|
-
},
|
|
1154
1060
|
play: function play() {
|
|
1155
1061
|
return _async_to_generator(function() {
|
|
1156
1062
|
var _window_google, width, height, adVolume, _video_play;
|
|
@@ -1259,8 +1165,6 @@ function createImaController(video, options) {
|
|
|
1259
1165
|
adDisplayContainer = void 0;
|
|
1260
1166
|
adsLoader = void 0;
|
|
1261
1167
|
contentVideoHidden = false;
|
|
1262
|
-
preloadedVast.clear();
|
|
1263
|
-
preloadingVast.clear();
|
|
1264
1168
|
},
|
|
1265
1169
|
isAdPlaying: function isAdPlaying() {
|
|
1266
1170
|
return adPlaying;
|
|
@@ -1861,51 +1765,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1861
1765
|
});
|
|
1862
1766
|
})();
|
|
1863
1767
|
},
|
|
1864
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1865
|
-
return _async_to_generator(function() {
|
|
1866
|
-
var inflight, preloadPromise;
|
|
1867
|
-
return _ts_generator(this, function(_state) {
|
|
1868
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1869
|
-
return [
|
|
1870
|
-
2,
|
|
1871
|
-
Promise.resolve()
|
|
1872
|
-
];
|
|
1873
|
-
}
|
|
1874
|
-
if (preloadedAds.has(vastTagUrl)) {
|
|
1875
|
-
return [
|
|
1876
|
-
2,
|
|
1877
|
-
Promise.resolve()
|
|
1878
|
-
];
|
|
1879
|
-
}
|
|
1880
|
-
inflight = preloadingAds.get(vastTagUrl);
|
|
1881
|
-
if (inflight) {
|
|
1882
|
-
return [
|
|
1883
|
-
2,
|
|
1884
|
-
inflight
|
|
1885
|
-
];
|
|
1886
|
-
}
|
|
1887
|
-
preloadPromise = fetchAndParseVastAd(vastTagUrl).then(function(ad) {
|
|
1888
|
-
if (ad) {
|
|
1889
|
-
preloadedAds.set(vastTagUrl, ad);
|
|
1890
|
-
console.log("[HlsAdPlayer] Cached VAST response for preloading:", vastTagUrl);
|
|
1891
|
-
}
|
|
1892
|
-
}).catch(function(error) {
|
|
1893
|
-
console.warn("[HlsAdPlayer] Failed to preload VAST response:", error);
|
|
1894
|
-
preloadedAds.delete(vastTagUrl);
|
|
1895
|
-
}).finally(function() {
|
|
1896
|
-
preloadingAds.delete(vastTagUrl);
|
|
1897
|
-
});
|
|
1898
|
-
preloadingAds.set(vastTagUrl, preloadPromise);
|
|
1899
|
-
return [
|
|
1900
|
-
2,
|
|
1901
|
-
preloadPromise
|
|
1902
|
-
];
|
|
1903
|
-
});
|
|
1904
|
-
})();
|
|
1905
|
-
},
|
|
1906
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1907
|
-
return preloadedAds.has(vastTagUrl);
|
|
1908
|
-
},
|
|
1909
1768
|
play: function play() {
|
|
1910
1769
|
return _async_to_generator(function() {
|
|
1911
1770
|
var contentVolume, adVolume, mediaFile;
|
|
@@ -2804,17 +2663,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2804
2663
|
this.failedVastUrls = /* @__PURE__ */ new Set();
|
|
2805
2664
|
this.continuousFetchingActive = false;
|
|
2806
2665
|
this.adRequestQueue = [];
|
|
2807
|
-
this.successfulAdRequests = [];
|
|
2808
2666
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2809
|
-
this.placeholderStartTimeMs = null;
|
|
2810
2667
|
this.isShowingPlaceholder = false;
|
|
2811
|
-
this.consecutiveEmptyResponses = 0;
|
|
2812
2668
|
this.totalAdRequestsInBreak = 0;
|
|
2813
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
2814
2669
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2815
|
-
this.maxConsecutiveEmptyResponses = 5;
|
|
2816
|
-
this.baseEmptyResponseDelayMs = 2e3;
|
|
2817
|
-
this.maxEmptyResponseDelayMs = 3e4;
|
|
2818
2670
|
initializePolyfills();
|
|
2819
2671
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2820
2672
|
this.config = _object_spread({}, config, browserOverrides);
|
|
@@ -4059,13 +3911,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4059
3911
|
}
|
|
4060
3912
|
this.failedVastUrls.clear();
|
|
4061
3913
|
this.adRequestQueue = [];
|
|
4062
|
-
this.successfulAdRequests = [];
|
|
4063
3914
|
this.continuousFetchingActive = true;
|
|
4064
3915
|
this.isShowingPlaceholder = false;
|
|
4065
|
-
this.placeholderStartTimeMs = null;
|
|
4066
|
-
this.consecutiveEmptyResponses = 0;
|
|
4067
3916
|
this.totalAdRequestsInBreak = 0;
|
|
4068
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
4069
3917
|
currentMuted = this.video.muted;
|
|
4070
3918
|
currentVolume = this.video.volume;
|
|
4071
3919
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
@@ -4111,7 +3959,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4111
3959
|
if (this.config.debugAdTiming) {
|
|
4112
3960
|
console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
|
|
4113
3961
|
}
|
|
4114
|
-
this.successfulAdRequests.push(firstAdUrl);
|
|
4115
3962
|
this.currentAdIndex++;
|
|
4116
3963
|
this.startContinuousFetching(baseVastUrl);
|
|
4117
3964
|
return [
|
|
@@ -4161,200 +4008,92 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4161
4008
|
key: "continuousFetchLoop",
|
|
4162
4009
|
value: function continuousFetchLoop(baseVastUrl) {
|
|
4163
4010
|
return _async_to_generator(function() {
|
|
4164
|
-
var
|
|
4011
|
+
var remaining, maxQueueSize, newAdUrl;
|
|
4165
4012
|
return _ts_generator(this, function(_state) {
|
|
4166
4013
|
switch(_state.label){
|
|
4167
4014
|
case 0:
|
|
4168
|
-
_loop = function() {
|
|
4169
|
-
var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
|
|
4170
|
-
return _ts_generator(this, function(_state) {
|
|
4171
|
-
switch(_state.label){
|
|
4172
|
-
case 0:
|
|
4173
|
-
remaining = _this.getRemainingAdMs();
|
|
4174
|
-
if (remaining <= 0) {
|
|
4175
|
-
if (_this.config.debugAdTiming) {
|
|
4176
|
-
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
|
|
4177
|
-
}
|
|
4178
|
-
return [
|
|
4179
|
-
2,
|
|
4180
|
-
"break"
|
|
4181
|
-
];
|
|
4182
|
-
}
|
|
4183
|
-
if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
|
|
4184
|
-
if (_this.config.debugAdTiming) {
|
|
4185
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
|
|
4186
|
-
}
|
|
4187
|
-
return [
|
|
4188
|
-
2,
|
|
4189
|
-
"break"
|
|
4190
|
-
];
|
|
4191
|
-
}
|
|
4192
|
-
if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
|
|
4193
|
-
if (_this.config.debugAdTiming) {
|
|
4194
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
|
|
4195
|
-
}
|
|
4196
|
-
return [
|
|
4197
|
-
2,
|
|
4198
|
-
"break"
|
|
4199
|
-
];
|
|
4200
|
-
}
|
|
4201
|
-
maxQueueSize = 3;
|
|
4202
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4203
|
-
3,
|
|
4204
|
-
2
|
|
4205
|
-
];
|
|
4206
|
-
if (_this.config.debugAdTiming) {
|
|
4207
|
-
console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
|
|
4208
|
-
}
|
|
4209
|
-
return [
|
|
4210
|
-
4,
|
|
4211
|
-
new Promise(function(resolve) {
|
|
4212
|
-
return setTimeout(resolve, 2e3);
|
|
4213
|
-
})
|
|
4214
|
-
];
|
|
4215
|
-
case 1:
|
|
4216
|
-
_state.sent();
|
|
4217
|
-
return [
|
|
4218
|
-
2,
|
|
4219
|
-
"continue"
|
|
4220
|
-
];
|
|
4221
|
-
case 2:
|
|
4222
|
-
newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4223
|
-
if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
|
|
4224
|
-
3,
|
|
4225
|
-
4
|
|
4226
|
-
];
|
|
4227
|
-
return [
|
|
4228
|
-
4,
|
|
4229
|
-
new Promise(function(resolve) {
|
|
4230
|
-
return setTimeout(resolve, 1e3);
|
|
4231
|
-
})
|
|
4232
|
-
];
|
|
4233
|
-
case 3:
|
|
4234
|
-
_state.sent();
|
|
4235
|
-
return [
|
|
4236
|
-
2,
|
|
4237
|
-
"continue"
|
|
4238
|
-
];
|
|
4239
|
-
case 4:
|
|
4240
|
-
_this.totalAdRequestsInBreak++;
|
|
4241
|
-
if (_this.config.debugAdTiming) {
|
|
4242
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
|
|
4243
|
-
}
|
|
4244
|
-
_state.label = 5;
|
|
4245
|
-
case 5:
|
|
4246
|
-
_state.trys.push([
|
|
4247
|
-
5,
|
|
4248
|
-
11,
|
|
4249
|
-
,
|
|
4250
|
-
13
|
|
4251
|
-
]);
|
|
4252
|
-
if (!_this.ima.preloadAds) return [
|
|
4253
|
-
3,
|
|
4254
|
-
7
|
|
4255
|
-
];
|
|
4256
|
-
return [
|
|
4257
|
-
4,
|
|
4258
|
-
_this.ima.preloadAds(newAdUrl)
|
|
4259
|
-
];
|
|
4260
|
-
case 6:
|
|
4261
|
-
_state.sent();
|
|
4262
|
-
_state.label = 7;
|
|
4263
|
-
case 7:
|
|
4264
|
-
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;
|
|
4265
|
-
if (!!hasPreloadedAd) return [
|
|
4266
|
-
3,
|
|
4267
|
-
9
|
|
4268
|
-
];
|
|
4269
|
-
_this.consecutiveEmptyResponses++;
|
|
4270
|
-
_this.lastEmptyResponseTimeMs = Date.now();
|
|
4271
|
-
backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4272
|
-
if (_this.config.debugAdTiming) {
|
|
4273
|
-
console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
|
|
4274
|
-
}
|
|
4275
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4276
|
-
return [
|
|
4277
|
-
4,
|
|
4278
|
-
new Promise(function(resolve) {
|
|
4279
|
-
return setTimeout(resolve, backoffDelay);
|
|
4280
|
-
})
|
|
4281
|
-
];
|
|
4282
|
-
case 8:
|
|
4283
|
-
_state.sent();
|
|
4284
|
-
return [
|
|
4285
|
-
2,
|
|
4286
|
-
"continue"
|
|
4287
|
-
];
|
|
4288
|
-
case 9:
|
|
4289
|
-
_this.consecutiveEmptyResponses = 0;
|
|
4290
|
-
if (_this.config.debugAdTiming) {
|
|
4291
|
-
console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
|
|
4292
|
-
}
|
|
4293
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
4294
|
-
_this.totalAdsInBreak++;
|
|
4295
|
-
return [
|
|
4296
|
-
4,
|
|
4297
|
-
new Promise(function(resolve) {
|
|
4298
|
-
return setTimeout(resolve, 500);
|
|
4299
|
-
})
|
|
4300
|
-
];
|
|
4301
|
-
case 10:
|
|
4302
|
-
_state.sent();
|
|
4303
|
-
return [
|
|
4304
|
-
3,
|
|
4305
|
-
13
|
|
4306
|
-
];
|
|
4307
|
-
case 11:
|
|
4308
|
-
error = _state.sent();
|
|
4309
|
-
if (_this.config.debugAdTiming) {
|
|
4310
|
-
console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
|
|
4311
|
-
}
|
|
4312
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4313
|
-
_this.consecutiveEmptyResponses++;
|
|
4314
|
-
backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4315
|
-
return [
|
|
4316
|
-
4,
|
|
4317
|
-
new Promise(function(resolve) {
|
|
4318
|
-
return setTimeout(resolve, backoffDelay1);
|
|
4319
|
-
})
|
|
4320
|
-
];
|
|
4321
|
-
case 12:
|
|
4322
|
-
_state.sent();
|
|
4323
|
-
return [
|
|
4324
|
-
3,
|
|
4325
|
-
13
|
|
4326
|
-
];
|
|
4327
|
-
case 13:
|
|
4328
|
-
return [
|
|
4329
|
-
2
|
|
4330
|
-
];
|
|
4331
|
-
}
|
|
4332
|
-
});
|
|
4333
|
-
};
|
|
4334
|
-
_state.label = 1;
|
|
4335
|
-
case 1:
|
|
4336
4015
|
if (!(this.continuousFetchingActive && this.inAdBreak)) return [
|
|
4337
4016
|
3,
|
|
4338
|
-
|
|
4017
|
+
6
|
|
4339
4018
|
];
|
|
4340
|
-
|
|
4019
|
+
remaining = this.getRemainingAdMs();
|
|
4020
|
+
if (remaining <= 0) {
|
|
4021
|
+
if (this.config.debugAdTiming) {
|
|
4022
|
+
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping URL generation");
|
|
4023
|
+
}
|
|
4024
|
+
return [
|
|
4025
|
+
3,
|
|
4026
|
+
6
|
|
4027
|
+
];
|
|
4028
|
+
}
|
|
4029
|
+
if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
|
|
4030
|
+
if (this.config.debugAdTiming) {
|
|
4031
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(this.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
4032
|
+
}
|
|
4033
|
+
return [
|
|
4034
|
+
3,
|
|
4035
|
+
6
|
|
4036
|
+
];
|
|
4037
|
+
}
|
|
4038
|
+
maxQueueSize = 5;
|
|
4039
|
+
if (!(this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4040
|
+
3,
|
|
4041
|
+
2
|
|
4042
|
+
];
|
|
4043
|
+
if (this.config.debugAdTiming) {
|
|
4044
|
+
console.log("[CONTINUOUS-FETCH] ⏸️ URL queue full (".concat(this.adRequestQueue.length, "), waiting..."));
|
|
4045
|
+
}
|
|
4341
4046
|
return [
|
|
4342
|
-
|
|
4343
|
-
|
|
4047
|
+
4,
|
|
4048
|
+
new Promise(function(resolve) {
|
|
4049
|
+
return setTimeout(resolve, 1e3);
|
|
4050
|
+
})
|
|
4051
|
+
];
|
|
4052
|
+
case 1:
|
|
4053
|
+
_state.sent();
|
|
4054
|
+
return [
|
|
4055
|
+
3,
|
|
4056
|
+
0
|
|
4344
4057
|
];
|
|
4345
4058
|
case 2:
|
|
4346
|
-
|
|
4347
|
-
if (
|
|
4059
|
+
newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4060
|
+
if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
|
|
4348
4061
|
3,
|
|
4349
|
-
|
|
4062
|
+
4
|
|
4350
4063
|
];
|
|
4351
4064
|
return [
|
|
4352
|
-
|
|
4353
|
-
|
|
4065
|
+
4,
|
|
4066
|
+
new Promise(function(resolve) {
|
|
4067
|
+
return setTimeout(resolve, 500);
|
|
4068
|
+
})
|
|
4354
4069
|
];
|
|
4355
4070
|
case 3:
|
|
4071
|
+
_state.sent();
|
|
4072
|
+
return [
|
|
4073
|
+
3,
|
|
4074
|
+
0
|
|
4075
|
+
];
|
|
4076
|
+
case 4:
|
|
4077
|
+
if (this.config.debugAdTiming) {
|
|
4078
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCDD Queued VAST URL (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
|
|
4079
|
+
}
|
|
4080
|
+
this.adRequestQueue.push(newAdUrl);
|
|
4081
|
+
this.totalAdsInBreak++;
|
|
4082
|
+
return [
|
|
4083
|
+
4,
|
|
4084
|
+
new Promise(function(resolve) {
|
|
4085
|
+
return setTimeout(resolve, 300);
|
|
4086
|
+
})
|
|
4087
|
+
];
|
|
4088
|
+
case 5:
|
|
4089
|
+
_state.sent();
|
|
4090
|
+
return [
|
|
4091
|
+
3,
|
|
4092
|
+
0
|
|
4093
|
+
];
|
|
4094
|
+
case 6:
|
|
4356
4095
|
if (this.config.debugAdTiming) {
|
|
4357
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1
|
|
4096
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"));
|
|
4358
4097
|
}
|
|
4359
4098
|
return [
|
|
4360
4099
|
2
|
|
@@ -4403,19 +4142,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4403
4142
|
2
|
|
4404
4143
|
];
|
|
4405
4144
|
if (this.config.debugAdTiming) {
|
|
4406
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC
|
|
4145
|
+
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC Requesting next ad via IMA SDK (".concat(this.currentAdIndex + 1, "/").concat(this.totalAdsInBreak, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
|
|
4407
4146
|
}
|
|
4408
4147
|
currentMuted = this.video.muted;
|
|
4409
4148
|
currentVolume = this.video.volume;
|
|
4410
4149
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
4411
|
-
if (this.config.debugAdTiming) {
|
|
4412
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDD0A Updated ad audio state: muted=".concat(currentMuted, ", volume=").concat(currentVolume));
|
|
4413
|
-
}
|
|
4414
4150
|
this.currentAdIndex++;
|
|
4415
|
-
this.
|
|
4151
|
+
this.totalAdRequestsInBreak++;
|
|
4416
4152
|
return [
|
|
4417
4153
|
4,
|
|
4418
|
-
this.playSingleAd(nextAdUrl).catch(function() {
|
|
4154
|
+
this.playSingleAd(nextAdUrl).catch(function(error) {
|
|
4155
|
+
if (_this.config.debugAdTiming) {
|
|
4156
|
+
console.log("[CONTINUOUS-FETCH] \u274C Ad request failed:", error.message);
|
|
4157
|
+
}
|
|
4158
|
+
_this.failedVastUrls.add(nextAdUrl);
|
|
4419
4159
|
_this.tryNextAvailableAd(0);
|
|
4420
4160
|
})
|
|
4421
4161
|
];
|
|
@@ -4425,18 +4165,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4425
4165
|
2
|
|
4426
4166
|
];
|
|
4427
4167
|
case 2:
|
|
4428
|
-
maxRetries =
|
|
4168
|
+
maxRetries = 3;
|
|
4429
4169
|
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
4430
4170
|
3,
|
|
4431
4171
|
5
|
|
4432
4172
|
];
|
|
4433
4173
|
if (this.config.debugAdTiming) {
|
|
4434
|
-
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty
|
|
4174
|
+
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
4435
4175
|
}
|
|
4436
4176
|
return [
|
|
4437
4177
|
4,
|
|
4438
4178
|
new Promise(function(resolve) {
|
|
4439
|
-
return setTimeout(resolve,
|
|
4179
|
+
return setTimeout(resolve, 500);
|
|
4440
4180
|
})
|
|
4441
4181
|
];
|
|
4442
4182
|
case 3:
|
|
@@ -4485,12 +4225,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4485
4225
|
];
|
|
4486
4226
|
}
|
|
4487
4227
|
if (this.config.debugAdTiming) {
|
|
4488
|
-
console.log("[CONTINUOUS-FETCH] ⬛ Showing
|
|
4228
|
+
console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad URLs"));
|
|
4489
4229
|
}
|
|
4490
4230
|
this.isShowingPlaceholder = true;
|
|
4491
|
-
this.placeholderStartTimeMs = Date.now();
|
|
4492
4231
|
this.ima.showPlaceholder();
|
|
4493
|
-
checkInterval =
|
|
4232
|
+
checkInterval = 300;
|
|
4494
4233
|
maxChecks = Math.floor(waitTime / checkInterval);
|
|
4495
4234
|
i = 0;
|
|
4496
4235
|
_state.label = 1;
|
|
@@ -4517,10 +4256,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4517
4256
|
5
|
|
4518
4257
|
];
|
|
4519
4258
|
if (this.config.debugAdTiming) {
|
|
4520
|
-
console.log("[CONTINUOUS-FETCH] \u2705
|
|
4259
|
+
console.log("[CONTINUOUS-FETCH] \u2705 Ad URL available, requesting via IMA SDK");
|
|
4521
4260
|
}
|
|
4522
4261
|
this.isShowingPlaceholder = false;
|
|
4523
|
-
this.placeholderStartTimeMs = null;
|
|
4524
4262
|
this.ima.hidePlaceholder();
|
|
4525
4263
|
currentMuted = this.video.muted;
|
|
4526
4264
|
currentVolume = this.video.volume;
|
|
@@ -4531,7 +4269,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4531
4269
|
4
|
|
4532
4270
|
];
|
|
4533
4271
|
this.currentAdIndex++;
|
|
4534
|
-
this.
|
|
4272
|
+
this.totalAdRequestsInBreak++;
|
|
4535
4273
|
return [
|
|
4536
4274
|
4,
|
|
4537
4275
|
this.playSingleAd(nextAdUrl).catch(function() {
|
|
@@ -4553,10 +4291,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4553
4291
|
];
|
|
4554
4292
|
case 6:
|
|
4555
4293
|
if (this.config.debugAdTiming) {
|
|
4556
|
-
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout
|
|
4294
|
+
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
|
|
4557
4295
|
}
|
|
4558
4296
|
this.isShowingPlaceholder = false;
|
|
4559
|
-
this.placeholderStartTimeMs = null;
|
|
4560
4297
|
this.ima.hidePlaceholder();
|
|
4561
4298
|
this.handleAdPodComplete();
|
|
4562
4299
|
return [
|
|
@@ -4858,10 +4595,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4858
4595
|
if (this.isShowingPlaceholder) {
|
|
4859
4596
|
this.ima.hidePlaceholder();
|
|
4860
4597
|
this.isShowingPlaceholder = false;
|
|
4861
|
-
this.placeholderStartTimeMs = null;
|
|
4862
4598
|
}
|
|
4863
4599
|
this.adRequestQueue = [];
|
|
4864
|
-
this.successfulAdRequests = [];
|
|
4865
4600
|
this.inAdBreak = false;
|
|
4866
4601
|
this.expectedAdBreakDurationMs = void 0;
|
|
4867
4602
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
@@ -5240,7 +4975,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5240
4975
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5241
4976
|
(_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
|
|
5242
4977
|
this.adRequestQueue = [];
|
|
5243
|
-
this.successfulAdRequests = [];
|
|
5244
4978
|
}
|
|
5245
4979
|
}
|
|
5246
4980
|
]);
|