Thank you for your donation!


Direct link to radiostation
#11
Not wishing to add a new work item to Tim's inexhaustible ToDo list [1], here's another client-side hint.

The MPD command protocol includes a command_list_begin/command_list_end construction. To quote from the protocol specification


Quote:To facilitate faster adding of files etc. you can pass a list of commands all at once using a command list. The command list begins with command_list_begin or command_list_ok_begin and ends with command_list_end.

It does not execute any commands until the list has ended. The response is a concatenation of all individual responses. On success for all commands, OK is returned. If a command fails, no more commands are executed and the appropriate ACK error is returned. If command_list_ok_begin is used, list_OK is returned for each successful command executed in the command list.



Based on that, here's a URL-encoded HTTP GET request for the moOde player hostname "moode" which when entered in my browser clears the player queue, loads the "Favorites" playlist into the queue, and starts playing the first playlist entry [2] in one fell swoop. Please note that this request is entered as a single line despite how it may be displayed when you read this post.

Code:
http://moode/command/?cmd=command_list_begin%0D%0Aclear%0D%0Aload%20Favorites%0D%0Aplay%200%0D%0Acommand_list_end

The string "%0D%0A" is the URL-encoding for CRLF, %20 is the URL-encoding for ASCII space, so this GET request is the equivalent of

Code:
command_list_begin
clear
load Favorites
play 0
command_list_end

There's no fancy error handling here (e.g., the ACK error messages spoken of in the quote are ignored). 

The first command stops whatever is playing and clears the queue. If the named playlist doesn't exist, that's the end of the story. If the playlist exists, it's loaded. Then, if the specified playlist entry doesn't exist the player remains stopped.

Obviously @DRONE7's proposal can be effected using this same command_list construction.

Regards,
Kent

[1] adding a new endpoint to the API entails a fair amount of work which has to be planned, documented, executed, and tested. Defining the requirements is key. Feature creep is like kudzu and must be guarded against.

[2] I forgot in my post yesterday that playlists begin at entry 0 not 1. Classic programmer mistake.
Reply
#12
(01-08-2020, 05:56 AM)smolesen Wrote:
(01-06-2020, 01:31 PM)Tim Curtis Wrote: MPD commands can be sent via

Code:
http://moode/command?cmd=

Example:

http://moode/command?cmd=stop

Volume commands via

Code:
http://moode/command?cmd=vol.sh

pi@rp3:~ $ /var/www/vol.sh --help
Usage: vol.sh [OPTION] [VOLUME]
Change the volume and update the knob.

With no OPTION or VOLUME, print the current volume.
With just VOLUME, set current volume to VOLUME.

 -up            VOLUME  value between 1 and 100
 -dn            VOLUME  value between 1 and 100
 -mute          mute or unmute the volume
 -restore       set volume to current knob level
 --version      print the program version
 --help         print this help text

Examples:

http://moode/command?cmd=vol.sh -up 1
http://moode/command?cmd=vol.sh -dn 1
http://moode/command?cmd=vol.sh 15
http://moode/command?cmd=vol.sh -mute

Yes, it's something like that I'm looking for, something in the line of:

http://mymoode/command?cmd=playradio -station 'somefolder/somestation.pls'

can that be done?

/Søren

Probably, but there would need to be more demand for such a feature. Keep in mind that features that make it to the TODO list compete with one another for developer time and they compete with bug fixes and updates.

-Tim
Reply
#13
Thanks @TheOldPresbyope  for the enlightenment !

Yes, works fine....

Code:
http://<moode-ip-address>/command/?cmd=command_list_begin%0D%0Aclear%0D%0Aadd%20http://relay3.slayradio.org:8000/%0D%0Aplay%200%0D%0Acommand_list_end


@smolesen    could that be an answer for your 'direct link' ?
Reply
#14
(01-08-2020, 10:07 PM)DRONE7 Wrote: Thanks @TheOldPresbyope  for the enlightenment !

Yes, works fine....

Code:
http://<moode-ip-address>/command/?cmd=command_list_begin%0D%0Aclear%0D%0Aadd%20http://relay3.slayradio.org:8000/%0D%0Aplay%200%0D%0Acommand_list_end


@smolesen    could that be an answer for your 'direct link' ?
Should be trivial to add an option 'save shortcut' to generate a Windows style shortcut file along with the add to playlist options.  Or generate the url for copying and pasting.
Pi 3B + Allo MiniBoss DAC / Pro-ject Elemental / Marantz CD6004 / Marantz PM6004 / Monitor Audio Bronze 2
Reply
#15
(01-08-2020, 10:07 PM)DRONE7 Wrote: Thanks @TheOldPresbyope  for the enlightenment !

Yes, works fine....

Code:
http://<moode-ip-address>/command/?cmd=command_list_begin%0D%0Aclear%0D%0Aadd%20http://relay3.slayradio.org:8000/%0D%0Aplay%200%0D%0Acommand_list_end


@smolesen    could that be an answer for your 'direct link' ?

Yes, that would definitely work for me. sorry if I didn't explain properly what I was looking for in the first place...

Thanks for all the help...

/Søren
Reply
#16
@duracell80

I think you misunderstand the point of my post.

I was merely showing how a comparable effect could be achieved with no change to moOde.

Your focus on making moOde a radio player sui generis is admirable and I'm following the work closely, but look how much time you've put into it already. That's what happens to Tim every time someone throws a demand for a new capability over the fence. 

We know that almost anything can be done in software if one puts one's mind to it, but "design, implement, test, support" is a demanding work cycle.

I stand by my solution as an easy win.

Regards,
Kent
Reply


Forum Jump: