music-assistant-server

Branch:dev-lidarr-plugin

Commit Details

Sonos speakers now play tracks you add to the queue (#6116)

# What does this implement/fix?

Adding a track to the queue of a Sonos speaker often did nothing: the
speaker played straight past
it and left it sitting in the queue unplayed. This affected enqueuing in
general — play next, a
reorder, a track appended mid-playback — it just became impossible to
miss with the Party plugin,
where every guest request went missing.

A Sonos speaker reads our cloud queue on its own schedule and plays out
of what it cached. We were
serving it a snapshot of the queue that we only rebuilt when handing it
the next track, and with
smart fades on we stop doing that for most of every track. So the
speaker read a window that
predated the change and played what it had.

- Build the cloud queue `itemWindow` from the live queue on every
request instead of from a snapshot.
- Serve only the playing track and the one after it, so the speaker asks
again for every track and
can never be more than one behind. Honour the `itemId` it asks about,
and never exceed the window
  maxima it names.
- Refresh the speaker and invalidate its cached version whenever the
queue contents change.
- Forget the cloud queue on stop and on switching source; tell a speaker
with no queue that the
  queue is over.

**Related issue (if applicable):**



## 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`

## 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.
Forgejo

Author

Marcel van der Veldt<[email protected]>
August 31, 2026 at 09:20 AM UTC

Committer

Marvin Schenkel<[email protected]>
September 4, 2026 at 07:55 AM UTC
229additions
101deletions
5files changed

Parent commits

Changes

5 files
+229-101

Changed Files (5)

music_assistant/providers/sonos/
tests/providers/sonos/
music_assistant/providers/sonos/const.py
music_assistant/providers/sonos/player.py
+145-81
music_assistant/providers/sonos/provider.py
+83-20
tests/providers/sonos/test_cloud_queue.py
tests/providers/sonos/test_provider.py
+1