fix(player): a library item played from the start keeps its point

A cached file that autoplays from 0:00 fires its one playing event before the resume hook
subscribes, so the hook never counted it as played and reported nothing - not on pause, not on
close. An element already playing when the hook subscribes now counts as played.
This commit is contained in:
2026-10-07 00:36:28 +02:00
parent 59b27467ab
commit f3c94641a7
2 changed files with 15 additions and 1 deletions
+3 -1
View File
@@ -48,7 +48,9 @@ export function useResume(
const report = useEffectEvent(save);
useEffect(() => {
if (!media || itemKey == null) return;
let played = false;
// Already playing counts as played: a cached file that autoplays from the start can fire its
// one `playing` before this effect subscribes, and would then never report at all.
let played = !media.paused;
let lastAt = 0;
const duration = () => (Number.isFinite(media.duration) ? media.duration : 0);
const put = (leaving: boolean) => {