user-friendly warning when mpv missing

This commit is contained in:
Damien Elmes 2017-10-05 13:48:24 +10:00
parent e1a4c52175
commit f7062ff0c6

View file

@ -22,10 +22,8 @@ import aqt.webview
import aqt.toolbar import aqt.toolbar
import aqt.stats import aqt.stats
import aqt.mediasrv import aqt.mediasrv
from aqt.utils import showWarning
from anki.sound import setupMPV, cleanupMPV import anki.sound
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
@ -72,6 +70,7 @@ class AnkiQt(QMainWindow):
self.setupKeys() self.setupKeys()
self.setupThreads() self.setupThreads()
self.setupMediaServer() self.setupMediaServer()
self.setupSound()
self.setupMainWindow() self.setupMainWindow()
self.setupSystemSpecific() self.setupSystemSpecific()
self.setupStyle() self.setupStyle()
@ -299,9 +298,20 @@ 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() anki.sound.cleanupMPV()
self.app.exit(0) self.app.exit(0)
# Sound/video
##########################################################################
def setupSound(self):
try:
anki.sound.setupMPV()
except FileNotFoundError:
showWarning(_("mpv is not installed - audio and video on cards will not work."))
anki.sound._player = lambda file: 1
anki.sound._queueEraser = lambda: 1
# Collection load/unload # Collection load/unload
########################################################################## ##########################################################################