stormcloud-video-player 0.3.10 → 0.3.11
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 +20 -9
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +20 -9
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +20 -9
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +20 -9
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +20 -9
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +20 -9
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/players/index.cjs
CHANGED
|
@@ -3143,9 +3143,10 @@ var StormcloudVideoPlayer = class {
|
|
|
3143
3143
|
}
|
|
3144
3144
|
break;
|
|
3145
3145
|
}
|
|
3146
|
-
|
|
3146
|
+
const maxQueueSize = 3;
|
|
3147
|
+
if (this.adRequestQueue.length >= maxQueueSize) {
|
|
3147
3148
|
if (this.config.debugAdTiming) {
|
|
3148
|
-
console.log(`[CONTINUOUS-FETCH] \
|
|
3149
|
+
console.log(`[CONTINUOUS-FETCH] \u23F8\uFE0F Queue full (${this.adRequestQueue.length}), pausing fetching...`);
|
|
3149
3150
|
}
|
|
3150
3151
|
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
3151
3152
|
continue;
|
|
@@ -3156,7 +3157,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3156
3157
|
continue;
|
|
3157
3158
|
}
|
|
3158
3159
|
if (this.config.debugAdTiming) {
|
|
3159
|
-
console.log(
|
|
3160
|
+
console.log(`[CONTINUOUS-FETCH] \u{1F4E1} Attempting to fetch ad (${this.successfulAdRequests.length + this.adRequestQueue.length + 1} total)...`);
|
|
3160
3161
|
}
|
|
3161
3162
|
try {
|
|
3162
3163
|
const response = await fetch(newAdUrl, { mode: "cors" });
|
|
@@ -3176,17 +3177,17 @@ var StormcloudVideoPlayer = class {
|
|
|
3176
3177
|
continue;
|
|
3177
3178
|
}
|
|
3178
3179
|
if (this.config.debugAdTiming) {
|
|
3179
|
-
console.log(
|
|
3180
|
+
console.log(`[CONTINUOUS-FETCH] \u2705 Successfully fetched ad, adding to queue (queue size: ${this.adRequestQueue.length + 1})`);
|
|
3180
3181
|
}
|
|
3181
3182
|
this.adRequestQueue.push(newAdUrl);
|
|
3182
3183
|
this.totalAdsInBreak++;
|
|
3183
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
3184
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
3184
3185
|
} catch (error) {
|
|
3185
3186
|
if (this.config.debugAdTiming) {
|
|
3186
3187
|
console.log("[CONTINUOUS-FETCH] \u274C Ad fetch failed:", error.message);
|
|
3187
3188
|
}
|
|
3188
3189
|
this.failedVastUrls.add(newAdUrl);
|
|
3189
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
3190
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
3190
3191
|
}
|
|
3191
3192
|
}
|
|
3192
3193
|
if (this.config.debugAdTiming) {
|
|
@@ -3199,7 +3200,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3199
3200
|
console.log("[CONTINUOUS-FETCH] \u{1F6D1} Stopping continuous ad fetching");
|
|
3200
3201
|
}
|
|
3201
3202
|
}
|
|
3202
|
-
async tryNextAvailableAd() {
|
|
3203
|
+
async tryNextAvailableAd(retryCount = 0) {
|
|
3203
3204
|
const remaining = this.getRemainingAdMs();
|
|
3204
3205
|
if (remaining <= 500) {
|
|
3205
3206
|
if (this.config.debugAdTiming) {
|
|
@@ -3212,15 +3213,25 @@ var StormcloudVideoPlayer = class {
|
|
|
3212
3213
|
const nextAdUrl = this.adRequestQueue.shift();
|
|
3213
3214
|
if (nextAdUrl) {
|
|
3214
3215
|
if (this.config.debugAdTiming) {
|
|
3215
|
-
console.log(
|
|
3216
|
+
console.log(`[CONTINUOUS-FETCH] \u{1F3AC} Playing next queued ad (${this.currentAdIndex + 1}/${this.totalAdsInBreak}, ${this.adRequestQueue.length} remaining in queue)`);
|
|
3216
3217
|
}
|
|
3217
3218
|
this.currentAdIndex++;
|
|
3219
|
+
this.successfulAdRequests.push(nextAdUrl);
|
|
3218
3220
|
await this.playSingleAd(nextAdUrl).catch(() => {
|
|
3219
|
-
this.tryNextAvailableAd();
|
|
3221
|
+
this.tryNextAvailableAd(0);
|
|
3220
3222
|
});
|
|
3221
3223
|
return;
|
|
3222
3224
|
}
|
|
3223
3225
|
}
|
|
3226
|
+
const maxRetries = 5;
|
|
3227
|
+
if (this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3) {
|
|
3228
|
+
if (this.config.debugAdTiming) {
|
|
3229
|
+
console.log(`[CONTINUOUS-FETCH] \u23F3 Queue empty but fetching active, waiting... (retry ${retryCount + 1}/${maxRetries})`);
|
|
3230
|
+
}
|
|
3231
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
3232
|
+
await this.tryNextAvailableAd(retryCount + 1);
|
|
3233
|
+
return;
|
|
3234
|
+
}
|
|
3224
3235
|
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
3225
3236
|
this.showPlaceholderAndWaitForAds();
|
|
3226
3237
|
} else {
|