Mercurial > vixm
comparison vixm/player.py @ 42:bc6db55448e1 pure
statistics engine
author | Josef "Jeff" Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sun, 05 Nov 2006 19:25:30 -0500 |
parents | 06b5a7db3d19 |
children | d3ac3a46a294 |
comparison
equal
deleted
inserted
replaced
41:f56aeafb05b1 | 42:bc6db55448e1 |
---|---|
1 import time | 1 import time |
2 from threading import Thread | 2 from threading import Thread |
3 | 3 |
4 import mad, ao | 4 import mad, ao |
5 | 5 |
6 import playlist | 6 import playlist, stats |
7 | 7 |
8 class playerThread(Thread): | 8 class playerThread(Thread): |
9 def __init__(self): | 9 def __init__(self): |
10 Thread.__init__(self) | 10 Thread.__init__(self) |
11 | 11 |
15 | 15 |
16 self.current = None | 16 self.current = None |
17 | 17 |
18 self.blksize = 40960 | 18 self.blksize = 40960 |
19 self.dev = ao.AudioDevice("oss") | 19 self.dev = ao.AudioDevice("oss") |
20 | |
21 self.stats = stats.statsengine("stats") | |
20 | 22 |
21 def play_next(self, lists): | 23 def play_next(self, lists): |
22 try: | 24 try: |
23 # pop song off the PRIO queue | 25 # pop song off the PRIO queue |
24 s = lists[playlist.LIST_PRIO].pop() | 26 s = lists[playlist.LIST_PRIO].pop() |
35 if self.playing: | 37 if self.playing: |
36 self.end_current = True | 38 self.end_current = True |
37 | 39 |
38 self.playing = True | 40 self.playing = True |
39 self.current = s | 41 self.current = s |
42 self.stats.current = s | |
40 | 43 |
41 def run(self): | 44 def run(self): |
42 while not self.shutdown: | 45 while not self.shutdown: |
43 if self.current and self.playing: | 46 if self.current and self.playing: |
44 # play the file | 47 # play the file |
53 self.dev.play(buf, len(buf)) | 56 self.dev.play(buf, len(buf)) |
54 | 57 |
55 if self.end_current: | 58 if self.end_current: |
56 self.end_current = False | 59 self.end_current = False |
57 else: | 60 else: |
61 self.stats.played() | |
58 self.playing = False | 62 self.playing = False |
59 else: | 63 else: |
60 # nothing to play, just sleep | 64 # nothing to play, just sleep |
61 time.sleep(0.5) | 65 time.sleep(0.5) |
62 | 66 |