# HG changeset patch # User Josef "Jeff" Sipek # Date 1162615769 18000 # Node ID a7d370f326df5de2801a4167da09a8804c5a7529 # Parent 8028f2addb004e7699fbe5761cc2e2485b794596 Implement song playing diff -r 8028f2addb00 -r a7d370f326df vixm/player.py --- 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: diff -r 8028f2addb00 -r a7d370f326df vixm/ui.py --- 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..."