+ def _play_track(self, track, notify='play'):
+ self.backend.play_url('mp3', track.mp3_url())
+ log.debug("playing %s", track)
+ postoffice.notify(notify, track)
+
+ def _refill_radio(self):
+ log.debug("Refilling radio %s", self.playlist)
+ #self.playlist.add(jamaendo.get_radio_tracks(self.playlist.radio_id))
+ self._start_radio_fetcher()
+
+ def _start_radio_fetcher(self):
+ if self.fetcher:
+ self.fetcher.stop()
+ self.fetcher = None
+ self.fetcher = Fetcher(lambda: jamaendo.get_radio_tracks(self.playlist.radio_id),
+ self,
+ on_item = self._on_radio_result,
+ on_ok = self._on_radio_complete,
+ on_fail = self._on_radio_complete)
+ self.fetcher.has_no_results = True
+ self.fetcher.start()
+
+ def _on_radio_result(self, wnd, item):
+ if wnd is self:
+ self.playlist.add(item)
+ if not self.playing():
+ if self.fetcher.has_no_results:
+ self.fetcher.has_no_results = False
+ entry = self.playlist.next()
+ self._play_track(entry)
+
+ def _on_radio_complete(self, wnd, error=None):
+ if wnd is self:
+ if error:
+ self.stop()
+ self.fetcher.stop()
+ self.fetcher = None
+