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/index.cjs
CHANGED
|
@@ -3168,9 +3168,10 @@ var StormcloudVideoPlayer = class {
|
|
|
3168
3168
|
}
|
|
3169
3169
|
break;
|
|
3170
3170
|
}
|
|
3171
|
-
|
|
3171
|
+
const maxQueueSize = 3;
|
|
3172
|
+
if (this.adRequestQueue.length >= maxQueueSize) {
|
|
3172
3173
|
if (this.config.debugAdTiming) {
|
|
3173
|
-
console.log(`[CONTINUOUS-FETCH] \
|
|
3174
|
+
console.log(`[CONTINUOUS-FETCH] \u23F8\uFE0F Queue full (${this.adRequestQueue.length}), pausing fetching...`);
|
|
3174
3175
|
}
|
|
3175
3176
|
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
3176
3177
|
continue;
|
|
@@ -3181,7 +3182,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3181
3182
|
continue;
|
|
3182
3183
|
}
|
|
3183
3184
|
if (this.config.debugAdTiming) {
|
|
3184
|
-
console.log(
|
|
3185
|
+
console.log(`[CONTINUOUS-FETCH] \u{1F4E1} Attempting to fetch ad (${this.successfulAdRequests.length + this.adRequestQueue.length + 1} total)...`);
|
|
3185
3186
|
}
|
|
3186
3187
|
try {
|
|
3187
3188
|
const response = await fetch(newAdUrl, { mode: "cors" });
|
|
@@ -3201,17 +3202,17 @@ var StormcloudVideoPlayer = class {
|
|
|
3201
3202
|
continue;
|
|
3202
3203
|
}
|
|
3203
3204
|
if (this.config.debugAdTiming) {
|
|
3204
|
-
console.log(
|
|
3205
|
+
console.log(`[CONTINUOUS-FETCH] \u2705 Successfully fetched ad, adding to queue (queue size: ${this.adRequestQueue.length + 1})`);
|
|
3205
3206
|
}
|
|
3206
3207
|
this.adRequestQueue.push(newAdUrl);
|
|
3207
3208
|
this.totalAdsInBreak++;
|
|
3208
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
3209
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
3209
3210
|
} catch (error) {
|
|
3210
3211
|
if (this.config.debugAdTiming) {
|
|
3211
3212
|
console.log("[CONTINUOUS-FETCH] \u274C Ad fetch failed:", error.message);
|
|
3212
3213
|
}
|
|
3213
3214
|
this.failedVastUrls.add(newAdUrl);
|
|
3214
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
3215
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
3215
3216
|
}
|
|
3216
3217
|
}
|
|
3217
3218
|
if (this.config.debugAdTiming) {
|
|
@@ -3224,7 +3225,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3224
3225
|
console.log("[CONTINUOUS-FETCH] \u{1F6D1} Stopping continuous ad fetching");
|
|
3225
3226
|
}
|
|
3226
3227
|
}
|
|
3227
|
-
async tryNextAvailableAd() {
|
|
3228
|
+
async tryNextAvailableAd(retryCount = 0) {
|
|
3228
3229
|
const remaining = this.getRemainingAdMs();
|
|
3229
3230
|
if (remaining <= 500) {
|
|
3230
3231
|
if (this.config.debugAdTiming) {
|
|
@@ -3237,15 +3238,31 @@ var StormcloudVideoPlayer = class {
|
|
|
3237
3238
|
const nextAdUrl = this.adRequestQueue.shift();
|
|
3238
3239
|
if (nextAdUrl) {
|
|
3239
3240
|
if (this.config.debugAdTiming) {
|
|
3240
|
-
console.log(
|
|
3241
|
+
console.log(`[CONTINUOUS-FETCH] \u{1F3AC} Playing next queued ad (${this.currentAdIndex + 1}/${this.totalAdsInBreak}, ${this.adRequestQueue.length} remaining in queue)`);
|
|
3242
|
+
}
|
|
3243
|
+
const currentMuted = this.video.muted;
|
|
3244
|
+
const currentVolume = this.video.volume;
|
|
3245
|
+
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
3246
|
+
if (this.config.debugAdTiming) {
|
|
3247
|
+
console.log(`[CONTINUOUS-FETCH] \u{1F50A} Updated ad audio state: muted=${currentMuted}, volume=${currentVolume}`);
|
|
3241
3248
|
}
|
|
3242
3249
|
this.currentAdIndex++;
|
|
3250
|
+
this.successfulAdRequests.push(nextAdUrl);
|
|
3243
3251
|
await this.playSingleAd(nextAdUrl).catch(() => {
|
|
3244
|
-
this.tryNextAvailableAd();
|
|
3252
|
+
this.tryNextAvailableAd(0);
|
|
3245
3253
|
});
|
|
3246
3254
|
return;
|
|
3247
3255
|
}
|
|
3248
3256
|
}
|
|
3257
|
+
const maxRetries = 5;
|
|
3258
|
+
if (this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3) {
|
|
3259
|
+
if (this.config.debugAdTiming) {
|
|
3260
|
+
console.log(`[CONTINUOUS-FETCH] \u23F3 Queue empty but fetching active, waiting... (retry ${retryCount + 1}/${maxRetries})`);
|
|
3261
|
+
}
|
|
3262
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
3263
|
+
await this.tryNextAvailableAd(retryCount + 1);
|
|
3264
|
+
return;
|
|
3265
|
+
}
|
|
3249
3266
|
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
3250
3267
|
this.showPlaceholderAndWaitForAds();
|
|
3251
3268
|
} else {
|
|
@@ -3282,9 +3299,13 @@ var StormcloudVideoPlayer = class {
|
|
|
3282
3299
|
this.isShowingPlaceholder = false;
|
|
3283
3300
|
this.placeholderStartTimeMs = null;
|
|
3284
3301
|
this.ima.hidePlaceholder();
|
|
3302
|
+
const currentMuted = this.video.muted;
|
|
3303
|
+
const currentVolume = this.video.volume;
|
|
3304
|
+
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
3285
3305
|
const nextAdUrl = this.adRequestQueue.shift();
|
|
3286
3306
|
if (nextAdUrl) {
|
|
3287
3307
|
this.currentAdIndex++;
|
|
3308
|
+
this.successfulAdRequests.push(nextAdUrl);
|
|
3288
3309
|
await this.playSingleAd(nextAdUrl).catch(() => {
|
|
3289
3310
|
this.tryNextAvailableAd();
|
|
3290
3311
|
});
|