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
|
@@ -274,20 +274,6 @@ function _ts_generator(thisArg, body) {
|
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
function _ts_values(o) {
|
|
278
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
279
|
-
if (m) return m.call(o);
|
|
280
|
-
if (o && typeof o.length === "number") return {
|
|
281
|
-
next: function() {
|
|
282
|
-
if (o && i >= o.length) o = void 0;
|
|
283
|
-
return {
|
|
284
|
-
value: o && o[i++],
|
|
285
|
-
done: !o
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
290
|
-
}
|
|
291
277
|
var __create = Object.create;
|
|
292
278
|
var __defProp = Object.defineProperty;
|
|
293
279
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -524,8 +510,6 @@ function createImaController(video, options) {
|
|
|
524
510
|
var originalMutedState = false;
|
|
525
511
|
var originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
526
512
|
var listeners = /* @__PURE__ */ new Map();
|
|
527
|
-
var preloadedVast = /* @__PURE__ */ new Map();
|
|
528
|
-
var preloadingVast = /* @__PURE__ */ new Map();
|
|
529
513
|
var adVideoElement;
|
|
530
514
|
function setAdPlayingFlag(isPlaying) {
|
|
531
515
|
if (isPlaying) {
|
|
@@ -675,15 +659,8 @@ function createImaController(video, options) {
|
|
|
675
659
|
var adsLoadedReject;
|
|
676
660
|
function makeAdsRequest(google, vastTagUrl) {
|
|
677
661
|
var adsRequest = new google.ima.AdsRequest();
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
console.log("[IMA] \uD83D\uDCE6 Using preloaded VAST response");
|
|
681
|
-
adsRequest.adsResponse = preloadedXml;
|
|
682
|
-
preloadedVast.delete(vastTagUrl);
|
|
683
|
-
} else {
|
|
684
|
-
console.log("[IMA] \uD83D\uDCE1 Requesting VAST from URL (letting IMA fetch fresh)");
|
|
685
|
-
adsRequest.adTagUrl = vastTagUrl;
|
|
686
|
-
}
|
|
662
|
+
console.log("[IMA] \uD83D\uDCE1 Requesting VAST via IMA SDK:", vastTagUrl.substring(0, 80) + "...");
|
|
663
|
+
adsRequest.adTagUrl = vastTagUrl;
|
|
687
664
|
var videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
688
665
|
var videoHeight = video.offsetHeight || video.clientHeight || 480;
|
|
689
666
|
adsRequest.linearAdSlotWidth = videoWidth;
|
|
@@ -731,36 +708,6 @@ function createImaController(video, options) {
|
|
|
731
708
|
(_video_parentElement = video.parentElement) === null || _video_parentElement === void 0 ? void 0 : _video_parentElement.appendChild(container);
|
|
732
709
|
adContainerEl = container;
|
|
733
710
|
}
|
|
734
|
-
function fetchVastDocument(vastTagUrl) {
|
|
735
|
-
return _async_to_generator(function() {
|
|
736
|
-
var response;
|
|
737
|
-
return _ts_generator(this, function(_state) {
|
|
738
|
-
switch(_state.label){
|
|
739
|
-
case 0:
|
|
740
|
-
return [
|
|
741
|
-
4,
|
|
742
|
-
fetch(vastTagUrl, {
|
|
743
|
-
mode: "cors",
|
|
744
|
-
credentials: "include",
|
|
745
|
-
headers: {
|
|
746
|
-
"Accept": "application/xml, text/xml, */*"
|
|
747
|
-
},
|
|
748
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
749
|
-
})
|
|
750
|
-
];
|
|
751
|
-
case 1:
|
|
752
|
-
response = _state.sent();
|
|
753
|
-
if (!response.ok) {
|
|
754
|
-
throw new Error("Failed to preload VAST: ".concat(response.status));
|
|
755
|
-
}
|
|
756
|
-
return [
|
|
757
|
-
2,
|
|
758
|
-
response.text()
|
|
759
|
-
];
|
|
760
|
-
}
|
|
761
|
-
});
|
|
762
|
-
})();
|
|
763
|
-
}
|
|
764
711
|
function destroyAdsManager() {
|
|
765
712
|
if (adsManager) {
|
|
766
713
|
try {
|
|
@@ -1075,47 +1022,6 @@ function createImaController(video, options) {
|
|
|
1075
1022
|
});
|
|
1076
1023
|
})();
|
|
1077
1024
|
},
|
|
1078
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1079
|
-
return _async_to_generator(function() {
|
|
1080
|
-
var inflight, preloadPromise;
|
|
1081
|
-
return _ts_generator(this, function(_state) {
|
|
1082
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1083
|
-
return [
|
|
1084
|
-
2,
|
|
1085
|
-
Promise.resolve()
|
|
1086
|
-
];
|
|
1087
|
-
}
|
|
1088
|
-
if (preloadedVast.has(vastTagUrl)) {
|
|
1089
|
-
return [
|
|
1090
|
-
2,
|
|
1091
|
-
Promise.resolve()
|
|
1092
|
-
];
|
|
1093
|
-
}
|
|
1094
|
-
inflight = preloadingVast.get(vastTagUrl);
|
|
1095
|
-
if (inflight) {
|
|
1096
|
-
return [
|
|
1097
|
-
2,
|
|
1098
|
-
inflight
|
|
1099
|
-
];
|
|
1100
|
-
}
|
|
1101
|
-
preloadPromise = fetchVastDocument(vastTagUrl).then(function(xml) {
|
|
1102
|
-
preloadedVast.set(vastTagUrl, xml);
|
|
1103
|
-
}).catch(function() {
|
|
1104
|
-
preloadedVast.delete(vastTagUrl);
|
|
1105
|
-
}).finally(function() {
|
|
1106
|
-
preloadingVast.delete(vastTagUrl);
|
|
1107
|
-
});
|
|
1108
|
-
preloadingVast.set(vastTagUrl, preloadPromise);
|
|
1109
|
-
return [
|
|
1110
|
-
2,
|
|
1111
|
-
preloadPromise
|
|
1112
|
-
];
|
|
1113
|
-
});
|
|
1114
|
-
})();
|
|
1115
|
-
},
|
|
1116
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1117
|
-
return preloadedVast.has(vastTagUrl);
|
|
1118
|
-
},
|
|
1119
1025
|
play: function play() {
|
|
1120
1026
|
return _async_to_generator(function() {
|
|
1121
1027
|
var _window_google, width, height, adVolume, _video_play;
|
|
@@ -1224,8 +1130,6 @@ function createImaController(video, options) {
|
|
|
1224
1130
|
adDisplayContainer = void 0;
|
|
1225
1131
|
adsLoader = void 0;
|
|
1226
1132
|
contentVideoHidden = false;
|
|
1227
|
-
preloadedVast.clear();
|
|
1228
|
-
preloadingVast.clear();
|
|
1229
1133
|
},
|
|
1230
1134
|
isAdPlaying: function isAdPlaying() {
|
|
1231
1135
|
return adPlaying;
|
|
@@ -1826,51 +1730,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1826
1730
|
});
|
|
1827
1731
|
})();
|
|
1828
1732
|
},
|
|
1829
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1830
|
-
return _async_to_generator(function() {
|
|
1831
|
-
var inflight, preloadPromise;
|
|
1832
|
-
return _ts_generator(this, function(_state) {
|
|
1833
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1834
|
-
return [
|
|
1835
|
-
2,
|
|
1836
|
-
Promise.resolve()
|
|
1837
|
-
];
|
|
1838
|
-
}
|
|
1839
|
-
if (preloadedAds.has(vastTagUrl)) {
|
|
1840
|
-
return [
|
|
1841
|
-
2,
|
|
1842
|
-
Promise.resolve()
|
|
1843
|
-
];
|
|
1844
|
-
}
|
|
1845
|
-
inflight = preloadingAds.get(vastTagUrl);
|
|
1846
|
-
if (inflight) {
|
|
1847
|
-
return [
|
|
1848
|
-
2,
|
|
1849
|
-
inflight
|
|
1850
|
-
];
|
|
1851
|
-
}
|
|
1852
|
-
preloadPromise = fetchAndParseVastAd(vastTagUrl).then(function(ad) {
|
|
1853
|
-
if (ad) {
|
|
1854
|
-
preloadedAds.set(vastTagUrl, ad);
|
|
1855
|
-
console.log("[HlsAdPlayer] Cached VAST response for preloading:", vastTagUrl);
|
|
1856
|
-
}
|
|
1857
|
-
}).catch(function(error) {
|
|
1858
|
-
console.warn("[HlsAdPlayer] Failed to preload VAST response:", error);
|
|
1859
|
-
preloadedAds.delete(vastTagUrl);
|
|
1860
|
-
}).finally(function() {
|
|
1861
|
-
preloadingAds.delete(vastTagUrl);
|
|
1862
|
-
});
|
|
1863
|
-
preloadingAds.set(vastTagUrl, preloadPromise);
|
|
1864
|
-
return [
|
|
1865
|
-
2,
|
|
1866
|
-
preloadPromise
|
|
1867
|
-
];
|
|
1868
|
-
});
|
|
1869
|
-
})();
|
|
1870
|
-
},
|
|
1871
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1872
|
-
return preloadedAds.has(vastTagUrl);
|
|
1873
|
-
},
|
|
1874
1733
|
play: function play() {
|
|
1875
1734
|
return _async_to_generator(function() {
|
|
1876
1735
|
var contentVolume, adVolume, mediaFile;
|
|
@@ -2769,17 +2628,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2769
2628
|
this.failedVastUrls = /* @__PURE__ */ new Set();
|
|
2770
2629
|
this.continuousFetchingActive = false;
|
|
2771
2630
|
this.adRequestQueue = [];
|
|
2772
|
-
this.successfulAdRequests = [];
|
|
2773
2631
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2774
|
-
this.placeholderStartTimeMs = null;
|
|
2775
2632
|
this.isShowingPlaceholder = false;
|
|
2776
|
-
this.consecutiveEmptyResponses = 0;
|
|
2777
2633
|
this.totalAdRequestsInBreak = 0;
|
|
2778
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
2779
2634
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2780
|
-
this.maxConsecutiveEmptyResponses = 5;
|
|
2781
|
-
this.baseEmptyResponseDelayMs = 2e3;
|
|
2782
|
-
this.maxEmptyResponseDelayMs = 3e4;
|
|
2783
2635
|
initializePolyfills();
|
|
2784
2636
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2785
2637
|
this.config = _object_spread({}, config, browserOverrides);
|
|
@@ -4024,13 +3876,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4024
3876
|
}
|
|
4025
3877
|
this.failedVastUrls.clear();
|
|
4026
3878
|
this.adRequestQueue = [];
|
|
4027
|
-
this.successfulAdRequests = [];
|
|
4028
3879
|
this.continuousFetchingActive = true;
|
|
4029
3880
|
this.isShowingPlaceholder = false;
|
|
4030
|
-
this.placeholderStartTimeMs = null;
|
|
4031
|
-
this.consecutiveEmptyResponses = 0;
|
|
4032
3881
|
this.totalAdRequestsInBreak = 0;
|
|
4033
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
4034
3882
|
currentMuted = this.video.muted;
|
|
4035
3883
|
currentVolume = this.video.volume;
|
|
4036
3884
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
@@ -4076,7 +3924,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4076
3924
|
if (this.config.debugAdTiming) {
|
|
4077
3925
|
console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
|
|
4078
3926
|
}
|
|
4079
|
-
this.successfulAdRequests.push(firstAdUrl);
|
|
4080
3927
|
this.currentAdIndex++;
|
|
4081
3928
|
this.startContinuousFetching(baseVastUrl);
|
|
4082
3929
|
return [
|
|
@@ -4126,200 +3973,92 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4126
3973
|
key: "continuousFetchLoop",
|
|
4127
3974
|
value: function continuousFetchLoop(baseVastUrl) {
|
|
4128
3975
|
return _async_to_generator(function() {
|
|
4129
|
-
var
|
|
3976
|
+
var remaining, maxQueueSize, newAdUrl;
|
|
4130
3977
|
return _ts_generator(this, function(_state) {
|
|
4131
3978
|
switch(_state.label){
|
|
4132
3979
|
case 0:
|
|
4133
|
-
_loop = function() {
|
|
4134
|
-
var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
|
|
4135
|
-
return _ts_generator(this, function(_state) {
|
|
4136
|
-
switch(_state.label){
|
|
4137
|
-
case 0:
|
|
4138
|
-
remaining = _this.getRemainingAdMs();
|
|
4139
|
-
if (remaining <= 0) {
|
|
4140
|
-
if (_this.config.debugAdTiming) {
|
|
4141
|
-
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
|
|
4142
|
-
}
|
|
4143
|
-
return [
|
|
4144
|
-
2,
|
|
4145
|
-
"break"
|
|
4146
|
-
];
|
|
4147
|
-
}
|
|
4148
|
-
if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
|
|
4149
|
-
if (_this.config.debugAdTiming) {
|
|
4150
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
|
|
4151
|
-
}
|
|
4152
|
-
return [
|
|
4153
|
-
2,
|
|
4154
|
-
"break"
|
|
4155
|
-
];
|
|
4156
|
-
}
|
|
4157
|
-
if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
|
|
4158
|
-
if (_this.config.debugAdTiming) {
|
|
4159
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
|
|
4160
|
-
}
|
|
4161
|
-
return [
|
|
4162
|
-
2,
|
|
4163
|
-
"break"
|
|
4164
|
-
];
|
|
4165
|
-
}
|
|
4166
|
-
maxQueueSize = 3;
|
|
4167
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4168
|
-
3,
|
|
4169
|
-
2
|
|
4170
|
-
];
|
|
4171
|
-
if (_this.config.debugAdTiming) {
|
|
4172
|
-
console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
|
|
4173
|
-
}
|
|
4174
|
-
return [
|
|
4175
|
-
4,
|
|
4176
|
-
new Promise(function(resolve) {
|
|
4177
|
-
return setTimeout(resolve, 2e3);
|
|
4178
|
-
})
|
|
4179
|
-
];
|
|
4180
|
-
case 1:
|
|
4181
|
-
_state.sent();
|
|
4182
|
-
return [
|
|
4183
|
-
2,
|
|
4184
|
-
"continue"
|
|
4185
|
-
];
|
|
4186
|
-
case 2:
|
|
4187
|
-
newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4188
|
-
if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
|
|
4189
|
-
3,
|
|
4190
|
-
4
|
|
4191
|
-
];
|
|
4192
|
-
return [
|
|
4193
|
-
4,
|
|
4194
|
-
new Promise(function(resolve) {
|
|
4195
|
-
return setTimeout(resolve, 1e3);
|
|
4196
|
-
})
|
|
4197
|
-
];
|
|
4198
|
-
case 3:
|
|
4199
|
-
_state.sent();
|
|
4200
|
-
return [
|
|
4201
|
-
2,
|
|
4202
|
-
"continue"
|
|
4203
|
-
];
|
|
4204
|
-
case 4:
|
|
4205
|
-
_this.totalAdRequestsInBreak++;
|
|
4206
|
-
if (_this.config.debugAdTiming) {
|
|
4207
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
|
|
4208
|
-
}
|
|
4209
|
-
_state.label = 5;
|
|
4210
|
-
case 5:
|
|
4211
|
-
_state.trys.push([
|
|
4212
|
-
5,
|
|
4213
|
-
11,
|
|
4214
|
-
,
|
|
4215
|
-
13
|
|
4216
|
-
]);
|
|
4217
|
-
if (!_this.ima.preloadAds) return [
|
|
4218
|
-
3,
|
|
4219
|
-
7
|
|
4220
|
-
];
|
|
4221
|
-
return [
|
|
4222
|
-
4,
|
|
4223
|
-
_this.ima.preloadAds(newAdUrl)
|
|
4224
|
-
];
|
|
4225
|
-
case 6:
|
|
4226
|
-
_state.sent();
|
|
4227
|
-
_state.label = 7;
|
|
4228
|
-
case 7:
|
|
4229
|
-
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;
|
|
4230
|
-
if (!!hasPreloadedAd) return [
|
|
4231
|
-
3,
|
|
4232
|
-
9
|
|
4233
|
-
];
|
|
4234
|
-
_this.consecutiveEmptyResponses++;
|
|
4235
|
-
_this.lastEmptyResponseTimeMs = Date.now();
|
|
4236
|
-
backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4237
|
-
if (_this.config.debugAdTiming) {
|
|
4238
|
-
console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
|
|
4239
|
-
}
|
|
4240
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4241
|
-
return [
|
|
4242
|
-
4,
|
|
4243
|
-
new Promise(function(resolve) {
|
|
4244
|
-
return setTimeout(resolve, backoffDelay);
|
|
4245
|
-
})
|
|
4246
|
-
];
|
|
4247
|
-
case 8:
|
|
4248
|
-
_state.sent();
|
|
4249
|
-
return [
|
|
4250
|
-
2,
|
|
4251
|
-
"continue"
|
|
4252
|
-
];
|
|
4253
|
-
case 9:
|
|
4254
|
-
_this.consecutiveEmptyResponses = 0;
|
|
4255
|
-
if (_this.config.debugAdTiming) {
|
|
4256
|
-
console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
|
|
4257
|
-
}
|
|
4258
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
4259
|
-
_this.totalAdsInBreak++;
|
|
4260
|
-
return [
|
|
4261
|
-
4,
|
|
4262
|
-
new Promise(function(resolve) {
|
|
4263
|
-
return setTimeout(resolve, 500);
|
|
4264
|
-
})
|
|
4265
|
-
];
|
|
4266
|
-
case 10:
|
|
4267
|
-
_state.sent();
|
|
4268
|
-
return [
|
|
4269
|
-
3,
|
|
4270
|
-
13
|
|
4271
|
-
];
|
|
4272
|
-
case 11:
|
|
4273
|
-
error = _state.sent();
|
|
4274
|
-
if (_this.config.debugAdTiming) {
|
|
4275
|
-
console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
|
|
4276
|
-
}
|
|
4277
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4278
|
-
_this.consecutiveEmptyResponses++;
|
|
4279
|
-
backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4280
|
-
return [
|
|
4281
|
-
4,
|
|
4282
|
-
new Promise(function(resolve) {
|
|
4283
|
-
return setTimeout(resolve, backoffDelay1);
|
|
4284
|
-
})
|
|
4285
|
-
];
|
|
4286
|
-
case 12:
|
|
4287
|
-
_state.sent();
|
|
4288
|
-
return [
|
|
4289
|
-
3,
|
|
4290
|
-
13
|
|
4291
|
-
];
|
|
4292
|
-
case 13:
|
|
4293
|
-
return [
|
|
4294
|
-
2
|
|
4295
|
-
];
|
|
4296
|
-
}
|
|
4297
|
-
});
|
|
4298
|
-
};
|
|
4299
|
-
_state.label = 1;
|
|
4300
|
-
case 1:
|
|
4301
3980
|
if (!(this.continuousFetchingActive && this.inAdBreak)) return [
|
|
4302
3981
|
3,
|
|
4303
|
-
|
|
3982
|
+
6
|
|
4304
3983
|
];
|
|
4305
|
-
|
|
3984
|
+
remaining = this.getRemainingAdMs();
|
|
3985
|
+
if (remaining <= 0) {
|
|
3986
|
+
if (this.config.debugAdTiming) {
|
|
3987
|
+
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping URL generation");
|
|
3988
|
+
}
|
|
3989
|
+
return [
|
|
3990
|
+
3,
|
|
3991
|
+
6
|
|
3992
|
+
];
|
|
3993
|
+
}
|
|
3994
|
+
if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
|
|
3995
|
+
if (this.config.debugAdTiming) {
|
|
3996
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(this.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
3997
|
+
}
|
|
3998
|
+
return [
|
|
3999
|
+
3,
|
|
4000
|
+
6
|
|
4001
|
+
];
|
|
4002
|
+
}
|
|
4003
|
+
maxQueueSize = 5;
|
|
4004
|
+
if (!(this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4005
|
+
3,
|
|
4006
|
+
2
|
|
4007
|
+
];
|
|
4008
|
+
if (this.config.debugAdTiming) {
|
|
4009
|
+
console.log("[CONTINUOUS-FETCH] ⏸️ URL queue full (".concat(this.adRequestQueue.length, "), waiting..."));
|
|
4010
|
+
}
|
|
4306
4011
|
return [
|
|
4307
|
-
|
|
4308
|
-
|
|
4012
|
+
4,
|
|
4013
|
+
new Promise(function(resolve) {
|
|
4014
|
+
return setTimeout(resolve, 1e3);
|
|
4015
|
+
})
|
|
4016
|
+
];
|
|
4017
|
+
case 1:
|
|
4018
|
+
_state.sent();
|
|
4019
|
+
return [
|
|
4020
|
+
3,
|
|
4021
|
+
0
|
|
4309
4022
|
];
|
|
4310
4023
|
case 2:
|
|
4311
|
-
|
|
4312
|
-
if (
|
|
4024
|
+
newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4025
|
+
if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
|
|
4313
4026
|
3,
|
|
4314
|
-
|
|
4027
|
+
4
|
|
4315
4028
|
];
|
|
4316
4029
|
return [
|
|
4317
|
-
|
|
4318
|
-
|
|
4030
|
+
4,
|
|
4031
|
+
new Promise(function(resolve) {
|
|
4032
|
+
return setTimeout(resolve, 500);
|
|
4033
|
+
})
|
|
4319
4034
|
];
|
|
4320
4035
|
case 3:
|
|
4036
|
+
_state.sent();
|
|
4037
|
+
return [
|
|
4038
|
+
3,
|
|
4039
|
+
0
|
|
4040
|
+
];
|
|
4041
|
+
case 4:
|
|
4042
|
+
if (this.config.debugAdTiming) {
|
|
4043
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCDD Queued VAST URL (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
|
|
4044
|
+
}
|
|
4045
|
+
this.adRequestQueue.push(newAdUrl);
|
|
4046
|
+
this.totalAdsInBreak++;
|
|
4047
|
+
return [
|
|
4048
|
+
4,
|
|
4049
|
+
new Promise(function(resolve) {
|
|
4050
|
+
return setTimeout(resolve, 300);
|
|
4051
|
+
})
|
|
4052
|
+
];
|
|
4053
|
+
case 5:
|
|
4054
|
+
_state.sent();
|
|
4055
|
+
return [
|
|
4056
|
+
3,
|
|
4057
|
+
0
|
|
4058
|
+
];
|
|
4059
|
+
case 6:
|
|
4321
4060
|
if (this.config.debugAdTiming) {
|
|
4322
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1
|
|
4061
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"));
|
|
4323
4062
|
}
|
|
4324
4063
|
return [
|
|
4325
4064
|
2
|
|
@@ -4368,19 +4107,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4368
4107
|
2
|
|
4369
4108
|
];
|
|
4370
4109
|
if (this.config.debugAdTiming) {
|
|
4371
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC
|
|
4110
|
+
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)"));
|
|
4372
4111
|
}
|
|
4373
4112
|
currentMuted = this.video.muted;
|
|
4374
4113
|
currentVolume = this.video.volume;
|
|
4375
4114
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
4376
|
-
if (this.config.debugAdTiming) {
|
|
4377
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDD0A Updated ad audio state: muted=".concat(currentMuted, ", volume=").concat(currentVolume));
|
|
4378
|
-
}
|
|
4379
4115
|
this.currentAdIndex++;
|
|
4380
|
-
this.
|
|
4116
|
+
this.totalAdRequestsInBreak++;
|
|
4381
4117
|
return [
|
|
4382
4118
|
4,
|
|
4383
|
-
this.playSingleAd(nextAdUrl).catch(function() {
|
|
4119
|
+
this.playSingleAd(nextAdUrl).catch(function(error) {
|
|
4120
|
+
if (_this.config.debugAdTiming) {
|
|
4121
|
+
console.log("[CONTINUOUS-FETCH] \u274C Ad request failed:", error.message);
|
|
4122
|
+
}
|
|
4123
|
+
_this.failedVastUrls.add(nextAdUrl);
|
|
4384
4124
|
_this.tryNextAvailableAd(0);
|
|
4385
4125
|
})
|
|
4386
4126
|
];
|
|
@@ -4390,18 +4130,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4390
4130
|
2
|
|
4391
4131
|
];
|
|
4392
4132
|
case 2:
|
|
4393
|
-
maxRetries =
|
|
4133
|
+
maxRetries = 3;
|
|
4394
4134
|
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
4395
4135
|
3,
|
|
4396
4136
|
5
|
|
4397
4137
|
];
|
|
4398
4138
|
if (this.config.debugAdTiming) {
|
|
4399
|
-
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty
|
|
4139
|
+
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
4400
4140
|
}
|
|
4401
4141
|
return [
|
|
4402
4142
|
4,
|
|
4403
4143
|
new Promise(function(resolve) {
|
|
4404
|
-
return setTimeout(resolve,
|
|
4144
|
+
return setTimeout(resolve, 500);
|
|
4405
4145
|
})
|
|
4406
4146
|
];
|
|
4407
4147
|
case 3:
|
|
@@ -4450,12 +4190,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4450
4190
|
];
|
|
4451
4191
|
}
|
|
4452
4192
|
if (this.config.debugAdTiming) {
|
|
4453
|
-
console.log("[CONTINUOUS-FETCH] ⬛ Showing
|
|
4193
|
+
console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad URLs"));
|
|
4454
4194
|
}
|
|
4455
4195
|
this.isShowingPlaceholder = true;
|
|
4456
|
-
this.placeholderStartTimeMs = Date.now();
|
|
4457
4196
|
this.ima.showPlaceholder();
|
|
4458
|
-
checkInterval =
|
|
4197
|
+
checkInterval = 300;
|
|
4459
4198
|
maxChecks = Math.floor(waitTime / checkInterval);
|
|
4460
4199
|
i = 0;
|
|
4461
4200
|
_state.label = 1;
|
|
@@ -4482,10 +4221,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4482
4221
|
5
|
|
4483
4222
|
];
|
|
4484
4223
|
if (this.config.debugAdTiming) {
|
|
4485
|
-
console.log("[CONTINUOUS-FETCH] \u2705
|
|
4224
|
+
console.log("[CONTINUOUS-FETCH] \u2705 Ad URL available, requesting via IMA SDK");
|
|
4486
4225
|
}
|
|
4487
4226
|
this.isShowingPlaceholder = false;
|
|
4488
|
-
this.placeholderStartTimeMs = null;
|
|
4489
4227
|
this.ima.hidePlaceholder();
|
|
4490
4228
|
currentMuted = this.video.muted;
|
|
4491
4229
|
currentVolume = this.video.volume;
|
|
@@ -4496,7 +4234,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4496
4234
|
4
|
|
4497
4235
|
];
|
|
4498
4236
|
this.currentAdIndex++;
|
|
4499
|
-
this.
|
|
4237
|
+
this.totalAdRequestsInBreak++;
|
|
4500
4238
|
return [
|
|
4501
4239
|
4,
|
|
4502
4240
|
this.playSingleAd(nextAdUrl).catch(function() {
|
|
@@ -4518,10 +4256,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4518
4256
|
];
|
|
4519
4257
|
case 6:
|
|
4520
4258
|
if (this.config.debugAdTiming) {
|
|
4521
|
-
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout
|
|
4259
|
+
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
|
|
4522
4260
|
}
|
|
4523
4261
|
this.isShowingPlaceholder = false;
|
|
4524
|
-
this.placeholderStartTimeMs = null;
|
|
4525
4262
|
this.ima.hidePlaceholder();
|
|
4526
4263
|
this.handleAdPodComplete();
|
|
4527
4264
|
return [
|
|
@@ -4823,10 +4560,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4823
4560
|
if (this.isShowingPlaceholder) {
|
|
4824
4561
|
this.ima.hidePlaceholder();
|
|
4825
4562
|
this.isShowingPlaceholder = false;
|
|
4826
|
-
this.placeholderStartTimeMs = null;
|
|
4827
4563
|
}
|
|
4828
4564
|
this.adRequestQueue = [];
|
|
4829
|
-
this.successfulAdRequests = [];
|
|
4830
4565
|
this.inAdBreak = false;
|
|
4831
4566
|
this.expectedAdBreakDurationMs = void 0;
|
|
4832
4567
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
@@ -5205,7 +4940,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5205
4940
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5206
4941
|
(_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
|
|
5207
4942
|
this.adRequestQueue = [];
|
|
5208
|
-
this.successfulAdRequests = [];
|
|
5209
4943
|
}
|
|
5210
4944
|
}
|
|
5211
4945
|
]);
|