From: Marcel van der Veldt Date: Tue, 26 Mar 2024 10:45:54 +0000 (+0100) Subject: fix streamed seconds calculation X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=83b44b0faccd4ab99a88b3e84932f6979f7bf513;p=music-assistant-server.git fix streamed seconds calculation --- diff --git a/music_assistant/server/controllers/streams.py b/music_assistant/server/controllers/streams.py index 70762a12..09ffa277 100644 --- a/music_assistant/server/controllers/streams.py +++ b/music_assistant/server/controllers/streams.py @@ -903,22 +903,25 @@ class StreamsController(CoreController): # update duration details based on the actual pcm data we sent # this also accounts for crossfade and silence stripping - seconds_streamed = (bytes_written + len(last_fadeout_part)) / pcm_sample_size + seconds_streamed = bytes_written / pcm_sample_size queue_track.streamdetails.seconds_streamed = seconds_streamed queue_track.streamdetails.duration = ( queue_track.streamdetails.seek_position + seconds_streamed ) self.logger.debug( - "Finished Streaming queue track: %s (%s) on queue %s - seconds streamed: %s", + "Finished Streaming queue track: %s (%s) on queue %s", queue_track.streamdetails.uri, queue_track.name, queue.display_name, - seconds_streamed, ) - + #### HANDLE END OF QUEUE FLOW STREAM # end of queue flow: make sure we yield the last_fadeout_part if last_fadeout_part: yield last_fadeout_part + # correct seconds streamed/duration + last_part_seconds = len(last_fadeout_part) / pcm_sample_size + queue_track.streamdetails.seconds_streamed += last_part_seconds + queue_track.streamdetails.duration += last_part_seconds del last_fadeout_part self.logger.info("Finished Queue Flow stream for Queue %s", queue.display_name)