You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(player): clear progress on episode switch to stop end-of-playback glitch (#94) (#194)
* fix(player): clear progress on episode switch to stop end-of-playback glitch (#94)
When an episode finishes and the queue auto-advances, currentEpisode.set swaps
the player to the next episode and its title/artwork update immediately, but the
$currentTime/$duration stores keep the finished episode's end values until the
new audio fires loadedmetadata. The progress bar therefore stays pinned at 100%
and the timestamps show the previous episode's end against the new episode for
the whole (network-bound) metadata-fetch window — the visual glitch in #94.
Reset $currentTime and $duration to 0 on a genuine in-player episode switch (in
the currentEpisode subscription), guarded by a first-fire flag so the
synchronous initial subscription does not wipe a restored resume position or
flash 0 on mount/remount. onMetadataLoaded -> restorePlaybackTime sets the real
position once the next episode loads, and the existing isLoading guard keeps
this reset from being persisted.
Also clamp non-finite and negative inputs to 0 in formatSeconds so the time
display can never render "NaN:NaN:NaN" or negative components during the brief
window where duration is unknown or currentTime exceeds a shorter next episode.
Verified in real Obsidian: at the auto-advance transition the bar now shows 0%
and 00:00:00 instead of the stale 100% / previous-episode timestamps.
* fix(player): never mark an unknown-duration episode finished on switch (#94)
Addresses Codex review on PR #194. The #94 progress reset sets currentTime and
duration to 0 the instant the episode changes. If the user switches away again
before the next episode's metadata loads (e.g. click B then C from the queue
while B is still loading), currentEpisode.set reads ct === dur === 0 and its
isFinished = (ct === dur) check persisted the skipped episode as finished at
0:00 — surfacing a never-played episode as played.
Guard the finished computation against a zero/unknown duration in both persist
paths: currentEpisode.set (store) and persistPlaybackPosition (player). A
duration of 0 (or NaN) is never "finished". Genuine finishes (duration > 0 and
currentTime === duration) are unaffected.
Reproduced and verified fixed in real Obsidian: rapid A->B->C switch now leaves
B as finished=false, while an episode played to its real end stays finished=true.
0 commit comments