Fix enqueue track on last item
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Wed, 2 Apr 2025 00:32:36 +0000 (02:32 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Wed, 2 Apr 2025 00:32:36 +0000 (02:32 +0200)
music_assistant/controllers/player_queues.py
music_assistant/helpers/audio.py

index 883719d6b501243709e1cc3b62ae215b5855efda..b02c39847a998b2cd1e704b45bb090decf45eca6 100644 (file)
@@ -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)
index f40991fd30a1a5cb5ff803a9d9accf7cfe24fcb2..495e4f9611b0f5b0d542695a3b49057b38929e4e 100644 (file)
@@ -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):