annotate vixm/playlist.py @ 8:79340745c952

Reimplemented enqueuing & quit properly, implemented list and number commands
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Sat, 19 Aug 2006 19:41:06 -0400
parents dd00b69169c6
children eaa800169f5b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
80a717f97cef Basic definition of a playlist class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
1 # a playlist definition
80a717f97cef Basic definition of a playlist class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
2
3
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
3 import xmms
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
4
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
5 LIST_PRIO = 0
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
6 LIST_DEFAULT = 1
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
7
2
80a717f97cef Basic definition of a playlist class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
8 class playlist:
3
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
9 def __init__(self, allowrandom=False):
2
80a717f97cef Basic definition of a playlist class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
10 self.__list = []
3
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
11 self.__allowrand = allowrandom # allow randomization of this list
2
80a717f97cef Basic definition of a playlist class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
12
3
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
13 def enqueue(self, song):
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
14 """ Append a song to the list """
2
80a717f97cef Basic definition of a playlist class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
15 self.__list.append(song)
80a717f97cef Basic definition of a playlist class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
16
3
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
17 def dequeue(self, song):
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
18 """ Remove a song from the list """
2
80a717f97cef Basic definition of a playlist class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
19 self.__list.remove(song)
80a717f97cef Basic definition of a playlist class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
20
80a717f97cef Basic definition of a playlist class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
21 def pop(self):
3
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
22 """ Pop the next song """
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
23 return self.__list.pop(0)
2
80a717f97cef Basic definition of a playlist class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
24
3
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
25 def __getitem__(self, i):
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
26 """ Get item at position i """
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
27 return self.__list[i]
dd00b69169c6 Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 2
diff changeset
28
8
79340745c952 Reimplemented enqueuing & quit properly, implemented list and number commands
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 3
diff changeset
29 def __len__(self):
79340745c952 Reimplemented enqueuing & quit properly, implemented list and number commands
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 3
diff changeset
30 """ Return the length of the playlist """
79340745c952 Reimplemented enqueuing & quit properly, implemented list and number commands
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 3
diff changeset
31 return len(self.__list)
79340745c952 Reimplemented enqueuing & quit properly, implemented list and number commands
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 3
diff changeset
32