Fix for _cleanup_player_memberships
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 22 Feb 2026 16:28:35 +0000 (17:28 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 22 Feb 2026 16:28:35 +0000 (17:28 +0100)
music_assistant/controllers/players/controller.py

index b4df5b3508d56787a165171db638c900a3d71ccb..676d58649fcf79191ab5dd6f5881d0e592942832 100644 (file)
@@ -1907,23 +1907,10 @@ class PlayerController(ProtocolLinkingMixin, CoreController):
 
     async def _cleanup_player_memberships(self, player_id: str) -> None:
         """Ensure a player is detached from any groups or syncgroups."""
-        if not (player := self.get_player(player_id)):
+        if not self.get_player(player_id):
             return
-
-        if (
-            player.state.active_group
-            and (group := self.get_player(player.state.active_group))
-            and group.supports_feature(PlayerFeature.SET_MEMBERS)
-        ):
-            # Ungroup the player if its part of an active group, this will ignore
-            # static_group_members since that is only checked when using cmd_set_members
-            with suppress(UnsupportedFeaturedException, PlayerCommandFailed):
-                await group.set_members(player_ids_to_remove=[player_id])
-        elif player.state.synced_to and player.supports_feature(PlayerFeature.SET_MEMBERS):
-            # Remove the player if it was synced, otherwise it will still show as
-            # synced to the other player after it gets registered again
-            with suppress(UnsupportedFeaturedException, PlayerCommandFailed):
-                await player.ungroup()
+        with suppress(UnsupportedFeaturedException, PlayerCommandFailed, PlayerUnavailableError):
+            await self.cmd_ungroup(player_id)
 
     def _get_player_with_redirect(self, player_id: str) -> Player:
         """Get player with check if playback related command should be redirected."""