mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
work around video focus stealing
https://anki.tenderapp.com/discussions/ankidesktop/27401-bug-when-playing-a-video-on-anki-for-mac-anki-lanches-mplayer-and-doesnt-quit-it-or-return-to-anki
This commit is contained in:
parent
693bb955ad
commit
47370af7c3
2 changed files with 10 additions and 1 deletions
|
@ -5,7 +5,7 @@
|
||||||
import html
|
import html
|
||||||
import re, sys, threading, time, subprocess, os, atexit
|
import re, sys, threading, time, subprocess, os, atexit
|
||||||
import random
|
import random
|
||||||
from anki.hooks import addHook
|
from anki.hooks import addHook, runHook
|
||||||
from anki.utils import tmpdir, isWin, isMac, isLin
|
from anki.utils import tmpdir, isWin, isMac, isLin
|
||||||
|
|
||||||
# Shared utils
|
# Shared utils
|
||||||
|
@ -114,6 +114,9 @@ class MpvManager(MPV):
|
||||||
def seekRelative(self, secs):
|
def seekRelative(self, secs):
|
||||||
self.command("seek", secs, "relative")
|
self.command("seek", secs, "relative")
|
||||||
|
|
||||||
|
def on_idle(self):
|
||||||
|
runHook("mpvIdleHook")
|
||||||
|
|
||||||
mpvManager = None
|
mpvManager = None
|
||||||
|
|
||||||
def setupMPV():
|
def setupMPV():
|
||||||
|
|
|
@ -958,12 +958,18 @@ Difference to correct time: %s.""") % diffText
|
||||||
addHook("modSchema", self.onSchemaMod)
|
addHook("modSchema", self.onSchemaMod)
|
||||||
addHook("remNotes", self.onRemNotes)
|
addHook("remNotes", self.onRemNotes)
|
||||||
addHook("odueInvalid", self.onOdueInvalid)
|
addHook("odueInvalid", self.onOdueInvalid)
|
||||||
|
addHook("mpvIdleHook", self.onMpvIdle)
|
||||||
|
|
||||||
def onOdueInvalid(self):
|
def onOdueInvalid(self):
|
||||||
showWarning(_("""\
|
showWarning(_("""\
|
||||||
Invalid property found on card. Please use Tools>Check Database, \
|
Invalid property found on card. Please use Tools>Check Database, \
|
||||||
and if the problem comes up again, please ask on the support site."""))
|
and if the problem comes up again, please ask on the support site."""))
|
||||||
|
|
||||||
|
def onMpvIdle(self):
|
||||||
|
# when audio player finishes playing, restore focus to anki window
|
||||||
|
self.activateWindow()
|
||||||
|
self.raise_()
|
||||||
|
|
||||||
# Log note deletion
|
# Log note deletion
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue