def set_radio_id(self, radio_id):
     """
         Set radio id
         @param radio_id as int
     """
     from lollypop.radios import Radios
     radios = Radios()
     name = radios.get_name(radio_id)
     uri = radios.get_uri(radio_id)
     self.set_radio(name, uri)
 def set_radio_id(self, radio_id):
     """
         Set radio id
         @param radio_id as int
     """
     from lollypop.radios import Radios
     radios = Radios()
     self.id = Type.RADIOS
     self._radio_id = radio_id
     self._radio_name = radios.get_name(radio_id)
     self._uri = radios.get_uri(radio_id)
Exemple #3
0
 def restore_state(self):
     """
         Restore player state
     """
     try:
         if App().settings.get_value("save-state"):
             self._current_playback_track = Track(
                 load(open(LOLLYPOP_DATA_PATH + "/track_id.bin", "rb")))
             self.set_queue(load(open(LOLLYPOP_DATA_PATH +
                                      "/queue.bin", "rb")))
             albums = load(open(LOLLYPOP_DATA_PATH + "/Albums.bin", "rb"))
             playlist_ids = load(open(LOLLYPOP_DATA_PATH +
                                      "/playlist_ids.bin", "rb"))
             (is_playing, was_party) = load(open(LOLLYPOP_DATA_PATH +
                                                 "/player.bin", "rb"))
             if playlist_ids and playlist_ids[0] == Type.RADIOS:
                 radios = Radios()
                 track = Track()
                 name = radios.get_name(self._current_playback_track.id)
                 uri = radios.get_uri(self._current_playback_track.id)
                 track.set_radio(name, uri)
                 self.load(track, is_playing)
             elif self._current_playback_track.uri:
                 if albums:
                     if was_party:
                         App().lookup_action("party").change_state(
                             GLib.Variant("b", True))
                     else:
                         self._albums = load(open(
                                             LOLLYPOP_DATA_PATH +
                                             "/Albums.bin",
                                             "rb"))
                     # Load track from player albums
                     index = self.album_ids.index(
                         self._current_playback_track.album.id)
                     for track in self._albums[index].tracks:
                         if track.id == self._current_playback_track.id:
                             self._load_track(track)
                             break
                 else:
                     tracks = []
                     track = Track()
                     for playlist_id in playlist_ids:
                         tracks += App().playlists.get_tracks(playlist_id)
                         for track in tracks:
                             if track.id == self._current_playback_track.id:
                                 break
                     self.populate_playlist_by_tracks(
                         tracks, playlist_ids, track)
                 if is_playing:
                     self.play()
                 else:
                     self.pause()
                 position = load(open(LOLLYPOP_DATA_PATH + "/position.bin",
                                 "rb"))
                 self.seek(position / Gst.SECOND)
             else:
                 Logger.info("Player::restore_state(): track missing")
             self.emit("playlist-changed")
     except Exception as e:
         Logger.error("Player::restore_state(): %s" % e)