I’m trying to add a web stream to the queue and play it using the “addPlay” websocket command.
The reason behind is that I want to control volumio with my Logitech Harmony remote, where I have several buttons for different web radio stations.
So I want it to append the radio station to the queue and play it.
I’m having trouble getting it to work in python. It seems like it is not even reaching the server:
payload = json.dumps({"uri": "http://mp3stream1.apasf.apa.at:8000", "title": "FM4"}, ensure_ascii = False).encode('utf8')
with SocketIO(HOST_NAME_VOLUMIO, 3000, LoggingNamespace) as socketIO:
socketIO.emit('addPlay', payload)
I’m using the socketIO-client from here: pypi.python.org/pypi/socketIO-client
I assume that it either has something to do with the JSON parameter or the fact that the "with … " part kills the connection too early. Since I’m not interested in a response I don’t need to listen to state changes.
From NodeJS something similar works:
var io=require('socket.io-client');
var socket= io.connect('HOST_NAME_VOLUMIO:3000');
socket.emit('addPlay', {'service':'webradio','title':'FM4','uri':'http://mp3stream1.apasf.apa.at:8000'});
Anyone have an idea?
There is kind of a mess of possible socketIO clients because there are several with the same name. So, I used the one mentioned above in version 0.7.0 (latest).
with SocketIO(HOST_NAME_VOLUMIO, 3000, LoggingNamespace) as socketIO:
socketIO.emit(command, argument)[/code]
you can append a webradio track and play it (with some caveats).
Note that argument is not a JSON string but directly a JSON structure. Yes, apparently that’s a thing in python.
The caveats are that there are some bugs surrounding the queue management which leaves the UI at inconsistent state or does not react if the same stream is readded to restart it. I will create some bug reports for that.