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
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)
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)
def stop(self): logging.info("stopping %s" % self) _pandora.stop() self._stop_playing.put(True)
def dislike(self): _pandora.stop() self.publish_message("disliking %s" % self) self._add_feedback(like=False) self.station.next()
def stop(self): _pandora.stop()
def next(self): #if self.account._queued_song: self.account._queued_song.cancel() self.publish_message("changing song...") _pandora.stop() self.play()