view 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
line wrap: on
line source

import time
from threading import Thread

import mad, ao

class playerThread(Thread):
	def __init__(self):
		Thread.__init__(self)

		self.shutdown = False
		self.playing  = False

		self.current  = None

		self.dev      = ao.AudioDevice("oss")

	def play(self, s):
		self.playing = True
		self.current = s

		mf = mad.MadFile(s["file"])

		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:
			time.sleep(0.5)