mpv support
This commit is contained in:
parent
bb661a4b7d
commit
7dc8f82906
@ -75,14 +75,51 @@ def retryWait(proc):
|
|||||||
except OSError:
|
except OSError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Mplayer settings
|
# MPV
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
mplayerCmd = ["mplayer", "-really-quiet", "-noautosub"]
|
from anki.mpv import MPV
|
||||||
|
|
||||||
|
class MpvManager(MPV):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(window_id=None, debug=True)
|
||||||
|
|
||||||
|
def queueFile(self, file):
|
||||||
|
path = os.path.join(os.getcwd(), file)
|
||||||
|
self.command("loadfile", path, "append")
|
||||||
|
self.set_property("playlist-pos", 0)
|
||||||
|
self.set_property("pause", False)
|
||||||
|
|
||||||
|
def clearQueue(self):
|
||||||
|
self.command("stop")
|
||||||
|
|
||||||
|
def togglePause(self):
|
||||||
|
self.set_property("pause", not self.get_property("pause"))
|
||||||
|
|
||||||
|
def seekRelative(self, secs):
|
||||||
|
self.command("seek", secs, "relative")
|
||||||
|
|
||||||
|
mpvManager = None
|
||||||
|
|
||||||
|
def setupMPV():
|
||||||
|
global mpvManager, _player, _queueEraser
|
||||||
|
mpvManager = MpvManager()
|
||||||
|
_player = mpvManager.queueFile
|
||||||
|
_queueEraser = mpvManager.clearQueue
|
||||||
|
|
||||||
|
def cleanupMPV():
|
||||||
|
global mpvManager, _player, _queueEraser
|
||||||
|
if mpvManager:
|
||||||
|
mpvManager.close()
|
||||||
|
mpvManager = None
|
||||||
|
_player = None
|
||||||
|
_queueEraser = None
|
||||||
|
|
||||||
# Mplayer in slave mode
|
# Mplayer in slave mode
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
mplayerCmd = ["mplayer", "-really-quiet", "-noautosub"]
|
||||||
|
|
||||||
mplayerQueue = []
|
mplayerQueue = []
|
||||||
mplayerManager = None
|
mplayerManager = None
|
||||||
mplayerReader = None
|
mplayerReader = None
|
||||||
|
@ -22,6 +22,10 @@ import aqt.webview
|
|||||||
import aqt.toolbar
|
import aqt.toolbar
|
||||||
import aqt.stats
|
import aqt.stats
|
||||||
import aqt.mediasrv
|
import aqt.mediasrv
|
||||||
|
|
||||||
|
from anki.sound import setupMPV, cleanupMPV
|
||||||
|
setupMPV()
|
||||||
|
|
||||||
from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \
|
from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \
|
||||||
restoreState, getOnlyText, askUser, applyStyles, showText, tooltip, \
|
restoreState, getOnlyText, askUser, applyStyles, showText, tooltip, \
|
||||||
openHelp, openLink, checkInvalidFilename, getFile
|
openHelp, openLink, checkInvalidFilename, getFile
|
||||||
@ -294,6 +298,7 @@ close the profile or restart Anki."""))
|
|||||||
def cleanupAndExit(self):
|
def cleanupAndExit(self):
|
||||||
self.errorHandler.unload()
|
self.errorHandler.unload()
|
||||||
self.mediaServer.shutdown()
|
self.mediaServer.shutdown()
|
||||||
|
cleanupMPV()
|
||||||
self.app.exit(0)
|
self.app.exit(0)
|
||||||
|
|
||||||
# Collection load/unload
|
# Collection load/unload
|
||||||
|
Loading…
Reference in New Issue
Block a user