Squeezebox API | |
-------------- | |
This document outlines the JSON RPC interface with a squeezeserver to control and obtain information about squeezeboxes. | |
JSON : JavaScript Object Notation | |
RPC : Remote Procedure Call | |
Uses POST requests sent to: | |
http://<squeezeserver_address>:9000/jsonrpc.js | |
With Content-Type header set to | |
application/json | |
And a JSON object in the body. | |
{'method': 'slim.request', 'params': [<player_mac_address>, <command>]} | |
where <player_mac_address> is the squeezebox's MAC address that you are controlling (or "-" to get server info). | |
and <command> is the command you want to send. | |
# Simple commands: | |
- PLAY: ["play"] | |
- PAUSE: ["pause"], | |
- POWER ON: ["power", "1"], | |
- POWER OFF: ["power", "0"], | |
- VOLUME UP: ["mixer","volume","+<i>"], # <i> is a base 10 number. (volume goes from 0-100) | |
- VOLUME DOWN: ["mixer","volume","-<i>"], | |
- SET VOLUME: ["mixer","volume","<i>"], | |
- SLEEP IN SECONDS: ["sleep","300"], | |
- SLEEP END OF SONG: ["jiveendoftracksleep"], | |
- SKIP: ["playlist","index","+1"], | |
- PREVIOUS: ["playlist","index","-1"], | |
- UNSYNC FROM ALL PLAYERS: ["sync","-"] | |
So to pause the squeezebox with mac address FF:FF:FF:FF you would send the JSON object: | |
{'method': 'slim.request', 'params': ["FF:FF:FF:FF", ["play"]]} | |
To get a player's status use the command: | |
STATUS: ["status","-"] | |
To SYNCHRONISE two players together: | |
'params': [<master>, ["sync",<slave>]] | |
where <master> and <slave> are the player MAC address strings. | |
The slave player will follow the master player. | |
To SWITCH PLAYER from one squeezebox to another. | |
'params': [<either>["switchplayer","from:" + <source>,"to:" + <destination>]] | |
where <source>, <destination> and <either> are the player MAC address strings. | |
The music will be sent from the source player to the destination player. | |
You can get the connected players with: | |
use get number of players first: | |
'params': ["FF:FF:FF:FF", ["player","count", "?"]] | |
Then using returned _count: | |
'params': ["FF:FF:FF:FF", ["players","0", <count>]] | |
You can search for music accroding to a search term by: | |
SEARCH: ["search", <i>, <j>, "term:" + <search_term>] | |
where <search_term> is the search term, | |
<i> is the beginning index, and <j> the finish index. ie. for the first 10 results: i=0, j=10. | |
Once you have obtained the "id" of the music you want to play, you can set it to play on a squeezebox: | |
- ["playlistcontrol", "cmd:"+<cmd>, "artist_id:"+<artist_id>] | |
- ["playlistcontrol", "cmd:"+<cmd>, "album_id:"+<album_id>] | |
- ["playlistcontrol", "cmd:"+<cmd>, "track_id:"+<track_id>] | |
where command is one of: | |
- PLAY NOW: "load" | |
- ADD TO END: "add" | |
- ADD NEXT: "insert" |
This comment has been minimized.
This comment has been minimized.
Does this work using this library or is it only by querying the server directly? |
This comment has been minimized.
This comment has been minimized.
Sorry for not replying. This is the Squeeze Server JSON RPC api. https://github.com/samtherussell/squeezebox-controller library interfaces with the Squeeze Server using this api, but so could any thing else if it so wished. |
This comment has been minimized.
This comment has been minimized.
Thanks for this. One fix for getting the list of players:
should be:
|
This comment has been minimized.
This comment has been minimized.
Done. Thanks for the suggestion |
This comment has been minimized.
This comment has been minimized.
If you are doing this from an IP address other than the server's, how do you get around the CORS issue? |
This comment has been minimized.
This comment has been minimized.
Sorry, I ran these requests from a python program not a webpage so I don't know. My intuition would be you'd have to disable CORS protection in the browser or make your webserver do the request not the client browser. |
This comment has been minimized.
This comment has been minimized.
Warnings here that I don't have much of a coding background. Running LMS on an RPi with the Chromecast add-in to play on my speakers. Do you know how to incorporate this into webCoRE? Below is a piston I'm trying to write to play a playlist, but I'd probably first need to start with a single file. Also, I'm having trouble using the commands to figure out the track or album IDs. |
This comment has been minimized.
This comment has been minimized.
Sorry I don't know and don't a have a system to test on at the moment but could image it would take the form:
|
This comment has been minimized.
Thanks, very helpful!