From 07a9c16420bc78c4c6c75c6d55f9e7f9ad7df508 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Mon, 17 Mar 2025 18:02:23 +0100 Subject: [PATCH] Fix snapcast using external snapserver (#2044) Don't use the controlscript for external snapservers --- music_assistant/providers/snapcast/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/music_assistant/providers/snapcast/__init__.py b/music_assistant/providers/snapcast/__init__.py index 108f4599..401e1e65 100644 --- a/music_assistant/providers/snapcast/__init__.py +++ b/music_assistant/providers/snapcast/__init__.py @@ -679,6 +679,14 @@ class SnapCastProvider(PlayerProvider): if stream.identifier == stream_name: return stream + if self._use_builtin_server: + extra_args = ( + f"&controlscript={urllib.parse.quote_plus(str(CONTROL_SCRIPT))}" + f"&controlscriptparams=--queueid={urllib.parse.quote_plus(queue_id)}%20--api-port={self.mass.webserver.publish_port}" + ) + else: + extra_args = "" + attempts = 50 while attempts: attempts -= 1 @@ -689,9 +697,7 @@ class SnapCastProvider(PlayerProvider): # (like 24 bits bit depth) does not seem to work at all! f"tcp://0.0.0.0:{port}?sampleformat=48000:16:2" f"&idle_threshold={self._snapcast_stream_idle_threshold}" - f"&controlscript={urllib.parse.quote_plus(str(CONTROL_SCRIPT))}" - f"&controlscriptparams=--queueid={urllib.parse.quote_plus(queue_id)}%20--api-port={self.mass.webserver.publish_port}" - f"&name={stream_name}" + f"{extra_args}&name={stream_name}" ) if "id" not in result: # if the port is already taken, the result will be an error -- 2.34.1