Skip to content

Commit

Permalink
Add support for browsing media sources
Browse files Browse the repository at this point in the history
  • Loading branch information
definitio committed May 20, 2022
1 parent 85cae7e commit 49294dc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion custom_components/sox/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
DEFAULT_PORT = 7777

SUPPORTED_FEATURES_DEFAULT = (
MediaPlayerEntityFeature.PLAY | MediaPlayerEntityFeature.PLAY_MEDIA
MediaPlayerEntityFeature.BROWSE_MEDIA
| MediaPlayerEntityFeature.PLAY
| MediaPlayerEntityFeature.PLAY_MEDIA
)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
Expand Down Expand Up @@ -139,6 +141,14 @@ def media_stop(self):
"""Send stop command."""
self._send("stop")

async def async_browse_media(self, media_content_type, media_content_id):
"""Implement the websocket media browsing helper."""
return await media_source.async_browse_media(
self.hass,
media_content_id,
content_filter=lambda item: item.media_content_type.startswith("audio/"),
)

async def async_play_media(self, media_type, media_id, **kwargs):
"""Send the play command."""
del kwargs
Expand Down

0 comments on commit 49294dc

Please sign in to comment.