Damien Elmes 2018-04-30 17:12:26 +10:00
parent 693bb955ad
commit 47370af7c3
2 changed files with 10 additions and 1 deletions

View file

@ -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():

View file

@ -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
########################################################################## ##########################################################################