From b71649876ae3461daf7d4a7d7833b279385983dc Mon Sep 17 00:00:00 2001 From: albaintor <118518828+albaintor@users.noreply.github.com> Date: Fri, 7 Jun 2024 20:27:08 +0200 Subject: [PATCH] Better play/pause command not relied on playback state which may be uncorrect) --- intg-kodi/kodi.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/intg-kodi/kodi.py b/intg-kodi/kodi.py index 6177835..82ce206 100644 --- a/intg-kodi/kodi.py +++ b/intg-kodi/kodi.py @@ -673,10 +673,15 @@ async def async_media_pause(self): @cmd_wrapper async def play_pause(self): """Send toggle-play-pause command to Kodi""" - if self._paused: - await self.async_media_play() - else: - await self.async_media_pause() + try: + players = await self._kodi.get_players() + player_id = players[0]["playerid"] + await self._kodi.call_method("Player.PlayPause", **{"playerid": player_id}) + except Exception: + if self._paused: + await self.async_media_play() + else: + await self.async_media_pause() @cmd_wrapper async def stop(self):