Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluesound: fixed deprecated enqueue next issue, announcements removed #1659

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions music_assistant/server/providers/bluesound/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
PLAYER_FEATURES_BASE = {
PlayerFeature.SYNC,
PlayerFeature.VOLUME_MUTE,
PlayerFeature.ENQUEUE_NEXT,
PlayerFeature.PAUSE,
}

Expand Down Expand Up @@ -275,8 +274,6 @@ async def on_mdns_service_state_change(
supported_features=(
PlayerFeature.VOLUME_SET,
PlayerFeature.VOLUME_MUTE,
PlayerFeature.PLAY_ANNOUNCEMENT,
PlayerFeature.ENQUEUE_NEXT,
PlayerFeature.PAUSE,
),
needs_poll=True,
Expand Down Expand Up @@ -358,26 +355,18 @@ async def play_media(
"""Handle PLAY MEDIA for BluOS player using the provided URL."""
mass_player = self.mass.players.get(player_id)
if bluos_player := self.bluos_players[player_id]:
await bluos_player.client.play_url(media.uri, timeout=timeout)
# Update media info then optimistically override playback state and source
await bluos_player.update_attributes()
mass_player.state = PLAYBACK_STATE_MAP["play"]
mass_player.active_source = None
self.mass.players.update(player_id)

mass_player = self.mass.players.get(player_id)
play_status = await bluos_player.client.play_url(media.uri, timeout=timeout)
if play_status == "stream":
# Update media info then optimistically override playback state and source
await bluos_player.update_attributes()
mass_player.state = PLAYBACK_STATE_MAP["play"]
mass_player.active_source = None
self.mass.players.update(player_id)

# Optionally, handle the playback_state or additional logic here
if mass_player.state != "playing":
if play_status in ("PlayerUnexpectedResponseError", "PlayerUnreachableError"):
raise PlayerCommandFailed("Failed to start playback.")

async def play_announcement(
self, player_id: str, announcement: PlayerMedia, volume_level: int | None = None
) -> None:
"""Send announcement to player."""
if bluos_player := self.bluos_players[player_id]:
await bluos_player.client.Input(announcement.uri, volume_level)

async def poll_player(self, player_id: str) -> None:
"""Poll player for state updates."""
if bluos_player := self.bluos_players[player_id]:
Expand Down
Loading