def listen(): while True: aFile = playQ.get() if util.isInRoot(aFile): ServerStatus.send(util.nameToTitle(aFile), event='playing') playerCmd = __getPlayerCommand(aFile) cmdTable = commandTable[playerCmd[0]] playFile(playerCmd, aFile, cmdTable)
def listen(): while True: aFile = playQ.get() if util.isInRoot(aFile): ServerStatus.send(util.nameToTitle(aFile), event='playing') playerCmd = __getPlayerCommand(aFile) cmdTable = commandTable[playerCmd[0]] playFile(playerCmd, aFile, cmdTable) elif(aFile.startswith("http")): ServerStatus.send(aFile, event='playing') playerCmd = playerTable.get("youtube", defaultPlayer) cmdTable = commandTable[playerCmd[0]] playFile(playerCmd, aFile, cmdTable)
def playFile(playerCmd, fileName, cmdTable): __clearQueue(commandQueue) activePlayer = Popen(playerCmd + [fileName], stdin=PIPE) while activePlayer.poll() == None: try: res = commandQueue.get(timeout=1) activePlayer.stdin.write(cmdTable[res]) if unicode(res) == unicode("stop"): ServerStatus.send(util.nameToTitle(fileName), event="stopped") __clearQueue(playQ) activePlayer.terminate() return False except: None ServerStatus.send(util.nameToTitle(fileName), event="finished") return True