Skip to content

Commit

Permalink
feat: update streamdetails.dsp on group/ungroup
Browse files Browse the repository at this point in the history
  • Loading branch information
maximmaxim345 committed Jan 16, 2025
1 parent ff2484f commit 338c8cb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion music_assistant/controllers/player_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
MASS_LOGO_ONLINE,
)
from music_assistant.helpers.api import api_command
from music_assistant.helpers.audio import get_stream_details
from music_assistant.helpers.audio import get_stream_details, get_stream_dsp_details
from music_assistant.helpers.throttle_retry import BYPASS_THROTTLER
from music_assistant.helpers.util import get_changed_keys
from music_assistant.models.core_controller import CoreController
Expand Down Expand Up @@ -108,6 +108,7 @@ class CompareState(TypedDict):
elapsed_time: int
stream_title: str | None
content_type: str | None
group_childs_count: int


class PlayerQueuesController(CoreController):
Expand Down Expand Up @@ -962,6 +963,7 @@ def on_player_update(
next_item_id=None,
elapsed_time=0,
stream_title=None,
group_childs_count=0,
),
)

Expand All @@ -978,6 +980,7 @@ def on_player_update(
content_type=queue.current_item.streamdetails.audio_format.output_format_str
if queue.current_item and queue.current_item.streamdetails
else None,
group_childs_count=len(player.group_childs),
)
changed_keys = get_changed_keys(prev_state, new_state)
# return early if nothing changed
Expand All @@ -999,6 +1002,14 @@ def on_player_update(
else:
self._prev_states.pop(queue_id, None)

if "group_childs_count" in changed_keys:
# refresh DSP details since a player has been added/removed from the group
dsp = get_stream_dsp_details(self.mass, queue_id)
if queue.current_item and queue.current_item.streamdetails:
queue.current_item.streamdetails.dsp = dsp
if queue.next_item and queue.next_item.streamdetails:
queue.next_item.streamdetails.dsp = dsp

# detect change in current index to report that a item has been played
prev_item_id = prev_state["current_item_id"]
player_stopped = (
Expand Down

0 comments on commit 338c8cb

Please sign in to comment.