Can't play a stream with python and websocket.io

Hi,
I use the websocket with python to control volumio.
Changing volume and other simple things work fine like that:

socket.emit(‘next’)
socket.emit(‘volume’, ‘+’)

But I can’t play a webradiostream. I tried something like that:

socket.emit(‘addToQueue’, {‘uri’:“http://radioeins.de/livemp3”})

Is the syntax wrong?

Thank you
Nansen

It might be that you need to send the service in the payload aswell as the uri.

I tried a lot (or all), but nothing worked. Any idea?

I havent really used python, but lets see, based on this site → Python JSON

it could be →

import json

obj = {
  "uri": "http://radioeins.de/livemp3",
  "service": "webradio",
  "albumart": "/albumart"
}

payload = json.dumps(obj)

socket.emit("addToQueue", payload)

Im not 100% sure if the albumart is necessary information to add for the payload.

Hi and thank you,

but it doesn’t work. I tried it without albumart too.
Now I solved the problem with mpd instead websocket:

import mpd

client = mpd.MPDClient()
client.timeout = 10
client.idletimeout = None
client.connect(“192.168.2.22”, 6600)
url = “http://radioeins.de/livemp3
client.addid(url, 1)
client.play(1)

It is necessary, to control volume etc with websocket and the queue with mpd. Not good, but I have no better idea.

Hi again,
I found a better solution:

This solved all my problems an give more than an example.