diff --git a/music_assistant/server/providers/snapcast/__init__.py b/music_assistant/server/providers/snapcast/__init__.py index a21ff0c12..72c20db54 100644 --- a/music_assistant/server/providers/snapcast/__init__.py +++ b/music_assistant/server/providers/snapcast/__init__.py @@ -192,9 +192,12 @@ async def cmd_play_url( player = self.mass.players.get(player_id) stream = self._get_snapstream(player_id) if stream.path != "": - await self._get_snapgroup(player_id).set_stream(await self._get_empty_stream()) + new_stream_id = await self._get_empty_stream() + await self._get_snapgroup(player_id).set_stream(new_stream_id) + stream = self._snapserver.stream(new_stream_id) stream_host = stream._stream.get("uri").get("host") + stream_host = stream_host.replace("0.0.0.0", self.snapcast_server_host) ffmpeg = ( FFmpeg() .option("y") @@ -208,6 +211,7 @@ async def cmd_play_url( ar=48000, ) ) + await self.cmd_stop(player_id) ffmpeg_task = self.mass.create_task(ffmpeg.execute()) @@ -295,9 +299,9 @@ async def _get_empty_stream(self) -> str: port = 4953 name = str(uuid.uuid4()) while True: - port += 1 new_stream = await self._snapserver.stream_add_stream( - f"tcp://{self.snapcast_server_host}:{port}?name={name}" + f"tcp://0.0.0.0:{port}?name={name}" ) - if new_stream["id"] not in used_streams: + if "id" in new_stream and new_stream["id"] not in used_streams: return new_stream["id"] + port += 1