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.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,31 @@ 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)`);
|
|
3173
|
+
}
|
|
3174
|
+
const currentMuted = this.video.muted;
|
|
3175
|
+
const currentVolume = this.video.volume;
|
|
3176
|
+
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
3177
|
+
if (this.config.debugAdTiming) {
|
|
3178
|
+
console.log(`[CONTINUOUS-FETCH] \u{1F50A} Updated ad audio state: muted=${currentMuted}, volume=${currentVolume}`);
|
|
3172
3179
|
}
|
|
3173
3180
|
this.currentAdIndex++;
|
|
3181
|
+
this.successfulAdRequests.push(nextAdUrl);
|
|
3174
3182
|
await this.playSingleAd(nextAdUrl).catch(() => {
|
|
3175
|
-
this.tryNextAvailableAd();
|
|
3183
|
+
this.tryNextAvailableAd(0);
|
|
3176
3184
|
});
|
|
3177
3185
|
return;
|
|
3178
3186
|
}
|
|
3179
3187
|
}
|
|
3188
|
+
const maxRetries = 5;
|
|
3189
|
+
if (this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3) {
|
|
3190
|
+
if (this.config.debugAdTiming) {
|
|
3191
|
+
console.log(`[CONTINUOUS-FETCH] \u23F3 Queue empty but fetching active, waiting... (retry ${retryCount + 1}/${maxRetries})`);
|
|
3192
|
+
}
|
|
3193
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
3194
|
+
await this.tryNextAvailableAd(retryCount + 1);
|
|
3195
|
+
return;
|
|
3196
|
+
}
|
|
3180
3197
|
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
3181
3198
|
this.showPlaceholderAndWaitForAds();
|
|
3182
3199
|
} else {
|
|
@@ -3213,9 +3230,13 @@ var StormcloudVideoPlayer = class {
|
|
|
3213
3230
|
this.isShowingPlaceholder = false;
|
|
3214
3231
|
this.placeholderStartTimeMs = null;
|
|
3215
3232
|
this.ima.hidePlaceholder();
|
|
3233
|
+
const currentMuted = this.video.muted;
|
|
3234
|
+
const currentVolume = this.video.volume;
|
|
3235
|
+
this.ima.updateOriginalMutedState(currentMuted, currentVolume);
|
|
3216
3236
|
const nextAdUrl = this.adRequestQueue.shift();
|
|
3217
3237
|
if (nextAdUrl) {
|
|
3218
3238
|
this.currentAdIndex++;
|
|
3239
|
+
this.successfulAdRequests.push(nextAdUrl);
|
|
3219
3240
|
await this.playSingleAd(nextAdUrl).catch(() => {
|
|
3220
3241
|
this.tryNextAvailableAd();
|
|
3221
3242
|
});
|