feat: pause playback on app quit#967
Conversation
Send a Pause request before setting is_running to false so playback stops when the user quits. The PlayerRequest::Pause handler already guards on is_playing, so this is a no-op when nothing is playing. Fixes aome510#944
|
Does this mean that playback will be paused when you're listening on another device through Spotify Connect? I often use the TUI to start playing some playlist on a set of speakers, and I'd like that to continue when i close the TUI. |
|
@mielpeeters Good catch -- yes, For your workflow (start speakers from the TUI, then close it) this PR is the wrong default. I'll gate it behind a config option (something like |
Summary
Sends a Pause request when the user quits the TUI so playback stops instead of continuing in the background.
Why this matters
If a song is playing and you close the app, it keeps playing through Spotify's servers. Reopening the app later doesn't resume where you left off. Pausing on quit fixes both problems.
Changes
spotify_player/src/event/mod.rs: AddPlayerRequest::Pausesend in theCommand::Quithandler, before settingis_running = false.The
PlayerRequest::Pausehandler (inclient/mod.rs:296) already checksplayback.is_playing, so this is a no-op when nothing is playing. The flume channelsend()queues the message synchronously, and the client consumer processes it during the UI loop's refresh sleep beforeprocess::exitruns.Testing
Verified the change compiles and follows the same pattern as other player commands (NextTrack, PreviousTrack, ResumePause) which all use
client_pub.send(ClientRequest::Player(...)).Fixes #944
This contribution was developed with AI assistance (Claude Code).