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
|
@@ -247,20 +247,6 @@ function _ts_generator(thisArg, body) {
|
|
|
247
247
|
};
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
|
-
function _ts_values(o) {
|
|
251
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
252
|
-
if (m) return m.call(o);
|
|
253
|
-
if (o && typeof o.length === "number") return {
|
|
254
|
-
next: function() {
|
|
255
|
-
if (o && i >= o.length) o = void 0;
|
|
256
|
-
return {
|
|
257
|
-
value: o && o[i++],
|
|
258
|
-
done: !o
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
263
|
-
}
|
|
264
250
|
var __create = Object.create;
|
|
265
251
|
var __defProp = Object.defineProperty;
|
|
266
252
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -495,8 +481,6 @@ function createImaController(video, options) {
|
|
|
495
481
|
var originalMutedState = false;
|
|
496
482
|
var originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
497
483
|
var listeners = /* @__PURE__ */ new Map();
|
|
498
|
-
var preloadedVast = /* @__PURE__ */ new Map();
|
|
499
|
-
var preloadingVast = /* @__PURE__ */ new Map();
|
|
500
484
|
var adVideoElement;
|
|
501
485
|
function setAdPlayingFlag(isPlaying) {
|
|
502
486
|
if (isPlaying) {
|
|
@@ -646,15 +630,8 @@ function createImaController(video, options) {
|
|
|
646
630
|
var adsLoadedReject;
|
|
647
631
|
function makeAdsRequest(google, vastTagUrl) {
|
|
648
632
|
var adsRequest = new google.ima.AdsRequest();
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
console.log("[IMA] \uD83D\uDCE6 Using preloaded VAST response");
|
|
652
|
-
adsRequest.adsResponse = preloadedXml;
|
|
653
|
-
preloadedVast.delete(vastTagUrl);
|
|
654
|
-
} else {
|
|
655
|
-
console.log("[IMA] \uD83D\uDCE1 Requesting VAST from URL (letting IMA fetch fresh)");
|
|
656
|
-
adsRequest.adTagUrl = vastTagUrl;
|
|
657
|
-
}
|
|
633
|
+
console.log("[IMA] \uD83D\uDCE1 Requesting VAST via IMA SDK:", vastTagUrl.substring(0, 80) + "...");
|
|
634
|
+
adsRequest.adTagUrl = vastTagUrl;
|
|
658
635
|
var videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
659
636
|
var videoHeight = video.offsetHeight || video.clientHeight || 480;
|
|
660
637
|
adsRequest.linearAdSlotWidth = videoWidth;
|
|
@@ -702,36 +679,6 @@ function createImaController(video, options) {
|
|
|
702
679
|
(_video_parentElement = video.parentElement) === null || _video_parentElement === void 0 ? void 0 : _video_parentElement.appendChild(container);
|
|
703
680
|
adContainerEl = container;
|
|
704
681
|
}
|
|
705
|
-
function fetchVastDocument(vastTagUrl) {
|
|
706
|
-
return _async_to_generator(function() {
|
|
707
|
-
var response;
|
|
708
|
-
return _ts_generator(this, function(_state) {
|
|
709
|
-
switch(_state.label){
|
|
710
|
-
case 0:
|
|
711
|
-
return [
|
|
712
|
-
4,
|
|
713
|
-
fetch(vastTagUrl, {
|
|
714
|
-
mode: "cors",
|
|
715
|
-
credentials: "include",
|
|
716
|
-
headers: {
|
|
717
|
-
"Accept": "application/xml, text/xml, */*"
|
|
718
|
-
},
|
|
719
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
720
|
-
})
|
|
721
|
-
];
|
|
722
|
-
case 1:
|
|
723
|
-
response = _state.sent();
|
|
724
|
-
if (!response.ok) {
|
|
725
|
-
throw new Error("Failed to preload VAST: ".concat(response.status));
|
|
726
|
-
}
|
|
727
|
-
return [
|
|
728
|
-
2,
|
|
729
|
-
response.text()
|
|
730
|
-
];
|
|
731
|
-
}
|
|
732
|
-
});
|
|
733
|
-
})();
|
|
734
|
-
}
|
|
735
682
|
function destroyAdsManager() {
|
|
736
683
|
if (adsManager) {
|
|
737
684
|
try {
|
|
@@ -1046,47 +993,6 @@ function createImaController(video, options) {
|
|
|
1046
993
|
});
|
|
1047
994
|
})();
|
|
1048
995
|
},
|
|
1049
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1050
|
-
return _async_to_generator(function() {
|
|
1051
|
-
var inflight, preloadPromise;
|
|
1052
|
-
return _ts_generator(this, function(_state) {
|
|
1053
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1054
|
-
return [
|
|
1055
|
-
2,
|
|
1056
|
-
Promise.resolve()
|
|
1057
|
-
];
|
|
1058
|
-
}
|
|
1059
|
-
if (preloadedVast.has(vastTagUrl)) {
|
|
1060
|
-
return [
|
|
1061
|
-
2,
|
|
1062
|
-
Promise.resolve()
|
|
1063
|
-
];
|
|
1064
|
-
}
|
|
1065
|
-
inflight = preloadingVast.get(vastTagUrl);
|
|
1066
|
-
if (inflight) {
|
|
1067
|
-
return [
|
|
1068
|
-
2,
|
|
1069
|
-
inflight
|
|
1070
|
-
];
|
|
1071
|
-
}
|
|
1072
|
-
preloadPromise = fetchVastDocument(vastTagUrl).then(function(xml) {
|
|
1073
|
-
preloadedVast.set(vastTagUrl, xml);
|
|
1074
|
-
}).catch(function() {
|
|
1075
|
-
preloadedVast.delete(vastTagUrl);
|
|
1076
|
-
}).finally(function() {
|
|
1077
|
-
preloadingVast.delete(vastTagUrl);
|
|
1078
|
-
});
|
|
1079
|
-
preloadingVast.set(vastTagUrl, preloadPromise);
|
|
1080
|
-
return [
|
|
1081
|
-
2,
|
|
1082
|
-
preloadPromise
|
|
1083
|
-
];
|
|
1084
|
-
});
|
|
1085
|
-
})();
|
|
1086
|
-
},
|
|
1087
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1088
|
-
return preloadedVast.has(vastTagUrl);
|
|
1089
|
-
},
|
|
1090
996
|
play: function play() {
|
|
1091
997
|
return _async_to_generator(function() {
|
|
1092
998
|
var _window_google, width, height, adVolume, _video_play;
|
|
@@ -1195,8 +1101,6 @@ function createImaController(video, options) {
|
|
|
1195
1101
|
adDisplayContainer = void 0;
|
|
1196
1102
|
adsLoader = void 0;
|
|
1197
1103
|
contentVideoHidden = false;
|
|
1198
|
-
preloadedVast.clear();
|
|
1199
|
-
preloadingVast.clear();
|
|
1200
1104
|
},
|
|
1201
1105
|
isAdPlaying: function isAdPlaying() {
|
|
1202
1106
|
return adPlaying;
|
|
@@ -1797,51 +1701,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1797
1701
|
});
|
|
1798
1702
|
})();
|
|
1799
1703
|
},
|
|
1800
|
-
preloadAds: function preloadAds(vastTagUrl) {
|
|
1801
|
-
return _async_to_generator(function() {
|
|
1802
|
-
var inflight, preloadPromise;
|
|
1803
|
-
return _ts_generator(this, function(_state) {
|
|
1804
|
-
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
1805
|
-
return [
|
|
1806
|
-
2,
|
|
1807
|
-
Promise.resolve()
|
|
1808
|
-
];
|
|
1809
|
-
}
|
|
1810
|
-
if (preloadedAds.has(vastTagUrl)) {
|
|
1811
|
-
return [
|
|
1812
|
-
2,
|
|
1813
|
-
Promise.resolve()
|
|
1814
|
-
];
|
|
1815
|
-
}
|
|
1816
|
-
inflight = preloadingAds.get(vastTagUrl);
|
|
1817
|
-
if (inflight) {
|
|
1818
|
-
return [
|
|
1819
|
-
2,
|
|
1820
|
-
inflight
|
|
1821
|
-
];
|
|
1822
|
-
}
|
|
1823
|
-
preloadPromise = fetchAndParseVastAd(vastTagUrl).then(function(ad) {
|
|
1824
|
-
if (ad) {
|
|
1825
|
-
preloadedAds.set(vastTagUrl, ad);
|
|
1826
|
-
console.log("[HlsAdPlayer] Cached VAST response for preloading:", vastTagUrl);
|
|
1827
|
-
}
|
|
1828
|
-
}).catch(function(error) {
|
|
1829
|
-
console.warn("[HlsAdPlayer] Failed to preload VAST response:", error);
|
|
1830
|
-
preloadedAds.delete(vastTagUrl);
|
|
1831
|
-
}).finally(function() {
|
|
1832
|
-
preloadingAds.delete(vastTagUrl);
|
|
1833
|
-
});
|
|
1834
|
-
preloadingAds.set(vastTagUrl, preloadPromise);
|
|
1835
|
-
return [
|
|
1836
|
-
2,
|
|
1837
|
-
preloadPromise
|
|
1838
|
-
];
|
|
1839
|
-
});
|
|
1840
|
-
})();
|
|
1841
|
-
},
|
|
1842
|
-
hasPreloadedAd: function hasPreloadedAd(vastTagUrl) {
|
|
1843
|
-
return preloadedAds.has(vastTagUrl);
|
|
1844
|
-
},
|
|
1845
1704
|
play: function play() {
|
|
1846
1705
|
return _async_to_generator(function() {
|
|
1847
1706
|
var contentVolume, adVolume, mediaFile;
|
|
@@ -2740,17 +2599,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2740
2599
|
this.failedVastUrls = /* @__PURE__ */ new Set();
|
|
2741
2600
|
this.continuousFetchingActive = false;
|
|
2742
2601
|
this.adRequestQueue = [];
|
|
2743
|
-
this.successfulAdRequests = [];
|
|
2744
2602
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2745
|
-
this.placeholderStartTimeMs = null;
|
|
2746
2603
|
this.isShowingPlaceholder = false;
|
|
2747
|
-
this.consecutiveEmptyResponses = 0;
|
|
2748
2604
|
this.totalAdRequestsInBreak = 0;
|
|
2749
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
2750
2605
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2751
|
-
this.maxConsecutiveEmptyResponses = 5;
|
|
2752
|
-
this.baseEmptyResponseDelayMs = 2e3;
|
|
2753
|
-
this.maxEmptyResponseDelayMs = 3e4;
|
|
2754
2606
|
initializePolyfills();
|
|
2755
2607
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2756
2608
|
this.config = _object_spread({}, config, browserOverrides);
|
|
@@ -3995,13 +3847,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3995
3847
|
}
|
|
3996
3848
|
this.failedVastUrls.clear();
|
|
3997
3849
|
this.adRequestQueue = [];
|
|
3998
|
-
this.successfulAdRequests = [];
|
|
3999
3850
|
this.continuousFetchingActive = true;
|
|
4000
3851
|
this.isShowingPlaceholder = false;
|
|
4001
|
-
this.placeholderStartTimeMs = null;
|
|
4002
|
-
this.consecutiveEmptyResponses = 0;
|
|
4003
3852
|
this.totalAdRequestsInBreak = 0;
|
|
4004
|
-
this.lastEmptyResponseTimeMs = 0;
|
|
4005
3853
|
currentMuted = this.video.muted;
|
|
4006
3854
|
currentVolume = this.video.volume;
|
|
4007
3855
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
@@ -4047,7 +3895,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4047
3895
|
if (this.config.debugAdTiming) {
|
|
4048
3896
|
console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
|
|
4049
3897
|
}
|
|
4050
|
-
this.successfulAdRequests.push(firstAdUrl);
|
|
4051
3898
|
this.currentAdIndex++;
|
|
4052
3899
|
this.startContinuousFetching(baseVastUrl);
|
|
4053
3900
|
return [
|
|
@@ -4097,200 +3944,92 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4097
3944
|
key: "continuousFetchLoop",
|
|
4098
3945
|
value: function continuousFetchLoop(baseVastUrl) {
|
|
4099
3946
|
return _async_to_generator(function() {
|
|
4100
|
-
var
|
|
3947
|
+
var remaining, maxQueueSize, newAdUrl;
|
|
4101
3948
|
return _ts_generator(this, function(_state) {
|
|
4102
3949
|
switch(_state.label){
|
|
4103
3950
|
case 0:
|
|
4104
|
-
_loop = function() {
|
|
4105
|
-
var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
|
|
4106
|
-
return _ts_generator(this, function(_state) {
|
|
4107
|
-
switch(_state.label){
|
|
4108
|
-
case 0:
|
|
4109
|
-
remaining = _this.getRemainingAdMs();
|
|
4110
|
-
if (remaining <= 0) {
|
|
4111
|
-
if (_this.config.debugAdTiming) {
|
|
4112
|
-
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
|
|
4113
|
-
}
|
|
4114
|
-
return [
|
|
4115
|
-
2,
|
|
4116
|
-
"break"
|
|
4117
|
-
];
|
|
4118
|
-
}
|
|
4119
|
-
if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
|
|
4120
|
-
if (_this.config.debugAdTiming) {
|
|
4121
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
|
|
4122
|
-
}
|
|
4123
|
-
return [
|
|
4124
|
-
2,
|
|
4125
|
-
"break"
|
|
4126
|
-
];
|
|
4127
|
-
}
|
|
4128
|
-
if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
|
|
4129
|
-
if (_this.config.debugAdTiming) {
|
|
4130
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
|
|
4131
|
-
}
|
|
4132
|
-
return [
|
|
4133
|
-
2,
|
|
4134
|
-
"break"
|
|
4135
|
-
];
|
|
4136
|
-
}
|
|
4137
|
-
maxQueueSize = 3;
|
|
4138
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4139
|
-
3,
|
|
4140
|
-
2
|
|
4141
|
-
];
|
|
4142
|
-
if (_this.config.debugAdTiming) {
|
|
4143
|
-
console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
|
|
4144
|
-
}
|
|
4145
|
-
return [
|
|
4146
|
-
4,
|
|
4147
|
-
new Promise(function(resolve) {
|
|
4148
|
-
return setTimeout(resolve, 2e3);
|
|
4149
|
-
})
|
|
4150
|
-
];
|
|
4151
|
-
case 1:
|
|
4152
|
-
_state.sent();
|
|
4153
|
-
return [
|
|
4154
|
-
2,
|
|
4155
|
-
"continue"
|
|
4156
|
-
];
|
|
4157
|
-
case 2:
|
|
4158
|
-
newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4159
|
-
if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
|
|
4160
|
-
3,
|
|
4161
|
-
4
|
|
4162
|
-
];
|
|
4163
|
-
return [
|
|
4164
|
-
4,
|
|
4165
|
-
new Promise(function(resolve) {
|
|
4166
|
-
return setTimeout(resolve, 1e3);
|
|
4167
|
-
})
|
|
4168
|
-
];
|
|
4169
|
-
case 3:
|
|
4170
|
-
_state.sent();
|
|
4171
|
-
return [
|
|
4172
|
-
2,
|
|
4173
|
-
"continue"
|
|
4174
|
-
];
|
|
4175
|
-
case 4:
|
|
4176
|
-
_this.totalAdRequestsInBreak++;
|
|
4177
|
-
if (_this.config.debugAdTiming) {
|
|
4178
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
|
|
4179
|
-
}
|
|
4180
|
-
_state.label = 5;
|
|
4181
|
-
case 5:
|
|
4182
|
-
_state.trys.push([
|
|
4183
|
-
5,
|
|
4184
|
-
11,
|
|
4185
|
-
,
|
|
4186
|
-
13
|
|
4187
|
-
]);
|
|
4188
|
-
if (!_this.ima.preloadAds) return [
|
|
4189
|
-
3,
|
|
4190
|
-
7
|
|
4191
|
-
];
|
|
4192
|
-
return [
|
|
4193
|
-
4,
|
|
4194
|
-
_this.ima.preloadAds(newAdUrl)
|
|
4195
|
-
];
|
|
4196
|
-
case 6:
|
|
4197
|
-
_state.sent();
|
|
4198
|
-
_state.label = 7;
|
|
4199
|
-
case 7:
|
|
4200
|
-
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;
|
|
4201
|
-
if (!!hasPreloadedAd) return [
|
|
4202
|
-
3,
|
|
4203
|
-
9
|
|
4204
|
-
];
|
|
4205
|
-
_this.consecutiveEmptyResponses++;
|
|
4206
|
-
_this.lastEmptyResponseTimeMs = Date.now();
|
|
4207
|
-
backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4208
|
-
if (_this.config.debugAdTiming) {
|
|
4209
|
-
console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
|
|
4210
|
-
}
|
|
4211
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4212
|
-
return [
|
|
4213
|
-
4,
|
|
4214
|
-
new Promise(function(resolve) {
|
|
4215
|
-
return setTimeout(resolve, backoffDelay);
|
|
4216
|
-
})
|
|
4217
|
-
];
|
|
4218
|
-
case 8:
|
|
4219
|
-
_state.sent();
|
|
4220
|
-
return [
|
|
4221
|
-
2,
|
|
4222
|
-
"continue"
|
|
4223
|
-
];
|
|
4224
|
-
case 9:
|
|
4225
|
-
_this.consecutiveEmptyResponses = 0;
|
|
4226
|
-
if (_this.config.debugAdTiming) {
|
|
4227
|
-
console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
|
|
4228
|
-
}
|
|
4229
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
4230
|
-
_this.totalAdsInBreak++;
|
|
4231
|
-
return [
|
|
4232
|
-
4,
|
|
4233
|
-
new Promise(function(resolve) {
|
|
4234
|
-
return setTimeout(resolve, 500);
|
|
4235
|
-
})
|
|
4236
|
-
];
|
|
4237
|
-
case 10:
|
|
4238
|
-
_state.sent();
|
|
4239
|
-
return [
|
|
4240
|
-
3,
|
|
4241
|
-
13
|
|
4242
|
-
];
|
|
4243
|
-
case 11:
|
|
4244
|
-
error = _state.sent();
|
|
4245
|
-
if (_this.config.debugAdTiming) {
|
|
4246
|
-
console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
|
|
4247
|
-
}
|
|
4248
|
-
_this.failedVastUrls.add(newAdUrl);
|
|
4249
|
-
_this.consecutiveEmptyResponses++;
|
|
4250
|
-
backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4251
|
-
return [
|
|
4252
|
-
4,
|
|
4253
|
-
new Promise(function(resolve) {
|
|
4254
|
-
return setTimeout(resolve, backoffDelay1);
|
|
4255
|
-
})
|
|
4256
|
-
];
|
|
4257
|
-
case 12:
|
|
4258
|
-
_state.sent();
|
|
4259
|
-
return [
|
|
4260
|
-
3,
|
|
4261
|
-
13
|
|
4262
|
-
];
|
|
4263
|
-
case 13:
|
|
4264
|
-
return [
|
|
4265
|
-
2
|
|
4266
|
-
];
|
|
4267
|
-
}
|
|
4268
|
-
});
|
|
4269
|
-
};
|
|
4270
|
-
_state.label = 1;
|
|
4271
|
-
case 1:
|
|
4272
3951
|
if (!(this.continuousFetchingActive && this.inAdBreak)) return [
|
|
4273
3952
|
3,
|
|
4274
|
-
|
|
3953
|
+
6
|
|
4275
3954
|
];
|
|
4276
|
-
|
|
3955
|
+
remaining = this.getRemainingAdMs();
|
|
3956
|
+
if (remaining <= 0) {
|
|
3957
|
+
if (this.config.debugAdTiming) {
|
|
3958
|
+
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping URL generation");
|
|
3959
|
+
}
|
|
3960
|
+
return [
|
|
3961
|
+
3,
|
|
3962
|
+
6
|
|
3963
|
+
];
|
|
3964
|
+
}
|
|
3965
|
+
if (this.totalAdRequestsInBreak >= this.maxTotalAdRequestsPerBreak) {
|
|
3966
|
+
if (this.config.debugAdTiming) {
|
|
3967
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(this.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
3968
|
+
}
|
|
3969
|
+
return [
|
|
3970
|
+
3,
|
|
3971
|
+
6
|
|
3972
|
+
];
|
|
3973
|
+
}
|
|
3974
|
+
maxQueueSize = 5;
|
|
3975
|
+
if (!(this.adRequestQueue.length >= maxQueueSize)) return [
|
|
3976
|
+
3,
|
|
3977
|
+
2
|
|
3978
|
+
];
|
|
3979
|
+
if (this.config.debugAdTiming) {
|
|
3980
|
+
console.log("[CONTINUOUS-FETCH] ⏸️ URL queue full (".concat(this.adRequestQueue.length, "), waiting..."));
|
|
3981
|
+
}
|
|
4277
3982
|
return [
|
|
4278
|
-
|
|
4279
|
-
|
|
3983
|
+
4,
|
|
3984
|
+
new Promise(function(resolve) {
|
|
3985
|
+
return setTimeout(resolve, 1e3);
|
|
3986
|
+
})
|
|
3987
|
+
];
|
|
3988
|
+
case 1:
|
|
3989
|
+
_state.sent();
|
|
3990
|
+
return [
|
|
3991
|
+
3,
|
|
3992
|
+
0
|
|
4280
3993
|
];
|
|
4281
3994
|
case 2:
|
|
4282
|
-
|
|
4283
|
-
if (
|
|
3995
|
+
newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
3996
|
+
if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
|
|
4284
3997
|
3,
|
|
4285
|
-
|
|
3998
|
+
4
|
|
4286
3999
|
];
|
|
4287
4000
|
return [
|
|
4288
|
-
|
|
4289
|
-
|
|
4001
|
+
4,
|
|
4002
|
+
new Promise(function(resolve) {
|
|
4003
|
+
return setTimeout(resolve, 500);
|
|
4004
|
+
})
|
|
4290
4005
|
];
|
|
4291
4006
|
case 3:
|
|
4007
|
+
_state.sent();
|
|
4008
|
+
return [
|
|
4009
|
+
3,
|
|
4010
|
+
0
|
|
4011
|
+
];
|
|
4012
|
+
case 4:
|
|
4013
|
+
if (this.config.debugAdTiming) {
|
|
4014
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCDD Queued VAST URL (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
|
|
4015
|
+
}
|
|
4016
|
+
this.adRequestQueue.push(newAdUrl);
|
|
4017
|
+
this.totalAdsInBreak++;
|
|
4018
|
+
return [
|
|
4019
|
+
4,
|
|
4020
|
+
new Promise(function(resolve) {
|
|
4021
|
+
return setTimeout(resolve, 300);
|
|
4022
|
+
})
|
|
4023
|
+
];
|
|
4024
|
+
case 5:
|
|
4025
|
+
_state.sent();
|
|
4026
|
+
return [
|
|
4027
|
+
3,
|
|
4028
|
+
0
|
|
4029
|
+
];
|
|
4030
|
+
case 6:
|
|
4292
4031
|
if (this.config.debugAdTiming) {
|
|
4293
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1
|
|
4032
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"));
|
|
4294
4033
|
}
|
|
4295
4034
|
return [
|
|
4296
4035
|
2
|
|
@@ -4339,19 +4078,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4339
4078
|
2
|
|
4340
4079
|
];
|
|
4341
4080
|
if (this.config.debugAdTiming) {
|
|
4342
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC
|
|
4081
|
+
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)"));
|
|
4343
4082
|
}
|
|
4344
4083
|
currentMuted = this.video.muted;
|
|
4345
4084
|
currentVolume = this.video.volume;
|
|
4346
4085
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
4347
|
-
if (this.config.debugAdTiming) {
|
|
4348
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDD0A Updated ad audio state: muted=".concat(currentMuted, ", volume=").concat(currentVolume));
|
|
4349
|
-
}
|
|
4350
4086
|
this.currentAdIndex++;
|
|
4351
|
-
this.
|
|
4087
|
+
this.totalAdRequestsInBreak++;
|
|
4352
4088
|
return [
|
|
4353
4089
|
4,
|
|
4354
|
-
this.playSingleAd(nextAdUrl).catch(function() {
|
|
4090
|
+
this.playSingleAd(nextAdUrl).catch(function(error) {
|
|
4091
|
+
if (_this.config.debugAdTiming) {
|
|
4092
|
+
console.log("[CONTINUOUS-FETCH] \u274C Ad request failed:", error.message);
|
|
4093
|
+
}
|
|
4094
|
+
_this.failedVastUrls.add(nextAdUrl);
|
|
4355
4095
|
_this.tryNextAvailableAd(0);
|
|
4356
4096
|
})
|
|
4357
4097
|
];
|
|
@@ -4361,18 +4101,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4361
4101
|
2
|
|
4362
4102
|
];
|
|
4363
4103
|
case 2:
|
|
4364
|
-
maxRetries =
|
|
4104
|
+
maxRetries = 3;
|
|
4365
4105
|
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
4366
4106
|
3,
|
|
4367
4107
|
5
|
|
4368
4108
|
];
|
|
4369
4109
|
if (this.config.debugAdTiming) {
|
|
4370
|
-
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty
|
|
4110
|
+
console.log("[CONTINUOUS-FETCH] ⏳ Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
4371
4111
|
}
|
|
4372
4112
|
return [
|
|
4373
4113
|
4,
|
|
4374
4114
|
new Promise(function(resolve) {
|
|
4375
|
-
return setTimeout(resolve,
|
|
4115
|
+
return setTimeout(resolve, 500);
|
|
4376
4116
|
})
|
|
4377
4117
|
];
|
|
4378
4118
|
case 3:
|
|
@@ -4421,12 +4161,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4421
4161
|
];
|
|
4422
4162
|
}
|
|
4423
4163
|
if (this.config.debugAdTiming) {
|
|
4424
|
-
console.log("[CONTINUOUS-FETCH] ⬛ Showing
|
|
4164
|
+
console.log("[CONTINUOUS-FETCH] ⬛ Showing placeholder for ".concat(waitTime, "ms while waiting for ad URLs"));
|
|
4425
4165
|
}
|
|
4426
4166
|
this.isShowingPlaceholder = true;
|
|
4427
|
-
this.placeholderStartTimeMs = Date.now();
|
|
4428
4167
|
this.ima.showPlaceholder();
|
|
4429
|
-
checkInterval =
|
|
4168
|
+
checkInterval = 300;
|
|
4430
4169
|
maxChecks = Math.floor(waitTime / checkInterval);
|
|
4431
4170
|
i = 0;
|
|
4432
4171
|
_state.label = 1;
|
|
@@ -4453,10 +4192,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4453
4192
|
5
|
|
4454
4193
|
];
|
|
4455
4194
|
if (this.config.debugAdTiming) {
|
|
4456
|
-
console.log("[CONTINUOUS-FETCH] \u2705
|
|
4195
|
+
console.log("[CONTINUOUS-FETCH] \u2705 Ad URL available, requesting via IMA SDK");
|
|
4457
4196
|
}
|
|
4458
4197
|
this.isShowingPlaceholder = false;
|
|
4459
|
-
this.placeholderStartTimeMs = null;
|
|
4460
4198
|
this.ima.hidePlaceholder();
|
|
4461
4199
|
currentMuted = this.video.muted;
|
|
4462
4200
|
currentVolume = this.video.volume;
|
|
@@ -4467,7 +4205,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4467
4205
|
4
|
|
4468
4206
|
];
|
|
4469
4207
|
this.currentAdIndex++;
|
|
4470
|
-
this.
|
|
4208
|
+
this.totalAdRequestsInBreak++;
|
|
4471
4209
|
return [
|
|
4472
4210
|
4,
|
|
4473
4211
|
this.playSingleAd(nextAdUrl).catch(function() {
|
|
@@ -4489,10 +4227,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4489
4227
|
];
|
|
4490
4228
|
case 6:
|
|
4491
4229
|
if (this.config.debugAdTiming) {
|
|
4492
|
-
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout
|
|
4230
|
+
console.log("[CONTINUOUS-FETCH] \u23F0 Placeholder timeout, ending ad break");
|
|
4493
4231
|
}
|
|
4494
4232
|
this.isShowingPlaceholder = false;
|
|
4495
|
-
this.placeholderStartTimeMs = null;
|
|
4496
4233
|
this.ima.hidePlaceholder();
|
|
4497
4234
|
this.handleAdPodComplete();
|
|
4498
4235
|
return [
|
|
@@ -4794,10 +4531,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4794
4531
|
if (this.isShowingPlaceholder) {
|
|
4795
4532
|
this.ima.hidePlaceholder();
|
|
4796
4533
|
this.isShowingPlaceholder = false;
|
|
4797
|
-
this.placeholderStartTimeMs = null;
|
|
4798
4534
|
}
|
|
4799
4535
|
this.adRequestQueue = [];
|
|
4800
|
-
this.successfulAdRequests = [];
|
|
4801
4536
|
this.inAdBreak = false;
|
|
4802
4537
|
this.expectedAdBreakDurationMs = void 0;
|
|
4803
4538
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
@@ -5176,7 +4911,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5176
4911
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5177
4912
|
(_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
|
|
5178
4913
|
this.adRequestQueue = [];
|
|
5179
|
-
this.successfulAdRequests = [];
|
|
5180
4914
|
}
|
|
5181
4915
|
}
|
|
5182
4916
|
]);
|