# HG changeset patch # User Josef "Jeff" Sipek # Date 1156032179 14400 # Node ID eaa800169f5bd75f41bdb1ba2ee9f669822e848c # Parent 79340745c9527091b24cba60824f5bd7aaeb7922 Hooked up the playlists to control xmms! Also added help string to all the commands, and added a stub for help command diff -r 79340745c952 -r eaa800169f5b vixm/playlist.py --- a/vixm/playlist.py Sat Aug 19 19:41:06 2006 -0400 +++ b/vixm/playlist.py Sat Aug 19 20:02:59 2006 -0400 @@ -20,7 +20,10 @@ def pop(self): """ Pop the next song """ - return self.__list.pop(0) + try: + return self.__list.pop(0) + except IndexError: + return None def __getitem__(self, i): """ Get item at position i """ @@ -30,3 +33,7 @@ """ Return the length of the playlist """ return len(self.__list) + def index(self, song): + """ Returns the index of the first occurence of song """ + return self.__list.index(song) + diff -r 79340745c952 -r eaa800169f5b vixm/ui.py --- a/vixm/ui.py Sat Aug 19 19:41:06 2006 -0400 +++ b/vixm/ui.py Sat Aug 19 20:02:59 2006 -0400 @@ -27,8 +27,32 @@ ui = uiThread(lists) ui.start() + last = None while not ui.shutdown: - time.sleep(1) + # check which song we are playing now + pos = xmms.control.get_playlist_pos() + current = lists[playlist.LIST_DEFAULT][pos] + + # if it is different from what we played last time we + # checked... + if current != last: + # pop song off the PRIO queue + next = lists[playlist.LIST_PRIO].pop() + + # if successful, play the popped song + if next: + try: + idx = lists[playlist.LIST_DEFAULT].index(next) + xmms.control.set_playlist_pos(idx) + current = next + except ValueError: + print "WTF is going on?!" + + # update last played song + last = current + + # sleep + time.sleep(0.5) class uiThread(Thread): """ This is the main ui thread class, it does all the magic @@ -115,6 +139,9 @@ def __cmd_dequeue(ui, start, stop, args): print "not implemented yet" + def __cmd_help(ui, start, stop, args): + print "not implemented yet" + def __do_list(ui, start, stop, number, args): # get the list id from the argument or default to # LIST_PRIO @@ -161,15 +188,17 @@ cmdtable = { "q([!]){,1}": - (__cmd_quit, False), + (__cmd_quit, False, "q[!]"), "n( ([0-9]+)){,1}": - (__cmd_number, True), + (__cmd_number, True, "[range]n [playlistid]"), "l( ([0-9]+)){,1}": - (__cmd_list, True), + (__cmd_list, True, "[range]l [playlistid]"), "a ([0-9]+)": - (__cmd_enqueue, False), + (__cmd_enqueue, False, "a [songid]"), "d ([0-9]+)": - (__cmd_dequeue, False), + (__cmd_dequeue, False, "d [songid]"), + "h": + (__cmd_help, False, "h"), } def special2int(s):