Skip to content

feat: pause playback on app quit#967

Open
mvanhorn wants to merge 1 commit into
aome510:masterfrom
mvanhorn:osc/944-pause-on-quit
Open

feat: pause playback on app quit#967
mvanhorn wants to merge 1 commit into
aome510:masterfrom
mvanhorn:osc/944-pause-on-quit

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Apr 7, 2026

Copy link
Copy Markdown

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: Add PlayerRequest::Pause send in the Command::Quit handler, before setting is_running = false.

The PlayerRequest::Pause handler (in client/mod.rs:296) already checks playback.is_playing, so this is a no-op when nothing is playing. The flume channel send() queues the message synchronously, and the client consumer processes it during the UI loop's refresh sleep before process::exit runs.

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).

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
@mielpeeters

mielpeeters commented May 14, 2026

Copy link
Copy Markdown
Contributor

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.

@mvanhorn

Copy link
Copy Markdown
Author

@mielpeeters Good catch -- yes, PlayerRequest::Pause hits Spotify's active-device endpoint, so if your active playback context is a Spotify Connect device (speakers, phone, web player), this will pause that too. The TUI doesn't distinguish between "playing through the TUI's own audio sink" vs "controlling a remote device" -- to Spotify they're the same playback session.

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 pause_on_quit = false with the default preserving current behavior) and update the PR. Thanks for flagging it before this landed.

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.

Pause playback on app quit

2 participants