stormcloud-video-player 0.3.12 → 0.3.13
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 +2 -2
- package/lib/index.cjs +41 -25
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +41 -25
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +41 -25
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +41 -25
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +41 -25
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +4 -9
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +41 -25
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -1254,15 +1254,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1254
1254
|
setAdPlayingFlag(false);
|
|
1255
1255
|
emit("content_resume");
|
|
1256
1256
|
setTimeout(() => {
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
);
|
|
1262
|
-
if (adContainerEl) {
|
|
1263
|
-
adContainerEl.style.display = "flex";
|
|
1264
|
-
adContainerEl.style.pointerEvents = "auto";
|
|
1265
|
-
}
|
|
1257
|
+
if (!adPlaying && adContainerEl) {
|
|
1258
|
+
adContainerEl.style.display = "none";
|
|
1259
|
+
adContainerEl.style.pointerEvents = "none";
|
|
1260
|
+
console.log("[HlsAdPlayer] Ad container hidden after completion (waiting for next ad)");
|
|
1266
1261
|
}
|
|
1267
1262
|
}, 50);
|
|
1268
1263
|
}
|
|
@@ -3118,7 +3113,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3118
3113
|
continue;
|
|
3119
3114
|
}
|
|
3120
3115
|
if (this.config.debugAdTiming) {
|
|
3121
|
-
console.log(`[CONTINUOUS-FETCH] \u{1F4E1} Attempting to fetch ad
|
|
3116
|
+
console.log(`[CONTINUOUS-FETCH] \u{1F4E1} Attempting to fetch ad #${this.successfulAdRequests.length + this.adRequestQueue.length + 1} (queue: ${this.adRequestQueue.length}, remaining: ${Math.round(remaining / 1e3)}s)...`);
|
|
3122
3117
|
}
|
|
3123
3118
|
try {
|
|
3124
3119
|
const response = await fetch(newAdUrl, { mode: "cors" });
|
|
@@ -3134,7 +3129,8 @@ var StormcloudVideoPlayer = class {
|
|
|
3134
3129
|
console.log("[CONTINUOUS-FETCH] \u26A0\uFE0F VAST response has no media files, skipping");
|
|
3135
3130
|
}
|
|
3136
3131
|
this.failedVastUrls.add(newAdUrl);
|
|
3137
|
-
|
|
3132
|
+
const retryDelay = this.adRequestQueue.length > 0 ? 1e3 : 500;
|
|
3133
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
3138
3134
|
continue;
|
|
3139
3135
|
}
|
|
3140
3136
|
if (this.config.debugAdTiming) {
|
|
@@ -3142,17 +3138,19 @@ var StormcloudVideoPlayer = class {
|
|
|
3142
3138
|
}
|
|
3143
3139
|
this.adRequestQueue.push(newAdUrl);
|
|
3144
3140
|
this.totalAdsInBreak++;
|
|
3145
|
-
|
|
3141
|
+
const successDelay = this.adRequestQueue.length <= 1 ? 300 : 500;
|
|
3142
|
+
await new Promise((resolve) => setTimeout(resolve, successDelay));
|
|
3146
3143
|
} catch (error) {
|
|
3147
3144
|
if (this.config.debugAdTiming) {
|
|
3148
3145
|
console.log("[CONTINUOUS-FETCH] \u274C Ad fetch failed:", error.message);
|
|
3149
3146
|
}
|
|
3150
3147
|
this.failedVastUrls.add(newAdUrl);
|
|
3151
|
-
|
|
3148
|
+
const retryDelay = this.adRequestQueue.length > 0 ? 2e3 : 1e3;
|
|
3149
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
3152
3150
|
}
|
|
3153
3151
|
}
|
|
3154
3152
|
if (this.config.debugAdTiming) {
|
|
3155
|
-
console.log(
|
|
3153
|
+
console.log(`[CONTINUOUS-FETCH] \u{1F6D1} Continuous fetch loop ended (fetched ${this.successfulAdRequests.length} ads, ${this.adRequestQueue.length} in queue)`);
|
|
3156
3154
|
}
|
|
3157
3155
|
}
|
|
3158
3156
|
stopContinuousFetching() {
|
|
@@ -3190,20 +3188,27 @@ var StormcloudVideoPlayer = class {
|
|
|
3190
3188
|
return;
|
|
3191
3189
|
}
|
|
3192
3190
|
}
|
|
3193
|
-
const
|
|
3194
|
-
|
|
3191
|
+
const hasPlayedAtLeastOneAd = this.successfulAdRequests.length > 0;
|
|
3192
|
+
const maxRetries = hasPlayedAtLeastOneAd ? 10 : 5;
|
|
3193
|
+
const retryDelayMs = hasPlayedAtLeastOneAd ? 500 : 1e3;
|
|
3194
|
+
const minRemainingForRetry = 1e3;
|
|
3195
|
+
if (this.continuousFetchingActive && retryCount < maxRetries && remaining > minRemainingForRetry) {
|
|
3195
3196
|
if (this.config.debugAdTiming) {
|
|
3196
|
-
console.log(`[CONTINUOUS-FETCH] \u23F3 Queue empty but fetching active, waiting... (retry ${retryCount + 1}/${maxRetries})`);
|
|
3197
|
+
console.log(`[CONTINUOUS-FETCH] \u23F3 Queue empty but fetching active, waiting ${retryDelayMs}ms... (retry ${retryCount + 1}/${maxRetries}, remaining: ${remaining}ms)`);
|
|
3197
3198
|
}
|
|
3198
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
3199
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
|
|
3199
3200
|
await this.tryNextAvailableAd(retryCount + 1);
|
|
3200
3201
|
return;
|
|
3201
3202
|
}
|
|
3202
|
-
|
|
3203
|
+
const minTimeForPlaceholder = 3e3;
|
|
3204
|
+
if (!this.isShowingPlaceholder && remaining >= minTimeForPlaceholder && this.continuousFetchingActive) {
|
|
3205
|
+
if (this.config.debugAdTiming) {
|
|
3206
|
+
console.log(`[CONTINUOUS-FETCH] \u2B1B Last resort: showing placeholder (${remaining}ms remaining)`);
|
|
3207
|
+
}
|
|
3203
3208
|
this.showPlaceholderAndWaitForAds();
|
|
3204
3209
|
} else {
|
|
3205
3210
|
if (this.config.debugAdTiming) {
|
|
3206
|
-
console.log(
|
|
3211
|
+
console.log(`[CONTINUOUS-FETCH] \u23F9\uFE0F No more ads available or insufficient time remaining (${remaining}ms), ending ad break`);
|
|
3207
3212
|
}
|
|
3208
3213
|
this.handleAdPodComplete();
|
|
3209
3214
|
}
|
|
@@ -3211,26 +3216,36 @@ var StormcloudVideoPlayer = class {
|
|
|
3211
3216
|
async showPlaceholderAndWaitForAds() {
|
|
3212
3217
|
const remaining = this.getRemainingAdMs();
|
|
3213
3218
|
const waitTime = Math.min(this.maxPlaceholderDurationMs, remaining);
|
|
3214
|
-
if (waitTime <
|
|
3219
|
+
if (waitTime < 3e3) {
|
|
3220
|
+
if (this.config.debugAdTiming) {
|
|
3221
|
+
console.log(`[CONTINUOUS-FETCH] \u23F9\uFE0F Insufficient time for placeholder (${waitTime}ms), ending ad break`);
|
|
3222
|
+
}
|
|
3215
3223
|
this.handleAdPodComplete();
|
|
3216
3224
|
return;
|
|
3217
3225
|
}
|
|
3218
3226
|
if (this.config.debugAdTiming) {
|
|
3219
|
-
console.log(`[CONTINUOUS-FETCH] \u2B1B Showing black placeholder for ${waitTime}ms while waiting for ads`);
|
|
3227
|
+
console.log(`[CONTINUOUS-FETCH] \u2B1B Showing black placeholder for up to ${waitTime}ms while waiting for ads (last resort)`);
|
|
3220
3228
|
}
|
|
3221
3229
|
this.isShowingPlaceholder = true;
|
|
3222
3230
|
this.placeholderStartTimeMs = Date.now();
|
|
3223
3231
|
this.ima.showPlaceholder();
|
|
3224
|
-
const checkInterval =
|
|
3232
|
+
const checkInterval = 300;
|
|
3225
3233
|
const maxChecks = Math.floor(waitTime / checkInterval);
|
|
3226
3234
|
for (let i = 0; i < maxChecks; i++) {
|
|
3227
3235
|
await new Promise((resolve) => setTimeout(resolve, checkInterval));
|
|
3228
3236
|
if (!this.inAdBreak) {
|
|
3237
|
+
if (this.config.debugAdTiming) {
|
|
3238
|
+
console.log("[CONTINUOUS-FETCH] \u2139\uFE0F Ad break ended during placeholder wait");
|
|
3239
|
+
}
|
|
3240
|
+
this.isShowingPlaceholder = false;
|
|
3241
|
+
this.placeholderStartTimeMs = null;
|
|
3242
|
+
this.ima.hidePlaceholder();
|
|
3229
3243
|
return;
|
|
3230
3244
|
}
|
|
3231
3245
|
if (this.adRequestQueue.length > 0) {
|
|
3246
|
+
const elapsedInPlaceholder = Date.now() - (this.placeholderStartTimeMs || Date.now());
|
|
3232
3247
|
if (this.config.debugAdTiming) {
|
|
3233
|
-
console.log(
|
|
3248
|
+
console.log(`[CONTINUOUS-FETCH] \u2705 New ad became available during placeholder (after ${elapsedInPlaceholder}ms)`);
|
|
3234
3249
|
}
|
|
3235
3250
|
this.isShowingPlaceholder = false;
|
|
3236
3251
|
this.placeholderStartTimeMs = null;
|
|
@@ -3249,8 +3264,9 @@ var StormcloudVideoPlayer = class {
|
|
|
3249
3264
|
return;
|
|
3250
3265
|
}
|
|
3251
3266
|
}
|
|
3267
|
+
const totalPlaceholderTime = Date.now() - (this.placeholderStartTimeMs || Date.now());
|
|
3252
3268
|
if (this.config.debugAdTiming) {
|
|
3253
|
-
console.log(
|
|
3269
|
+
console.log(`[CONTINUOUS-FETCH] \u23F0 Placeholder timeout reached after ${totalPlaceholderTime}ms, no ads fetched`);
|
|
3254
3270
|
}
|
|
3255
3271
|
this.isShowingPlaceholder = false;
|
|
3256
3272
|
this.placeholderStartTimeMs = null;
|