handle osx 10.3 audio

This commit is contained in:
Damien Elmes 2009-03-06 06:35:43 +09:00
parent e75036adde
commit 3bd9dd8494

View file

@ -270,7 +270,56 @@ try:
queue = [] queue = []
except ImportError: except ImportError:
pass # fall back to old nssound code for 10.3
try:
from AppKit import NSSound, NSObject
queue = []
current = None
class Sound(NSObject):
def init(self):
return self
def sound_didFinishPlaying_(self, sound, bool):
global current
while 1:
if not queue:
break
next = queue.pop(0)
if play_(next):
break
s = Sound.new()
def playOSX(path):
global current
if current:
if current.isPlaying():
queue.append(path)
return
# new handle
playOSX_(path)
def clearQueueOSX():
global queue
queue = []
def playOSX_(path):
global current
current = NSSound.alloc()
current = current.initWithContentsOfFile_byReference_(path, True)
if not current:
return False
current.setDelegate_(s)
current.play()
return True
except ImportError:
pass
# Default audio player # Default audio player
########################################################################## ##########################################################################