mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix homepod streaming and browsing apps (#71230)
This commit is contained in:
parent
19bff35437
commit
1a2a061c19
@ -79,7 +79,8 @@ SUPPORT_APPLE_TV = (
|
|||||||
SUPPORT_FEATURE_MAPPING = {
|
SUPPORT_FEATURE_MAPPING = {
|
||||||
FeatureName.PlayUrl: MediaPlayerEntityFeature.BROWSE_MEDIA
|
FeatureName.PlayUrl: MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||||
| MediaPlayerEntityFeature.PLAY_MEDIA,
|
| MediaPlayerEntityFeature.PLAY_MEDIA,
|
||||||
FeatureName.StreamFile: MediaPlayerEntityFeature.PLAY_MEDIA,
|
FeatureName.StreamFile: MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||||
|
| MediaPlayerEntityFeature.PLAY_MEDIA,
|
||||||
FeatureName.Pause: MediaPlayerEntityFeature.PAUSE,
|
FeatureName.Pause: MediaPlayerEntityFeature.PAUSE,
|
||||||
FeatureName.Play: MediaPlayerEntityFeature.PLAY,
|
FeatureName.Play: MediaPlayerEntityFeature.PLAY,
|
||||||
FeatureName.SetPosition: MediaPlayerEntityFeature.SEEK,
|
FeatureName.SetPosition: MediaPlayerEntityFeature.SEEK,
|
||||||
@ -282,23 +283,20 @@ class AppleTvMediaPlayer(AppleTVEntity, MediaPlayerEntity):
|
|||||||
if media_type == MEDIA_TYPE_APP:
|
if media_type == MEDIA_TYPE_APP:
|
||||||
await self.atv.apps.launch_app(media_id)
|
await self.atv.apps.launch_app(media_id)
|
||||||
|
|
||||||
is_media_source_id = media_source.is_media_source_id(media_id)
|
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_type = MEDIA_TYPE_MUSIC
|
||||||
|
|
||||||
if (
|
media_id = async_process_play_media_url(self.hass, media_id)
|
||||||
not is_media_source_id
|
|
||||||
and self._is_feature_available(FeatureName.StreamFile)
|
if self._is_feature_available(FeatureName.StreamFile) and (
|
||||||
and (await is_streamable(media_id) or media_type == MEDIA_TYPE_MUSIC)
|
media_type == MEDIA_TYPE_MUSIC or await is_streamable(media_id)
|
||||||
):
|
):
|
||||||
_LOGGER.debug("Streaming %s via RAOP", media_id)
|
_LOGGER.debug("Streaming %s via RAOP", media_id)
|
||||||
await self.atv.stream.stream_file(media_id)
|
await self.atv.stream.stream_file(media_id)
|
||||||
|
|
||||||
if self._is_feature_available(FeatureName.PlayUrl):
|
if self._is_feature_available(FeatureName.PlayUrl):
|
||||||
if is_media_source_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)
|
|
||||||
|
|
||||||
_LOGGER.debug("Playing %s via AirPlay", media_id)
|
_LOGGER.debug("Playing %s via AirPlay", media_id)
|
||||||
await self.atv.stream.play_url(media_id)
|
await self.atv.stream.play_url(media_id)
|
||||||
else:
|
else:
|
||||||
@ -397,9 +395,12 @@ class AppleTvMediaPlayer(AppleTVEntity, MediaPlayerEntity):
|
|||||||
media_content_id=None,
|
media_content_id=None,
|
||||||
) -> BrowseMedia:
|
) -> BrowseMedia:
|
||||||
"""Implement the websocket media browsing helper."""
|
"""Implement the websocket media browsing helper."""
|
||||||
# If we can't stream URLs, we can't browse media.
|
if media_content_id == "apps" or (
|
||||||
|
# If we can't stream files or URLs, we can't browse media.
|
||||||
# In that case the `BROWSE_MEDIA` feature was added because of AppList/LaunchApp
|
# In that case the `BROWSE_MEDIA` feature was added because of AppList/LaunchApp
|
||||||
if not self._is_feature_available(FeatureName.PlayUrl):
|
not self._is_feature_available(FeatureName.PlayUrl)
|
||||||
|
and not self._is_feature_available(FeatureName.StreamFile)
|
||||||
|
):
|
||||||
return build_app_list(self._app_list)
|
return build_app_list(self._app_list)
|
||||||
|
|
||||||
if self._app_list:
|
if self._app_list:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user