mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
handle osx 10.3 audio
This commit is contained in:
parent
e75036adde
commit
3bd9dd8494
1 changed files with 50 additions and 1 deletions
|
@ -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
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
Loading…
Reference in a new issue