Hi again,
try just the soco code on its own and get that working then you can integrate it to a GUI.
The render event will give you volume and the AV event what's playing. If a player is a slave then there is an AV event changing it to say the CurrentURI = 'x-rincon:RINCON_000E5832xxxxx1400' where this is the UID of the master (coordinator). After that you don't get any AV events. So you can subscribe and unsubscribe to these but I am not sure its necessary.
The code below is a demo (tested in Python 3) that subscribes to AV and Render for all Sonos players.
At present it just prints it has got an event but obviously you could change that to process the event.
Not perfect Python but demos what I think you want!
from __future__ import print_function
try:
import queue as queue
except: # Py2.7
import Queue as queue
import soco
from soco.events import event_listener
import queue
from pprint import pprint
# create a list to hold all subscriptions
sub_list = []
# get all sonos devices
devices = soco.discover()
for device in devices:
# subscribe to both av and render events for each sonos device
sub_list.append(device.avTransport.subscribe())
sub_list.append(device.renderingControl.subscribe())
keep_running = True
while keep_running:
for sub in sub_list:
try:
event = sub.events.get(timeout=0.1)
print('event_type: {:20} from: {}'.format(
event.service.service_type,
event.service.soco.player_name))
# pprint(event.variables)
except queue.Empty:
pass
except KeyboardInterrupt:
keep_running = False
for sub in sub_list:
sub.unsubscribe()
event_listener.stop()
Try this and see if it does what you want. If not post your soco code so I can look at it.
As far as the GUI is concerned I have not used PyQT, so can't help much there.
I do know that most GUIs have a loop that has to run for the GUI to respond - that means you need to find a way to have the soco read events loop running as well.
This therefore gets more complex, and it typically done using threads. So you could run your listen to sonos events in a thread and feed actions to your GUI via a queue.
If your not familiar with threads read up about them as they can be great, but also can get you into a lot of trouble!
It may be that PyQT helps with this - can anyone else comment on PyQT?
Hope this all helps
Shout if you need more help
Cheers David