diff --git a/music_assistant/server/controllers/players.py b/music_assistant/server/controllers/players.py index 19194daed..34f35f5c2 100644 --- a/music_assistant/server/controllers/players.py +++ b/music_assistant/server/controllers/players.py @@ -571,10 +571,14 @@ async def play_media(self, player_id: str, media: PlayerMedia) -> None: async def enqueue_next_media(self, player_id: str, media: PlayerMedia) -> None: """Handle enqueuing of a next media item on the player.""" - if (player := self.get(player_id)) and PlayerFeature.ENQUEUE in player.supported_features: - player_prov = self.mass.get_provider(player.provider) - async with self._player_throttlers[player_id]: - await player_prov.enqueue_next_media(player_id=player_id, media=media) + player = self.get(player_id, raise_unavailable=True) + if PlayerFeature.ENQUEUE not in player.supported_features: + raise UnsupportedFeaturedException( + f"Player {player.display_name} does not support enqueueing" + ) + player_prov = self.mass.get_provider(player.provider) + async with self._player_throttlers[player_id]: + await player_prov.enqueue_next_media(player_id=player_id, media=media) @api_command("players/cmd/sync") @handle_player_command diff --git a/music_assistant/server/providers/chromecast/__init__.py b/music_assistant/server/providers/chromecast/__init__.py index 4802716ae..6d13fa429 100644 --- a/music_assistant/server/providers/chromecast/__init__.py +++ b/music_assistant/server/providers/chromecast/__init__.py @@ -452,6 +452,7 @@ def on_new_cast_status(self, castplayer: CastPlayer, status: CastStatus) -> None PlayerFeature.POWER, PlayerFeature.VOLUME_SET, PlayerFeature.PAUSE, + PlayerFeature.ENQUEUE, ) # update player status diff --git a/music_assistant/server/providers/dlna/__init__.py b/music_assistant/server/providers/dlna/__init__.py index f13f7003c..fadc3dff4 100644 --- a/music_assistant/server/providers/dlna/__init__.py +++ b/music_assistant/server/providers/dlna/__init__.py @@ -60,8 +60,6 @@ from music_assistant.server import MusicAssistant from music_assistant.server.models import ProviderInstanceType -BASE_PLAYER_FEATURES = (PlayerFeature.VOLUME_MUTE, PlayerFeature.VOLUME_SET) - PLAYER_CONFIG_ENTRIES = ( CONF_ENTRY_CROSSFADE_FLOW_MODE_REQUIRED, @@ -179,7 +177,6 @@ def update_attributes(self) -> None: self.player.volume_level = int((self.device.volume_level or 0) * 100) self.player.volume_muted = self.device.is_volume_muted or False self.player.state = self.get_state(self.device) - self.player.supported_features = self.get_supported_features(self.device) self.player.current_item_id = self.device.current_track_uri or "" if self.player.player_id in self.player.current_item_id: self.player.active_source = self.player.player_id @@ -227,21 +224,6 @@ def get_state(device: DmrDevice) -> PlayerState: return PlayerState.IDLE - @staticmethod - def get_supported_features(device: DmrDevice) -> set[PlayerFeature]: - """Get player features that are supported at this moment. - - Supported features may change as the device enters different states. - """ - supported_features = set() - - if device.has_volume_level: - supported_features.add(PlayerFeature.VOLUME_SET) - if device.has_volume_mute: - supported_features.add(PlayerFeature.VOLUME_MUTE) - - return supported_features - class DLNAPlayerProvider(PlayerProvider): """DLNA Player provider.""" @@ -619,11 +601,18 @@ async def _update_player(self, dlna_player: DLNAPlayer) -> None: def _set_player_features(self, dlna_player: DLNAPlayer) -> None: """Set Player Features based on config values and capabilities.""" - if self.mass.config.get_raw_player_config_value( + supported_features: set[PlayerFeature] = set() + if not self.mass.config.get_raw_player_config_value( dlna_player.udn, CONF_ENTRY_FLOW_MODE_DEFAULT_ENABLED.key, CONF_ENTRY_FLOW_MODE_DEFAULT_ENABLED.default_value, ): - dlna_player.player.supported_features = BASE_PLAYER_FEATURES - else: - dlna_player.player.supported_features = (*BASE_PLAYER_FEATURES, PlayerFeature.ENQUEUE) + supported_features.add(PlayerFeature.ENQUEUE) + + if dlna_player.device.has_volume_level: + supported_features.add(PlayerFeature.VOLUME_SET) + if dlna_player.device.has_volume_mute: + supported_features.add(PlayerFeature.VOLUME_MUTE) + if dlna_player.device.has_pause: + supported_features.add(PlayerFeature.PAUSE) + dlna_player.player.supported_features = tuple(supported_features)