stormcloud-video-player 0.3.16 → 0.3.18
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 -10
- package/lib/index.cjs +314 -142
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +7 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +314 -142
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +303 -139
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +7 -0
- package/lib/players/FilePlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +303 -139
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +303 -139
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +6 -0
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/ima.cjs +4 -0
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +314 -142
- 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 +5 -1
- package/rollup.config.js +22 -0
|
@@ -286,6 +286,20 @@ function _ts_generator(thisArg, body) {
|
|
|
286
286
|
};
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
+
function _ts_values(o) {
|
|
290
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
291
|
+
if (m) return m.call(o);
|
|
292
|
+
if (o && typeof o.length === "number") return {
|
|
293
|
+
next: function() {
|
|
294
|
+
if (o && i >= o.length) o = void 0;
|
|
295
|
+
return {
|
|
296
|
+
value: o && o[i++],
|
|
297
|
+
done: !o
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
302
|
+
}
|
|
289
303
|
var __create = Object.create;
|
|
290
304
|
var __defProp = Object.defineProperty;
|
|
291
305
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -1276,6 +1290,7 @@ function createImaController(video, options) {
|
|
|
1276
1290
|
},
|
|
1277
1291
|
showPlaceholder: function showPlaceholder() {
|
|
1278
1292
|
ensurePlaceholderContainer();
|
|
1293
|
+
hideContentVideo();
|
|
1279
1294
|
if (adContainerEl) {
|
|
1280
1295
|
adContainerEl.style.display = "flex";
|
|
1281
1296
|
adContainerEl.style.backgroundColor = "#000";
|
|
@@ -1295,6 +1310,9 @@ function createImaController(video, options) {
|
|
|
1295
1310
|
}
|
|
1296
1311
|
}, 300);
|
|
1297
1312
|
}
|
|
1313
|
+
if (!adPlaying) {
|
|
1314
|
+
showContentVideo();
|
|
1315
|
+
}
|
|
1298
1316
|
}
|
|
1299
1317
|
};
|
|
1300
1318
|
}
|
|
@@ -2069,6 +2087,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2069
2087
|
return 1;
|
|
2070
2088
|
},
|
|
2071
2089
|
showPlaceholder: function showPlaceholder() {
|
|
2090
|
+
contentVideo.style.opacity = "0";
|
|
2091
|
+
contentVideo.style.visibility = "hidden";
|
|
2072
2092
|
if (!adContainerEl) {
|
|
2073
2093
|
var _contentVideo_parentElement;
|
|
2074
2094
|
var container = document.createElement("div");
|
|
@@ -2096,6 +2116,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2096
2116
|
adContainerEl.style.display = "none";
|
|
2097
2117
|
adContainerEl.style.pointerEvents = "none";
|
|
2098
2118
|
}
|
|
2119
|
+
if (!adPlaying) {
|
|
2120
|
+
contentVideo.style.visibility = "visible";
|
|
2121
|
+
contentVideo.style.opacity = "1";
|
|
2122
|
+
}
|
|
2099
2123
|
}
|
|
2100
2124
|
};
|
|
2101
2125
|
}
|
|
@@ -2750,6 +2774,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2750
2774
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2751
2775
|
this.placeholderStartTimeMs = null;
|
|
2752
2776
|
this.isShowingPlaceholder = false;
|
|
2777
|
+
this.consecutiveEmptyResponses = 0;
|
|
2778
|
+
this.totalAdRequestsInBreak = 0;
|
|
2779
|
+
this.lastEmptyResponseTimeMs = 0;
|
|
2780
|
+
this.maxTotalAdRequestsPerBreak = 20;
|
|
2781
|
+
this.maxConsecutiveEmptyResponses = 5;
|
|
2782
|
+
this.baseEmptyResponseDelayMs = 2e3;
|
|
2783
|
+
this.maxEmptyResponseDelayMs = 3e4;
|
|
2753
2784
|
initializePolyfills();
|
|
2754
2785
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2755
2786
|
this.config = _object_spread({}, config, browserOverrides);
|
|
@@ -2939,6 +2970,87 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2939
2970
|
});
|
|
2940
2971
|
}).call(_this);
|
|
2941
2972
|
});
|
|
2973
|
+
this.hls.on(import_hls2.default.Events.LEVEL_LOADED, function(_evt, data) {
|
|
2974
|
+
if (_this.inAdBreak) {
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2977
|
+
var details = data === null || data === void 0 ? void 0 : data.details;
|
|
2978
|
+
if (!details || !details.fragments || details.fragments.length === 0) {
|
|
2979
|
+
return;
|
|
2980
|
+
}
|
|
2981
|
+
var fragmentsToScan = Math.min(5, details.fragments.length);
|
|
2982
|
+
for(var i = 0; i < fragmentsToScan; i++){
|
|
2983
|
+
var frag = details.fragments[i];
|
|
2984
|
+
var tagList = frag === null || frag === void 0 ? void 0 : frag.tagList;
|
|
2985
|
+
if (!Array.isArray(tagList)) continue;
|
|
2986
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2987
|
+
try {
|
|
2988
|
+
for(var _iterator = tagList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2989
|
+
var entry = _step.value;
|
|
2990
|
+
var tag = "";
|
|
2991
|
+
var value = "";
|
|
2992
|
+
if (Array.isArray(entry)) {
|
|
2993
|
+
var _entry_;
|
|
2994
|
+
tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
|
|
2995
|
+
var _entry_1;
|
|
2996
|
+
value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
|
|
2997
|
+
} else if (typeof entry === "string") {
|
|
2998
|
+
var idx = entry.indexOf(":");
|
|
2999
|
+
if (idx >= 0) {
|
|
3000
|
+
tag = entry.substring(0, idx);
|
|
3001
|
+
value = entry.substring(idx + 1);
|
|
3002
|
+
} else {
|
|
3003
|
+
tag = entry;
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
if (!tag) continue;
|
|
3007
|
+
if (tag.includes("EXT-X-CUE-OUT") || tag.includes("EXT-X-DATERANGE")) {
|
|
3008
|
+
var attrs = tag.includes("EXT-X-DATERANGE") ? _this.parseAttributeList(value) : {};
|
|
3009
|
+
var hasScteOut = tag.includes("EXT-X-CUE-OUT") || "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
3010
|
+
if (hasScteOut) {
|
|
3011
|
+
if (_this.config.debugAdTiming) {
|
|
3012
|
+
console.log("[StormcloudVideoPlayer] \uD83C\uDFAF EARLY SCTE-35 DETECTION: Ad break marker found in fragment", i, "- triggering ad handling immediately");
|
|
3013
|
+
}
|
|
3014
|
+
var durationSeconds = _this.parseCueOutDuration(value);
|
|
3015
|
+
var marker = _object_spread_props(_object_spread({
|
|
3016
|
+
type: "start"
|
|
3017
|
+
}, durationSeconds !== void 0 ? {
|
|
3018
|
+
durationSeconds: durationSeconds
|
|
3019
|
+
} : {}), {
|
|
3020
|
+
raw: {
|
|
3021
|
+
tag: tag,
|
|
3022
|
+
value: value,
|
|
3023
|
+
earlyDetection: true
|
|
3024
|
+
}
|
|
3025
|
+
});
|
|
3026
|
+
_this.inAdBreak = true;
|
|
3027
|
+
_this.expectedAdBreakDurationMs = durationSeconds ? durationSeconds * 1e3 : void 0;
|
|
3028
|
+
_this.currentAdBreakStartWallClockMs = Date.now();
|
|
3029
|
+
_this.clearAdStartTimer();
|
|
3030
|
+
_this.handleAdStart(marker);
|
|
3031
|
+
if (_this.expectedAdBreakDurationMs != null) {
|
|
3032
|
+
_this.scheduleAdStopCountdown(_this.expectedAdBreakDurationMs);
|
|
3033
|
+
}
|
|
3034
|
+
return;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
} catch (err) {
|
|
3039
|
+
_didIteratorError = true;
|
|
3040
|
+
_iteratorError = err;
|
|
3041
|
+
} finally{
|
|
3042
|
+
try {
|
|
3043
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3044
|
+
_iterator.return();
|
|
3045
|
+
}
|
|
3046
|
+
} finally{
|
|
3047
|
+
if (_didIteratorError) {
|
|
3048
|
+
throw _iteratorError;
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
});
|
|
2942
3054
|
this.hls.on(import_hls2.default.Events.FRAG_BUFFERED, function(_evt, data) {
|
|
2943
3055
|
return _async_to_generator(function() {
|
|
2944
3056
|
var _this, _this_config_minSegmentsBeforePlay, minSegments, _this_video_play;
|
|
@@ -3146,11 +3258,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3146
3258
|
this.ima.initialize();
|
|
3147
3259
|
this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3148
3260
|
this.ima.on("all_ads_completed", function() {
|
|
3261
|
+
var remaining = _this.getRemainingAdMs();
|
|
3149
3262
|
if (_this.config.debugAdTiming) {
|
|
3150
|
-
console.log("[StormcloudVideoPlayer] IMA all_ads_completed event received -
|
|
3263
|
+
console.log("[StormcloudVideoPlayer] IMA all_ads_completed event received - remaining=".concat(remaining, "ms, queued ads=").concat(_this.adRequestQueue.length));
|
|
3151
3264
|
}
|
|
3152
3265
|
if (_this.inAdBreak) {
|
|
3153
|
-
|
|
3266
|
+
if (remaining > 500) {
|
|
3267
|
+
_this.tryNextAvailableAd();
|
|
3268
|
+
} else {
|
|
3269
|
+
_this.handleAdPodComplete();
|
|
3270
|
+
}
|
|
3154
3271
|
}
|
|
3155
3272
|
});
|
|
3156
3273
|
this.ima.on("ad_error", function(errorPayload) {
|
|
@@ -3945,6 +4062,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3945
4062
|
this.continuousFetchingActive = true;
|
|
3946
4063
|
this.isShowingPlaceholder = false;
|
|
3947
4064
|
this.placeholderStartTimeMs = null;
|
|
4065
|
+
this.consecutiveEmptyResponses = 0;
|
|
4066
|
+
this.totalAdRequestsInBreak = 0;
|
|
4067
|
+
this.lastEmptyResponseTimeMs = 0;
|
|
3948
4068
|
currentMuted = this.video.muted;
|
|
3949
4069
|
currentVolume = this.video.volume;
|
|
3950
4070
|
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
@@ -3952,6 +4072,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3952
4072
|
this.currentAdIndex = 0;
|
|
3953
4073
|
this.totalAdsInBreak = 1;
|
|
3954
4074
|
this.adPodQueue = [];
|
|
4075
|
+
this.showAds = true;
|
|
4076
|
+
this.ima.showPlaceholder();
|
|
3955
4077
|
if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
3956
4078
|
this.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
3957
4079
|
this.currentAdBreakStartWallClockMs = Date.now();
|
|
@@ -4038,158 +4160,200 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4038
4160
|
key: "continuousFetchLoop",
|
|
4039
4161
|
value: function continuousFetchLoop(baseVastUrl) {
|
|
4040
4162
|
return _async_to_generator(function() {
|
|
4041
|
-
var
|
|
4163
|
+
var _this, _loop, _ret;
|
|
4042
4164
|
return _ts_generator(this, function(_state) {
|
|
4043
4165
|
switch(_state.label){
|
|
4044
4166
|
case 0:
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4167
|
+
_loop = function() {
|
|
4168
|
+
var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
|
|
4169
|
+
return _ts_generator(this, function(_state) {
|
|
4170
|
+
switch(_state.label){
|
|
4171
|
+
case 0:
|
|
4172
|
+
remaining = _this.getRemainingAdMs();
|
|
4173
|
+
if (remaining <= 0) {
|
|
4174
|
+
if (_this.config.debugAdTiming) {
|
|
4175
|
+
console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
|
|
4176
|
+
}
|
|
4177
|
+
return [
|
|
4178
|
+
2,
|
|
4179
|
+
"break"
|
|
4180
|
+
];
|
|
4181
|
+
}
|
|
4182
|
+
if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
|
|
4183
|
+
if (_this.config.debugAdTiming) {
|
|
4184
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
|
|
4185
|
+
}
|
|
4186
|
+
return [
|
|
4187
|
+
2,
|
|
4188
|
+
"break"
|
|
4189
|
+
];
|
|
4190
|
+
}
|
|
4191
|
+
if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
|
|
4192
|
+
if (_this.config.debugAdTiming) {
|
|
4193
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
|
|
4194
|
+
}
|
|
4195
|
+
return [
|
|
4196
|
+
2,
|
|
4197
|
+
"break"
|
|
4198
|
+
];
|
|
4199
|
+
}
|
|
4200
|
+
maxQueueSize = 3;
|
|
4201
|
+
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
4202
|
+
3,
|
|
4203
|
+
2
|
|
4204
|
+
];
|
|
4205
|
+
if (_this.config.debugAdTiming) {
|
|
4206
|
+
console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
|
|
4207
|
+
}
|
|
4208
|
+
return [
|
|
4209
|
+
4,
|
|
4210
|
+
new Promise(function(resolve) {
|
|
4211
|
+
return setTimeout(resolve, 2e3);
|
|
4212
|
+
})
|
|
4213
|
+
];
|
|
4214
|
+
case 1:
|
|
4215
|
+
_state.sent();
|
|
4216
|
+
return [
|
|
4217
|
+
2,
|
|
4218
|
+
"continue"
|
|
4219
|
+
];
|
|
4220
|
+
case 2:
|
|
4221
|
+
newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4222
|
+
if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
|
|
4223
|
+
3,
|
|
4224
|
+
4
|
|
4225
|
+
];
|
|
4226
|
+
return [
|
|
4227
|
+
4,
|
|
4228
|
+
new Promise(function(resolve) {
|
|
4229
|
+
return setTimeout(resolve, 1e3);
|
|
4230
|
+
})
|
|
4231
|
+
];
|
|
4232
|
+
case 3:
|
|
4233
|
+
_state.sent();
|
|
4234
|
+
return [
|
|
4235
|
+
2,
|
|
4236
|
+
"continue"
|
|
4237
|
+
];
|
|
4238
|
+
case 4:
|
|
4239
|
+
_this.totalAdRequestsInBreak++;
|
|
4240
|
+
if (_this.config.debugAdTiming) {
|
|
4241
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
|
|
4242
|
+
}
|
|
4243
|
+
_state.label = 5;
|
|
4244
|
+
case 5:
|
|
4245
|
+
_state.trys.push([
|
|
4246
|
+
5,
|
|
4247
|
+
11,
|
|
4248
|
+
,
|
|
4249
|
+
13
|
|
4250
|
+
]);
|
|
4251
|
+
if (!_this.ima.preloadAds) return [
|
|
4252
|
+
3,
|
|
4253
|
+
7
|
|
4254
|
+
];
|
|
4255
|
+
return [
|
|
4256
|
+
4,
|
|
4257
|
+
_this.ima.preloadAds(newAdUrl)
|
|
4258
|
+
];
|
|
4259
|
+
case 6:
|
|
4260
|
+
_state.sent();
|
|
4261
|
+
_state.label = 7;
|
|
4262
|
+
case 7:
|
|
4263
|
+
hasPreloadedAd = (_this_ima_hasPreloadedAd1 = (_this_ima_hasPreloadedAd = (_this_ima = _this.ima).hasPreloadedAd) === null || _this_ima_hasPreloadedAd === void 0 ? void 0 : _this_ima_hasPreloadedAd.call(_this_ima, newAdUrl)) !== null && _this_ima_hasPreloadedAd1 !== void 0 ? _this_ima_hasPreloadedAd1 : false;
|
|
4264
|
+
if (!!hasPreloadedAd) return [
|
|
4265
|
+
3,
|
|
4266
|
+
9
|
|
4267
|
+
];
|
|
4268
|
+
_this.consecutiveEmptyResponses++;
|
|
4269
|
+
_this.lastEmptyResponseTimeMs = Date.now();
|
|
4270
|
+
backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4271
|
+
if (_this.config.debugAdTiming) {
|
|
4272
|
+
console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
|
|
4273
|
+
}
|
|
4274
|
+
_this.failedVastUrls.add(newAdUrl);
|
|
4275
|
+
return [
|
|
4276
|
+
4,
|
|
4277
|
+
new Promise(function(resolve) {
|
|
4278
|
+
return setTimeout(resolve, backoffDelay);
|
|
4279
|
+
})
|
|
4280
|
+
];
|
|
4281
|
+
case 8:
|
|
4282
|
+
_state.sent();
|
|
4283
|
+
return [
|
|
4284
|
+
2,
|
|
4285
|
+
"continue"
|
|
4286
|
+
];
|
|
4287
|
+
case 9:
|
|
4288
|
+
_this.consecutiveEmptyResponses = 0;
|
|
4289
|
+
if (_this.config.debugAdTiming) {
|
|
4290
|
+
console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
|
|
4291
|
+
}
|
|
4292
|
+
_this.adRequestQueue.push(newAdUrl);
|
|
4293
|
+
_this.totalAdsInBreak++;
|
|
4294
|
+
return [
|
|
4295
|
+
4,
|
|
4296
|
+
new Promise(function(resolve) {
|
|
4297
|
+
return setTimeout(resolve, 500);
|
|
4298
|
+
})
|
|
4299
|
+
];
|
|
4300
|
+
case 10:
|
|
4301
|
+
_state.sent();
|
|
4302
|
+
return [
|
|
4303
|
+
3,
|
|
4304
|
+
13
|
|
4305
|
+
];
|
|
4306
|
+
case 11:
|
|
4307
|
+
error = _state.sent();
|
|
4308
|
+
if (_this.config.debugAdTiming) {
|
|
4309
|
+
console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
|
|
4310
|
+
}
|
|
4311
|
+
_this.failedVastUrls.add(newAdUrl);
|
|
4312
|
+
_this.consecutiveEmptyResponses++;
|
|
4313
|
+
backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
|
|
4314
|
+
return [
|
|
4315
|
+
4,
|
|
4316
|
+
new Promise(function(resolve) {
|
|
4317
|
+
return setTimeout(resolve, backoffDelay1);
|
|
4318
|
+
})
|
|
4319
|
+
];
|
|
4320
|
+
case 12:
|
|
4321
|
+
_state.sent();
|
|
4322
|
+
return [
|
|
4323
|
+
3,
|
|
4324
|
+
13
|
|
4325
|
+
];
|
|
4326
|
+
case 13:
|
|
4327
|
+
return [
|
|
4328
|
+
2
|
|
4329
|
+
];
|
|
4330
|
+
}
|
|
4331
|
+
});
|
|
4332
|
+
};
|
|
4333
|
+
_state.label = 1;
|
|
4073
4334
|
case 1:
|
|
4074
|
-
|
|
4075
|
-
return [
|
|
4076
|
-
3,
|
|
4077
|
-
0
|
|
4078
|
-
];
|
|
4079
|
-
case 2:
|
|
4080
|
-
newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
|
|
4081
|
-
if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
|
|
4335
|
+
if (!(this.continuousFetchingActive && this.inAdBreak)) return [
|
|
4082
4336
|
3,
|
|
4083
|
-
|
|
4337
|
+
3
|
|
4084
4338
|
];
|
|
4339
|
+
_this = this;
|
|
4085
4340
|
return [
|
|
4086
|
-
4,
|
|
4087
|
-
new Promise(function(resolve) {
|
|
4088
|
-
return setTimeout(resolve, 1e3);
|
|
4089
|
-
})
|
|
4090
|
-
];
|
|
4091
|
-
case 3:
|
|
4092
|
-
_state.sent();
|
|
4093
|
-
return [
|
|
4094
|
-
3,
|
|
4095
|
-
0
|
|
4096
|
-
];
|
|
4097
|
-
case 4:
|
|
4098
|
-
if (this.config.debugAdTiming) {
|
|
4099
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (".concat(this.successfulAdRequests.length + this.adRequestQueue.length + 1, " total)..."));
|
|
4100
|
-
}
|
|
4101
|
-
_state.label = 5;
|
|
4102
|
-
case 5:
|
|
4103
|
-
_state.trys.push([
|
|
4104
4341
|
5,
|
|
4105
|
-
|
|
4106
|
-
,
|
|
4107
|
-
13
|
|
4108
|
-
]);
|
|
4109
|
-
return [
|
|
4110
|
-
4,
|
|
4111
|
-
fetch(newAdUrl, {
|
|
4112
|
-
mode: "cors"
|
|
4113
|
-
})
|
|
4114
|
-
];
|
|
4115
|
-
case 6:
|
|
4116
|
-
response = _state.sent();
|
|
4117
|
-
if (!response.ok) {
|
|
4118
|
-
throw new Error("Failed to fetch VAST: ".concat(response.status));
|
|
4119
|
-
}
|
|
4120
|
-
return [
|
|
4121
|
-
4,
|
|
4122
|
-
response.text()
|
|
4123
|
-
];
|
|
4124
|
-
case 7:
|
|
4125
|
-
xmlText = _state.sent();
|
|
4126
|
-
parser = new DOMParser();
|
|
4127
|
-
xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
4128
|
-
mediaFiles = xmlDoc.querySelectorAll("MediaFile");
|
|
4129
|
-
if (!(mediaFiles.length === 0)) return [
|
|
4130
|
-
3,
|
|
4131
|
-
9
|
|
4132
|
-
];
|
|
4133
|
-
if (this.config.debugAdTiming) {
|
|
4134
|
-
console.log("[CONTINUOUS-FETCH] \u26A0\uFE0F VAST response has no media files, skipping");
|
|
4135
|
-
}
|
|
4136
|
-
this.failedVastUrls.add(newAdUrl);
|
|
4137
|
-
return [
|
|
4138
|
-
4,
|
|
4139
|
-
new Promise(function(resolve) {
|
|
4140
|
-
return setTimeout(resolve, 1e3);
|
|
4141
|
-
})
|
|
4342
|
+
_ts_values(_loop())
|
|
4142
4343
|
];
|
|
4143
|
-
case
|
|
4144
|
-
_state.sent();
|
|
4145
|
-
return [
|
|
4146
|
-
3,
|
|
4147
|
-
0
|
|
4148
|
-
];
|
|
4149
|
-
case 9:
|
|
4150
|
-
if (this.config.debugAdTiming) {
|
|
4151
|
-
console.log("[CONTINUOUS-FETCH] ✅ Successfully fetched ad, adding to queue (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
|
|
4152
|
-
}
|
|
4153
|
-
this.adRequestQueue.push(newAdUrl);
|
|
4154
|
-
this.totalAdsInBreak++;
|
|
4155
|
-
return [
|
|
4156
|
-
4,
|
|
4157
|
-
new Promise(function(resolve) {
|
|
4158
|
-
return setTimeout(resolve, 500);
|
|
4159
|
-
})
|
|
4160
|
-
];
|
|
4161
|
-
case 10:
|
|
4162
|
-
_state.sent();
|
|
4163
|
-
return [
|
|
4164
|
-
3,
|
|
4165
|
-
13
|
|
4166
|
-
];
|
|
4167
|
-
case 11:
|
|
4168
|
-
error = _state.sent();
|
|
4169
|
-
if (this.config.debugAdTiming) {
|
|
4170
|
-
console.log("[CONTINUOUS-FETCH] \u274C Ad fetch failed:", error.message);
|
|
4171
|
-
}
|
|
4172
|
-
this.failedVastUrls.add(newAdUrl);
|
|
4173
|
-
return [
|
|
4174
|
-
4,
|
|
4175
|
-
new Promise(function(resolve) {
|
|
4176
|
-
return setTimeout(resolve, 2e3);
|
|
4177
|
-
})
|
|
4178
|
-
];
|
|
4179
|
-
case 12:
|
|
4180
|
-
_state.sent();
|
|
4181
|
-
return [
|
|
4344
|
+
case 2:
|
|
4345
|
+
_ret = _state.sent();
|
|
4346
|
+
if (_ret === "break") return [
|
|
4182
4347
|
3,
|
|
4183
|
-
|
|
4348
|
+
3
|
|
4184
4349
|
];
|
|
4185
|
-
case 13:
|
|
4186
4350
|
return [
|
|
4187
4351
|
3,
|
|
4188
|
-
|
|
4352
|
+
1
|
|
4189
4353
|
];
|
|
4190
|
-
case
|
|
4354
|
+
case 3:
|
|
4191
4355
|
if (this.config.debugAdTiming) {
|
|
4192
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Continuous fetch loop ended");
|
|
4356
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Continuous fetch loop ended (total requests: ".concat(this.totalAdRequestsInBreak, ", empty responses: ").concat(this.consecutiveEmptyResponses, ")"));
|
|
4193
4357
|
}
|
|
4194
4358
|
return [
|
|
4195
4359
|
2
|
|
@@ -5957,11 +6121,17 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
|
|
|
5957
6121
|
if (!playerRef.current) return;
|
|
5958
6122
|
var checkAdStatus = function() {
|
|
5959
6123
|
if (playerRef.current) {
|
|
5960
|
-
var
|
|
6124
|
+
var _videoRef_current_dataset, _videoRef_current;
|
|
6125
|
+
var showAdsFromMethod = playerRef.current.isShowingAds();
|
|
6126
|
+
var showAdsFromAttribute = ((_videoRef_current = videoRef.current) === null || _videoRef_current === void 0 ? void 0 : (_videoRef_current_dataset = _videoRef_current.dataset) === null || _videoRef_current_dataset === void 0 ? void 0 : _videoRef_current_dataset.stormcloudAdPlaying) === "true";
|
|
6127
|
+
var showAds = showAdsFromMethod || showAdsFromAttribute;
|
|
5961
6128
|
var currentIndex = playerRef.current.getCurrentAdIndex();
|
|
5962
6129
|
var totalAds = playerRef.current.getTotalAdsInBreak();
|
|
5963
6130
|
setAdStatus(function(prev) {
|
|
5964
6131
|
if (prev.showAds !== showAds || prev.currentIndex !== currentIndex || prev.totalAds !== totalAds) {
|
|
6132
|
+
if (showAds && !prev.showAds) {
|
|
6133
|
+
setShowCenterPlay(false);
|
|
6134
|
+
}
|
|
5965
6135
|
return {
|
|
5966
6136
|
showAds: showAds,
|
|
5967
6137
|
currentIndex: currentIndex,
|
|
@@ -5972,7 +6142,7 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
|
|
|
5972
6142
|
});
|
|
5973
6143
|
}
|
|
5974
6144
|
};
|
|
5975
|
-
var interval = setInterval(checkAdStatus,
|
|
6145
|
+
var interval = setInterval(checkAdStatus, 50);
|
|
5976
6146
|
return function() {
|
|
5977
6147
|
return clearInterval(interval);
|
|
5978
6148
|
};
|
|
@@ -6100,7 +6270,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
|
|
|
6100
6270
|
}
|
|
6101
6271
|
};
|
|
6102
6272
|
var handlePause = function() {
|
|
6103
|
-
|
|
6273
|
+
var _playerRef_current, _videoRef_current_dataset, _videoRef_current;
|
|
6274
|
+
var isAdActive = ((_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.isShowingAds()) || ((_videoRef_current = videoRef.current) === null || _videoRef_current === void 0 ? void 0 : (_videoRef_current_dataset = _videoRef_current.dataset) === null || _videoRef_current_dataset === void 0 ? void 0 : _videoRef_current_dataset.stormcloudAdPlaying) === "true";
|
|
6275
|
+
if (playerRef.current && !isAdActive) {
|
|
6104
6276
|
setShowCenterPlay(true);
|
|
6105
6277
|
} else {
|
|
6106
6278
|
setShowCenterPlay(false);
|