Add media source support to bluesound (#67563)
parent
f91a809350
commit
12a7b64e64
|
@ -15,10 +15,15 @@ import async_timeout
|
|||
import voluptuous as vol
|
||||
import xmltodict
|
||||
|
||||
from homeassistant.components import media_source
|
||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
|
||||
from homeassistant.components.media_player.browse_media import (
|
||||
async_process_play_media_url,
|
||||
)
|
||||
from homeassistant.components.media_player.const import (
|
||||
ATTR_MEDIA_ENQUEUE,
|
||||
MEDIA_TYPE_MUSIC,
|
||||
SUPPORT_BROWSE_MEDIA,
|
||||
SUPPORT_CLEAR_PLAYLIST,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
|
@ -800,7 +805,7 @@ class BluesoundPlayer(MediaPlayerEntity):
|
|||
if self.is_grouped and not self.is_master:
|
||||
return SUPPORT_VOLUME_STEP | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE
|
||||
|
||||
supported = SUPPORT_CLEAR_PLAYLIST
|
||||
supported = SUPPORT_CLEAR_PLAYLIST | SUPPORT_BROWSE_MEDIA
|
||||
|
||||
if self._status.get("indexing", "0") == "0":
|
||||
supported = (
|
||||
|
@ -1029,6 +1034,12 @@ class BluesoundPlayer(MediaPlayerEntity):
|
|||
if self.is_grouped and not self.is_master:
|
||||
return
|
||||
|
||||
if media_source.is_media_source_id(media_id):
|
||||
play_item = await media_source.async_resolve_media(self.hass, media_id)
|
||||
media_id = play_item.url
|
||||
|
||||
media_id = async_process_play_media_url(self.hass, media_id)
|
||||
|
||||
url = f"Play?url={media_id}"
|
||||
|
||||
if kwargs.get(ATTR_MEDIA_ENQUEUE):
|
||||
|
@ -1063,3 +1074,11 @@ class BluesoundPlayer(MediaPlayerEntity):
|
|||
if mute:
|
||||
return await self.send_bluesound_command("Volume?mute=1")
|
||||
return await self.send_bluesound_command("Volume?mute=0")
|
||||
|
||||
async def async_browse_media(self, media_content_type=None, media_content_id=None):
|
||||
"""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/"),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue