mirror of
https://github.com/ankitects/anki.git
synced 2025-12-20 10:22:57 -05:00
Replace default mpv quit keybindings if mpv version is >= 0.30
4614d432a8
This commit is contained in:
parent
5e5dc517ca
commit
610f9eb236
2 changed files with 15 additions and 1 deletions
|
|
@ -448,6 +448,10 @@ class MPV(MPVBase):
|
||||||
if not inspect.ismethod(method):
|
if not inspect.ismethod(method):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Bypass MPVError: no such event 'init'
|
||||||
|
if method_name == "on_init":
|
||||||
|
continue
|
||||||
|
|
||||||
if method_name.startswith("on_property_"):
|
if method_name.startswith("on_property_"):
|
||||||
name = method_name[12:]
|
name = method_name[12:]
|
||||||
name = name.replace("_", "-")
|
name = name.replace("_", "-")
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ from anki.lang import _
|
||||||
from anki.sound import AV_REF_RE, AVTag, SoundOrVideoTag
|
from anki.sound import AV_REF_RE, AVTag, SoundOrVideoTag
|
||||||
from anki.utils import isLin, isMac, isWin
|
from anki.utils import isLin, isMac, isWin
|
||||||
from aqt import gui_hooks
|
from aqt import gui_hooks
|
||||||
from aqt.mpv import MPV, MPVBase
|
from aqt.mpv import MPV, MPVBase, MPVCommandError
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.taskman import TaskManager
|
from aqt.taskman import TaskManager
|
||||||
from aqt.utils import restoreGeom, saveGeom, showWarning, startup_info
|
from aqt.utils import restoreGeom, saveGeom, showWarning, startup_info
|
||||||
|
|
@ -334,6 +334,16 @@ class MpvManager(MPV, SoundOrVideoPlayer):
|
||||||
self.default_argv += ["--config-dir=" + base_path]
|
self.default_argv += ["--config-dir=" + base_path]
|
||||||
super().__init__(window_id=None, debug=False)
|
super().__init__(window_id=None, debug=False)
|
||||||
|
|
||||||
|
def on_init(self) -> None:
|
||||||
|
try:
|
||||||
|
self.command("keybind", "q", "stop")
|
||||||
|
self.command("keybind", "Q", "stop")
|
||||||
|
self.command("keybind", "CLOSE_WIN", "stop")
|
||||||
|
self.command("keybind", "ctrl+w", "stop")
|
||||||
|
self.command("keybind", "ctrl+c", "stop")
|
||||||
|
except MPVCommandError:
|
||||||
|
print("mpv too old")
|
||||||
|
|
||||||
def play(self, tag: AVTag, on_done: OnDoneCallback) -> None:
|
def play(self, tag: AVTag, on_done: OnDoneCallback) -> None:
|
||||||
assert isinstance(tag, SoundOrVideoTag)
|
assert isinstance(tag, SoundOrVideoTag)
|
||||||
self._on_done = on_done
|
self._on_done = on_done
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue