Ejemplo n.º 1
0
        def load_and_play():
            self._play_lock.acquire()

            # stop anything that is currently playing
            _pandora.stop()

            self.length = _pandora.play(self.load(block=True), self.gain)
            logging.info("playing %s" % self)
            self.publish_message("playing %s" % self)

            finished_naturally = False
            preloading_next = False
            while True:
                stats = _pandora.stats()
                if stats:
                    total, pos = stats
                    self.progress = pos

                    if pos + self.station.PRELOAD_OFFSET >= total and not preloading_next:
                        preloading_next = True
                        self.station.preload_next()

                    if pos == total:
                        self.done = True
                        finished_naturally = True
                        break

                try:
                    self._stop_playing.get(block=True, timeout=.25)
                    logging.debug(
                        "got a stop signal for %s, breaking out of play loop" %
                        self)
                    break
                except eventlet.queue.Empty, e:
                    pass
Ejemplo n.º 2
0
 def load_and_play():
     self.length = _pandora.play(self._download())
     self.publish_message("playing %s" % self)
     
     while True:            
         stats = _pandora.stats()
         if stats:
             total, pos = stats
             if pos == total and account.current_station: break
                 
         time.sleep(1)
     self.publish_message("finished playing %s" % self)
Ejemplo n.º 3
0
        def load_and_play():
            self._play_lock.acquire()

            # stop anything that is currently playing
            _pandora.stop()

            self.length = _pandora.play(self.load(block=True), self.gain)            
            logging.info("playing %s" % self)
            self.publish_message("playing %s" % self)

            finished_naturally = False
            preloading_next = False
            while True:            
                _pandora.update()
                stats = _pandora.stats()
                if stats:
                    total, pos = stats
                    self.progress = pos

                    if pos + self.station.PRELOAD_OFFSET >= total and not preloading_next:
                        preloading_next = True
                        self.station.preload_next()

                    if pos == total:
                        self.done = True
                        finished_naturally = True
                        break

                try:
                    self._stop_playing.get(block=True, timeout=.25)
                    logging.debug("got a stop signal for %s, breaking out of play loop" % self)
                    break
                except eventlet.queue.Empty, e: pass

            logging.info("finished playing %s" % self)
            self.publish_message("finished playing %s" % self)
            self._play_lock.release()
            if finished_naturally and callable(finished_cb):
                # call the callback
                logging.debug("calling callback %r" % finished_cb)
                eventlet.spawn_n(finished_cb, self.station.account, self.station, self)