Mercurial > vixm
annotate vixm/playlist.py @ 11:50584a5c300e
Fixed up code to make more sense
author  Josef "Jeff" Sipek <jeffpc@josefsipek.net> 

date  Sat, 19 Aug 2006 20:06:56 0400 
parents  eaa800169f5b 
children  ae3451bedeb6 
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 """ 
11
50584a5c300e
Fixed up code to make more sense
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
9
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 
9
eaa800169f5b
Hooked up the playlists to control xmms!
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
8
diff
changeset

33 def index(self, song): 
eaa800169f5b
Hooked up the playlists to control xmms!
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
8
diff
changeset

34 """ Returns the index of the first occurence of song """ 
eaa800169f5b
Hooked up the playlists to control xmms!
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
8
diff
changeset

35 return self.__list.index(song) 
eaa800169f5b
Hooked up the playlists to control xmms!
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
8
diff
changeset

36 