Moode Forum
Python code for detecting if Airplay is active - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: Python code for detecting if Airplay is active (/showthread.php?tid=3742)



Python code for detecting if Airplay is active - Max Schmeling - 04-26-2021

I have previously used the following python code for detecting if Airplay is active:

Code:
# Connect to player database, in order to read Airplay status     
try:
        con = SQLite3.connect('/var/local/www/db/moode-sqlite3.db')    
except SQLite3.Error as e:
        if Debug: print("Error %s:" % e.args[0])
        sys.exit(1)


# Airplay state check
def IsAirplayOn():
    
    global ButtonOverride
    
    AirplayOn = False
    try:
        cur = con.cursor()    
        cur.execute('select value from cfg_system where param=\'airplayactv\'')
        data = cur.fetchone()[0]    
        if (Debug): print("SQL = %s" % data)
        if data == "1":
            AirplayOn = True

    except SQLite3.Error as e:
        if (Debug): print("Error %s:" % e.args[0])

    if ButtonOverride:
        AirplayOn = False
    
    if Debug: print("Returning IsAirplayOn = {0}".format(AirplayOn))
    return AirplayOn


Is this still correct under Moode 7?