mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Refactor forked_daapd to use _async_announce (#78446)
This commit is contained in:
parent
5cccb24830
commit
13c7a7bbcc
@ -668,6 +668,11 @@ class ForkedDaapdMaster(MediaPlayerEntity):
|
||||
if media_type == MediaType.MUSIC:
|
||||
media_id = async_process_play_media_url(self.hass, media_id)
|
||||
|
||||
await self._async_announce(media_id)
|
||||
else:
|
||||
_LOGGER.debug("Media type '%s' not supported", media_type)
|
||||
|
||||
async def _async_announce(self, media_id: str):
|
||||
saved_state = self.state # save play state
|
||||
saved_mute = self.is_volume_muted
|
||||
sleep_future = asyncio.create_task(
|
||||
@ -677,9 +682,7 @@ class ForkedDaapdMaster(MediaPlayerEntity):
|
||||
await self._save_and_set_tts_volumes()
|
||||
# save position
|
||||
saved_song_position = self._player["item_progress_ms"]
|
||||
saved_queue = (
|
||||
self._queue if self._queue["count"] > 0 else None
|
||||
) # stash queue
|
||||
saved_queue = self._queue if self._queue["count"] > 0 else None # stash queue
|
||||
if saved_queue:
|
||||
saved_queue_position = next(
|
||||
i
|
||||
@ -690,9 +693,7 @@ class ForkedDaapdMaster(MediaPlayerEntity):
|
||||
await sleep_future
|
||||
await self._api.add_to_queue(uris=media_id, playback="start", clear=True)
|
||||
try:
|
||||
await asyncio.wait_for(
|
||||
self._tts_playing_event.wait(), timeout=TTS_TIMEOUT
|
||||
)
|
||||
await asyncio.wait_for(self._tts_playing_event.wait(), timeout=TTS_TIMEOUT)
|
||||
# we have started TTS, now wait for completion
|
||||
await asyncio.sleep(
|
||||
self._queue["items"][0]["length_ms"]
|
||||
@ -729,8 +730,6 @@ class ForkedDaapdMaster(MediaPlayerEntity):
|
||||
await self.async_media_pause()
|
||||
elif saved_state != MediaPlayerState.PLAYING:
|
||||
await self.async_media_stop()
|
||||
else:
|
||||
_LOGGER.debug("Media type '%s' not supported", media_type)
|
||||
|
||||
async def async_select_source(self, source: str) -> None:
|
||||
"""Change source.
|
||||
|
Loading…
x
Reference in New Issue
Block a user