/
/
/
# What does this implement/fix? Pressing play in Music Assistant on a Sonos speaker could restart Spotify instead of starting your Music Assistant queue. Sonos keeps a source like Spotify Connect loaded and reported as *paused* long after the stream was abandoned — even once the speaker has been deselected in the Spotify app. Playback commands from Music Assistant then went to that dead session, so pressing play resumed Spotify. Switching back to Music Assistant only worked when the speaker happened to clear the source on its own, which is why it seemed random. Sonos offers nothing that tells an abandoned session apart from a real pause, so such a source is now reported as idle in two cases: when the speaker rejects a play command for it, and otherwise once it has been sitting paused for a minute. Normal queue handling takes over from there, for play as well as resume. Pausing an external source from Music Assistant and picking it straight back up still works. **Related issue (if applicable):** - Reported on Discord ## Types of changes - [x] Bugfix (non-breaking change which fixes an issue) — `bugfix` - [ ] New feature (non-breaking change which adds functionality) — `new-feature` - [ ] Enhancement to an existing feature — `enhancement` - [ ] New music/player/metadata/plugin provider — `new-provider` - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) — `breaking-change` - [ ] Refactor (no behaviour change) — `refactor` - [ ] Documentation only — `documentation` - [ ] Maintenance / chore — `maintenance` - [ ] CI / workflow change — `ci` - [ ] Dependencies bump — `dependencies` ## Changes - Give up on a source the speaker refuses to resume, since a rejected play command means the session is gone - Otherwise report a source that has been paused for longer than a minute as idle, clearing the stale source and media along with it - Keep re-checking the state ourselves until that grace period is over, since Sonos sends no event when a session goes stale - Cancel that pending check when the player is unloaded ## Checklist - [x] The code change is tested and works locally. - [x] `pre-commit run --all-files` passes. - [x] `pytest` passes, and tests have been added/updated under `tests/` where applicable. - [ ] For changes to shared models, the companion PR in `music-assistant/models` is linked. - [ ] For changes affecting the UI, the companion PR in `music-assistant/frontend` is linked. - [x] I have read and complied with the project's [AI Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md) for any AI-assisted contributions. - [ ] I have [raised a PR against the documentation repository](https://github.com/music-assistant/music-assistant.io/blob/main/CONTRIBUTING.md) targeting the main or beta branch as appropriate.