Can't play a stream with python and

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

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

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

socket.emit(‘addToQueue’, {‘uri’:“”})

Is the syntax wrong?

Thank you

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": "",
  "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(“”, 6600)
url = “
client.addid(url, 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.