From e85f8db53e5970bae7d1cfb3301c0e90584d4c5a Mon Sep 17 00:00:00 2001 From: Anton Maminov Date: Tue, 1 Oct 2024 17:05:10 +0300 Subject: [PATCH] pause with state --- src/crystal_mpd/client.cr | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/crystal_mpd/client.cr b/src/crystal_mpd/client.cr index 140bc1b..da8f9e8 100644 --- a/src/crystal_mpd/client.cr +++ b/src/crystal_mpd/client.cr @@ -655,10 +655,17 @@ module MPD end end - # Toggles pause/resumes playing. - def pause + # Pause or resume playback. + # Pass `state` `true` to pause playback or `false` to resume playback. + # Without the parameter, the pause state is toggled. + def pause(state : Bool? = nil) synchronize do - write_command("pause") + if state + write_command("pause", boolean(state)) + else + write_command("pause") + end + execute("fetch_nothing") end end