"""Calculate current queue index and current track elapsed time when flow mode is active."""
elapsed_time_queue_total = player.corrected_elapsed_time or 0
if queue.current_index is None and not queue.flow_mode_stream_log:
- return None, elapsed_time_queue_total
+ return queue.current_index, queue.elapsed_time
# For each track that has been streamed/buffered to the player,
# a playlog entry will be created with the queue item id
track_sec_skipped = 0
track_time = elapsed_time_queue_total + track_sec_skipped - played_time
break
-
+ if player.state != PlayerState.PLAYING:
+ # if the player is not playing, we can't be sure that the elapsed time is correct
+ # so we just return the queue index and the elapsed time
+ return queue.current_index, queue.elapsed_time
return queue_index, track_time
def _parse_player_current_item_id(self, queue_id: str, player: Player) -> str | None: