Hi,
I created a small widgetto control my Squeezeboxes around the house and thought it might be of interest to others too. It offers most of the player controls that are available (play/pause, power, repeat mode, volume control). In addition it show progress of current song and queries the server for the track length (which isn’t available through the binding), this also shows a method to fetch basically all the data that the server has via a json rpc api. I know it isn’t very good code, but I’m not a good coder, and the thing works It’s made for a 1920x1080 screen and doesn’t scale down very nicely. Maybe someone might like to develop it further?
SqueezeboxController.widget.json (8.6 KB)
Rule for track duration:
rule "BedroomPlayerData"
when
Item SqueezeLiteBedroom_Title changed
then
logInfo("Squeezebox", "Title change")
val myURL = 'http://x.x.x.x:9000/jsonrpc.js'
val payload = '{"id":1,"method":"slim.request","params":["00:00:00:00:00:01",["duration","?"]]}'
val String json = sendHttpPostRequest(myURL, "application/json", payload)
SqueezeLiteBedroom_CurrentTrackLength.postUpdate(Float.valueOf(transform("JSONPATH", "$.result._duration", json)))
logInfo("Squeezebox", "Track length: " + SqueezeLiteBedroom_CurrentTrackLength.state + " seconds.")
end
replace x.x.x.x with the ip of your server and 00:00:00:00:00:01 with the mac address of your squeezebox. It sometimes takes a few seconds for the new track length to come through.