From f7062ff0c636beaa491b8f0a9d7d5c7ecba10230 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 5 Oct 2017 13:48:24 +1000 Subject: [PATCH] user-friendly warning when mpv missing --- aqt/main.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/aqt/main.py b/aqt/main.py index b96040b4f..50a574845 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -22,10 +22,8 @@ import aqt.webview import aqt.toolbar import aqt.stats import aqt.mediasrv - -from anki.sound import setupMPV, cleanupMPV -setupMPV() - +from aqt.utils import showWarning +import anki.sound from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \ restoreState, getOnlyText, askUser, applyStyles, showText, tooltip, \ openHelp, openLink, checkInvalidFilename, getFile @@ -72,6 +70,7 @@ class AnkiQt(QMainWindow): self.setupKeys() self.setupThreads() self.setupMediaServer() + self.setupSound() self.setupMainWindow() self.setupSystemSpecific() self.setupStyle() @@ -299,9 +298,20 @@ close the profile or restart Anki.""")) def cleanupAndExit(self): self.errorHandler.unload() self.mediaServer.shutdown() - cleanupMPV() + anki.sound.cleanupMPV() 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 ##########################################################################