mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Improve repeat and shuffle support for Squeezebox (#70941)
This commit is contained in:
parent
573e966d74
commit
0264f060e4
@ -20,6 +20,9 @@ from homeassistant.components.media_player.const import (
|
||||
ATTR_MEDIA_ENQUEUE,
|
||||
MEDIA_TYPE_MUSIC,
|
||||
MEDIA_TYPE_PLAYLIST,
|
||||
REPEAT_MODE_ALL,
|
||||
REPEAT_MODE_OFF,
|
||||
REPEAT_MODE_ONE,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_INTEGRATION_DISCOVERY, ConfigEntry
|
||||
from homeassistant.const import (
|
||||
@ -231,6 +234,7 @@ class SqueezeBoxEntity(MediaPlayerEntity):
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.REPEAT_SET
|
||||
| MediaPlayerEntityFeature.SHUFFLE_SET
|
||||
| MediaPlayerEntityFeature.CLEAR_PLAYLIST
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
@ -373,10 +377,20 @@ class SqueezeBoxEntity(MediaPlayerEntity):
|
||||
"""Album of current playing media."""
|
||||
return self._player.album
|
||||
|
||||
@property
|
||||
def repeat(self):
|
||||
"""Repeat setting."""
|
||||
if self._player.repeat == "song":
|
||||
return REPEAT_MODE_ONE
|
||||
if self._player.repeat == "playlist":
|
||||
return REPEAT_MODE_ALL
|
||||
return REPEAT_MODE_OFF
|
||||
|
||||
@property
|
||||
def shuffle(self):
|
||||
"""Boolean if shuffle is enabled."""
|
||||
return self._player.shuffle
|
||||
# Squeezebox has a third shuffle mode (album) not recognized by Home Assistant
|
||||
return self._player.shuffle == "song"
|
||||
|
||||
@property
|
||||
def sync_group(self):
|
||||
@ -499,6 +513,17 @@ class SqueezeBoxEntity(MediaPlayerEntity):
|
||||
if index is not None:
|
||||
await self._player.async_index(index)
|
||||
|
||||
async def async_set_repeat(self, repeat):
|
||||
"""Set the repeat mode."""
|
||||
if repeat == REPEAT_MODE_ALL:
|
||||
repeat_mode = "playlist"
|
||||
elif repeat == REPEAT_MODE_ONE:
|
||||
repeat_mode = "song"
|
||||
else:
|
||||
repeat_mode = "none"
|
||||
|
||||
await self._player.async_set_repeat(repeat_mode)
|
||||
|
||||
async def async_set_shuffle(self, shuffle):
|
||||
"""Enable/disable shuffle mode."""
|
||||
shuffle_mode = "song" if shuffle else "none"
|
||||
|
Loading…
x
Reference in New Issue
Block a user