From 6166140c1216ca14c2fa59e15e0f96530bcfbeec Mon Sep 17 00:00:00 2001 From: ABelliqueux Date: Wed, 20 Mar 2024 11:48:35 +0100 Subject: [PATCH] Fix send_mpd_cmd --- mpdlisten.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mpdlisten.py b/mpdlisten.py index 58445b0..0c69575 100644 --- a/mpdlisten.py +++ b/mpdlisten.py @@ -191,6 +191,7 @@ def update_display(device, currentsong, status): def send_mpd_cmd(client, cmd:str): + idle_states = ['stop', 'pause'] if cmd == 'menu': global current_mode current_mode_index = MODES_ORDER.index(current_mode) @@ -203,11 +204,16 @@ def send_mpd_cmd(client, cmd:str): global static_ui static_ui = generate_static_ui(current_mode) if cmd == 'prev': - client.previous() + if client.status()['state'] != 'stop': + client.previous() elif cmd == 'next': - client.next() + if client.status()['state'] != 'stop': + client.next() elif cmd == 'toggle': - client.pause() + if client.status()['state'] in idle_states: + client.play() + else: + client.pause() elif cmd == 'stop': client.stop() else: