From 8c0d4c80595afdef8d69ca25cb9aa7f67b940f8c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 29 Feb 2020 21:05:37 +1000 Subject: [PATCH] restore mpv/mplayer missing warning that got lost in the av changes and ensure the UI doesn't get temporarily stuck after the command fails --- qt/aqt/errors.py | 6 ------ qt/aqt/sound.py | 11 +++++++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/qt/aqt/errors.py b/qt/aqt/errors.py index d099537c1..30092fd51 100644 --- a/qt/aqt/errors.py +++ b/qt/aqt/errors.py @@ -82,12 +82,6 @@ your system's temporary folder may be incorrect.""" "Your firewall or antivirus program is preventing Anki from creating a connection to itself. Please add an exception for Anki." ) ) - if "install mplayer" in error: - return showWarning( - _( - "Sound and video on cards will not function until mpv or mplayer is installed." - ) - ) if "no default input" in error.lower(): return showWarning( _( diff --git a/qt/aqt/sound.py b/qt/aqt/sound.py index 508a9611c..16611950c 100644 --- a/qt/aqt/sound.py +++ b/qt/aqt/sound.py @@ -1,6 +1,5 @@ # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - import atexit import os import re @@ -25,7 +24,7 @@ from aqt import gui_hooks from aqt.mpv import MPV, MPVBase from aqt.qt import * from aqt.taskman import TaskManager -from aqt.utils import restoreGeom, saveGeom, startup_info +from aqt.utils import restoreGeom, saveGeom, showWarning, startup_info # AV player protocol ########################################################################## @@ -291,6 +290,14 @@ class SimpleProcessPlayer(Player): # pylint: disable=abstract-method except PlayerInterrupted: # don't fire done callback when interrupted return + except FileNotFoundError: + showWarning( + _( + "Sound and video on cards will not function until mpv or mplayer is installed." + ) + ) + # must call cb() here, as we don't currently have another way + # to flag to av_player that we've stopped cb()