Skip to content

Allow moving the buffered next track on Sendspin players - #8084

Merged
marcelveldt merged 8 commits into
devfrom
feat/queue-replaceable-next-item
Nov 27, 2026
Merged

marcelveldt merged 8 commits into
devfrom
feat/queue-replaceable-next-item

Conversation

@maximmaxim345

@maximmaxim345 maximmaxim345 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

What does this implement/fix?

Sendspin players can now drop a next track they already received and play another one in its place. "Play next", moving, deleting and shuffling then also change the next track on them, up to 5 seconds before it starts. Unless a crossfade into the old next track was already prepared, the switch happens inside the running stream without a gap or restart.

Players opt in with the new replaces_enqueued_media property on PlayerProtocol. Sendspin sets it while "Allow legacy clients" is off and every group member supports the cut, so groups with a bridged Squeezelite or Cast speaker keep the existing lock. The queue publishes the last queue index the player holds as the PlayerQueue.last_locked_index field, and the frontend locks the queue up to that index instead of up to the buffered track. A buffered track stays locked while no playable track follows it, since the player can only replace it with one that does.

Tested with sendspin-cli 1.0.1 (sendspin-cpp v0.10.0) and Python scripts built on the aiosendspin client: "Play next", move, delete and shuffle near the end of a track all switched to the new next track without a gap.

Related issue (if applicable):

Types of changes

  • 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

  • The code change is tested and works locally.
  • pre-commit run --all-files passes.
  • 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.
  • I have read and complied with the project's AI Policy for any AI-assisted contributions.
  • I have raised a PR against the documentation repository targeting the main or beta branch as appropriate.

@maximmaxim345

Copy link
Copy Markdown
Member Author

@Bot-MArley review

@Bot-MArley Bot-MArley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This comment was written by Claude and posted by Bot-MArley on behalf of the Music Assistant maintainers.

Thanks @maximmaxim345! This lets Sendspin players swap a next track they already received, so "Play next", move, delete and shuffle also change the next track until about 5 seconds before it starts. I read the whole diff on top of the base branch and found nothing that needs changing before merge.

Requested changes: none. The lock timer, the crossfade hand-off and the committed_index change all hold up, and every caller of committed_index still behaves as intended.

One heads-up: the description says the frontend reads next_item_replaceable, but I couldn't find a frontend change or companion PR for it. Until that lands, moving or deleting the buffered next track from the web UI stays blocked as before. The PR is still a draft, so it's waiting on you to mark it ready.

@maximmaxim345
maximmaxim345 force-pushed the feat/queue-replaceable-next-item branch from 46f63e4 to 32d148c Compare November 24, 2026 09:12
@maximmaxim345
maximmaxim345 force-pushed the feat/queue-replaceable-next-item branch from 32d148c to eee48c7 Compare November 24, 2026 11:27
@maximmaxim345
maximmaxim345 force-pushed the feat/queue-replaceable-next-item branch 3 times, most recently from 7d607ba to 60773c4 Compare November 24, 2026 17:28
@maximmaxim345
maximmaxim345 marked this pull request as ready for review November 25, 2026 13:51
@MarvinSchenkel

Copy link
Copy Markdown
Contributor

@Bot-MArley review again

@Bot-MArley Bot-MArley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This comment was written by Claude and posted by Bot-MArley on behalf of the Music Assistant maintainers.

