def set_highlight_song(self, song): if not song: return False if SongItem(song) in self.items: self.set_highlight_item(self.items[self.items.index(SongItem(song))]) self.visible_highlight() self.queue_draw() return True return False
def add_songs(self, songs, pos=None, sort=False, play=False): '''Add song to songlist.''' if not songs: return if not isinstance(songs, (list, tuple, set)): songs = [songs] song_items = [ SongItem(song) for song in songs if song not in self.get_songs() ] if song_items: if not self.items: self.emit_add_signal() self.add_items(song_items, pos, False) if len(songs) >= 1 and play: if songs[0].exists(): del self.select_rows[:] self.queue_draw() self.set_highlight_song(songs[0]) Player.play_new(self.highlight_item.get_song(), seek=self.highlight_item.get_song().get( "seek", 0)) self.set_current_source() self.async_reset_error_items()
def add_songs(self, songs, pos=None, sort=False): if not songs: return if not isinstance(songs, (list, tuple, set)): songs = [ songs ] song_items = [ SongItem(song, True) for song in songs if song not in self.get_songs() ] if song_items: self.add_items(song_items, pos, False)
def add_songs(self, songs, pos=None, sort=False, play=False): if not songs: return song_items = [ SongItem(song) for song in songs if song not in self.get_playlist_songs() ] if song_items: if not self.items: self.emit_add_signal() self.add_items(song_items, pos, False) #save songs #if self.view_type == self.DEFAULT_TYPE: #self.save() #if self.view_type == self.LOCAL_TYPE: #event_manager.emit("save-listen-lists") if len(songs) >= 1 and play: song = songs[0] self.request_song(song, play=True)
def __remove_songs(self, db, song_type, songs): flag = False if self.highlight_item and self.highlight_item.get_song() in songs: Player.stop() self.highlight_item = None flag = True for song in songs: try: self.items.remove(SongItem(song)) except: pass self.update_item_index() self.update_vadjustment() self.queue_draw() if flag: if len(self.get_valid_items()) > 0: item = self.get_valid_items()[0] self.set_highlight_item(item) Player.play_new(item.get_song(), seek=item.get_song().get("seek", None))
def update_songitem(self, song): if not song: return if song in self.items: self.items[self.items.index(SongItem(song))].update(song, True)
def add_invaild_song(self, song): item = SongItem(song) if item in self.items: vaild_item = self.items[self.items.index(item)] vaild_item.set_error() self.invaild_items.add(vaild_item)