http get/post commands for quick mpd play/pause toggle?

Suggestions/requests/ideas for RuneAudio core features and functions

http get/post commands for quick mpd play/pause toggle?

Postby waves » 16 Jan 2015, 14:19

Sometimes a user may want to toggle play/pause as quickly as possible. With a smartphone it takes some time to load RA in the browser and then click the play button. I request something quicker. The android app Tasker can silently send http get or post commands at the click of a shortcut. And chrome for android can save a shortcut to a specific website adress.

Is there already some post/get command or url parameter I can pass to RA to in one step quickly toggle play/pause without waiting for and interacting with the GUI? For example 192.168.0.5/toggle

If not then I request that feature.

There are ways to do this with other tools (buy JuiceSSH tasker plugin and set tasker to silently SSH in and send "mpc toggle" on a shortcut click). But I think such a quick toggle feature would be useful to have built into RA.
waves
 
Posts: 125
Joined: 31 Dec 2014, 10:33

Re: http get/post commands for quick mpd play/pause toggle?

Postby skrodahl » 16 Jan 2015, 16:27

There's another thread in the forum discussing just this:
control-rune-from-android-without-webui-t434.html

The MPD playback commands can be found here:
http://www.musicpd.org/doc/protocol/pla ... mands.html

Using this information would give you the following URLs for pause and play:
PAUSE: http://runeaudio.local/command/?cmd=pause%201
PLAY: http://runeaudio.local/command/?cmd=pause%200

The %20 at the end is a whitespace, the command is <pause {option}>", where <option> is 0 or 1. The string "pause 1" in an URL would then be "pause%201".

Hope this helps.
-skrodahl

Muffsy Phono Preamp PP-3 || Audiobah TPA3116 || ESP P88 || ProJect Debut Carbon Espirit DC || RuneAudio / RaspBerry Pi / HifiBerry DAC || Dynaco A25
User avatar
skrodahl
Moderator
 
Posts: 160
Joined: 27 Jan 2014, 10:08
Location: Sweden

Re: http get/post commands for quick mpd play/pause toggle?

Postby waves » 17 Jan 2015, 01:56

That helps.

Note to anyone else looking to do the same thing through Tasker in Android: the mpd pause command requires an alternating parameter (i.e. "pause 1" or "pause 0" to set pause on or off) so to toggle pause with one shortcut we need to make a Tasker task with several actions:
- http get 192.168.101.4/command/?cmd=status
- split the returned variable %HTTPD (use "state:" and "song:" as splitters)
- http get 192.168.101.4/command/?cmd=pause 1 if the split result matches *play* , else pause 0
waves
 
Posts: 125
Joined: 31 Dec 2014, 10:33

Re: http get/post commands for quick mpd play/pause toggle?

Postby skrodahl » 18 Jan 2015, 14:29

The MPD docs say that using the pause command without an option is depreciated. I found that it works without the option though, it might make your tasker commands easier.

Although... If the playback is stopped, the pause command does nothing at all. You might want to do a check for that state as well, and send the play command.
-skrodahl

Muffsy Phono Preamp PP-3 || Audiobah TPA3116 || ESP P88 || ProJect Debut Carbon Espirit DC || RuneAudio / RaspBerry Pi / HifiBerry DAC || Dynaco A25
User avatar
skrodahl
Moderator
 
Posts: 160
Joined: 27 Jan 2014, 10:08
Location: Sweden

Re: http get/post commands for quick mpd play/pause toggle?

Postby ACX » 18 Jan 2015, 17:37

In the future API we are designing we'll probably add a custom "playpause" command that it's smart enough to detect the state itself and perform consequently, without having to worry from the client side.
User avatar
ACX
RuneAudio co-founder
 
Posts: 1689
Joined: 29 Nov 2013, 02:25
Location: Udine, Italy

Re: http get/post commands for quick mpd play/pause toggle?

Postby waves » 19 Jan 2015, 14:56

skrodahl wrote:Although... If the playback is stopped, the pause command does nothing at all. You might want to do a check for that state as well, and send the play command.

Yes, changed to this behaviour in the last steps instead:
- http get 192.168.101.4/command/?cmd=pause 1 if the split result matches *play* , else cmd=play
That triggers play from either stopped or paused states.

Edit: I ran into an issue when RuneAudio froze (manual reboot needed) and I think the cause was when a live stream was paused for a long time with this method. To fix that I added a one more condition to Tasker. It now first gets the current song ( ?cmd=currentsong ). If the current song is a stream do cmd=stop command, if music file do cmd=pause 1 . Seems to work all right now.
waves
 
Posts: 125
Joined: 31 Dec 2014, 10:33

Re: http get/post commands for quick mpd play/pause toggle?

Postby antipiot » 02 Mar 2017, 10:17

Hello mates,

New user of mpd, and http commands, I followed this thread to get a current playlist being played or paused, but I wanted something else and couldn't find anything in the mpd documetation, google or I don't know how to write the comment:-/

I wanted to get a playlist "calme" being played with an http command.

May you please help me? Thanks in advance!
antipiot
 
Posts: 3
Joined: 02 Mar 2017, 10:09

Re: http get/post commands for quick mpd play/pause toggle?

Postby waves » 04 Mar 2017, 02:13

antipiot wrote:I wanted to get a playlist "calme" being played with an http command.

I don't think you can do that. But you can ssh connect to the Rune device and start the playlist on the command line with mpc.
waves
 
Posts: 125
Joined: 31 Dec 2014, 10:33

Re: http get/post commands for quick mpd play/pause toggle?

Postby hondagx35 » 04 Mar 2017, 02:28

Hi antipiot, hi waves,

I don't think you can do that.


Code: Select all
http://192.168.0.24/command/?cmd=load calme
http://192.168.0.24/command/?cmd=play

Should work.

Frank
User avatar
hondagx35
 
Posts: 3041
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: http get/post commands for quick mpd play/pause toggle?

Postby antipiot » 05 Mar 2017, 10:01

hondagx35 wrote:Hi antipiot, hi waves,

I don't think you can do that.


Code: Select all
http://192.168.0.24/command/?cmd=load calme
http://192.168.0.24/command/?cmd=play

Should work.

Frank


Hey, mate!

Thanks for your answer!

In the meantime, i've found how to get it working:
at first i wanted to have a single http command for more than one action like:
Clear, load, play.

Got it working by finding a way to send 3 http command with a single input.

I've made a little youtube video about controlling playlist from domoticz if anybody is interested: https://www.youtube.com/watch?v=ltjz_gaWNjk
https://www.youtube.com/watch?v=ltjz_gaWNjk
antipiot
 
Posts: 3
Joined: 02 Mar 2017, 10:09

support RuneAudio Donate with PayPal

Next

Return to Feature request

Who is online

Users browsing this forum: No registered users and 0 guests