Mercurial > vixm
annotate vixm/main.py @ 47:1ae315a49009 pure
Removed references to XMMS
author  Josef "Jeff" Sipek <jeffpc@josefsipek.net> 

date  Mon, 06 Nov 2006 05:25:05 0500 
parents  2d570448aba5 
children  3eee483b5c4e 
rev  line source 

45
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

1 import time 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

2 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

3 import playlist, song, player 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

4 import ui as uimod 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

5 
46
2d570448aba5
Abstract out the stats code a little bit more
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
45
diff
changeset

6 def run(listfn, statsfn): 
45
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

7 """ this is where we start execution """ 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

8 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

9 # first, let's create the two playlists 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

10 print "Creating playlists..." 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

11 lists = {} 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

12 lists[playlist.LIST_PRIO] = playlist.playlist() 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

13 lists[playlist.LIST_DEFAULT] = playlist.playlist(allowrandom=True) 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

14 
47
1ae315a49009
Removed references to XMMS
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
46
diff
changeset

15 # read in the info for all the songs in the playlist 
1ae315a49009
Removed references to XMMS
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
46
diff
changeset

16 print "Loading songs from the playlist..." 
45
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

17 songs = [] 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

18 idx = 0 
46
2d570448aba5
Abstract out the stats code a little bit more
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
45
diff
changeset

19 for l in open(listfn, "r").readlines(): 
45
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

20 if l[0] == "#": 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

21 continue 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

22 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

23 s = song.song(l[:1], idx) 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

24 lists[playlist.LIST_DEFAULT].enqueue(s) 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

25 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

26 idx += 1 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

27 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

28 print "Instanciating player thread..." 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

29 play = player.playerThread() 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

30 play.start() 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

31 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

32 print "Instanciating ui thread..." 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

33 ui = uimod.uiThread(play, lists) 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

34 ui.start() 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

35 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

36 while not play.shutdown: 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

37 # check which song we are playing now 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

38 if not play.playing: 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

39 play.play_next(lists) 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

40 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

41 # sleep 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

42 time.sleep(0.5) 
2bf81d95246a
Move starting code into main.py
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset

43 