mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
move the simple player code into a plugin
This commit is contained in:
parent
ebac830248
commit
76376d9040
1 changed files with 2 additions and 39 deletions
|
@ -228,38 +228,6 @@ def stopMplayerOnce():
|
||||||
|
|
||||||
addHook("deckClosed", stopMplayerOnce)
|
addHook("deckClosed", stopMplayerOnce)
|
||||||
|
|
||||||
# Simple player
|
|
||||||
##########################################################################
|
|
||||||
|
|
||||||
externalManager = None
|
|
||||||
|
|
||||||
class QueueMonitor(threading.Thread):
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
while 1:
|
|
||||||
if queue:
|
|
||||||
path = queue.pop(0)
|
|
||||||
try:
|
|
||||||
retryWait(subprocess.Popen(
|
|
||||||
mplayerCmd + [path], startupinfo=si))
|
|
||||||
except OSError:
|
|
||||||
raise Exception("Audio player not found")
|
|
||||||
else:
|
|
||||||
return
|
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
def queueExternal(path):
|
|
||||||
global externalManager
|
|
||||||
path = path.encode(sys.getfilesystemencoding())
|
|
||||||
queue.append(path)
|
|
||||||
if not externalManager or not externalManager.isAlive():
|
|
||||||
externalManager = QueueMonitor()
|
|
||||||
externalManager.start()
|
|
||||||
|
|
||||||
def clearExternalQueue():
|
|
||||||
global queue
|
|
||||||
queue = []
|
|
||||||
|
|
||||||
# PyAudio recording
|
# PyAudio recording
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
@ -359,13 +327,8 @@ class PyAudioRecorder(_Recorder):
|
||||||
# Audio interface
|
# Audio interface
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
if sys.platform.startswith("darwin") and platform.mac_ver()[0] < "10.4":
|
_player = queueMplayer
|
||||||
# fall back to primitive player
|
_queueEraser = clearMplayerQueue
|
||||||
_player = queueExternal
|
|
||||||
_queueEraser = clearExternalQueue
|
|
||||||
else:
|
|
||||||
_player = queueMplayer
|
|
||||||
_queueEraser = clearMplayerQueue
|
|
||||||
|
|
||||||
def play(path):
|
def play(path):
|
||||||
_player(path)
|
_player(path)
|
||||||
|
|
Loading…
Reference in a new issue