Add playback_speed for variable-speed elapsed-time tracking#213
Add playback_speed for variable-speed elapsed-time tracking#213
Conversation
|
I don't think we need this on the |
|
I think you're right that But I think we still use the speed in one spot — when working out how far into the current track the listener actually is, we multiply the player's elapsed seconds by the speed to convert it back into audiobook seconds (so the progress bar shows the right position). I think we could probably just read that speed off Happy to drop it if you don't think that window matters in practice. |
|
You don't need this on the PlayLogEntry |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Looking to satisfy https://github.com/orgs/music-assistant/discussions/3790
Music Assistant already supports variable playback speed by applying ffmpeg's atempo filter to speed up the audio before it reaches the player. However, this will break elapsed-time accounting because the player only knows how long it has been playing the (sped-up) audio — it has no idea how much of the original content the listener has heard.
Without knowing the speed, the queue and the progress bar can't tell those two values apart, which causes:
The progress bar to drift from the listener's actual position between server updates, because the realtime tick advances using real-world seconds instead of audiobook seconds; and
Flow mode (where MA stitches multiple tracks into one continuous stream for players that can't gap-lessly switch tracks) to pick the wrong track boundary when the speed varies across items in the stream.
This PR adds two new fields, both defaulting to 1.0, so the speed travels alongside the timing data:
PlayerQueue.playback_speed: the speed in effect at the moment of the lastelapsed_timeupdate. Thecorrected_elapsed_timeproperty is updated to multiply its between-update delta by this value, so the progress bar ticks in audiobook/podcast playback seconds rather than real-world seconds.PlayLogEntry.playback_speed: the speed at which each flow-mode segment was streamed. The MA controller uses this to figure out which track is currently playing when the speed has varied across segments in a single stream.The new fields default to 1.0 which means the current callers get exactly the same behaviour.
The corresponding server PR uses these fields to record
elapsed_timein audiobook/podcast playback seconds and to step through the flow-mode playlog with the correct speed for each segment.