Files

41 lines
929 B
Python

from socketIO_client import SocketIO, LoggingNamespace
import threading
import time
is_playing = False # for toggling play/pause (stores the current status from the pushState events)
socketIO = SocketIO('localhost', 3000)
def play_callback(channel):
global is_playing
if is_playing:
logging.info("PAUSE")
socketIO.emit('pause')
else:
logging.info("PLAY")
socketIO.emit('play')
def events_thread():
socketIO.wait()
try:
socketIO.on('pushState', on_pushState)
socketIO.emit('replaceAndPlay', {'service':'mpd','uri':'mnt/INTERNAL/qudio/sounds/armstrong.mp3'})
time.sleep(3.5)
t1 = threading.Thread(target=play_callback)
t1.start()
t1.join()
time.sleep(3)
t1 = threading.Thread(target=play_callback)
t1.start()
t1.join()
# Exit when Ctrl-C is pressed
except KeyboardInterrupt:
logging.info('Shutdown')