Skip to content

Commit 6a01b61

Browse files
committed
Merge branch 'dev' into feat/resonate-update2
2 parents 75ba475 + ad6eb43 commit 6a01b61

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

music_assistant/controllers/streams.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,15 @@ def get_stream(
877877
# because this could have been a group
878878
player_id=media.custom_data["player_id"],
879879
)
880-
elif media.source_id and media.source_id.startswith(UGP_PREFIX):
881-
# special case: UGP stream
880+
elif (
881+
media.media_type == MediaType.FLOW_STREAM
882+
and media.source_id
883+
and media.source_id.startswith(UGP_PREFIX)
884+
and media.uri
885+
and "/ugp/" in media.uri
886+
):
887+
# special case: member player accessing UGP stream
888+
# Check URI to distinguish from the UGP accessing its own stream
882889
ugp_player = cast("UniversalGroupPlayer", self.mass.players.get(media.source_id))
883890
ugp_stream = ugp_player.stream
884891
assert ugp_stream is not None # for type checker

music_assistant/providers/builtin_player/player.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,6 @@ async def _serve_audio_stream(self, request: web.Request) -> web.StreamResponse:
227227
"""Serve the flow stream audio to a player."""
228228
player_id = request.path.rsplit(".")[0].rsplit("/")[-1]
229229
format_str = request.path.rsplit(".")[-1]
230-
# bitrate = request.query.get("bitrate")
231-
queue = self.mass.player_queues.get(player_id)
232230
self.logger.debug("Serving audio stream to %s", player_id)
233231

234232
if not (player := self.mass.players.get(player_id)):
@@ -256,16 +254,8 @@ async def _serve_audio_stream(self, request: web.Request) -> web.StreamResponse:
256254
# on iOS devices with Home Assistant OS installations.
257255

258256
media = player._current_media
259-
if queue is None or media is None:
260-
raise web.HTTPNotFound(reason="No active queue or media found!")
261-
262-
if media.source_id is None:
263-
raise web.HTTPError # TODO: better error
264-
265-
queue_item = self.mass.player_queues.get_item(media.source_id, media.queue_item_id)
266-
267-
if queue_item is None:
268-
raise web.HTTPError # TODO: better error
257+
if media is None:
258+
raise web.HTTPNotFound(reason="No active media found!")
269259

270260
# TODO: set encoding quality using a bitrate parameter,
271261
# maybe even dynamic with auto/semiauto switching with bad network?
@@ -280,12 +270,10 @@ async def _serve_audio_stream(self, request: web.Request) -> web.StreamResponse:
280270
bit_depth=INTERNAL_PCM_FORMAT.bit_depth,
281271
channels=INTERNAL_PCM_FORMAT.channels,
282272
)
273+
283274
async for chunk in get_ffmpeg_stream(
284-
audio_input=self.mass.streams.get_queue_flow_stream(
285-
queue=queue,
286-
start_queue_item=queue_item,
287-
pcm_format=pcm_format,
288-
),
275+
# Use get_stream helper which handles all media types including UGP streams
276+
audio_input=self.mass.streams.get_stream(media, pcm_format),
289277
input_format=pcm_format,
290278
output_format=stream_format,
291279
# Apple ignores "Accept-Ranges=none" on iOS and iPadOS for some reason,

0 commit comments

Comments
 (0)