changeset 35:a7d370f326df master

Implement song playing
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Fri, 03 Nov 2006 23:49:29 -0500
parents 8028f2addb00
children c6a3a4d09a9a
files vixm/player.py vixm/ui.py
diffstat 2 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/vixm/player.py	Fri Nov 03 23:34:59 2006 -0500
+++ b/vixm/player.py	Fri Nov 03 23:49:29 2006 -0500
@@ -1,8 +1,10 @@
 import time
 from threading import Thread
 
+import mad, ao
+
 class playerThread(Thread):
-	def __init__(self, lists):
+	def __init__(self):
 		Thread.__init__(self)
 
 		self.shutdown = False
@@ -10,12 +12,23 @@
 
 		self.current  = None
 
-		self.lists = lists
+		self.dev      = ao.AudioDevice("raw", \
+					filename="/tmp/foo", \
+					overwrite = 1)
 
 	def play(self, s):
-		print "about to play %s" % (str(s),)
+		self.playing = True
+		self.current = s
+
+		mf = mad.MadFile(s["file"])
 
-		self.current = s
+		while True:
+			buf = mf.read()
+			if buf is None:
+				break
+			self.dev.play(buf, len(buf))
+
+		self.playing = False
 
 	def run(self):
 		while not self.shutdown:
--- a/vixm/ui.py	Fri Nov 03 23:34:59 2006 -0500
+++ b/vixm/ui.py	Fri Nov 03 23:49:29 2006 -0500
@@ -34,7 +34,7 @@
 		idx += 1
 	
 	print "Instanciating player thread..."
-	play = player.playerThread(lists)
+	play = player.playerThread()
 	play.start()
 
 	print "Instanciating ui thread..."