Improve play media support in LinkPlay (#125205)

Improve play media support in linkplay
pull/125417/head
Simon Lamon 2024-09-06 15:02:38 +02:00 committed by GitHub
parent f3e2c51774
commit af0a6d2820
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 4 deletions

View File

@ -20,6 +20,9 @@ from homeassistant.components.media_player import (
MediaType,
RepeatMode,
)
from homeassistant.components.media_player.browse_media import (
async_process_play_media_url,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import device_registry as dr
@ -238,10 +241,14 @@ class LinkPlayMediaPlayerEntity(MediaPlayerEntity):
self, media_type: MediaType | str, media_id: str, **kwargs: Any
) -> None:
"""Play a piece of media."""
media = await media_source.async_resolve_media(
self.hass, media_id, self.entity_id
)
await self._bridge.player.play(media.url)
if media_source.is_media_source_id(media_id):
play_item = await media_source.async_resolve_media(
self.hass, media_id, self.entity_id
)
media_id = play_item.url
url = async_process_play_media_url(self.hass, media_id)
await self._bridge.player.play(url)
def _update_properties(self) -> None:
"""Update the properties of the media player."""