Repository navigation
fix: pausing a natively queued Spotify track actually pauses it - #427
Conversation
Spirc silently ignores play/pause for tracks it did not start itself, which covers every direct-loaded track (native queue Spotify slots and raw URI lists). The command router only sent those commands to Spirc, so spacebar flipped the playbar while audio kept going, and the stray-audio guard and queue-handoff preempt pauses were no-ops. Send the commands to the underlying player too, and log the end-of-track decision points to help pin down any remaining auto-advance stalls.
📝 WalkthroughWalkthroughChangesThe change makes deferred play and pause commands update both the direct player and Spirc. Playback continuation and end-of-track paths now log their selected decisions. The changelog documents the native queued-track control fix. Native playback control
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant DeferredPlayerCommand
participant Player
participant Spirc
DeferredPlayerCommand->>Player: Apply play or pause directly
DeferredPlayerCommand->>Spirc: Synchronize playback state
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/infra/player/streaming.rs`:
- Around line 72-87: Update the DeferredPlayerCommand handling around Self::Play
and Self::Pause to avoid sending duplicate Player operations when Spirc owns the
current track. Track whether Spirc successfully handles the command, and invoke
player.play() or player.pause() directly only when Spirc cannot own the current
track, preserving direct-player behavior for tracks loaded outside Spirc.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 4c190053-8203-47e3-aaf7-3cfdfe040d4c
📒 Files selected for processing (4)
CHANGELOG.mdsrc/infra/network/playback.rssrc/infra/player/events.rssrc/infra/player/streaming.rs
Summary
With spotatui as the playback device, pausing a track played through the
native queue (or from a raw track list like Liked Songs) flipped the playbar
to paused while the audio kept playing, and resume was broken the same way.
Those tracks are loaded via a direct
player.load()with no Spirc context,and Spirc drops any command whose play_request_id it did not issue: its
handle_pause/handle_playno-op unless its ownplay_statuscovers thecurrent audio. The command router sent Pause/Play to Spirc only, so both
were silent no-ops for direct-loaded tracks while every caller flipped the
UI state optimistically.
Pause/Play now go to both the raw
Player(always acts on whatever isactually loaded) and Spirc (keeps Connect state in sync when it is
managing playback). The double-send is safe in both directions: the Player
ignores commands invalid for its state, and Spirc re-syncs its status from
the resulting Paused/Playing events. This also un-breaks safeguards that
silently relied on the same call (the stray-audio-over-queue guard, the
preemptive pauses during queue handoff, the unavailable-track escalation
stop), which explains the ghost audio and some stuck auto-advances around
the native queue.
Also adds info-level logging at the end-of-track decision points
(
end of track <id>: <decision>and the continuation branches) so anyremaining auto-advance stall can be pinned from the log.
Testing
track and queue auto-advance now behave correctly
Additional notes
Verified against the vendored librespot fork that
player.load(..., play=true)starts playback regardless of a prior paused sink, so the now-real preemptive
pauses before queue advances cannot introduce a new stall.
💬 Questions or want to chat with other contributors? Join the spotatui Discord.
Summary by CodeRabbit