Support VLC 4 pause (#77302)

* Support VLC 4 pause

* Clean vlc tests types
This commit is contained in:
Martin Hjelmare 2022-09-26 16:17:39 +02:00 committed by GitHub
parent fc62ba58a6
commit 2a94c42cea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -260,7 +260,12 @@ class VlcDevice(MediaPlayerEntity):
@catch_vlc_errors
async def async_media_play(self) -> None:
"""Send play command."""
await self._vlc.play()
status = await self._vlc.status()
if status.state == "paused":
# If already paused, play by toggling pause.
await self._vlc.pause()
else:
await self._vlc.play()
self._attr_state = MediaPlayerState.PLAYING
@catch_vlc_errors
@ -268,8 +273,7 @@ class VlcDevice(MediaPlayerEntity):
"""Send pause command."""
status = await self._vlc.status()
if status.state != "paused":
# Make sure we're not already paused since VLCTelnet.pause() toggles
# pause.
# Make sure we're not already paused as pausing again will unpause.
await self._vlc.pause()
self._attr_state = MediaPlayerState.PAUSED

View File

@ -15,8 +15,6 @@ from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
# mypy: allow-untyped-calls
@pytest.mark.parametrize(
"input_data, entry_data",
@ -139,7 +137,7 @@ async def test_errors(
async def test_reauth_flow(hass: HomeAssistant) -> None:
"""Test successful reauth flow."""
entry_data = {
entry_data: dict[str, Any] = {
"password": "old-password",
"host": "1.1.1.1",
"port": 8888,