コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
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)
コード例 #4
0
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)
コード例 #5
0
ファイル: player.py プロジェクト: mvonmaltitz/web-mote
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)
コード例 #6
0
ファイル: main.py プロジェクト: Inaimathi/web-mote
 def post(self):
     t = self.get_argument('target')
     player.commandQueue.put('stop')
     if os.path.isfile(t):
         fileList = [t]
     elif os.path.isdir(t):
         fileList = util.deepListDir(t)
     else:
         fileList = json.loads(t)
     if self.get_argument('shuffle', False):
         random.shuffle(fileList)
     time.sleep(.5)
     ServerStatus.write_message_to_all(json.dumps(fileList), event="new-queue")
     self.write("Ok")
     ServerStatus.newList([util.nameToTitle(f) for f in fileList])
     [player.playQ.put(f) for f in fileList]
コード例 #7
0
 def post(self):
     t = self.get_argument('target')
     player.commandQueue.put('stop')
     if os.path.isfile(t):
         fileList = [t]
     elif os.path.isdir(t):
         fileList = util.deepListDir(t)
     else:
         fileList = json.loads(t)
     if self.get_argument('shuffle', False):
         random.shuffle(fileList)
     time.sleep(.5)
     ServerStatus.write_message_to_all(json.dumps(fileList),
                                       event="new-queue")
     self.write("Ok")
     ServerStatus.newList([util.nameToTitle(f) for f in fileList])
     [player.playQ.put(f) for f in fileList]