Skip to content

Reset play state when a new album loads into the drawer - #305

Merged
IanHoar merged 2 commits into
mainfrom
fix/preview-play-state-reset
Oct 3, 2026
Merged

IanHoar merged 2 commits into
mainfrom
fix/preview-play-state-reset

Conversation

@IanHoar

@IanHoar IanHoar commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

When a track is playing and you hit Preview on a different album, the drawer keeps showing the pause button and the old progress position. You had to toggle play/pause to get it back in sync.

Cause

Assigning a new src to a playing <audio> element pauses it as part of the media load algorithm, but fires emptied rather than pause, so our onpause handler never ran.

Fix

Handle emptied in bindAudioEvents to show the paused state and reset the progress bar and elapsed time. Next/prev while playing still continue playback, since play fires after emptied.

Testing

  • Play a track, then hit Preview on another album: the button shows play and progress resets to 0.
  • npm run typecheck, npm run lint, npm test pass.

Screen recording

before:

before.mov

after:

after.mov

Swapping src on a playing audio element pauses it without firing a
pause event, so the play button and progress bar kept showing the
previous track as playing. Handle emptied to reflect the paused state
and reset the progress display.

@sabjorn sabjorn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment please -- and then also add a test for this. unless there are no tests for the other parts that were already here (i.e. the onpause and onended callbacks)

Comment thread src/components/player/loader.ts Outdated
@IanHoar

IanHoar commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

Updated 👍

@sabjorn sabjorn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛴️ it

@IanHoar
IanHoar merged commit 594c964 into main Oct 3, 2026
1 check passed
@IanHoar
IanHoar deleted the fix/preview-play-state-reset branch October 3, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants