Ejemplo n.º 1
0
def loadRadioStations():
    try:
        client.clear()
        client.load("[Radio Streams]")
        mediaVariables.loadedPlaylist = "[Radio Streams]"
    except:
        print("Error loading radio station playlist!")
        establishConnection()
Ejemplo n.º 2
0
def playRadioStation(stationid):
    print("Playing ID", stationid)
    try:
        client.play(stationid)
    except:
        print("Error playing the station!")
        establishConnection()
    globalParameters.setScreen(0)
Ejemplo n.º 3
0
def loadPlaylist(name):
    try:
        client.clear()
        client.load(name)
        client.shuffle()
        mediaVariables.loadedPlaylist = name
        print("Loaded and playing Playlist", name)
        client.play()
    except:
        print("Error loading and playing Playlist", name)
        establishConnection()
Ejemplo n.º 4
0
def playbackControl(command):
    try:
        if command == "pause": client.pause()
        elif command == "previous": client.previous()
        elif command == "next": client.next()
        elif command == "play": client.play()
        print("Playback:", command)
    except:
        print("Error changing the playback mode!")
        establishConnection()
    globalParameters.setScreen(0)
Ejemplo n.º 5
0
def update(stopEvent):
    global text_name, text_position, text_print, text_position
    global playbackState, playingInfo, text_name

    while not stopEvent.is_set():
        if mediaVariables.loadedPlaylist != "[AirPlay]":
            #Current playback state
            try:
                playbackInfo = helperFunctions.client.status()
                playbackState = playbackInfo["state"]
            except:
                #connection lost -> restart
                playbackInfo = {'state': 'play'}
                establishConnection()

            #Currently playing song name
            try:
                playingInfo = helperFunctions.client.currentsong()
            except:
                #connection lost -> restart
                playingInfo = {'title': 'Could not load name!'}
                establishConnection()
            if playingInfo != {}:
                currentSong = playingInfo["title"]
                if currentSong != text_name:
                    text_name = currentSong
                    text_position = 0
        else:
            #Get Airplay Info
            info = mediaVariables.airplayinfo
            if 'songartist' in info and 'itemname' in info:
                text_name = info['songartist'] + " - " + info['itemname']
            elif 'itemname' in info:
                text_name = info['itemname']
            else:
                text_name = "AirPlay Streaming"

        stopEvent.wait(20)