Skip to content

Commit

Permalink
Feat: Implement missing player methods
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Oct 30, 2024
1 parent 821f963 commit 8a58122
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions music_assistant_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import urllib.parse
import uuid
from collections.abc import Callable, Coroutine
from typing import TYPE_CHECKING, Any, Self
from typing import TYPE_CHECKING, Any, Self, cast

from music_assistant_models.api import (
CommandMessage,
Expand Down Expand Up @@ -131,7 +131,7 @@ def get_image_url(self, image: MediaItemImage, size: int = 0) -> str:
"""Get (proxied) URL for MediaItemImage."""
assert self.server_info
if image.remotely_accessible and not size:
return image.path
return cast(str, image.path)
if image.remotely_accessible and size:
# get url to resized image(thumb) from weserv service
return (
Expand Down
18 changes: 17 additions & 1 deletion music_assistant_client/players.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ async def player_command_seek(self, player_id: str, position: int) -> None:
"""
await self.client.send_command("players/cmd/seek", player_id=player_id, position=position)

async def cmd_next_track(self, player_id: str) -> None:
"""Handle NEXT TRACK command for given player."""
await self.client.send_command("players/cmd/next", player_id=player_id)

async def cmd_previous_track(self, player_id: str) -> None:
"""Handle PREVIOUS TRACK command for given player."""
await self.client.send_command("players/cmd/previous", player_id=player_id)

async def player_command_sync(self, player_id: str, target_player: str) -> None:
"""
Handle SYNC command for given player.
Expand Down Expand Up @@ -133,7 +141,7 @@ async def cmd_sync_many(self, target_player: str, child_player_ids: list[str]) -
)

async def cmd_unsync_many(self, player_ids: list[str]) -> None:
"""Create temporary sync group by joining given players to target player."""
"""Handle UNSYNC command for all the given players."""
await self.client.send_command("players/cmd/unsync_many", player_ids=player_ids)

async def play_announcement(
Expand Down Expand Up @@ -178,6 +186,14 @@ async def set_player_group_volume(self, player_id: str, volume_level: int) -> No
"players/cmd/group_volume", player_id=player_id, volume_level=volume_level
)

async def cmd_group_volume_up(self, player_id: str) -> None:
"""Send VOLUME_UP command to given playergroup."""
await self.client.send_command("players/cmd/group_volume_up", player_id=player_id)

async def cmd_group_volume_down(self, player_id: str) -> None:
"""Send VOLUME_DOWN command to given playergroup."""
await self.client.send_command("players/cmd/group_volume_down", player_id=player_id)

async def set_player_group_members(self, player_id: str, members: list[str]) -> None:
"""
Update the memberlist of the given PlayerGroup.
Expand Down

0 comments on commit 8a58122

Please sign in to comment.