From: Marcel van der Veldt Date: Tue, 31 May 2022 14:16:27 +0000 (+0200) Subject: fix valueerror X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=2a5e5549d1854cd85313587ff170a7f74b5161a7;p=music-assistant-server.git fix valueerror --- diff --git a/music_assistant/models/player_queue.py b/music_assistant/models/player_queue.py index 7e51d10d..a05bb772 100644 --- a/music_assistant/models/player_queue.py +++ b/music_assistant/models/player_queue.py @@ -219,7 +219,7 @@ class PlayerQueue: queue_items.append(QueueItem.from_media_item(track)) # clear queue first if it was finished - if self._current_index >= (len(self._items) - 1): + if (self._current_index or 0) >= (len(self._items) - 1): self._current_index = None self._items = [] @@ -437,12 +437,16 @@ class PlayerQueue: def on_player_update(self) -> None: """Call when player updates.""" if self._last_state != self.player.state: + # playback state changed self._last_state = self.player.state + # always signal update if playback state changed self.signal_update() - if self.player.state != PlayerState.PLAYING: + if self.player.state == PlayerState.IDLE: # handle end of queue - if (self._current_index or 0) >= (len(self._items) - 1): + if self._current_index and self._current_index >= ( + len(self._items) - 1 + ): self._current_index += 1 self._current_item_elapsed_time = 0 # repeat enabled (of whole queue), play queue from beginning