stormcloud-video-player 0.3.20 → 0.3.21
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 +17 -706
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +0 -17
- package/lib/index.d.ts +0 -17
- package/lib/index.js +17 -706
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +17 -718
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +0 -17
- package/lib/players/FilePlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +17 -706
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +17 -706
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/ima.cjs +11 -4
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +17 -718
- package/lib/ui/StormcloudVideoPlayer.cjs.map +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/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -700,10 +700,17 @@ function createImaController(video, options) {
|
|
|
700
700
|
var adsLoadedReject;
|
|
701
701
|
function makeAdsRequest(google, vastTagUrl) {
|
|
702
702
|
var adsRequest = new google.ima.AdsRequest();
|
|
703
|
-
|
|
704
|
-
|
|
703
|
+
var preloadedXml = preloadedVast.get(vastTagUrl);
|
|
704
|
+
if (preloadedXml) {
|
|
705
|
+
console.log("[IMA] \uD83D\uDCE6 Using preloaded VAST response");
|
|
706
|
+
adsRequest.adsResponse = preloadedXml;
|
|
707
|
+
preloadedVast.delete(vastTagUrl);
|
|
708
|
+
} else {
|
|
709
|
+
console.log("[IMA] \uD83D\uDCE1 Requesting VAST from URL (letting IMA fetch fresh)");
|
|
710
|
+
adsRequest.adTagUrl = vastTagUrl;
|
|
711
|
+
}
|
|
705
712
|
var videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
706
|
-
var videoHeight = video.offsetHeight || video.clientHeight ||
|
|
713
|
+
var videoHeight = video.offsetHeight || video.clientHeight || 480;
|
|
707
714
|
adsRequest.linearAdSlotWidth = videoWidth;
|
|
708
715
|
adsRequest.linearAdSlotHeight = videoHeight;
|
|
709
716
|
adsRequest.nonLinearAdSlotWidth = videoWidth;
|
|
@@ -1152,7 +1159,7 @@ function createImaController(video, options) {
|
|
|
1152
1159
|
}
|
|
1153
1160
|
try {
|
|
1154
1161
|
width = video.clientWidth || 640;
|
|
1155
|
-
height = video.clientHeight ||
|
|
1162
|
+
height = video.clientHeight || 480;
|
|
1156
1163
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
1157
1164
|
adPlaying = true;
|
|
1158
1165
|
adVolume = originalMutedState ? 0 : originalVolume;
|
|
@@ -2783,18 +2790,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2783
2790
|
this.bufferedSegmentsCount = 0;
|
|
2784
2791
|
this.shouldAutoplayAfterBuffering = false;
|
|
2785
2792
|
this.hasInitialBufferCompleted = false;
|
|
2786
|
-
this.adPodAllUrls = [];
|
|
2787
|
-
this.preloadingAdUrls = /* @__PURE__ */ new Set();
|
|
2788
|
-
this.vastToMediaUrlMap = /* @__PURE__ */ new Map();
|
|
2789
|
-
this.preloadedMediaUrls = /* @__PURE__ */ new Set();
|
|
2790
|
-
this.preloadingMediaUrls = /* @__PURE__ */ new Set();
|
|
2791
2793
|
this.adRequestTokenCounter = 0;
|
|
2792
2794
|
this.activeAdRequestToken = null;
|
|
2793
2795
|
this.adRequestWatchdogToken = null;
|
|
2794
2796
|
this.adFailsafeToken = null;
|
|
2795
|
-
this.fetchedAdDurations = /* @__PURE__ */ new Map();
|
|
2796
|
-
this.targetAdBreakDurationMs = null;
|
|
2797
|
-
this.isAdaptiveMode = false;
|
|
2798
2797
|
this.failedVastUrls = /* @__PURE__ */ new Set();
|
|
2799
2798
|
this.continuousFetchingActive = false;
|
|
2800
2799
|
this.adRequestQueue = [];
|
|
@@ -3299,25 +3298,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3299
3298
|
}
|
|
3300
3299
|
});
|
|
3301
3300
|
this.ima.on("ad_error", function(errorPayload) {
|
|
3302
|
-
var remaining = _this.getRemainingAdMs();
|
|
3303
3301
|
console.error("[AD-ERROR] Ad playback failed", errorPayload || "");
|
|
3304
|
-
|
|
3305
|
-
if (remaining > 500 && _this.adPodQueue.length > 0) {
|
|
3306
|
-
var nextPreloaded = _this.findNextPreloadedAd();
|
|
3307
|
-
if (nextPreloaded) {
|
|
3308
|
-
_this.currentAdIndex++;
|
|
3309
|
-
_this.playSingleAd(nextPreloaded).catch(function() {
|
|
3310
|
-
_this.handleAdFailure();
|
|
3311
|
-
});
|
|
3312
|
-
} else {
|
|
3313
|
-
_this.handleAdFailure();
|
|
3314
|
-
}
|
|
3315
|
-
} else {
|
|
3316
|
-
_this.handleAdFailure();
|
|
3317
|
-
}
|
|
3318
|
-
} else {
|
|
3319
|
-
_this.handleAdFailure();
|
|
3320
|
-
}
|
|
3302
|
+
_this.handleAdFailure();
|
|
3321
3303
|
});
|
|
3322
3304
|
this.ima.on("content_pause", function() {
|
|
3323
3305
|
_this.clearAdFailsafeTimer();
|
|
@@ -4048,7 +4030,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4048
4030
|
key: "handleAdStart",
|
|
4049
4031
|
value: function handleAdStart(_marker) {
|
|
4050
4032
|
return _async_to_generator(function() {
|
|
4051
|
-
var scheduled, tags, baseVastUrl, adBreakDurationMs, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
4033
|
+
var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
4052
4034
|
return _ts_generator(this, function(_state) {
|
|
4053
4035
|
switch(_state.label){
|
|
4054
4036
|
case 0:
|
|
@@ -4064,26 +4046,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4064
4046
|
];
|
|
4065
4047
|
}
|
|
4066
4048
|
adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
|
|
4067
|
-
if (this.
|
|
4068
|
-
this.
|
|
4069
|
-
|
|
4070
|
-
this.fetchedAdDurations.clear();
|
|
4071
|
-
if (this.config.debugAdTiming) {
|
|
4072
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA LIVE MODE: Target duration=".concat(adBreakDurationMs, "ms | Will continuously fetch ads during break"));
|
|
4073
|
-
}
|
|
4074
|
-
} else {
|
|
4075
|
-
this.isAdaptiveMode = false;
|
|
4076
|
-
this.targetAdBreakDurationMs = null;
|
|
4077
|
-
this.fetchedAdDurations.clear();
|
|
4078
|
-
if (this.config.debugAdTiming) {
|
|
4079
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC VOD MODE: Using fixed ad strategy");
|
|
4080
|
-
}
|
|
4049
|
+
if (this.config.debugAdTiming) {
|
|
4050
|
+
mode = this.isLiveStream ? "LIVE" : "VOD";
|
|
4051
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
4081
4052
|
}
|
|
4082
|
-
this.adPodAllUrls = [];
|
|
4083
|
-
this.preloadingAdUrls.clear();
|
|
4084
|
-
this.vastToMediaUrlMap.clear();
|
|
4085
|
-
this.preloadedMediaUrls.clear();
|
|
4086
|
-
this.preloadingMediaUrls.clear();
|
|
4087
4053
|
this.failedVastUrls.clear();
|
|
4088
4054
|
this.adRequestQueue = [];
|
|
4089
4055
|
this.successfulAdRequests = [];
|
|
@@ -4887,10 +4853,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4887
4853
|
this.isShowingPlaceholder = false;
|
|
4888
4854
|
this.placeholderStartTimeMs = null;
|
|
4889
4855
|
}
|
|
4890
|
-
this.preloadingAdUrls.clear();
|
|
4891
|
-
this.vastToMediaUrlMap.clear();
|
|
4892
|
-
this.preloadedMediaUrls.clear();
|
|
4893
|
-
this.preloadingMediaUrls.clear();
|
|
4894
4856
|
this.adRequestQueue = [];
|
|
4895
4857
|
this.successfulAdRequests = [];
|
|
4896
4858
|
this.inAdBreak = false;
|
|
@@ -4899,7 +4861,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4899
4861
|
this.clearAdStartTimer();
|
|
4900
4862
|
this.clearAdStopTimer();
|
|
4901
4863
|
this.adPodQueue = [];
|
|
4902
|
-
this.adPodAllUrls = [];
|
|
4903
4864
|
this.showAds = false;
|
|
4904
4865
|
this.currentAdIndex = 0;
|
|
4905
4866
|
this.totalAdsInBreak = 0;
|
|
@@ -5054,651 +5015,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5054
5015
|
}, extra));
|
|
5055
5016
|
}
|
|
5056
5017
|
},
|
|
5057
|
-
{
|
|
5058
|
-
key: "fetchAndParseVastXml",
|
|
5059
|
-
value: function fetchAndParseVastXml(vastTagUrl) {
|
|
5060
|
-
return _async_to_generator(function() {
|
|
5061
|
-
var response, xmlText, error;
|
|
5062
|
-
return _ts_generator(this, function(_state) {
|
|
5063
|
-
switch(_state.label){
|
|
5064
|
-
case 0:
|
|
5065
|
-
_state.trys.push([
|
|
5066
|
-
0,
|
|
5067
|
-
3,
|
|
5068
|
-
,
|
|
5069
|
-
4
|
|
5070
|
-
]);
|
|
5071
|
-
return [
|
|
5072
|
-
4,
|
|
5073
|
-
fetch(vastTagUrl, {
|
|
5074
|
-
mode: "cors",
|
|
5075
|
-
credentials: "include",
|
|
5076
|
-
headers: {
|
|
5077
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5078
|
-
},
|
|
5079
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5080
|
-
})
|
|
5081
|
-
];
|
|
5082
|
-
case 1:
|
|
5083
|
-
response = _state.sent();
|
|
5084
|
-
if (!response.ok) {
|
|
5085
|
-
throw new Error("Failed to fetch VAST: ".concat(response.status));
|
|
5086
|
-
}
|
|
5087
|
-
return [
|
|
5088
|
-
4,
|
|
5089
|
-
response.text()
|
|
5090
|
-
];
|
|
5091
|
-
case 2:
|
|
5092
|
-
xmlText = _state.sent();
|
|
5093
|
-
return [
|
|
5094
|
-
2,
|
|
5095
|
-
this.extractMediaUrlsFromVast(xmlText)
|
|
5096
|
-
];
|
|
5097
|
-
case 3:
|
|
5098
|
-
error = _state.sent();
|
|
5099
|
-
if (this.config.debugAdTiming) {
|
|
5100
|
-
console.warn("[StormcloudVideoPlayer] Failed to fetch/parse VAST XML: ".concat(vastTagUrl), error);
|
|
5101
|
-
}
|
|
5102
|
-
return [
|
|
5103
|
-
2,
|
|
5104
|
-
[]
|
|
5105
|
-
];
|
|
5106
|
-
case 4:
|
|
5107
|
-
return [
|
|
5108
|
-
2
|
|
5109
|
-
];
|
|
5110
|
-
}
|
|
5111
|
-
});
|
|
5112
|
-
}).call(this);
|
|
5113
|
-
}
|
|
5114
|
-
},
|
|
5115
|
-
{
|
|
5116
|
-
key: "extractMediaUrlsFromVast",
|
|
5117
|
-
value: function extractMediaUrlsFromVast(xmlText) {
|
|
5118
|
-
var mediaUrls = [];
|
|
5119
|
-
try {
|
|
5120
|
-
var parser = new DOMParser();
|
|
5121
|
-
var xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5122
|
-
var mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
|
|
5123
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5124
|
-
try {
|
|
5125
|
-
for(var _iterator = Array.from(mediaFileElements)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5126
|
-
var mediaFile = _step.value;
|
|
5127
|
-
var _mediaFile_textContent;
|
|
5128
|
-
var url = (_mediaFile_textContent = mediaFile.textContent) === null || _mediaFile_textContent === void 0 ? void 0 : _mediaFile_textContent.trim();
|
|
5129
|
-
if (url) {
|
|
5130
|
-
var lowerUrl = url.toLowerCase();
|
|
5131
|
-
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")) {
|
|
5132
|
-
mediaUrls.push(url);
|
|
5133
|
-
}
|
|
5134
|
-
}
|
|
5135
|
-
}
|
|
5136
|
-
} catch (err) {
|
|
5137
|
-
_didIteratorError = true;
|
|
5138
|
-
_iteratorError = err;
|
|
5139
|
-
} finally{
|
|
5140
|
-
try {
|
|
5141
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5142
|
-
_iterator.return();
|
|
5143
|
-
}
|
|
5144
|
-
} finally{
|
|
5145
|
-
if (_didIteratorError) {
|
|
5146
|
-
throw _iteratorError;
|
|
5147
|
-
}
|
|
5148
|
-
}
|
|
5149
|
-
}
|
|
5150
|
-
if (this.config.debugAdTiming && mediaUrls.length > 0) {
|
|
5151
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs from VAST:"), mediaUrls);
|
|
5152
|
-
}
|
|
5153
|
-
} catch (error) {
|
|
5154
|
-
if (this.config.debugAdTiming) {
|
|
5155
|
-
console.warn("[StormcloudVideoPlayer] Failed to parse VAST XML:", error);
|
|
5156
|
-
}
|
|
5157
|
-
}
|
|
5158
|
-
return mediaUrls;
|
|
5159
|
-
}
|
|
5160
|
-
},
|
|
5161
|
-
{
|
|
5162
|
-
key: "fetchVastDuration",
|
|
5163
|
-
value: function fetchVastDuration(vastTagUrl) {
|
|
5164
|
-
return _async_to_generator(function() {
|
|
5165
|
-
var _xmlDoc_querySelector, response, xmlText, parser, xmlDoc, durationText, durationParts, durationSeconds, error;
|
|
5166
|
-
return _ts_generator(this, function(_state) {
|
|
5167
|
-
switch(_state.label){
|
|
5168
|
-
case 0:
|
|
5169
|
-
_state.trys.push([
|
|
5170
|
-
0,
|
|
5171
|
-
3,
|
|
5172
|
-
,
|
|
5173
|
-
4
|
|
5174
|
-
]);
|
|
5175
|
-
return [
|
|
5176
|
-
4,
|
|
5177
|
-
fetch(vastTagUrl, {
|
|
5178
|
-
mode: "cors",
|
|
5179
|
-
credentials: "include",
|
|
5180
|
-
headers: {
|
|
5181
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5182
|
-
},
|
|
5183
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5184
|
-
})
|
|
5185
|
-
];
|
|
5186
|
-
case 1:
|
|
5187
|
-
response = _state.sent();
|
|
5188
|
-
if (!response.ok) {
|
|
5189
|
-
if (this.config.debugAdTiming) {
|
|
5190
|
-
console.warn("[ADAPTIVE-POD] Failed to fetch VAST: ".concat(response.status));
|
|
5191
|
-
}
|
|
5192
|
-
return [
|
|
5193
|
-
2,
|
|
5194
|
-
null
|
|
5195
|
-
];
|
|
5196
|
-
}
|
|
5197
|
-
return [
|
|
5198
|
-
4,
|
|
5199
|
-
response.text()
|
|
5200
|
-
];
|
|
5201
|
-
case 2:
|
|
5202
|
-
xmlText = _state.sent();
|
|
5203
|
-
parser = new DOMParser();
|
|
5204
|
-
xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5205
|
-
durationText = (_xmlDoc_querySelector = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector === void 0 ? void 0 : _xmlDoc_querySelector.textContent;
|
|
5206
|
-
if (!durationText) {
|
|
5207
|
-
if (this.config.debugAdTiming) {
|
|
5208
|
-
console.warn("[ADAPTIVE-POD] No Duration element found in VAST");
|
|
5209
|
-
}
|
|
5210
|
-
return [
|
|
5211
|
-
2,
|
|
5212
|
-
null
|
|
5213
|
-
];
|
|
5214
|
-
}
|
|
5215
|
-
durationParts = durationText.split(":");
|
|
5216
|
-
durationSeconds = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
5217
|
-
return [
|
|
5218
|
-
2,
|
|
5219
|
-
durationSeconds
|
|
5220
|
-
];
|
|
5221
|
-
case 3:
|
|
5222
|
-
error = _state.sent();
|
|
5223
|
-
if (this.config.debugAdTiming) {
|
|
5224
|
-
console.warn("[ADAPTIVE-POD] Error fetching VAST duration from ".concat(vastTagUrl, ":"), error);
|
|
5225
|
-
}
|
|
5226
|
-
return [
|
|
5227
|
-
2,
|
|
5228
|
-
null
|
|
5229
|
-
];
|
|
5230
|
-
case 4:
|
|
5231
|
-
return [
|
|
5232
|
-
2
|
|
5233
|
-
];
|
|
5234
|
-
}
|
|
5235
|
-
});
|
|
5236
|
-
}).call(this);
|
|
5237
|
-
}
|
|
5238
|
-
},
|
|
5239
|
-
{
|
|
5240
|
-
key: "calculateAdditionalAdsNeeded",
|
|
5241
|
-
value: function calculateAdditionalAdsNeeded() {
|
|
5242
|
-
if (!this.isAdaptiveMode || this.targetAdBreakDurationMs === null) {
|
|
5243
|
-
return 0;
|
|
5244
|
-
}
|
|
5245
|
-
var totalFetchedDurationMs = 0;
|
|
5246
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5247
|
-
try {
|
|
5248
|
-
for(var _iterator = this.fetchedAdDurations.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5249
|
-
var duration = _step.value;
|
|
5250
|
-
totalFetchedDurationMs += duration * 1e3;
|
|
5251
|
-
}
|
|
5252
|
-
} catch (err) {
|
|
5253
|
-
_didIteratorError = true;
|
|
5254
|
-
_iteratorError = err;
|
|
5255
|
-
} finally{
|
|
5256
|
-
try {
|
|
5257
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5258
|
-
_iterator.return();
|
|
5259
|
-
}
|
|
5260
|
-
} finally{
|
|
5261
|
-
if (_didIteratorError) {
|
|
5262
|
-
throw _iteratorError;
|
|
5263
|
-
}
|
|
5264
|
-
}
|
|
5265
|
-
}
|
|
5266
|
-
var fetchedCount = this.fetchedAdDurations.size;
|
|
5267
|
-
var averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
5268
|
-
var queuedButNotFetched = this.adPodAllUrls.length - fetchedCount;
|
|
5269
|
-
var estimatedQueuedDurationMs = queuedButNotFetched * averageDurationMs;
|
|
5270
|
-
var estimatedTotalDurationMs = totalFetchedDurationMs + estimatedQueuedDurationMs;
|
|
5271
|
-
var remainingTimeMs = this.targetAdBreakDurationMs - estimatedTotalDurationMs;
|
|
5272
|
-
if (remainingTimeMs <= 0) {
|
|
5273
|
-
if (this.config.debugAdTiming) {
|
|
5274
|
-
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"));
|
|
5275
|
-
}
|
|
5276
|
-
return 0;
|
|
5277
|
-
}
|
|
5278
|
-
var additionalAds = Math.ceil(remainingTimeMs / averageDurationMs);
|
|
5279
|
-
if (this.config.debugAdTiming) {
|
|
5280
|
-
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"));
|
|
5281
|
-
}
|
|
5282
|
-
return additionalAds;
|
|
5283
|
-
}
|
|
5284
|
-
},
|
|
5285
|
-
{
|
|
5286
|
-
key: "addAdaptiveAdsToQueue",
|
|
5287
|
-
value: function addAdaptiveAdsToQueue() {
|
|
5288
|
-
return _async_to_generator(function() {
|
|
5289
|
-
var _this_adPodAllUrls, _this_adPodQueue, additionalAds, newUrls;
|
|
5290
|
-
return _ts_generator(this, function(_state) {
|
|
5291
|
-
if (!this.isAdaptiveMode || !this.apiVastTagUrl) {
|
|
5292
|
-
return [
|
|
5293
|
-
2
|
|
5294
|
-
];
|
|
5295
|
-
}
|
|
5296
|
-
additionalAds = this.calculateAdditionalAdsNeeded();
|
|
5297
|
-
if (additionalAds <= 0) {
|
|
5298
|
-
return [
|
|
5299
|
-
2
|
|
5300
|
-
];
|
|
5301
|
-
}
|
|
5302
|
-
newUrls = this.generateVastUrlsWithCorrelators(this.apiVastTagUrl, additionalAds);
|
|
5303
|
-
if (this.config.debugAdTiming) {
|
|
5304
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Adding ".concat(newUrls.length, " additional VAST URLs to queue (will be preloaded sequentially)"));
|
|
5305
|
-
}
|
|
5306
|
-
(_this_adPodAllUrls = this.adPodAllUrls).push.apply(_this_adPodAllUrls, _to_consumable_array(newUrls));
|
|
5307
|
-
(_this_adPodQueue = this.adPodQueue).push.apply(_this_adPodQueue, _to_consumable_array(newUrls));
|
|
5308
|
-
this.totalAdsInBreak += newUrls.length;
|
|
5309
|
-
return [
|
|
5310
|
-
2
|
|
5311
|
-
];
|
|
5312
|
-
});
|
|
5313
|
-
}).call(this);
|
|
5314
|
-
}
|
|
5315
|
-
},
|
|
5316
|
-
{
|
|
5317
|
-
key: "preloadMediaFile",
|
|
5318
|
-
value: function preloadMediaFile(mediaUrl) {
|
|
5319
|
-
return _async_to_generator(function() {
|
|
5320
|
-
var response, error;
|
|
5321
|
-
return _ts_generator(this, function(_state) {
|
|
5322
|
-
switch(_state.label){
|
|
5323
|
-
case 0:
|
|
5324
|
-
if (this.preloadedMediaUrls.has(mediaUrl)) {
|
|
5325
|
-
return [
|
|
5326
|
-
2
|
|
5327
|
-
];
|
|
5328
|
-
}
|
|
5329
|
-
if (this.preloadingMediaUrls.has(mediaUrl)) {
|
|
5330
|
-
return [
|
|
5331
|
-
2
|
|
5332
|
-
];
|
|
5333
|
-
}
|
|
5334
|
-
this.preloadingMediaUrls.add(mediaUrl);
|
|
5335
|
-
_state.label = 1;
|
|
5336
|
-
case 1:
|
|
5337
|
-
_state.trys.push([
|
|
5338
|
-
1,
|
|
5339
|
-
3,
|
|
5340
|
-
4,
|
|
5341
|
-
5
|
|
5342
|
-
]);
|
|
5343
|
-
if (this.config.debugAdTiming) {
|
|
5344
|
-
console.log("[StormcloudVideoPlayer] Preloading video file: ".concat(mediaUrl));
|
|
5345
|
-
}
|
|
5346
|
-
return [
|
|
5347
|
-
4,
|
|
5348
|
-
fetch(mediaUrl, {
|
|
5349
|
-
mode: "cors",
|
|
5350
|
-
credentials: "include",
|
|
5351
|
-
method: "GET",
|
|
5352
|
-
headers: {
|
|
5353
|
-
Range: "bytes=0-1048576"
|
|
5354
|
-
},
|
|
5355
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5356
|
-
})
|
|
5357
|
-
];
|
|
5358
|
-
case 2:
|
|
5359
|
-
response = _state.sent();
|
|
5360
|
-
if (response.ok || response.status === 206) {
|
|
5361
|
-
this.preloadedMediaUrls.add(mediaUrl);
|
|
5362
|
-
if (this.config.debugAdTiming) {
|
|
5363
|
-
console.log("[StormcloudVideoPlayer] Successfully preloaded video file: ".concat(mediaUrl));
|
|
5364
|
-
}
|
|
5365
|
-
}
|
|
5366
|
-
return [
|
|
5367
|
-
3,
|
|
5368
|
-
5
|
|
5369
|
-
];
|
|
5370
|
-
case 3:
|
|
5371
|
-
error = _state.sent();
|
|
5372
|
-
if (this.config.debugAdTiming) {
|
|
5373
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload video file: ".concat(mediaUrl), error);
|
|
5374
|
-
}
|
|
5375
|
-
return [
|
|
5376
|
-
3,
|
|
5377
|
-
5
|
|
5378
|
-
];
|
|
5379
|
-
case 4:
|
|
5380
|
-
this.preloadingMediaUrls.delete(mediaUrl);
|
|
5381
|
-
return [
|
|
5382
|
-
7
|
|
5383
|
-
];
|
|
5384
|
-
case 5:
|
|
5385
|
-
return [
|
|
5386
|
-
2
|
|
5387
|
-
];
|
|
5388
|
-
}
|
|
5389
|
-
});
|
|
5390
|
-
}).call(this);
|
|
5391
|
-
}
|
|
5392
|
-
},
|
|
5393
|
-
{
|
|
5394
|
-
key: "preloadAllAdsInBackground",
|
|
5395
|
-
value: function preloadAllAdsInBackground() {
|
|
5396
|
-
return _async_to_generator(function() {
|
|
5397
|
-
var _this, processedUrls, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, _this_ima_hasPreloadedAd, _this_ima, nextUrl, error, preloadPromises;
|
|
5398
|
-
return _ts_generator(this, function(_state) {
|
|
5399
|
-
switch(_state.label){
|
|
5400
|
-
case 0:
|
|
5401
|
-
_this = this;
|
|
5402
|
-
if (this.adPodAllUrls.length === 0) {
|
|
5403
|
-
return [
|
|
5404
|
-
2
|
|
5405
|
-
];
|
|
5406
|
-
}
|
|
5407
|
-
if (!this.isAdaptiveMode) return [
|
|
5408
|
-
3,
|
|
5409
|
-
7
|
|
5410
|
-
];
|
|
5411
|
-
if (this.config.debugAdTiming) {
|
|
5412
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Starting sequential preload of remaining ads");
|
|
5413
|
-
}
|
|
5414
|
-
processedUrls = /* @__PURE__ */ new Set();
|
|
5415
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5416
|
-
try {
|
|
5417
|
-
for(_iterator = this.adPodAllUrls[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5418
|
-
url = _step.value;
|
|
5419
|
-
;
|
|
5420
|
-
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)) {
|
|
5421
|
-
processedUrls.add(url);
|
|
5422
|
-
}
|
|
5423
|
-
}
|
|
5424
|
-
} catch (err) {
|
|
5425
|
-
_didIteratorError = true;
|
|
5426
|
-
_iteratorError = err;
|
|
5427
|
-
} finally{
|
|
5428
|
-
try {
|
|
5429
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5430
|
-
_iterator.return();
|
|
5431
|
-
}
|
|
5432
|
-
} finally{
|
|
5433
|
-
if (_didIteratorError) {
|
|
5434
|
-
throw _iteratorError;
|
|
5435
|
-
}
|
|
5436
|
-
}
|
|
5437
|
-
}
|
|
5438
|
-
if (this.config.debugAdTiming && processedUrls.size > 0) {
|
|
5439
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE6 Skipping ".concat(processedUrls.size, " already-preloaded ads"));
|
|
5440
|
-
}
|
|
5441
|
-
_state.label = 1;
|
|
5442
|
-
case 1:
|
|
5443
|
-
if (!true) return [
|
|
5444
|
-
3,
|
|
5445
|
-
6
|
|
5446
|
-
];
|
|
5447
|
-
nextUrl = this.adPodAllUrls.find(function(url) {
|
|
5448
|
-
return !processedUrls.has(url);
|
|
5449
|
-
});
|
|
5450
|
-
if (!nextUrl) {
|
|
5451
|
-
if (this.config.debugAdTiming) {
|
|
5452
|
-
console.log("[ADAPTIVE-POD] ✅ All queued ads processed (".concat(processedUrls.size, " total)"));
|
|
5453
|
-
}
|
|
5454
|
-
return [
|
|
5455
|
-
3,
|
|
5456
|
-
6
|
|
5457
|
-
];
|
|
5458
|
-
}
|
|
5459
|
-
processedUrls.add(nextUrl);
|
|
5460
|
-
if (this.config.debugAdTiming) {
|
|
5461
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE5 Preloading ad ".concat(processedUrls.size, "/").concat(this.adPodAllUrls.length, "..."));
|
|
5462
|
-
}
|
|
5463
|
-
_state.label = 2;
|
|
5464
|
-
case 2:
|
|
5465
|
-
_state.trys.push([
|
|
5466
|
-
2,
|
|
5467
|
-
4,
|
|
5468
|
-
,
|
|
5469
|
-
5
|
|
5470
|
-
]);
|
|
5471
|
-
return [
|
|
5472
|
-
4,
|
|
5473
|
-
this.preloadSingleAd(nextUrl)
|
|
5474
|
-
];
|
|
5475
|
-
case 3:
|
|
5476
|
-
_state.sent();
|
|
5477
|
-
return [
|
|
5478
|
-
3,
|
|
5479
|
-
5
|
|
5480
|
-
];
|
|
5481
|
-
case 4:
|
|
5482
|
-
error = _state.sent();
|
|
5483
|
-
if (this.config.debugAdTiming) {
|
|
5484
|
-
console.warn("[ADAPTIVE-POD] ⚠️ Preload failed for ad ".concat(processedUrls.size, ":"), error);
|
|
5485
|
-
}
|
|
5486
|
-
return [
|
|
5487
|
-
3,
|
|
5488
|
-
5
|
|
5489
|
-
];
|
|
5490
|
-
case 5:
|
|
5491
|
-
if (this.calculateAdditionalAdsNeeded() === 0) {
|
|
5492
|
-
if (this.config.debugAdTiming) {
|
|
5493
|
-
console.log("[ADAPTIVE-POD] ✅ Target duration reached (".concat(processedUrls.size, " ads preloaded), stopping"));
|
|
5494
|
-
}
|
|
5495
|
-
return [
|
|
5496
|
-
3,
|
|
5497
|
-
6
|
|
5498
|
-
];
|
|
5499
|
-
}
|
|
5500
|
-
return [
|
|
5501
|
-
3,
|
|
5502
|
-
1
|
|
5503
|
-
];
|
|
5504
|
-
case 6:
|
|
5505
|
-
if (this.config.debugAdTiming) {
|
|
5506
|
-
console.log("[ADAPTIVE-POD] ✅ Sequential preloading completed (".concat(processedUrls.size, " ads ready)"));
|
|
5507
|
-
}
|
|
5508
|
-
return [
|
|
5509
|
-
3,
|
|
5510
|
-
9
|
|
5511
|
-
];
|
|
5512
|
-
case 7:
|
|
5513
|
-
if (this.config.debugAdTiming) {
|
|
5514
|
-
console.log("[StormcloudVideoPlayer] Starting parallel preload of ".concat(this.adPodAllUrls.length, " ads"));
|
|
5515
|
-
}
|
|
5516
|
-
preloadPromises = this.adPodAllUrls.map(function(vastTagUrl) {
|
|
5517
|
-
return _this.preloadSingleAd(vastTagUrl).catch(function(error) {
|
|
5518
|
-
if (_this.config.debugAdTiming) {
|
|
5519
|
-
console.warn("[StormcloudVideoPlayer] Preload failed for ".concat(vastTagUrl, ":"), error);
|
|
5520
|
-
}
|
|
5521
|
-
});
|
|
5522
|
-
});
|
|
5523
|
-
return [
|
|
5524
|
-
4,
|
|
5525
|
-
Promise.all(preloadPromises)
|
|
5526
|
-
];
|
|
5527
|
-
case 8:
|
|
5528
|
-
_state.sent();
|
|
5529
|
-
if (this.config.debugAdTiming) {
|
|
5530
|
-
console.log("[StormcloudVideoPlayer] Background preloading completed for all ads");
|
|
5531
|
-
}
|
|
5532
|
-
_state.label = 9;
|
|
5533
|
-
case 9:
|
|
5534
|
-
return [
|
|
5535
|
-
2
|
|
5536
|
-
];
|
|
5537
|
-
}
|
|
5538
|
-
});
|
|
5539
|
-
}).call(this);
|
|
5540
|
-
}
|
|
5541
|
-
},
|
|
5542
|
-
{
|
|
5543
|
-
key: "preloadSingleAd",
|
|
5544
|
-
value: function preloadSingleAd(vastTagUrl) {
|
|
5545
|
-
return _async_to_generator(function() {
|
|
5546
|
-
var _this, duration, mediaUrls, primaryMediaUrl, error;
|
|
5547
|
-
return _ts_generator(this, function(_state) {
|
|
5548
|
-
switch(_state.label){
|
|
5549
|
-
case 0:
|
|
5550
|
-
_this = this;
|
|
5551
|
-
if (!vastTagUrl) return [
|
|
5552
|
-
2
|
|
5553
|
-
];
|
|
5554
|
-
_state.label = 1;
|
|
5555
|
-
case 1:
|
|
5556
|
-
_state.trys.push([
|
|
5557
|
-
1,
|
|
5558
|
-
11,
|
|
5559
|
-
,
|
|
5560
|
-
12
|
|
5561
|
-
]);
|
|
5562
|
-
if (!(this.isAdaptiveMode && !this.fetchedAdDurations.has(vastTagUrl))) return [
|
|
5563
|
-
3,
|
|
5564
|
-
4
|
|
5565
|
-
];
|
|
5566
|
-
return [
|
|
5567
|
-
4,
|
|
5568
|
-
this.fetchVastDuration(vastTagUrl)
|
|
5569
|
-
];
|
|
5570
|
-
case 2:
|
|
5571
|
-
duration = _state.sent();
|
|
5572
|
-
if (!(duration !== null)) return [
|
|
5573
|
-
3,
|
|
5574
|
-
4
|
|
5575
|
-
];
|
|
5576
|
-
this.fetchedAdDurations.set(vastTagUrl, duration);
|
|
5577
|
-
if (this.config.debugAdTiming) {
|
|
5578
|
-
console.log("[ADAPTIVE-POD] ✓ Fetched ad duration: ".concat(duration, "s (").concat(this.fetchedAdDurations.size, " ads fetched so far)"));
|
|
5579
|
-
}
|
|
5580
|
-
return [
|
|
5581
|
-
4,
|
|
5582
|
-
this.addAdaptiveAdsToQueue()
|
|
5583
|
-
];
|
|
5584
|
-
case 3:
|
|
5585
|
-
_state.sent();
|
|
5586
|
-
_state.label = 4;
|
|
5587
|
-
case 4:
|
|
5588
|
-
if (!(this.ima.preloadAds && !this.ima.hasPreloadedAd(vastTagUrl))) return [
|
|
5589
|
-
3,
|
|
5590
|
-
6
|
|
5591
|
-
];
|
|
5592
|
-
if (!!this.preloadingAdUrls.has(vastTagUrl)) return [
|
|
5593
|
-
3,
|
|
5594
|
-
6
|
|
5595
|
-
];
|
|
5596
|
-
if (this.config.debugAdTiming) {
|
|
5597
|
-
console.log("[StormcloudVideoPlayer] Preloading VAST: ".concat(vastTagUrl));
|
|
5598
|
-
}
|
|
5599
|
-
this.preloadingAdUrls.add(vastTagUrl);
|
|
5600
|
-
return [
|
|
5601
|
-
4,
|
|
5602
|
-
this.ima.preloadAds(vastTagUrl).then(function() {
|
|
5603
|
-
if (_this.config.debugAdTiming) {
|
|
5604
|
-
console.log("[StormcloudVideoPlayer] IMA VAST preload complete: ".concat(vastTagUrl));
|
|
5605
|
-
}
|
|
5606
|
-
}).catch(function(error) {
|
|
5607
|
-
if (_this.config.debugAdTiming) {
|
|
5608
|
-
console.warn("[StormcloudVideoPlayer] IMA VAST preload failed: ".concat(vastTagUrl), error);
|
|
5609
|
-
}
|
|
5610
|
-
}).finally(function() {
|
|
5611
|
-
_this.preloadingAdUrls.delete(vastTagUrl);
|
|
5612
|
-
})
|
|
5613
|
-
];
|
|
5614
|
-
case 5:
|
|
5615
|
-
_state.sent();
|
|
5616
|
-
_state.label = 6;
|
|
5617
|
-
case 6:
|
|
5618
|
-
mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5619
|
-
if (!!mediaUrls) return [
|
|
5620
|
-
3,
|
|
5621
|
-
8
|
|
5622
|
-
];
|
|
5623
|
-
if (this.config.debugAdTiming) {
|
|
5624
|
-
console.log("[StormcloudVideoPlayer] Fetching and parsing VAST to extract media URLs: ".concat(vastTagUrl));
|
|
5625
|
-
}
|
|
5626
|
-
return [
|
|
5627
|
-
4,
|
|
5628
|
-
this.fetchAndParseVastXml(vastTagUrl)
|
|
5629
|
-
];
|
|
5630
|
-
case 7:
|
|
5631
|
-
mediaUrls = _state.sent();
|
|
5632
|
-
if (this.config.debugAdTiming) {
|
|
5633
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs:"), mediaUrls);
|
|
5634
|
-
}
|
|
5635
|
-
if (mediaUrls.length > 0) {
|
|
5636
|
-
this.vastToMediaUrlMap.set(vastTagUrl, mediaUrls);
|
|
5637
|
-
}
|
|
5638
|
-
_state.label = 8;
|
|
5639
|
-
case 8:
|
|
5640
|
-
if (!(mediaUrls && mediaUrls.length > 0)) return [
|
|
5641
|
-
3,
|
|
5642
|
-
10
|
|
5643
|
-
];
|
|
5644
|
-
primaryMediaUrl = mediaUrls[0];
|
|
5645
|
-
if (!(primaryMediaUrl && !this.preloadedMediaUrls.has(primaryMediaUrl))) return [
|
|
5646
|
-
3,
|
|
5647
|
-
10
|
|
5648
|
-
];
|
|
5649
|
-
return [
|
|
5650
|
-
4,
|
|
5651
|
-
this.preloadMediaFile(primaryMediaUrl)
|
|
5652
|
-
];
|
|
5653
|
-
case 9:
|
|
5654
|
-
_state.sent();
|
|
5655
|
-
_state.label = 10;
|
|
5656
|
-
case 10:
|
|
5657
|
-
return [
|
|
5658
|
-
3,
|
|
5659
|
-
12
|
|
5660
|
-
];
|
|
5661
|
-
case 11:
|
|
5662
|
-
error = _state.sent();
|
|
5663
|
-
if (this.config.debugAdTiming) {
|
|
5664
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload ad: ".concat(vastTagUrl), error);
|
|
5665
|
-
}
|
|
5666
|
-
return [
|
|
5667
|
-
3,
|
|
5668
|
-
12
|
|
5669
|
-
];
|
|
5670
|
-
case 12:
|
|
5671
|
-
return [
|
|
5672
|
-
2
|
|
5673
|
-
];
|
|
5674
|
-
}
|
|
5675
|
-
});
|
|
5676
|
-
}).call(this);
|
|
5677
|
-
}
|
|
5678
|
-
},
|
|
5679
|
-
{
|
|
5680
|
-
key: "findNextPreloadedAd",
|
|
5681
|
-
value: function findNextPreloadedAd() {
|
|
5682
|
-
for(var i = 0; i < this.adPodQueue.length; i++){
|
|
5683
|
-
var _this_ima_hasPreloadedAd, _this_ima;
|
|
5684
|
-
var vastTagUrl = this.adPodQueue[i];
|
|
5685
|
-
if (!vastTagUrl) continue;
|
|
5686
|
-
if (this.failedVastUrls.has(vastTagUrl)) {
|
|
5687
|
-
console.warn("[AD-ERROR] Skipping failed URL in queue");
|
|
5688
|
-
continue;
|
|
5689
|
-
}
|
|
5690
|
-
var _this_ima_hasPreloadedAd1;
|
|
5691
|
-
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;
|
|
5692
|
-
var mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5693
|
-
var hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
|
|
5694
|
-
if (hasImaPreload || hasMediaPreload) {
|
|
5695
|
-
this.adPodQueue.splice(0, i + 1);
|
|
5696
|
-
return vastTagUrl;
|
|
5697
|
-
}
|
|
5698
|
-
}
|
|
5699
|
-
return void 0;
|
|
5700
|
-
}
|
|
5701
|
-
},
|
|
5702
5018
|
{
|
|
5703
5019
|
key: "getRemainingAdMs",
|
|
5704
5020
|
value: function getRemainingAdMs() {
|
|
@@ -5885,7 +5201,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5885
5201
|
}
|
|
5886
5202
|
if (this.ima && this.ima.isAdPlaying()) {
|
|
5887
5203
|
var width = this.video.clientWidth || 640;
|
|
5888
|
-
var height = this.video.clientHeight ||
|
|
5204
|
+
var height = this.video.clientHeight || 480;
|
|
5889
5205
|
if (this.config.debugAdTiming) {
|
|
5890
5206
|
console.log("[StormcloudVideoPlayer] Resizing ads manager to ".concat(width, "x").concat(height));
|
|
5891
5207
|
}
|
|
@@ -5916,11 +5232,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5916
5232
|
}
|
|
5917
5233
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5918
5234
|
(_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
|
|
5919
|
-
this.preloadingAdUrls.clear();
|
|
5920
|
-
this.vastToMediaUrlMap.clear();
|
|
5921
|
-
this.preloadedMediaUrls.clear();
|
|
5922
|
-
this.preloadingMediaUrls.clear();
|
|
5923
|
-
this.adPodAllUrls = [];
|
|
5924
5235
|
this.adRequestQueue = [];
|
|
5925
5236
|
this.successfulAdRequests = [];
|
|
5926
5237
|
}
|