Thanks @maximmaxim345! This lets Sendspin players swap the next track they already received, so "Play next", move, delete and shuffle change it until about 5 seconds before it starts, and the queue publishes last_locked_index for the frontend (frontend#3326). I read the whole diff again on top of feat/sendspin-replace-sent-next-track. The lock timer, the crossfade hand-off through fading_into and the new committed_index all hold up, every caller now goes through the controller, and _play_index now resets the replaceable flag on a fresh load.

Requested changes: none, it looks good to me. It changes core queue and stream code as well as the Sendspin provider, so I don't approve it on my own. If you're a server admin, comment @Bot-MArley approve and I will. Otherwise it needs another maintainer's approval.

@maximmaxim345
maximmaxim345 force-pushed the feat/queue-replaceable-next-item branch from 60773c4 to bb9687a Compare November 26, 2026 16:09

@Bot-MArley Bot-MArley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This comment was written by Claude and posted by Bot-MArley on behalf of the Music Assistant maintainers.

Thanks @maximmaxim345! This lets Sendspin players that can replace an already-sent next track keep it free to move: "Play next", move, delete and shuffle change it up to 5 seconds before it starts, and the queue publishes last_locked_index. This covers the changes since the last review (review).

I went through the whole diff against the #8083 branch and didn't find anything that needs to change before merge. Every caller of the old lock helper was moved over, and for players other than Sendspin the lock behaves as before.

It's stacked on #8083, so that one has to land first. It also changes core queue code, so another maintainer approves it, and a maintainer decides whether the sendspin-cli test counts as testing on a real device.

# What does this implement/fix?

<!-- Quick description and explanation of changes. -->

Stacked on #8084. Clients get the locked part of the queue as one queue
field, `last_locked_index`, instead of an `extra_attributes` key next to
`index_in_buffer`. That one value tells every client which items it may
move or remove, so none of them has to combine it with `index_in_buffer`
or repeat a server rule.

## Changes

- The queue publishes the lock as `PlayerQueue.last_locked_index`
(music-assistant/models#495).
- The buffered next track counts as replaceable only while a track
follows it. The lock covers the "last track can't be deleted" rule
itself, so `delete_item` needs no special case. "Play next" while the
next track is the last one lands after it.
- The MCP queue tools follow the same lock.
- API schema version 128, models 1.1.254.

**Related issue (if applicable):**

- stacked on #8084
- models music-assistant/models#495
- frontend music-assistant/frontend#3360 (stacked on
music-assistant/frontend#3326)

## Types of changes

<!--
Tick exactly one box. CI (.github/workflows/pr-labels.yaml) derives
the label from the ticked box and applies it automatically; the
release-notes generator uses that same label to slot this change
into the next release notes.
-->

- [ ] 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`
- [x] 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.
- [x] For changes to shared models, the companion PR in
`music-assistant/models` is linked.
- [x] 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.
@marcelveldt

Copy link
Copy Markdown
Member

@maximmaxim345 merged #8246 into your branch (and frontend#3360 into #3326): the lock is now the PlayerQueue.last_locked_index field (models 1.1.254) and the last-track rule moved into committed_index — pull before you continue.

@marcelveldt

Copy link
Copy Markdown
Member

lab gate --all on cbe4b8edc (includes #8083): green, 17/17 on every player kind incl. sendspin — run 20261127-140600-cfc3

Base automatically changed from feat/sendspin-replace-sent-next-track to dev November 27, 2026 14:58

@Bot-MArley Bot-MArley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This comment was written by Claude and posted by Bot-MArley on behalf of the Music Assistant maintainers.

Thanks @maximmaxim345! This covers the changes since the last review: the lock is now published as the PlayerQueue.last_locked_index field (models 1.1.254, pin and API_SCHEMA_VERSION bumped), the last-track rule lives in committed_index, and a buffered last track stays locked. I found no problems in the new commits, and the move, delete, play-next and shuffle paths all use the same boundary now.

No changes requested. The description still says the index goes into extra_attributes, so it's worth updating it and ticking the models item. The hardware test still names only sendspin-cli and scripts, so a maintainer decides whether that is enough; the PR is also stacked on #8083.

…ol-simplify

# Conflicts:
#	music_assistant/constants.py
#	music_assistant/controllers/player_queues/controller.py
#	music_assistant/controllers/player_queues/queue_loader.py
#	music_assistant/models/player_protocol.py
#	pyproject.toml
#	requirements_all.txt
@marcelveldt

Copy link
Copy Markdown
Member

@Bot-MArley review again

@Bot-MArley Bot-MArley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This comment was written by Claude and posted by Bot-MArley on behalf of the Music Assistant maintainers.

Thanks @maximmaxim345! This lets Sendspin players swap a next track they already received, so "Play next", move, delete and shuffle can change it up to 5 seconds before it starts. The queue publishes the locked range as PlayerQueue.last_locked_index. I read the whole diff again on top of the latest dev, where #8083 has now landed. The lock timer, the crossfade hand-off, the last-track rule in committed_index and every caller of the boundary (queue loader, smart shuffle, party, plex_connect, ai_radio, MCP tools) all hold up. The API_SCHEMA_VERSION bump to 128 matches the new field.

Requested changes: none, it looks good to me. The earlier note about the description is fixed too.

It changes core queue and stream code and touches more than the Sendspin provider, so I don't approve it on my own. If you're a server admin, comment @Bot-MArley approve and I will. Otherwise it needs another maintainer's approval.

@marcelveldt marcelveldt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @maximmaxim345!

@marcelveldt
marcelveldt added this pull request to the merge queue Nov 27, 2026
Merged via the queue into dev with commit fc9fbba Nov 27, 2026
26 of 31 checks passed
@marcelveldt
marcelveldt deleted the feat/queue-replaceable-next-item branch November 27, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants