fix(plex): a reload during a binge reopens the episode playing now

The player stepped to the next item in its own state while the history entry still held the item it
opened with, so F5 restarted the first episode. The player now says every item it moves on to, and the
page rewrites its entry with it (useHistorySubview's `follow`: no navigation, the overlays over the
player stay open, and the entry under an overlay is rewritten when a step lands back on it). The
player's URL is the item playing (`?v=player:<id>`), so a bookmark opens it; the list it plays from
stays in the history entry.
This commit is contained in:
2026-10-25 23:24:29 +01:00
parent b30c60d1a5
commit 9bd7304bb9
14 changed files with 302 additions and 28 deletions
+18 -3
View File
@@ -133,10 +133,24 @@ const DOUBLE_TAP_MS = 300;
// the queue instead of the item's own episode neighbours.
// `fromStart` (the card's Restart, C5) applies to the item the player opened with; every item it
// moves on to starts at its own resume point.
type Props = { itemId: string; onClose: () => void; queue?: string[]; fromStart?: boolean };
// `onItemChange` hears every item it moves on to (Next, Back, an auto-advance, a collection sibling):
// the page's history entry keeps the item playing NOW, so a reload reopens that one, not the first.
type Props = {
itemId: string;
onClose: () => void;
onItemChange: (id: string) => void;
queue?: string[];
fromStart?: boolean;
};
type Panel = "none" | "more" | "tracks" | "settings" | "info" | "upNext";
export default function PlexPlayer({ itemId, onClose, queue, fromStart = false }: Props) {
export default function PlexPlayer({
itemId,
onClose,
onItemChange,
queue,
fromStart = false,
}: Props) {
const { t, i18n } = useTranslation();
// A track named in the reader's language (lib/vocab), not in the Plex server's ("English (AC3 5.1)").
const audioName = (a: PlexTrackNaming) => trackLabel(t, a, "audio", i18n.language);
@@ -745,9 +759,10 @@ export default function PlexPlayer({ itemId, onClose, queue, fromStart = false }
movedOnRef.current = true;
setAbs(0);
setId(otherId);
onItemChange(otherId);
}
},
[id, engine, seekTo, requestPlay, settleProgress, finishProgress],
[id, engine, seekTo, requestPlay, settleProgress, finishProgress, onItemChange],
);
// Prev/next: from the playlist queue when playing one, else the item's own episode neighbours.