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/index.js
CHANGED
|
@@ -3099,9 +3099,10 @@ var StormcloudVideoPlayer = class {
|
|
|
3099
3099
|
}
|
|
3100
3100
|
break;
|
|
3101
3101
|
}
|
|
3102
|
-
|
|
3102
|
+
const maxQueueSize = 3;
|
|
3103
|
+
if (this.adRequestQueue.length >= maxQueueSize) {
|
|
3103
3104
|
if (this.config.debugAdTiming) {
|
|
3104
|
-
console.log(`[CONTINUOUS-FETCH] \
|
|
3105
|
+
console.log(`[CONTINUOUS-FETCH] \u23F8\uFE0F Queue full (${this.adRequestQueue.length}), pausing fetching...`);
|
|
3105
3106
|
}
|
|
3106
3107
|
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
3107
3108
|
continue;
|
|
@@ -3112,7 +3113,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3112
3113
|
continue;
|
|
3113
3114
|
}
|
|
3114
3115
|
if (this.config.debugAdTiming) {
|
|
3115
|
-
console.log(
|
|
3116
|
+
console.log(`[CONTINUOUS-FETCH] \u{1F4E1} Attempting to fetch ad (${this.successfulAdRequests.length + this.adRequestQueue.length + 1} total)...`);
|
|
3116
3117
|
}
|
|
3117
3118
|
try {
|
|
3118
3119
|
const response = await fetch(newAdUrl, { mode: "cors" });
|
|
@@ -3132,17 +3133,17 @@ var StormcloudVideoPlayer = class {
|
|
|
3132
3133
|
continue;
|
|
3133
3134
|
}
|
|
3134
3135
|
if (this.config.debugAdTiming) {
|
|
3135
|
-
console.log(
|
|
3136
|
+
console.log(`[CONTINUOUS-FETCH] \u2705 Successfully fetched ad, adding to queue (queue size: ${this.adRequestQueue.length + 1})`);
|
|
3136
3137
|
}
|
|
3137
3138
|
this.adRequestQueue.push(newAdUrl);
|
|
3138
3139
|
this.totalAdsInBreak++;
|
|
3139
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
3140
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
3140
3141
|
} catch (error) {
|
|
3141
3142
|
if (this.config.debugAdTiming) {
|
|
3142
3143
|
console.log("[CONTINUOUS-FETCH] \u274C Ad fetch failed:", error.message);
|
|
3143
3144
|
}
|
|
3144
3145
|
this.failedVastUrls.add(newAdUrl);
|
|
3145
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
3146
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
3146
3147
|
}
|
|
3147
3148
|
}
|
|
3148
3149
|
if (this.config.debugAdTiming) {
|
|
@@ -3155,7 +3156,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3155
3156
|
console.log("[CONTINUOUS-FETCH] \u{1F6D1} Stopping continuous ad fetching");
|
|
3156
3157
|
}
|
|
3157
3158
|
}
|
|
3158
|
-
async tryNextAvailableAd() {
|
|
3159
|
+
async tryNextAvailableAd(retryCount = 0) {
|
|
3159
3160
|
const remaining = this.getRemainingAdMs();
|
|
3160
3161
|
if (remaining <= 500) {
|
|
3161
3162
|
if (this.config.debugAdTiming) {
|
|
@@ -3168,15 +3169,25 @@ var StormcloudVideoPlayer = class {
|
|
|
3168
3169
|
const nextAdUrl = this.adRequestQueue.shift();
|
|
3169
3170
|
if (nextAdUrl) {
|
|
3170
3171
|
if (this.config.debugAdTiming) {
|
|
3171
|
-
console.log(
|
|
3172
|
+
console.log(`[CONTINUOUS-FETCH] \u{1F3AC} Playing next queued ad (${this.currentAdIndex + 1}/${this.totalAdsInBreak}, ${this.adRequestQueue.length} remaining in queue)`);
|
|
3172
3173
|
}
|
|
3173
3174
|
this.currentAdIndex++;
|
|
3175
|
+
this.successfulAdRequests.push(nextAdUrl);
|
|
3174
3176
|
await this.playSingleAd(nextAdUrl).catch(() => {
|
|
3175
|
-
this.tryNextAvailableAd();
|
|
3177
|
+
this.tryNextAvailableAd(0);
|
|
3176
3178
|
});
|
|
3177
3179
|
return;
|
|
3178
3180
|
}
|
|
3179
3181
|
}
|
|
3182
|
+
const maxRetries = 5;
|
|
3183
|
+
if (this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3) {
|
|
3184
|
+
if (this.config.debugAdTiming) {
|
|
3185
|
+
console.log(`[CONTINUOUS-FETCH] \u23F3 Queue empty but fetching active, waiting... (retry ${retryCount + 1}/${maxRetries})`);
|
|
3186
|
+
}
|
|
3187
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
3188
|
+
await this.tryNextAvailableAd(retryCount + 1);
|
|
3189
|
+
return;
|
|
3190
|
+
}
|
|
3180
3191
|
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
3181
3192
|
this.showPlaceholderAndWaitForAds();
|
|
3182
3193
|
} else {
|