annotate vixm/player.py @ 36:c6a3a4d09a9a master

Small fix & change output to OSS
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Fri, 03 Nov 2006 23:59:10 -0500
parents a7d370f326df
children 87aa31e41f4a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
1 import time
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
2 from threading import Thread
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
3
35
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
4 import mad, ao
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
5
30
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
6 class playerThread(Thread):
35
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
7 def __init__(self):
30
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
8 Thread.__init__(self)
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
9
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
10 self.shutdown = False
32
f97eb9f0c207 Add random song selection for default queue
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 30
diff changeset
11 self.playing = False
f97eb9f0c207 Add random song selection for default queue
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 30
diff changeset
12
34
8028f2addb00 Destroy all traces of xmms
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 32
diff changeset
13 self.current = None
30
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
14
36
c6a3a4d09a9a Small fix & change output to OSS
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 35
diff changeset
15 self.dev = ao.AudioDevice("oss")
30
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
16
32
f97eb9f0c207 Add random song selection for default queue
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 30
diff changeset
17 def play(self, s):
35
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
18 self.playing = True
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
19 self.current = s
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
20
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
21 mf = mad.MadFile(s["file"])
32
f97eb9f0c207 Add random song selection for default queue
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 30
diff changeset
22
35
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
23 while True:
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
24 buf = mf.read()
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
25 if buf is None:
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
26 break
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
27 self.dev.play(buf, len(buf))
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
28
a7d370f326df Implement song playing
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 34
diff changeset
29 self.playing = False
34
8028f2addb00 Destroy all traces of xmms
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 32
diff changeset
30
30
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
31 def run(self):
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
32 while not self.shutdown:
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
33 time.sleep(0.5)
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
34