mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Improve Roon media player play_media (#45221)
* Use revised play_media api. * Move split path function to library.
This commit is contained in:
parent
ae3d038baa
commit
a1b0d6baad
@ -4,7 +4,7 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/roon",
|
||||
"requirements": [
|
||||
"roonapi==0.0.30"
|
||||
"roonapi==0.0.31"
|
||||
],
|
||||
"codeowners": [
|
||||
"@pavoni"
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""MediaPlayer platform for Roon integration."""
|
||||
import logging
|
||||
|
||||
from roonapi import split_media_path
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import MediaPlayerEntity
|
||||
@ -120,8 +121,6 @@ class RoonDevice(MediaPlayerEntity):
|
||||
self._last_position_update = None
|
||||
self._supports_standby = False
|
||||
self._state = STATE_IDLE
|
||||
self._last_playlist = None
|
||||
self._last_media = None
|
||||
self._unique_id = None
|
||||
self._zone_id = None
|
||||
self._output_id = None
|
||||
@ -354,11 +353,6 @@ class RoonDevice(MediaPlayerEntity):
|
||||
"""Album artist of current playing media (Music track only)."""
|
||||
return self._media_artist
|
||||
|
||||
@property
|
||||
def media_playlist(self):
|
||||
"""Title of Playlist currently playing."""
|
||||
return self._last_playlist
|
||||
|
||||
@property
|
||||
def media_image_url(self):
|
||||
"""Image url of current playing media."""
|
||||
@ -481,31 +475,12 @@ class RoonDevice(MediaPlayerEntity):
|
||||
|
||||
def play_media(self, media_type, media_id, **kwargs):
|
||||
"""Send the play_media command to the media player."""
|
||||
# Roon itself doesn't support playback of media by filename/url so this a bit of a workaround.
|
||||
media_type = media_type.lower()
|
||||
if media_type == "radio":
|
||||
if self._server.roonapi.play_radio(self.zone_id, media_id):
|
||||
self._last_playlist = media_id
|
||||
self._last_media = media_id
|
||||
elif media_type == "playlist":
|
||||
if self._server.roonapi.play_playlist(
|
||||
self.zone_id, media_id, shuffle=False
|
||||
):
|
||||
self._last_playlist = media_id
|
||||
elif media_type == "shuffleplaylist":
|
||||
if self._server.roonapi.play_playlist(self.zone_id, media_id, shuffle=True):
|
||||
self._last_playlist = media_id
|
||||
elif media_type == "queueplaylist":
|
||||
self._server.roonapi.queue_playlist(self.zone_id, media_id)
|
||||
elif media_type == "genre":
|
||||
self._server.roonapi.play_genre(self.zone_id, media_id)
|
||||
elif media_type in ("library", "track"):
|
||||
self._server.roonapi.play_id(self.zone_id, media_id)
|
||||
else:
|
||||
# media_id is treated as a path matching the Roon menu structure
|
||||
|
||||
path_list = split_media_path(media_id)
|
||||
if not self._server.roonapi.play_media(self.zone_id, path_list):
|
||||
_LOGGER.error(
|
||||
"Playback requested of unsupported type: %s --> %s",
|
||||
media_type,
|
||||
media_id,
|
||||
"Playback request for %s / %s was unsuccessful", media_id, path_list
|
||||
)
|
||||
|
||||
def join(self, join_ids):
|
||||
|
@ -1955,7 +1955,7 @@ rokuecp==0.6.0
|
||||
roombapy==1.6.2
|
||||
|
||||
# homeassistant.components.roon
|
||||
roonapi==0.0.30
|
||||
roonapi==0.0.31
|
||||
|
||||
# homeassistant.components.rova
|
||||
rova==0.1.0
|
||||
|
@ -966,7 +966,7 @@ rokuecp==0.6.0
|
||||
roombapy==1.6.2
|
||||
|
||||
# homeassistant.components.roon
|
||||
roonapi==0.0.30
|
||||
roonapi==0.0.31
|
||||
|
||||
# homeassistant.components.rpi_power
|
||||
rpi-bad-power==0.1.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user