stormcloud-video-player 0.3.19 → 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 +8075 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +3872 -0
- package/lib/index.d.ts +3872 -0
- package/lib/index.js +7881 -0
- package/lib/index.js.map +1 -0
- 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/players/index.cjs
CHANGED
|
@@ -746,10 +746,17 @@ function createImaController(video, options) {
|
|
|
746
746
|
var adsLoadedReject;
|
|
747
747
|
function makeAdsRequest(google, vastTagUrl) {
|
|
748
748
|
var adsRequest = new google.ima.AdsRequest();
|
|
749
|
-
|
|
750
|
-
|
|
749
|
+
var preloadedXml = preloadedVast.get(vastTagUrl);
|
|
750
|
+
if (preloadedXml) {
|
|
751
|
+
console.log("[IMA] \uD83D\uDCE6 Using preloaded VAST response");
|
|
752
|
+
adsRequest.adsResponse = preloadedXml;
|
|
753
|
+
preloadedVast.delete(vastTagUrl);
|
|
754
|
+
} else {
|
|
755
|
+
console.log("[IMA] \uD83D\uDCE1 Requesting VAST from URL (letting IMA fetch fresh)");
|
|
756
|
+
adsRequest.adTagUrl = vastTagUrl;
|
|
757
|
+
}
|
|
751
758
|
var videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
752
|
-
var videoHeight = video.offsetHeight || video.clientHeight ||
|
|
759
|
+
var videoHeight = video.offsetHeight || video.clientHeight || 480;
|
|
753
760
|
adsRequest.linearAdSlotWidth = videoWidth;
|
|
754
761
|
adsRequest.linearAdSlotHeight = videoHeight;
|
|
755
762
|
adsRequest.nonLinearAdSlotWidth = videoWidth;
|
|
@@ -1198,7 +1205,7 @@ function createImaController(video, options) {
|
|
|
1198
1205
|
}
|
|
1199
1206
|
try {
|
|
1200
1207
|
width = video.clientWidth || 640;
|
|
1201
|
-
height = video.clientHeight ||
|
|
1208
|
+
height = video.clientHeight || 480;
|
|
1202
1209
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
1203
1210
|
adPlaying = true;
|
|
1204
1211
|
adVolume = originalMutedState ? 0 : originalVolume;
|
|
@@ -2826,18 +2833,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2826
2833
|
this.bufferedSegmentsCount = 0;
|
|
2827
2834
|
this.shouldAutoplayAfterBuffering = false;
|
|
2828
2835
|
this.hasInitialBufferCompleted = false;
|
|
2829
|
-
this.adPodAllUrls = [];
|
|
2830
|
-
this.preloadingAdUrls = /* @__PURE__ */ new Set();
|
|
2831
|
-
this.vastToMediaUrlMap = /* @__PURE__ */ new Map();
|
|
2832
|
-
this.preloadedMediaUrls = /* @__PURE__ */ new Set();
|
|
2833
|
-
this.preloadingMediaUrls = /* @__PURE__ */ new Set();
|
|
2834
2836
|
this.adRequestTokenCounter = 0;
|
|
2835
2837
|
this.activeAdRequestToken = null;
|
|
2836
2838
|
this.adRequestWatchdogToken = null;
|
|
2837
2839
|
this.adFailsafeToken = null;
|
|
2838
|
-
this.fetchedAdDurations = /* @__PURE__ */ new Map();
|
|
2839
|
-
this.targetAdBreakDurationMs = null;
|
|
2840
|
-
this.isAdaptiveMode = false;
|
|
2841
2840
|
this.failedVastUrls = /* @__PURE__ */ new Set();
|
|
2842
2841
|
this.continuousFetchingActive = false;
|
|
2843
2842
|
this.adRequestQueue = [];
|
|
@@ -3342,25 +3341,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3342
3341
|
}
|
|
3343
3342
|
});
|
|
3344
3343
|
this.ima.on("ad_error", function(errorPayload) {
|
|
3345
|
-
var remaining = _this.getRemainingAdMs();
|
|
3346
3344
|
console.error("[AD-ERROR] Ad playback failed", errorPayload || "");
|
|
3347
|
-
|
|
3348
|
-
if (remaining > 500 && _this.adPodQueue.length > 0) {
|
|
3349
|
-
var nextPreloaded = _this.findNextPreloadedAd();
|
|
3350
|
-
if (nextPreloaded) {
|
|
3351
|
-
_this.currentAdIndex++;
|
|
3352
|
-
_this.playSingleAd(nextPreloaded).catch(function() {
|
|
3353
|
-
_this.handleAdFailure();
|
|
3354
|
-
});
|
|
3355
|
-
} else {
|
|
3356
|
-
_this.handleAdFailure();
|
|
3357
|
-
}
|
|
3358
|
-
} else {
|
|
3359
|
-
_this.handleAdFailure();
|
|
3360
|
-
}
|
|
3361
|
-
} else {
|
|
3362
|
-
_this.handleAdFailure();
|
|
3363
|
-
}
|
|
3345
|
+
_this.handleAdFailure();
|
|
3364
3346
|
});
|
|
3365
3347
|
this.ima.on("content_pause", function() {
|
|
3366
3348
|
_this.clearAdFailsafeTimer();
|
|
@@ -4091,7 +4073,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4091
4073
|
key: "handleAdStart",
|
|
4092
4074
|
value: function handleAdStart(_marker) {
|
|
4093
4075
|
return _async_to_generator(function() {
|
|
4094
|
-
var scheduled, tags, baseVastUrl, adBreakDurationMs, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
4076
|
+
var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, firstAdUrlArray, firstAdUrl, error;
|
|
4095
4077
|
return _ts_generator(this, function(_state) {
|
|
4096
4078
|
switch(_state.label){
|
|
4097
4079
|
case 0:
|
|
@@ -4107,26 +4089,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4107
4089
|
];
|
|
4108
4090
|
}
|
|
4109
4091
|
adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
|
|
4110
|
-
if (this.
|
|
4111
|
-
this.
|
|
4112
|
-
|
|
4113
|
-
this.fetchedAdDurations.clear();
|
|
4114
|
-
if (this.config.debugAdTiming) {
|
|
4115
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA LIVE MODE: Target duration=".concat(adBreakDurationMs, "ms | Will continuously fetch ads during break"));
|
|
4116
|
-
}
|
|
4117
|
-
} else {
|
|
4118
|
-
this.isAdaptiveMode = false;
|
|
4119
|
-
this.targetAdBreakDurationMs = null;
|
|
4120
|
-
this.fetchedAdDurations.clear();
|
|
4121
|
-
if (this.config.debugAdTiming) {
|
|
4122
|
-
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC VOD MODE: Using fixed ad strategy");
|
|
4123
|
-
}
|
|
4092
|
+
if (this.config.debugAdTiming) {
|
|
4093
|
+
mode = this.isLiveStream ? "LIVE" : "VOD";
|
|
4094
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
4124
4095
|
}
|
|
4125
|
-
this.adPodAllUrls = [];
|
|
4126
|
-
this.preloadingAdUrls.clear();
|
|
4127
|
-
this.vastToMediaUrlMap.clear();
|
|
4128
|
-
this.preloadedMediaUrls.clear();
|
|
4129
|
-
this.preloadingMediaUrls.clear();
|
|
4130
4096
|
this.failedVastUrls.clear();
|
|
4131
4097
|
this.adRequestQueue = [];
|
|
4132
4098
|
this.successfulAdRequests = [];
|
|
@@ -4930,10 +4896,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4930
4896
|
this.isShowingPlaceholder = false;
|
|
4931
4897
|
this.placeholderStartTimeMs = null;
|
|
4932
4898
|
}
|
|
4933
|
-
this.preloadingAdUrls.clear();
|
|
4934
|
-
this.vastToMediaUrlMap.clear();
|
|
4935
|
-
this.preloadedMediaUrls.clear();
|
|
4936
|
-
this.preloadingMediaUrls.clear();
|
|
4937
4899
|
this.adRequestQueue = [];
|
|
4938
4900
|
this.successfulAdRequests = [];
|
|
4939
4901
|
this.inAdBreak = false;
|
|
@@ -4942,7 +4904,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4942
4904
|
this.clearAdStartTimer();
|
|
4943
4905
|
this.clearAdStopTimer();
|
|
4944
4906
|
this.adPodQueue = [];
|
|
4945
|
-
this.adPodAllUrls = [];
|
|
4946
4907
|
this.showAds = false;
|
|
4947
4908
|
this.currentAdIndex = 0;
|
|
4948
4909
|
this.totalAdsInBreak = 0;
|
|
@@ -5097,651 +5058,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5097
5058
|
}, extra));
|
|
5098
5059
|
}
|
|
5099
5060
|
},
|
|
5100
|
-
{
|
|
5101
|
-
key: "fetchAndParseVastXml",
|
|
5102
|
-
value: function fetchAndParseVastXml(vastTagUrl) {
|
|
5103
|
-
return _async_to_generator(function() {
|
|
5104
|
-
var response, xmlText, error;
|
|
5105
|
-
return _ts_generator(this, function(_state) {
|
|
5106
|
-
switch(_state.label){
|
|
5107
|
-
case 0:
|
|
5108
|
-
_state.trys.push([
|
|
5109
|
-
0,
|
|
5110
|
-
3,
|
|
5111
|
-
,
|
|
5112
|
-
4
|
|
5113
|
-
]);
|
|
5114
|
-
return [
|
|
5115
|
-
4,
|
|
5116
|
-
fetch(vastTagUrl, {
|
|
5117
|
-
mode: "cors",
|
|
5118
|
-
credentials: "include",
|
|
5119
|
-
headers: {
|
|
5120
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5121
|
-
},
|
|
5122
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5123
|
-
})
|
|
5124
|
-
];
|
|
5125
|
-
case 1:
|
|
5126
|
-
response = _state.sent();
|
|
5127
|
-
if (!response.ok) {
|
|
5128
|
-
throw new Error("Failed to fetch VAST: ".concat(response.status));
|
|
5129
|
-
}
|
|
5130
|
-
return [
|
|
5131
|
-
4,
|
|
5132
|
-
response.text()
|
|
5133
|
-
];
|
|
5134
|
-
case 2:
|
|
5135
|
-
xmlText = _state.sent();
|
|
5136
|
-
return [
|
|
5137
|
-
2,
|
|
5138
|
-
this.extractMediaUrlsFromVast(xmlText)
|
|
5139
|
-
];
|
|
5140
|
-
case 3:
|
|
5141
|
-
error = _state.sent();
|
|
5142
|
-
if (this.config.debugAdTiming) {
|
|
5143
|
-
console.warn("[StormcloudVideoPlayer] Failed to fetch/parse VAST XML: ".concat(vastTagUrl), error);
|
|
5144
|
-
}
|
|
5145
|
-
return [
|
|
5146
|
-
2,
|
|
5147
|
-
[]
|
|
5148
|
-
];
|
|
5149
|
-
case 4:
|
|
5150
|
-
return [
|
|
5151
|
-
2
|
|
5152
|
-
];
|
|
5153
|
-
}
|
|
5154
|
-
});
|
|
5155
|
-
}).call(this);
|
|
5156
|
-
}
|
|
5157
|
-
},
|
|
5158
|
-
{
|
|
5159
|
-
key: "extractMediaUrlsFromVast",
|
|
5160
|
-
value: function extractMediaUrlsFromVast(xmlText) {
|
|
5161
|
-
var mediaUrls = [];
|
|
5162
|
-
try {
|
|
5163
|
-
var parser = new DOMParser();
|
|
5164
|
-
var xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5165
|
-
var mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
|
|
5166
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5167
|
-
try {
|
|
5168
|
-
for(var _iterator = Array.from(mediaFileElements)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5169
|
-
var mediaFile = _step.value;
|
|
5170
|
-
var _mediaFile_textContent;
|
|
5171
|
-
var url = (_mediaFile_textContent = mediaFile.textContent) === null || _mediaFile_textContent === void 0 ? void 0 : _mediaFile_textContent.trim();
|
|
5172
|
-
if (url) {
|
|
5173
|
-
var lowerUrl = url.toLowerCase();
|
|
5174
|
-
if (lowerUrl.endsWith(".mp4") || lowerUrl.endsWith(".webm") || lowerUrl.endsWith(".mov") || lowerUrl.endsWith(".avi") || lowerUrl.includes(".mp4?") || lowerUrl.includes(".webm?") || lowerUrl.includes("/mp4/") || lowerUrl.includes("type=video")) {
|
|
5175
|
-
mediaUrls.push(url);
|
|
5176
|
-
}
|
|
5177
|
-
}
|
|
5178
|
-
}
|
|
5179
|
-
} catch (err) {
|
|
5180
|
-
_didIteratorError = true;
|
|
5181
|
-
_iteratorError = err;
|
|
5182
|
-
} finally{
|
|
5183
|
-
try {
|
|
5184
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5185
|
-
_iterator.return();
|
|
5186
|
-
}
|
|
5187
|
-
} finally{
|
|
5188
|
-
if (_didIteratorError) {
|
|
5189
|
-
throw _iteratorError;
|
|
5190
|
-
}
|
|
5191
|
-
}
|
|
5192
|
-
}
|
|
5193
|
-
if (this.config.debugAdTiming && mediaUrls.length > 0) {
|
|
5194
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs from VAST:"), mediaUrls);
|
|
5195
|
-
}
|
|
5196
|
-
} catch (error) {
|
|
5197
|
-
if (this.config.debugAdTiming) {
|
|
5198
|
-
console.warn("[StormcloudVideoPlayer] Failed to parse VAST XML:", error);
|
|
5199
|
-
}
|
|
5200
|
-
}
|
|
5201
|
-
return mediaUrls;
|
|
5202
|
-
}
|
|
5203
|
-
},
|
|
5204
|
-
{
|
|
5205
|
-
key: "fetchVastDuration",
|
|
5206
|
-
value: function fetchVastDuration(vastTagUrl) {
|
|
5207
|
-
return _async_to_generator(function() {
|
|
5208
|
-
var _xmlDoc_querySelector, response, xmlText, parser, xmlDoc, durationText, durationParts, durationSeconds, error;
|
|
5209
|
-
return _ts_generator(this, function(_state) {
|
|
5210
|
-
switch(_state.label){
|
|
5211
|
-
case 0:
|
|
5212
|
-
_state.trys.push([
|
|
5213
|
-
0,
|
|
5214
|
-
3,
|
|
5215
|
-
,
|
|
5216
|
-
4
|
|
5217
|
-
]);
|
|
5218
|
-
return [
|
|
5219
|
-
4,
|
|
5220
|
-
fetch(vastTagUrl, {
|
|
5221
|
-
mode: "cors",
|
|
5222
|
-
credentials: "include",
|
|
5223
|
-
headers: {
|
|
5224
|
-
"Accept": "application/xml, text/xml, */*"
|
|
5225
|
-
},
|
|
5226
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5227
|
-
})
|
|
5228
|
-
];
|
|
5229
|
-
case 1:
|
|
5230
|
-
response = _state.sent();
|
|
5231
|
-
if (!response.ok) {
|
|
5232
|
-
if (this.config.debugAdTiming) {
|
|
5233
|
-
console.warn("[ADAPTIVE-POD] Failed to fetch VAST: ".concat(response.status));
|
|
5234
|
-
}
|
|
5235
|
-
return [
|
|
5236
|
-
2,
|
|
5237
|
-
null
|
|
5238
|
-
];
|
|
5239
|
-
}
|
|
5240
|
-
return [
|
|
5241
|
-
4,
|
|
5242
|
-
response.text()
|
|
5243
|
-
];
|
|
5244
|
-
case 2:
|
|
5245
|
-
xmlText = _state.sent();
|
|
5246
|
-
parser = new DOMParser();
|
|
5247
|
-
xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
5248
|
-
durationText = (_xmlDoc_querySelector = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector === void 0 ? void 0 : _xmlDoc_querySelector.textContent;
|
|
5249
|
-
if (!durationText) {
|
|
5250
|
-
if (this.config.debugAdTiming) {
|
|
5251
|
-
console.warn("[ADAPTIVE-POD] No Duration element found in VAST");
|
|
5252
|
-
}
|
|
5253
|
-
return [
|
|
5254
|
-
2,
|
|
5255
|
-
null
|
|
5256
|
-
];
|
|
5257
|
-
}
|
|
5258
|
-
durationParts = durationText.split(":");
|
|
5259
|
-
durationSeconds = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
5260
|
-
return [
|
|
5261
|
-
2,
|
|
5262
|
-
durationSeconds
|
|
5263
|
-
];
|
|
5264
|
-
case 3:
|
|
5265
|
-
error = _state.sent();
|
|
5266
|
-
if (this.config.debugAdTiming) {
|
|
5267
|
-
console.warn("[ADAPTIVE-POD] Error fetching VAST duration from ".concat(vastTagUrl, ":"), error);
|
|
5268
|
-
}
|
|
5269
|
-
return [
|
|
5270
|
-
2,
|
|
5271
|
-
null
|
|
5272
|
-
];
|
|
5273
|
-
case 4:
|
|
5274
|
-
return [
|
|
5275
|
-
2
|
|
5276
|
-
];
|
|
5277
|
-
}
|
|
5278
|
-
});
|
|
5279
|
-
}).call(this);
|
|
5280
|
-
}
|
|
5281
|
-
},
|
|
5282
|
-
{
|
|
5283
|
-
key: "calculateAdditionalAdsNeeded",
|
|
5284
|
-
value: function calculateAdditionalAdsNeeded() {
|
|
5285
|
-
if (!this.isAdaptiveMode || this.targetAdBreakDurationMs === null) {
|
|
5286
|
-
return 0;
|
|
5287
|
-
}
|
|
5288
|
-
var totalFetchedDurationMs = 0;
|
|
5289
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5290
|
-
try {
|
|
5291
|
-
for(var _iterator = this.fetchedAdDurations.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5292
|
-
var duration = _step.value;
|
|
5293
|
-
totalFetchedDurationMs += duration * 1e3;
|
|
5294
|
-
}
|
|
5295
|
-
} catch (err) {
|
|
5296
|
-
_didIteratorError = true;
|
|
5297
|
-
_iteratorError = err;
|
|
5298
|
-
} finally{
|
|
5299
|
-
try {
|
|
5300
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5301
|
-
_iterator.return();
|
|
5302
|
-
}
|
|
5303
|
-
} finally{
|
|
5304
|
-
if (_didIteratorError) {
|
|
5305
|
-
throw _iteratorError;
|
|
5306
|
-
}
|
|
5307
|
-
}
|
|
5308
|
-
}
|
|
5309
|
-
var fetchedCount = this.fetchedAdDurations.size;
|
|
5310
|
-
var averageDurationMs = fetchedCount > 0 ? totalFetchedDurationMs / fetchedCount : 30 * 1e3;
|
|
5311
|
-
var queuedButNotFetched = this.adPodAllUrls.length - fetchedCount;
|
|
5312
|
-
var estimatedQueuedDurationMs = queuedButNotFetched * averageDurationMs;
|
|
5313
|
-
var estimatedTotalDurationMs = totalFetchedDurationMs + estimatedQueuedDurationMs;
|
|
5314
|
-
var remainingTimeMs = this.targetAdBreakDurationMs - estimatedTotalDurationMs;
|
|
5315
|
-
if (remainingTimeMs <= 0) {
|
|
5316
|
-
if (this.config.debugAdTiming) {
|
|
5317
|
-
console.log("[ADAPTIVE-POD] ✅ Target duration met: Fetched=".concat(totalFetchedDurationMs, "ms + Queued(").concat(queuedButNotFetched, " ads)=").concat(estimatedQueuedDurationMs, "ms = ").concat(estimatedTotalDurationMs, "ms / Target=").concat(this.targetAdBreakDurationMs, "ms"));
|
|
5318
|
-
}
|
|
5319
|
-
return 0;
|
|
5320
|
-
}
|
|
5321
|
-
var additionalAds = Math.ceil(remainingTimeMs / averageDurationMs);
|
|
5322
|
-
if (this.config.debugAdTiming) {
|
|
5323
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCCA Need ".concat(additionalAds, " more ads | Fetched: ").concat(totalFetchedDurationMs, "ms (").concat(fetchedCount, " ads) | Queued: ").concat(estimatedQueuedDurationMs, "ms (").concat(queuedButNotFetched, " ads) | Target: ").concat(this.targetAdBreakDurationMs, "ms | Remaining: ").concat(remainingTimeMs, "ms | Avg duration: ").concat(averageDurationMs, "ms"));
|
|
5324
|
-
}
|
|
5325
|
-
return additionalAds;
|
|
5326
|
-
}
|
|
5327
|
-
},
|
|
5328
|
-
{
|
|
5329
|
-
key: "addAdaptiveAdsToQueue",
|
|
5330
|
-
value: function addAdaptiveAdsToQueue() {
|
|
5331
|
-
return _async_to_generator(function() {
|
|
5332
|
-
var _this_adPodAllUrls, _this_adPodQueue, additionalAds, newUrls;
|
|
5333
|
-
return _ts_generator(this, function(_state) {
|
|
5334
|
-
if (!this.isAdaptiveMode || !this.apiVastTagUrl) {
|
|
5335
|
-
return [
|
|
5336
|
-
2
|
|
5337
|
-
];
|
|
5338
|
-
}
|
|
5339
|
-
additionalAds = this.calculateAdditionalAdsNeeded();
|
|
5340
|
-
if (additionalAds <= 0) {
|
|
5341
|
-
return [
|
|
5342
|
-
2
|
|
5343
|
-
];
|
|
5344
|
-
}
|
|
5345
|
-
newUrls = this.generateVastUrlsWithCorrelators(this.apiVastTagUrl, additionalAds);
|
|
5346
|
-
if (this.config.debugAdTiming) {
|
|
5347
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Adding ".concat(newUrls.length, " additional VAST URLs to queue (will be preloaded sequentially)"));
|
|
5348
|
-
}
|
|
5349
|
-
(_this_adPodAllUrls = this.adPodAllUrls).push.apply(_this_adPodAllUrls, _to_consumable_array(newUrls));
|
|
5350
|
-
(_this_adPodQueue = this.adPodQueue).push.apply(_this_adPodQueue, _to_consumable_array(newUrls));
|
|
5351
|
-
this.totalAdsInBreak += newUrls.length;
|
|
5352
|
-
return [
|
|
5353
|
-
2
|
|
5354
|
-
];
|
|
5355
|
-
});
|
|
5356
|
-
}).call(this);
|
|
5357
|
-
}
|
|
5358
|
-
},
|
|
5359
|
-
{
|
|
5360
|
-
key: "preloadMediaFile",
|
|
5361
|
-
value: function preloadMediaFile(mediaUrl) {
|
|
5362
|
-
return _async_to_generator(function() {
|
|
5363
|
-
var response, error;
|
|
5364
|
-
return _ts_generator(this, function(_state) {
|
|
5365
|
-
switch(_state.label){
|
|
5366
|
-
case 0:
|
|
5367
|
-
if (this.preloadedMediaUrls.has(mediaUrl)) {
|
|
5368
|
-
return [
|
|
5369
|
-
2
|
|
5370
|
-
];
|
|
5371
|
-
}
|
|
5372
|
-
if (this.preloadingMediaUrls.has(mediaUrl)) {
|
|
5373
|
-
return [
|
|
5374
|
-
2
|
|
5375
|
-
];
|
|
5376
|
-
}
|
|
5377
|
-
this.preloadingMediaUrls.add(mediaUrl);
|
|
5378
|
-
_state.label = 1;
|
|
5379
|
-
case 1:
|
|
5380
|
-
_state.trys.push([
|
|
5381
|
-
1,
|
|
5382
|
-
3,
|
|
5383
|
-
4,
|
|
5384
|
-
5
|
|
5385
|
-
]);
|
|
5386
|
-
if (this.config.debugAdTiming) {
|
|
5387
|
-
console.log("[StormcloudVideoPlayer] Preloading video file: ".concat(mediaUrl));
|
|
5388
|
-
}
|
|
5389
|
-
return [
|
|
5390
|
-
4,
|
|
5391
|
-
fetch(mediaUrl, {
|
|
5392
|
-
mode: "cors",
|
|
5393
|
-
credentials: "include",
|
|
5394
|
-
method: "GET",
|
|
5395
|
-
headers: {
|
|
5396
|
-
Range: "bytes=0-1048576"
|
|
5397
|
-
},
|
|
5398
|
-
referrerPolicy: "no-referrer-when-downgrade"
|
|
5399
|
-
})
|
|
5400
|
-
];
|
|
5401
|
-
case 2:
|
|
5402
|
-
response = _state.sent();
|
|
5403
|
-
if (response.ok || response.status === 206) {
|
|
5404
|
-
this.preloadedMediaUrls.add(mediaUrl);
|
|
5405
|
-
if (this.config.debugAdTiming) {
|
|
5406
|
-
console.log("[StormcloudVideoPlayer] Successfully preloaded video file: ".concat(mediaUrl));
|
|
5407
|
-
}
|
|
5408
|
-
}
|
|
5409
|
-
return [
|
|
5410
|
-
3,
|
|
5411
|
-
5
|
|
5412
|
-
];
|
|
5413
|
-
case 3:
|
|
5414
|
-
error = _state.sent();
|
|
5415
|
-
if (this.config.debugAdTiming) {
|
|
5416
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload video file: ".concat(mediaUrl), error);
|
|
5417
|
-
}
|
|
5418
|
-
return [
|
|
5419
|
-
3,
|
|
5420
|
-
5
|
|
5421
|
-
];
|
|
5422
|
-
case 4:
|
|
5423
|
-
this.preloadingMediaUrls.delete(mediaUrl);
|
|
5424
|
-
return [
|
|
5425
|
-
7
|
|
5426
|
-
];
|
|
5427
|
-
case 5:
|
|
5428
|
-
return [
|
|
5429
|
-
2
|
|
5430
|
-
];
|
|
5431
|
-
}
|
|
5432
|
-
});
|
|
5433
|
-
}).call(this);
|
|
5434
|
-
}
|
|
5435
|
-
},
|
|
5436
|
-
{
|
|
5437
|
-
key: "preloadAllAdsInBackground",
|
|
5438
|
-
value: function preloadAllAdsInBackground() {
|
|
5439
|
-
return _async_to_generator(function() {
|
|
5440
|
-
var _this, processedUrls, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, _this_ima_hasPreloadedAd, _this_ima, nextUrl, error, preloadPromises;
|
|
5441
|
-
return _ts_generator(this, function(_state) {
|
|
5442
|
-
switch(_state.label){
|
|
5443
|
-
case 0:
|
|
5444
|
-
_this = this;
|
|
5445
|
-
if (this.adPodAllUrls.length === 0) {
|
|
5446
|
-
return [
|
|
5447
|
-
2
|
|
5448
|
-
];
|
|
5449
|
-
}
|
|
5450
|
-
if (!this.isAdaptiveMode) return [
|
|
5451
|
-
3,
|
|
5452
|
-
7
|
|
5453
|
-
];
|
|
5454
|
-
if (this.config.debugAdTiming) {
|
|
5455
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDD04 Starting sequential preload of remaining ads");
|
|
5456
|
-
}
|
|
5457
|
-
processedUrls = /* @__PURE__ */ new Set();
|
|
5458
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5459
|
-
try {
|
|
5460
|
-
for(_iterator = this.adPodAllUrls[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5461
|
-
url = _step.value;
|
|
5462
|
-
;
|
|
5463
|
-
if (((_this_ima_hasPreloadedAd = (_this_ima = this.ima).hasPreloadedAd) === null || _this_ima_hasPreloadedAd === void 0 ? void 0 : _this_ima_hasPreloadedAd.call(_this_ima, url)) || this.fetchedAdDurations.has(url)) {
|
|
5464
|
-
processedUrls.add(url);
|
|
5465
|
-
}
|
|
5466
|
-
}
|
|
5467
|
-
} catch (err) {
|
|
5468
|
-
_didIteratorError = true;
|
|
5469
|
-
_iteratorError = err;
|
|
5470
|
-
} finally{
|
|
5471
|
-
try {
|
|
5472
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5473
|
-
_iterator.return();
|
|
5474
|
-
}
|
|
5475
|
-
} finally{
|
|
5476
|
-
if (_didIteratorError) {
|
|
5477
|
-
throw _iteratorError;
|
|
5478
|
-
}
|
|
5479
|
-
}
|
|
5480
|
-
}
|
|
5481
|
-
if (this.config.debugAdTiming && processedUrls.size > 0) {
|
|
5482
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE6 Skipping ".concat(processedUrls.size, " already-preloaded ads"));
|
|
5483
|
-
}
|
|
5484
|
-
_state.label = 1;
|
|
5485
|
-
case 1:
|
|
5486
|
-
if (!true) return [
|
|
5487
|
-
3,
|
|
5488
|
-
6
|
|
5489
|
-
];
|
|
5490
|
-
nextUrl = this.adPodAllUrls.find(function(url) {
|
|
5491
|
-
return !processedUrls.has(url);
|
|
5492
|
-
});
|
|
5493
|
-
if (!nextUrl) {
|
|
5494
|
-
if (this.config.debugAdTiming) {
|
|
5495
|
-
console.log("[ADAPTIVE-POD] ✅ All queued ads processed (".concat(processedUrls.size, " total)"));
|
|
5496
|
-
}
|
|
5497
|
-
return [
|
|
5498
|
-
3,
|
|
5499
|
-
6
|
|
5500
|
-
];
|
|
5501
|
-
}
|
|
5502
|
-
processedUrls.add(nextUrl);
|
|
5503
|
-
if (this.config.debugAdTiming) {
|
|
5504
|
-
console.log("[ADAPTIVE-POD] \uD83D\uDCE5 Preloading ad ".concat(processedUrls.size, "/").concat(this.adPodAllUrls.length, "..."));
|
|
5505
|
-
}
|
|
5506
|
-
_state.label = 2;
|
|
5507
|
-
case 2:
|
|
5508
|
-
_state.trys.push([
|
|
5509
|
-
2,
|
|
5510
|
-
4,
|
|
5511
|
-
,
|
|
5512
|
-
5
|
|
5513
|
-
]);
|
|
5514
|
-
return [
|
|
5515
|
-
4,
|
|
5516
|
-
this.preloadSingleAd(nextUrl)
|
|
5517
|
-
];
|
|
5518
|
-
case 3:
|
|
5519
|
-
_state.sent();
|
|
5520
|
-
return [
|
|
5521
|
-
3,
|
|
5522
|
-
5
|
|
5523
|
-
];
|
|
5524
|
-
case 4:
|
|
5525
|
-
error = _state.sent();
|
|
5526
|
-
if (this.config.debugAdTiming) {
|
|
5527
|
-
console.warn("[ADAPTIVE-POD] ⚠️ Preload failed for ad ".concat(processedUrls.size, ":"), error);
|
|
5528
|
-
}
|
|
5529
|
-
return [
|
|
5530
|
-
3,
|
|
5531
|
-
5
|
|
5532
|
-
];
|
|
5533
|
-
case 5:
|
|
5534
|
-
if (this.calculateAdditionalAdsNeeded() === 0) {
|
|
5535
|
-
if (this.config.debugAdTiming) {
|
|
5536
|
-
console.log("[ADAPTIVE-POD] ✅ Target duration reached (".concat(processedUrls.size, " ads preloaded), stopping"));
|
|
5537
|
-
}
|
|
5538
|
-
return [
|
|
5539
|
-
3,
|
|
5540
|
-
6
|
|
5541
|
-
];
|
|
5542
|
-
}
|
|
5543
|
-
return [
|
|
5544
|
-
3,
|
|
5545
|
-
1
|
|
5546
|
-
];
|
|
5547
|
-
case 6:
|
|
5548
|
-
if (this.config.debugAdTiming) {
|
|
5549
|
-
console.log("[ADAPTIVE-POD] ✅ Sequential preloading completed (".concat(processedUrls.size, " ads ready)"));
|
|
5550
|
-
}
|
|
5551
|
-
return [
|
|
5552
|
-
3,
|
|
5553
|
-
9
|
|
5554
|
-
];
|
|
5555
|
-
case 7:
|
|
5556
|
-
if (this.config.debugAdTiming) {
|
|
5557
|
-
console.log("[StormcloudVideoPlayer] Starting parallel preload of ".concat(this.adPodAllUrls.length, " ads"));
|
|
5558
|
-
}
|
|
5559
|
-
preloadPromises = this.adPodAllUrls.map(function(vastTagUrl) {
|
|
5560
|
-
return _this.preloadSingleAd(vastTagUrl).catch(function(error) {
|
|
5561
|
-
if (_this.config.debugAdTiming) {
|
|
5562
|
-
console.warn("[StormcloudVideoPlayer] Preload failed for ".concat(vastTagUrl, ":"), error);
|
|
5563
|
-
}
|
|
5564
|
-
});
|
|
5565
|
-
});
|
|
5566
|
-
return [
|
|
5567
|
-
4,
|
|
5568
|
-
Promise.all(preloadPromises)
|
|
5569
|
-
];
|
|
5570
|
-
case 8:
|
|
5571
|
-
_state.sent();
|
|
5572
|
-
if (this.config.debugAdTiming) {
|
|
5573
|
-
console.log("[StormcloudVideoPlayer] Background preloading completed for all ads");
|
|
5574
|
-
}
|
|
5575
|
-
_state.label = 9;
|
|
5576
|
-
case 9:
|
|
5577
|
-
return [
|
|
5578
|
-
2
|
|
5579
|
-
];
|
|
5580
|
-
}
|
|
5581
|
-
});
|
|
5582
|
-
}).call(this);
|
|
5583
|
-
}
|
|
5584
|
-
},
|
|
5585
|
-
{
|
|
5586
|
-
key: "preloadSingleAd",
|
|
5587
|
-
value: function preloadSingleAd(vastTagUrl) {
|
|
5588
|
-
return _async_to_generator(function() {
|
|
5589
|
-
var _this, duration, mediaUrls, primaryMediaUrl, error;
|
|
5590
|
-
return _ts_generator(this, function(_state) {
|
|
5591
|
-
switch(_state.label){
|
|
5592
|
-
case 0:
|
|
5593
|
-
_this = this;
|
|
5594
|
-
if (!vastTagUrl) return [
|
|
5595
|
-
2
|
|
5596
|
-
];
|
|
5597
|
-
_state.label = 1;
|
|
5598
|
-
case 1:
|
|
5599
|
-
_state.trys.push([
|
|
5600
|
-
1,
|
|
5601
|
-
11,
|
|
5602
|
-
,
|
|
5603
|
-
12
|
|
5604
|
-
]);
|
|
5605
|
-
if (!(this.isAdaptiveMode && !this.fetchedAdDurations.has(vastTagUrl))) return [
|
|
5606
|
-
3,
|
|
5607
|
-
4
|
|
5608
|
-
];
|
|
5609
|
-
return [
|
|
5610
|
-
4,
|
|
5611
|
-
this.fetchVastDuration(vastTagUrl)
|
|
5612
|
-
];
|
|
5613
|
-
case 2:
|
|
5614
|
-
duration = _state.sent();
|
|
5615
|
-
if (!(duration !== null)) return [
|
|
5616
|
-
3,
|
|
5617
|
-
4
|
|
5618
|
-
];
|
|
5619
|
-
this.fetchedAdDurations.set(vastTagUrl, duration);
|
|
5620
|
-
if (this.config.debugAdTiming) {
|
|
5621
|
-
console.log("[ADAPTIVE-POD] ✓ Fetched ad duration: ".concat(duration, "s (").concat(this.fetchedAdDurations.size, " ads fetched so far)"));
|
|
5622
|
-
}
|
|
5623
|
-
return [
|
|
5624
|
-
4,
|
|
5625
|
-
this.addAdaptiveAdsToQueue()
|
|
5626
|
-
];
|
|
5627
|
-
case 3:
|
|
5628
|
-
_state.sent();
|
|
5629
|
-
_state.label = 4;
|
|
5630
|
-
case 4:
|
|
5631
|
-
if (!(this.ima.preloadAds && !this.ima.hasPreloadedAd(vastTagUrl))) return [
|
|
5632
|
-
3,
|
|
5633
|
-
6
|
|
5634
|
-
];
|
|
5635
|
-
if (!!this.preloadingAdUrls.has(vastTagUrl)) return [
|
|
5636
|
-
3,
|
|
5637
|
-
6
|
|
5638
|
-
];
|
|
5639
|
-
if (this.config.debugAdTiming) {
|
|
5640
|
-
console.log("[StormcloudVideoPlayer] Preloading VAST: ".concat(vastTagUrl));
|
|
5641
|
-
}
|
|
5642
|
-
this.preloadingAdUrls.add(vastTagUrl);
|
|
5643
|
-
return [
|
|
5644
|
-
4,
|
|
5645
|
-
this.ima.preloadAds(vastTagUrl).then(function() {
|
|
5646
|
-
if (_this.config.debugAdTiming) {
|
|
5647
|
-
console.log("[StormcloudVideoPlayer] IMA VAST preload complete: ".concat(vastTagUrl));
|
|
5648
|
-
}
|
|
5649
|
-
}).catch(function(error) {
|
|
5650
|
-
if (_this.config.debugAdTiming) {
|
|
5651
|
-
console.warn("[StormcloudVideoPlayer] IMA VAST preload failed: ".concat(vastTagUrl), error);
|
|
5652
|
-
}
|
|
5653
|
-
}).finally(function() {
|
|
5654
|
-
_this.preloadingAdUrls.delete(vastTagUrl);
|
|
5655
|
-
})
|
|
5656
|
-
];
|
|
5657
|
-
case 5:
|
|
5658
|
-
_state.sent();
|
|
5659
|
-
_state.label = 6;
|
|
5660
|
-
case 6:
|
|
5661
|
-
mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5662
|
-
if (!!mediaUrls) return [
|
|
5663
|
-
3,
|
|
5664
|
-
8
|
|
5665
|
-
];
|
|
5666
|
-
if (this.config.debugAdTiming) {
|
|
5667
|
-
console.log("[StormcloudVideoPlayer] Fetching and parsing VAST to extract media URLs: ".concat(vastTagUrl));
|
|
5668
|
-
}
|
|
5669
|
-
return [
|
|
5670
|
-
4,
|
|
5671
|
-
this.fetchAndParseVastXml(vastTagUrl)
|
|
5672
|
-
];
|
|
5673
|
-
case 7:
|
|
5674
|
-
mediaUrls = _state.sent();
|
|
5675
|
-
if (this.config.debugAdTiming) {
|
|
5676
|
-
console.log("[StormcloudVideoPlayer] Extracted ".concat(mediaUrls.length, " media URLs:"), mediaUrls);
|
|
5677
|
-
}
|
|
5678
|
-
if (mediaUrls.length > 0) {
|
|
5679
|
-
this.vastToMediaUrlMap.set(vastTagUrl, mediaUrls);
|
|
5680
|
-
}
|
|
5681
|
-
_state.label = 8;
|
|
5682
|
-
case 8:
|
|
5683
|
-
if (!(mediaUrls && mediaUrls.length > 0)) return [
|
|
5684
|
-
3,
|
|
5685
|
-
10
|
|
5686
|
-
];
|
|
5687
|
-
primaryMediaUrl = mediaUrls[0];
|
|
5688
|
-
if (!(primaryMediaUrl && !this.preloadedMediaUrls.has(primaryMediaUrl))) return [
|
|
5689
|
-
3,
|
|
5690
|
-
10
|
|
5691
|
-
];
|
|
5692
|
-
return [
|
|
5693
|
-
4,
|
|
5694
|
-
this.preloadMediaFile(primaryMediaUrl)
|
|
5695
|
-
];
|
|
5696
|
-
case 9:
|
|
5697
|
-
_state.sent();
|
|
5698
|
-
_state.label = 10;
|
|
5699
|
-
case 10:
|
|
5700
|
-
return [
|
|
5701
|
-
3,
|
|
5702
|
-
12
|
|
5703
|
-
];
|
|
5704
|
-
case 11:
|
|
5705
|
-
error = _state.sent();
|
|
5706
|
-
if (this.config.debugAdTiming) {
|
|
5707
|
-
console.warn("[StormcloudVideoPlayer] Failed to preload ad: ".concat(vastTagUrl), error);
|
|
5708
|
-
}
|
|
5709
|
-
return [
|
|
5710
|
-
3,
|
|
5711
|
-
12
|
|
5712
|
-
];
|
|
5713
|
-
case 12:
|
|
5714
|
-
return [
|
|
5715
|
-
2
|
|
5716
|
-
];
|
|
5717
|
-
}
|
|
5718
|
-
});
|
|
5719
|
-
}).call(this);
|
|
5720
|
-
}
|
|
5721
|
-
},
|
|
5722
|
-
{
|
|
5723
|
-
key: "findNextPreloadedAd",
|
|
5724
|
-
value: function findNextPreloadedAd() {
|
|
5725
|
-
for(var i = 0; i < this.adPodQueue.length; i++){
|
|
5726
|
-
var _this_ima_hasPreloadedAd, _this_ima;
|
|
5727
|
-
var vastTagUrl = this.adPodQueue[i];
|
|
5728
|
-
if (!vastTagUrl) continue;
|
|
5729
|
-
if (this.failedVastUrls.has(vastTagUrl)) {
|
|
5730
|
-
console.warn("[AD-ERROR] Skipping failed URL in queue");
|
|
5731
|
-
continue;
|
|
5732
|
-
}
|
|
5733
|
-
var _this_ima_hasPreloadedAd1;
|
|
5734
|
-
var hasImaPreload = (_this_ima_hasPreloadedAd1 = (_this_ima_hasPreloadedAd = (_this_ima = this.ima).hasPreloadedAd) === null || _this_ima_hasPreloadedAd === void 0 ? void 0 : _this_ima_hasPreloadedAd.call(_this_ima, vastTagUrl)) !== null && _this_ima_hasPreloadedAd1 !== void 0 ? _this_ima_hasPreloadedAd1 : false;
|
|
5735
|
-
var mediaUrls = this.vastToMediaUrlMap.get(vastTagUrl);
|
|
5736
|
-
var hasMediaPreload = mediaUrls && mediaUrls.length > 0 ? this.preloadedMediaUrls.has(mediaUrls[0]) : false;
|
|
5737
|
-
if (hasImaPreload || hasMediaPreload) {
|
|
5738
|
-
this.adPodQueue.splice(0, i + 1);
|
|
5739
|
-
return vastTagUrl;
|
|
5740
|
-
}
|
|
5741
|
-
}
|
|
5742
|
-
return void 0;
|
|
5743
|
-
}
|
|
5744
|
-
},
|
|
5745
5061
|
{
|
|
5746
5062
|
key: "getRemainingAdMs",
|
|
5747
5063
|
value: function getRemainingAdMs() {
|
|
@@ -5928,7 +5244,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5928
5244
|
}
|
|
5929
5245
|
if (this.ima && this.ima.isAdPlaying()) {
|
|
5930
5246
|
var width = this.video.clientWidth || 640;
|
|
5931
|
-
var height = this.video.clientHeight ||
|
|
5247
|
+
var height = this.video.clientHeight || 480;
|
|
5932
5248
|
if (this.config.debugAdTiming) {
|
|
5933
5249
|
console.log("[StormcloudVideoPlayer] Resizing ads manager to ".concat(width, "x").concat(height));
|
|
5934
5250
|
}
|
|
@@ -5959,11 +5275,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5959
5275
|
}
|
|
5960
5276
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
5961
5277
|
(_this_ima = this.ima) === null || _this_ima === void 0 ? void 0 : _this_ima.destroy();
|
|
5962
|
-
this.preloadingAdUrls.clear();
|
|
5963
|
-
this.vastToMediaUrlMap.clear();
|
|
5964
|
-
this.preloadedMediaUrls.clear();
|
|
5965
|
-
this.preloadingMediaUrls.clear();
|
|
5966
|
-
this.adPodAllUrls = [];
|
|
5967
5278
|
this.adRequestQueue = [];
|
|
5968
5279
|
this.successfulAdRequests = [];
|
|
5969
5280
|
}
|