Exemplo 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
Exemplo n.º 2
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)
Exemplo n.º 3
0
 def dislike(self, **kwargs):
     _pandora.stop()
     logging.info("disliking %s" % self)
     self.publish_message("disliking %s" % self)
     self._add_feedback(like=False)
     return self.station.next(**kwargs)
Exemplo n.º 4
0
 def stop(self):
     logging.info("stopping %s" % self)
     _pandora.stop()
     self._stop_playing.put(True)
Exemplo n.º 5
0
 def dislike(self):
     _pandora.stop()
     self.publish_message("disliking %s" % self)
     self._add_feedback(like=False)
     self.station.next()
Exemplo n.º 6
0
 def stop(self):
     _pandora.stop()
Exemplo n.º 7
0
 def next(self):
     #if self.account._queued_song: self.account._queued_song.cancel()
     self.publish_message("changing song...")
     _pandora.stop()
     self.play()
Exemplo n.º 8
0
 def dislike(self, **kwargs):
     _pandora.stop()
     logging.info("disliking %s" % self)
     self.publish_message("disliking %s" % self)
     self._add_feedback(like=False)
     return self.station.next(**kwargs)
Exemplo n.º 9
0
 def stop(self):
     logging.info("stopping %s" % self)
     _pandora.stop()
     self._stop_playing.put(True)