comparison vixm/player.py @ 43:d3ac3a46a294 pure

Abuse the Rhythmbox dbus messages to announce what is being played
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Mon, 06 Nov 2006 04:50:55 -0500
parents bc6db55448e1
children c46d3f8833f9
comparison
equal deleted inserted replaced
42:bc6db55448e1 43:d3ac3a46a294
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, stats 6 import playlist, stats, rb_dbus
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
17 17
18 self.blksize = 40960 18 self.blksize = 40960
19 self.dev = ao.AudioDevice("oss") 19 self.dev = ao.AudioDevice("oss")
20 20
21 self.stats = stats.statsengine("stats") 21 self.stats = stats.statsengine("stats")
22
23 self.rb = rb_dbus.RhythmboxDbusThread(self)
24 self.rb.start()
22 25
23 def play_next(self, lists): 26 def play_next(self, lists):
24 try: 27 try:
25 # pop song off the PRIO queue 28 # pop song off the PRIO queue
26 s = lists[playlist.LIST_PRIO].pop() 29 s = lists[playlist.LIST_PRIO].pop()
41 self.current = s 44 self.current = s
42 self.stats.current = s 45 self.stats.current = s
43 46
44 def run(self): 47 def run(self):
45 while not self.shutdown: 48 while not self.shutdown:
46 if self.current and self.playing: 49 c = self.current
50
51 if c and self.playing:
52 # notify everyone
53
54 self.rb.notify("file://" + c["file"], \
55 c["title"], c["artist"])
56
47 # play the file 57 # play the file
48 mf = mad.MadFile(self.current["file"]) 58 mf = mad.MadFile(c["file"])
49 59
50 while True: 60 while True:
51 buf = mf.read(self.blksize) 61 buf = mf.read(self.blksize)
52 if buf is None or \ 62 if buf is None or \
53 self.shutdown or \ 63 self.shutdown or \