Fix track duration shrinking when seeking near the end with smart crossfade#4176
Merged
Conversation
082ae47 to
1315dc2
Compare
1315dc2 to
3560d8f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect track duration recalculation when smart crossfade is enabled, specifically preventing the reported duration from shrinking after seeking near the end of a track (which could break UI seekbars and HA entity state).
Changes:
- Single-item (gapless) smartfade: account for the held-back fade-out tail when recomputing
streamdetails.duration. - Flow-mode streaming: include the held-back crossfade tail in per-track duration recomputation, and remove the now-duplicate end-of-queue duration correction.
marcelveldt
approved these changes
Jun 12, 2026
marcelveldt
pushed a commit
that referenced
this pull request
Jun 13, 2026
anatosun
pushed a commit
to anatosun/music-assistant-server
that referenced
this pull request
Jun 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this implement/fix?
With smart crossfade enabled, the last part of each track (up to 45s) is held back as the crossfade tail. The end-of-track duration recalculation excluded this tail, so the reported track duration shrank by up to the crossfade length. After seeking near the end of a track the error is large enough that the duration drops below the play position, breaking the seekbar and the duration/position reported to HA entities. The shrunken value was also reused on the next seek, compounding the error.
Related issue (if applicable):
Types of changes
bugfixnew-featureenhancementnew-providerbreaking-changerefactordocumentationmaintenancecidependenciesChecklist
pre-commit run --all-filespasses.pytestpasses, and tests have been added/updated undertests/where applicable.music-assistant/modelsis linked.music-assistant/frontendis linked.