diff --git a/music_assistant/server/controllers/streams.py b/music_assistant/server/controllers/streams.py index 6e4e36fe5..e35deaef2 100644 --- a/music_assistant/server/controllers/streams.py +++ b/music_assistant/server/controllers/streams.py @@ -814,7 +814,7 @@ async def get_media_stream( if streamdetails.media_type == MediaType.RADIO: # ffmpeg sometimes has trouble with HLS radio streams stopping # abruptly for no reason so this is a workaround to keep the stream alive - extra_input_args += ["-stream_loop", "-1"] + extra_input_args += ["-reconnect_at_eof", "1"] elif streamdetails.stream_type == StreamType.ENCRYPTED_HTTP: audio_source = streamdetails.path extra_input_args += ["-decryption_key", streamdetails.decryption_key] diff --git a/music_assistant/server/helpers/audio.py b/music_assistant/server/helpers/audio.py index 63e3474fd..b5fb21044 100644 --- a/music_assistant/server/helpers/audio.py +++ b/music_assistant/server/helpers/audio.py @@ -500,17 +500,17 @@ async def resolve_radio_stream(mass: MusicAssistant, url: str) -> tuple[str, boo or "audio/x-scpls" in headers.get("content-type", "") ): # url is playlist, we need to unfold it - substreams = await fetch_playlist(mass, url) - if not any(x for x in substreams if x.length): - try: + try: + substreams = await fetch_playlist(mass, url) + if not any(x for x in substreams if x.length): for line in substreams: if not line.is_url: continue # unfold first url of playlist return await resolve_radio_stream(mass, line.path) raise InvalidDataError("No content found in playlist") - except IsHLSPlaylist: - is_hls = True + except IsHLSPlaylist: + is_hls = True except Exception as err: LOGGER.warning("Error while parsing radio URL %s: %s", url, err) @@ -913,9 +913,9 @@ def get_ffmpeg_args( # these options are only supported in ffmpeg > 5 input_args += [ "-reconnect_on_network_error", - "1", + "5", "-reconnect_on_http_error", - "5xx", + "5xx,4xx", ] if input_format.content_type.is_pcm(): input_args += [ diff --git a/music_assistant/server/providers/slimproto/__init__.py b/music_assistant/server/providers/slimproto/__init__.py index fbe5ae429..f90852915 100644 --- a/music_assistant/server/providers/slimproto/__init__.py +++ b/music_assistant/server/providers/slimproto/__init__.py @@ -674,7 +674,9 @@ def _handle_player_heartbeat(self, slimplayer: SlimClient) -> None: # elapsed time change on the player will be auto picked up # by the player manager. - player = self.mass.players.get(slimplayer.player_id) + if not (player := self.mass.players.get(slimplayer.player_id)): + # race condition?! + return player.elapsed_time = slimplayer.elapsed_seconds player.elapsed_time_last_updated = time.time()