Handle cleared MPV entry during fallback failure

This commit is contained in:
2026-11-07 10:51:47 -08:00
parent f80fd99211
commit 907984d241
2 changed files with 14 additions and 1 deletions
+11 -1
View File
@@ -539,7 +539,10 @@ export class MediaPlayer {
if (result?.error !== "success") { if (result?.error !== "success") {
if (fallbackEligible) { if (fallbackEligible) {
this.removePendingCandidate(url); this.removePendingCandidate(url);
if (![...this.entryCandidates.values()].includes(url)) this.fallbackCandidates.delete(url); if (!this.pendingCandidateUrls.includes(url) &&
![...this.entryCandidates.values()].includes(url)) {
this.fallbackCandidates.delete(url);
}
} }
return; return;
} }
@@ -784,6 +787,13 @@ export class MediaPlayer {
const file = this.entryCandidates.get(entryId) || response.file || const file = this.entryCandidates.get(entryId) || response.file ||
(entryId === this.activeEntryId ? this.activeUrl : null); (entryId === this.activeEntryId ? this.activeUrl : null);
if (!file) return; if (!file) return;
if (this.activeEntryId === null && !this.fallbackSuppressedUntilStart) {
// MPV can clear its current entry before delivering end-file. Restore
// this event's known entry from its playlist_entry_id for mirroring.
this.activeEntryId = entryId;
this.activeUrl = file;
this.currentFile = file;
}
const errorMessage = response.file_error || response.error || response["file-error"] || "Unknown playback error"; const errorMessage = response.file_error || response.error || response["file-error"] || "Unknown playback error";
this.playbackErrors.set(file, errorMessage); this.playbackErrors.set(file, errorMessage);
this.handleEvent(UserEvent.PlaybackError, { filename: file, error: errorMessage }); this.handleEvent(UserEvent.PlaybackError, { filename: file, error: errorMessage });
@@ -119,6 +119,9 @@ test("failure is correlated from MPV end-file entry id without querying a cleare
assert.notEqual(command, "get_property", "failure correlation must use the emitted entry id"); assert.notEqual(command, "get_property", "failure correlation must use the emitted entry id");
return { data: [] }; return { data: [] };
}; };
player.activeEntryId = null;
player.activeUrl = null;
player.currentFile = null;
send(player, { reason: "error", file_error: "network unavailable" }, 42); send(player, { reason: "error", file_error: "network unavailable" }, 42);
await settle(); await settle();
assert.deepEqual(starts, [url]); assert.deepEqual(starts, [url]);