From: Marcel van der Veldt Date: Wed, 2 Apr 2025 00:32:36 +0000 (+0200) Subject: Fix enqueue track on last item X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=94e15cdf30092a587fb90e7226a4912fbdc5b19e;p=music-assistant-server.git Fix enqueue track on last item --- diff --git a/music_assistant/controllers/player_queues.py b/music_assistant/controllers/player_queues.py index 883719d6..b02c3984 100644 --- a/music_assistant/controllers/player_queues.py +++ b/music_assistant/controllers/player_queues.py @@ -395,10 +395,6 @@ class PlayerQueuesController(CoreController): if not isinstance(media, list): media = [media] - # clear queue first if it was finished - if queue.current_index and queue.current_index >= (len(self._queue_items[queue_id]) - 1): - queue.current_index = None - self._queue_items[queue_id] = [] # clear queue if needed if option == QueueOption.REPLACE: self.clear(queue_id) @@ -473,7 +469,7 @@ class PlayerQueuesController(CoreController): cur_index = queue.index_in_buffer or queue.current_index or 0 else: cur_index = queue.current_index or 0 - insert_at_index = cur_index + 1 if self._queue_items.get(queue_id) else 0 + insert_at_index = cur_index + 1 # Radio modes are already shuffled in a pattern we would like to keep. shuffle = queue.shuffle_enabled and len(queue_items) > 1 and not radio_mode @@ -524,7 +520,7 @@ class PlayerQueuesController(CoreController): queue_items=queue_items, insert_at_index=insert_at_index if queue.shuffle_enabled - else len(self._queue_items[queue_id]), + else len(self._queue_items[queue_id]) + 1, shuffle=queue.shuffle_enabled, ) # handle edgecase, queue is empty and items are only added (not played) diff --git a/music_assistant/helpers/audio.py b/music_assistant/helpers/audio.py index f40991fd..495e4f96 100644 --- a/music_assistant/helpers/audio.py +++ b/music_assistant/helpers/audio.py @@ -45,6 +45,7 @@ from music_assistant.constants import ( VERBOSE_LOG_LEVEL, ) from music_assistant.helpers.json import JSON_DECODE_EXCEPTIONS, json_loads +from music_assistant.helpers.throttle_retry import BYPASS_THROTTLER from music_assistant.helpers.util import clean_stream_title, remove_file from .datetime import utc @@ -528,6 +529,7 @@ async def get_stream_details( This is called just-in-time when a PlayerQueue wants a MediaItem to be played. Do not try to request streamdetails too much in advance as this is expiring data. """ + BYPASS_THROTTLER.set(True) time_start = time.time() LOGGER.debug("Getting streamdetails for %s", queue_item.uri) if seek_position and (queue_item.media_type == MediaType.RADIO or not queue_item.duration):