Playlist next

The playlist will play the next visible song when the current song ends.
If we have reached the end of the list, we loop back around to the
beginning.
This commit is contained in:
Bryan Schumaker 2010-10-20 22:18:41 -04:00
parent dc1b6dd4a6
commit bb86a70ae4
2 changed files with 36 additions and 2 deletions

View File

@ -75,15 +75,31 @@ def plist_save():
def plist_add_libid(lib_id):
global playlist
# Hey, Future Bryan. I really want to use a lib_get_attrs() function
# to return a list of attributes. Can you do that for me, please?
# Thank you, Past Bryan
artist = lib_get_attr(lib_id, "artist")
album = lib_get_attr(lib_id, "album")
title = lib_get_attr(lib_id, "title")
playlist.insert_tags(artist, album, title, lib_id)
def plist_is_visible(text):
def plist_is_visible(id):
global playlist
return playlist.is_visible(text)
return playlist.is_visible(id)
def plist_filter(text):
global playlist
return playlist.filter(text)
def plist_refresh():
return call("PLISTREFRESH")
def plist_next(arg):
global playlist
global cur_lib_id
next = playlist.next_id(cur_lib_id)
if next != None:
lib_play_id(next)
libsaria.event.invite("POSTEOS", plist_next)

View File

@ -62,3 +62,21 @@ class Playlist(collection.Collection):
def __init__(self):
collection.Collection.__init__(self, "playlist.dl_tree")
def next_id(self, last_id):
return_next = False
first = None
visible = self.is_visible
for id in self.walk_ids():
if visible(id):
if first == None:
first = id
if return_next == True:
return id
if id == last_id:
return_next = True
if first != None:
return first
return None