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