Example #1
0
 def play(self):
     while True:
         self.nextPlayer = self.playQueue.get()
         # A None object indicate that the thread should be stopped
         if not self.nextPlayer:
             break
         imgService.begin(LOADING)
         self.nextPlayer.init()
         logging.info("### Prepare %s", self.nextPlayer.video.title)
         logging.info("Let's download!")
         with downloadLock:
             if self.stopped:
                 break
             self.nextPlayer.download(downloadLock)
         logging.info("Let's play!")
         with playLock:
             if self.stopped:
                 break
             logging.info("### Play %s", self.nextPlayer.video.title)
             self.currentPlayer = self.nextPlayer
             self.nextPlayer = None
             self.currentPlayer.play(playLock)
             db_writeHistory(self.currentPlayer.video)
         if self.currentPlayer.video.nextVideo:
             logging.info("### Parse nextVideo")
             self.parse(self.currentPlayer.video.nextVideo, self.currentPlayer.video.currentFormat)
         else:
             self.playQueue.put(None)
     logging.info("End the play thread")
Example #2
0
 def play_thread(self, lock):
     with lock:
         logging.info("Got lock and play now")
         self.player.play()
         interval = 0
         while self.player.isalive():
             time.sleep(1)
             interval += 1
             self.video.progress = self.from_position + self.getPosition()
             if not imgService.stop and self.video.progress > 0:
                 imgService.end()
             if interval % 10 == 0:
                 db_writeHistory(self.video)
         if imgService.stop:
             imgService.begin(FINISHED)