Skip to content

Commit

Permalink
Fixes for dont stop the music
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Oct 24, 2024
1 parent 5c70ff2 commit f87ed61
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion music_assistant/common/models/player_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PlayerQueue(DataClassDictMixin):

shuffle_enabled: bool = False
repeat_mode: RepeatMode = RepeatMode.OFF
dont_stop_the_music_enabled: bool = True
dont_stop_the_music_enabled: bool = False
# current_index: index that is active (e.g. being played) by the player
current_index: int | None = None
# index_in_buffer: index that has been preloaded/buffered by the player
Expand Down
17 changes: 10 additions & 7 deletions music_assistant/server/controllers/player_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ def set_shuffle(self, queue_id: str, shuffle_enabled: bool) -> None:
@api_command("player_queues/dont_stop_the_music")
def set_dont_stop_the_music(self, queue_id: str, dont_stop_the_music_enabled: bool) -> None:
"""Configure Don't stop the music setting on the queue."""
providers_available_with_similar_tracks = any(
ProviderFeature.SIMILAR_TRACKS in provider.supported_features
for provider in self.mass.music.providers
)
if dont_stop_the_music_enabled and not providers_available_with_similar_tracks:
raise UnsupportedFeaturedException(
"Don't stop the music is not supported by any of the available music providers"
)
queue = self._queues[queue_id]
queue.dont_stop_the_music_enabled = dont_stop_the_music_enabled
self.signal_update(queue_id=queue_id)
Expand Down Expand Up @@ -848,17 +856,12 @@ async def on_player_register(self, player: Player) -> None:
str(err),
)
if queue is None:
# enable dont stop the music by default if we have providers that support similar tracks
providers_available_with_similar_tracks = any(
ProviderFeature.SIMILAR_TRACKS in provider.supported_features
for provider in self.mass.music.providers
)
queue = PlayerQueue(
queue_id=queue_id,
active=False,
display_name=player.display_name,
available=player.available,
dont_stop_the_music_enabled=providers_available_with_similar_tracks,
dont_stop_the_music_enabled=False,
items=0,
)
queue_items = []
Expand Down Expand Up @@ -1024,7 +1027,7 @@ def on_player_update(
queue.next_track_enqueued = None

# watch dynamic radio items refill if needed
elif "current_index" in changed_keys:
if "current_index" in changed_keys:
if (
queue.dont_stop_the_music_enabled
and queue.enqueued_media_items
Expand Down

0 comments on commit f87ed61

Please sign in to comment.