view vixm/ @ 37:87aa31e41f4a master

Play the files in a separate thread
author Josef "Jeff" Sipek <>
date Sat, 04 Nov 2006 15:31:32 -0500
parents c6a3a4d09a9a
children 06b5a7db3d19
line wrap: on
line source

import time
from threading import Thread

import mad, ao

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

		self.shutdown = False
		self.playing  = False

		self.current  = None

		self.blksize  = 40960      = ao.AudioDevice("oss")

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

	def run(self):
		while not self.shutdown:
			if self.current and self.playing:
				# play the file
				mf = mad.MadFile(self.current["file"])
				while True:
					buf =
					if buf is None or self.shutdown:
						break, len(buf))
				self.playing = False
				# nothing to play, just sleep