Keep fallback active while adding queued media

This commit is contained in:
2026-11-07 10:59:49 -08:00
parent 946771d406
commit 463bb823d8
2 changed files with 34 additions and 4 deletions
+12 -1
View File
@@ -76,6 +76,7 @@ export class MediaPlayer {
private activeEntryId: number | null = null;
private activeUrl: string | null = null;
private fallbackSuppressedUntilStart = false;
private fallbackPendingUrl: string | null = null;
private browserUrl: string | null = null;
private browserFallback = new ChromiumFallback((url) => {
if (this.browserUrl === url) {
@@ -384,7 +385,10 @@ export class MediaPlayer {
}
public async append(url: string) {
await this.loadFile(url, "append-play");
const mode = this.browserUrl || this.fallbackPendingUrl || this.browserFallback.isRunning
? "append"
: "append-play";
await this.loadFile(url, mode);
}
public async replace(url: string) {
@@ -740,6 +744,7 @@ export class MediaPlayer {
const hadBrowser = !!this.browserUrl || this.browserFallback.isRunning;
this.activeAttemptGeneration++;
this.fallbackSuppressedUntilStart = false;
this.fallbackPendingUrl = null;
this.browserUrl = null;
if (hadBrowser) void this.browserFallback.stop();
const entryId = typeof response.playlist_entry_id === "number"
@@ -805,6 +810,7 @@ export class MediaPlayer {
if (this.fallbackCandidates.has(file) &&
(entryId === this.activeEntryId || (this.activeEntryId === null && !this.fallbackSuppressedUntilStart)) &&
attemptGeneration === this.activeAttemptGeneration) {
this.fallbackPendingUrl = file;
void this.startBrowserFallback(file, attemptGeneration, entryId);
}
}
@@ -851,6 +857,10 @@ export class MediaPlayer {
}
} catch (error) {
console.error(`Failed to start Chromium fallback for ${url}:`, error);
} finally {
if (generation === this.activeAttemptGeneration && this.fallbackPendingUrl === url) {
this.fallbackPendingUrl = null;
}
}
}
@@ -860,6 +870,7 @@ export class MediaPlayer {
this.activeEntryId = null;
this.activeUrl = null;
this.currentFile = null;
this.fallbackPendingUrl = null;
this.browserUrl = null;
await this.browserFallback.stop();
}