From b33981f7fa3ea8af43d259e344f3ff497edcf6d8 Mon Sep 17 00:00:00 2001 From: pstruebi Date: Thu, 19 Jun 2025 13:46:40 +0200 Subject: [PATCH] Fix webrtc restart issue --- src/auracast/server/multicast_frontend.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/auracast/server/multicast_frontend.py b/src/auracast/server/multicast_frontend.py index 7a09ac9..a4b44ec 100644 --- a/src/auracast/server/multicast_frontend.py +++ b/src/auracast/server/multicast_frontend.py @@ -111,6 +111,20 @@ if audio_mode in ["Webapp", "USB"]: st.success("Stream was not running.") except Exception as e: st.error(f"Error: {e}") + # Ensure existing WebRTC connection is fully closed so that a fresh + # connection is created the next time we start the stream. + if audio_mode == "Webapp": + cleanup_js = """ + + """ + st.components.v1.html(cleanup_js, height=0) if start_stream: # Always send stop to ensure backend is in a clean state, regardless of current status @@ -158,10 +172,15 @@ if audio_mode in ["Webapp", "USB"]: component = f"""