emit(‘next’) and emit(‘prev’) operations from the Volumio WebSocket_API :-
volumio.github.io/docs/API/WebSocket_APIs.html
work great when the Queue contains a list of media files or a Spotify playlist but do
nothing when the Queue contains a list of Webstreams (e.g. WebRadio stations).
Is this intended behaviour or a bug ? What is the best way to advance through a
Queue containing a list of Webstreams using the Volumio WebSocket_API.
Here’s the python scripts I’m currently running :-
import time
import RPi.GPIO as GPIO
from rotary_class_nobutton import RotaryEncoder
from socketIO_client import SocketIO, LoggingNamespace
HOSTNAME='localhost'
PORT=3000
socket = SocketIO(HOSTNAME, PORT, LoggingNamespace)
# Define GPIO inputs for "tuning" rotary encoder.
PIN_A = 14 # Pin 8
PIN_B = 15 # Pin 10
BUTTON = 4 # Pin 7
# Define GPIO inputs for "volume" rotary encoder.
VPIN_A = 23 # Pin 16
VPIN_B = 24 # Pin 18
VBUTTON = 22 # Pin 15
# Set debug level for print statements
DEBUG = 2 # 0 = no print statements, 1 = limited, 2 = full
# This is the event callback routine to handle events
def tswitch_event(event):
if event == RotaryEncoder.CLOCKWISE:
if (DEBUG): print "Tuning Clockwise"
socket.emit('next')
time.sleep(.1)
elif event == RotaryEncoder.ANTICLOCKWISE:
if (DEBUG): print "Tuning Anticlockwise"
socket.emit('prev')
time.sleep(.1)
return
def vswitch_event(event):
if event == RotaryEncoder.CLOCKWISE:
if (DEBUG): print "Volume Clockwise"
socket.emit('volume', '+')
time.sleep(.1)
elif event == RotaryEncoder.ANTICLOCKWISE:
if (DEBUG): print "Volume Anticlockwise"
socket.emit('volume', '-')
time.sleep(.1)
return
# Define the switches
tswitch = RotaryEncoder(PIN_A,PIN_B,tswitch_event)
vswitch = RotaryEncoder(VPIN_A,VPIN_B,vswitch_event)
while True:
time.sleep(1.0)