From 13cc7583ed5c7de43c56b43db8fdc9879a853666 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 27 Apr 2022 11:48:00 +0200 Subject: [PATCH] Support buffering in media_player reproduce state (#70859) --- homeassistant/components/media_player/reproduce_state.py | 8 +++++--- tests/components/media_player/test_reproduce_state.py | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/media_player/reproduce_state.py b/homeassistant/components/media_player/reproduce_state.py index 131366ed95b..586ac61b4e1 100644 --- a/homeassistant/components/media_player/reproduce_state.py +++ b/homeassistant/components/media_player/reproduce_state.py @@ -14,6 +14,7 @@ from homeassistant.const import ( SERVICE_TURN_ON, SERVICE_VOLUME_MUTE, SERVICE_VOLUME_SET, + STATE_BUFFERING, STATE_IDLE, STATE_OFF, STATE_ON, @@ -71,10 +72,11 @@ async def _async_reproduce_states( if ( state.state in ( - STATE_ON, - STATE_PLAYING, + STATE_BUFFERING, STATE_IDLE, + STATE_ON, STATE_PAUSED, + STATE_PLAYING, ) and features & MediaPlayerEntityFeature.TURN_ON ): @@ -122,7 +124,7 @@ async def _async_reproduce_states( if ( not already_playing - and state.state == STATE_PLAYING + and state.state in (STATE_BUFFERING, STATE_PLAYING) and features & MediaPlayerEntityFeature.PLAY ): await call_service(SERVICE_MEDIA_PLAY, []) diff --git a/tests/components/media_player/test_reproduce_state.py b/tests/components/media_player/test_reproduce_state.py index c2e454d1a04..f1a243337e1 100644 --- a/tests/components/media_player/test_reproduce_state.py +++ b/tests/components/media_player/test_reproduce_state.py @@ -26,6 +26,7 @@ from homeassistant.const import ( SERVICE_TURN_ON, SERVICE_VOLUME_MUTE, SERVICE_VOLUME_SET, + STATE_BUFFERING, STATE_IDLE, STATE_OFF, STATE_ON, @@ -45,6 +46,7 @@ ENTITY_2 = "media_player.test2" [ (SERVICE_TURN_ON, STATE_ON, MediaPlayerEntityFeature.TURN_ON), (SERVICE_TURN_OFF, STATE_OFF, MediaPlayerEntityFeature.TURN_OFF), + (SERVICE_MEDIA_PLAY, STATE_BUFFERING, MediaPlayerEntityFeature.PLAY), (SERVICE_MEDIA_PLAY, STATE_PLAYING, MediaPlayerEntityFeature.PLAY), (SERVICE_MEDIA_STOP, STATE_IDLE, MediaPlayerEntityFeature.STOP), (SERVICE_MEDIA_PAUSE, STATE_PAUSED, MediaPlayerEntityFeature.PAUSE),