stormcloud-video-player 0.3.10 → 0.3.12
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 +30 -9
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +30 -9
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +30 -9
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +30 -9
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +30 -9
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +30 -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,31 @@ 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)`);
|
|
3217
|
+
}
|
|
3218
|
+
const currentMuted = this.video.muted;
|
|
3219
|
+
const currentVolume = this.video.volume;
|
|
3220
|
+
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
3221
|
+
if (this.config.debugAdTiming) {
|
|
3222
|
+
console.log(`[CONTINUOUS-FETCH] \u{1F50A} Updated ad audio state: muted=${currentMuted}, volume=${currentVolume}`);
|
|
3216
3223
|
}
|
|
3217
3224
|
this.currentAdIndex++;
|
|
3225
|
+
this.successfulAdRequests.push(nextAdUrl);
|
|
3218
3226
|
await this.playSingleAd(nextAdUrl).catch(() => {
|
|
3219
|
-
this.tryNextAvailableAd();
|
|
3227
|
+
this.tryNextAvailableAd(0);
|
|
3220
3228
|
});
|
|
3221
3229
|
return;
|
|
3222
3230
|
}
|
|
3223
3231
|
}
|
|
3232
|
+
const maxRetries = 5;
|
|
3233
|
+
if (this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3) {
|
|
3234
|
+
if (this.config.debugAdTiming) {
|
|
3235
|
+
console.log(`[CONTINUOUS-FETCH] \u23F3 Queue empty but fetching active, waiting... (retry ${retryCount + 1}/${maxRetries})`);
|
|
3236
|
+
}
|
|
3237
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
3238
|
+
await this.tryNextAvailableAd(retryCount + 1);
|
|
3239
|
+
return;
|
|
3240
|
+
}
|
|
3224
3241
|
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
3225
3242
|
this.showPlaceholderAndWaitForAds();
|
|
3226
3243
|
} else {
|
|
@@ -3257,9 +3274,13 @@ var StormcloudVideoPlayer = class {
|
|
|
3257
3274
|
this.isShowingPlaceholder = false;
|
|
3258
3275
|
this.placeholderStartTimeMs = null;
|
|
3259
3276
|
this.ima.hidePlaceholder();
|
|
3277
|
+
const currentMuted = this.video.muted;
|
|
3278
|
+
const currentVolume = this.video.volume;
|
|
3279
|
+
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
3260
3280
|
const nextAdUrl = this.adRequestQueue.shift();
|
|
3261
3281
|
if (nextAdUrl) {
|
|
3262
3282
|
this.currentAdIndex++;
|
|
3283
|
+
this.successfulAdRequests.push(nextAdUrl);
|
|
3263
3284
|
await this.playSingleAd(nextAdUrl).catch(() => {
|
|
3264
3285
|
this.tryNextAvailableAd();
|
|
3265
3286
|
});
|