move autoplay() into card

This commit is contained in:
Damien Elmes 2020-04-13 09:04:30 +10:00
parent 10eb947402
commit 351d8a309f
3 changed files with 10 additions and 4 deletions

View file

@ -170,6 +170,9 @@ class Card:
conf = self.col.decks.confForDid(self.odid or self.did)
return conf.get("replayq", True)
def autoplay(self) -> bool:
return self.col.decks.confForDid(self.odid or self.did)["autoplay"]
def timeTaken(self) -> int:
"Time taken to answer card, in integer MS."
total = int((time.time() - self.timerStarted) * 1000)

View file

@ -172,7 +172,7 @@ class Previewer(QDialog):
bodyclass = theme_manager.body_classes_for_card_ord(c.ord)
if self.mw.reviewer.autoplay(c):
if c.autoplay():
if self._show_both_sides:
# if we're showing both sides at once, remove any audio
# from the answer that's appeared on the question already

View file

@ -29,6 +29,7 @@ class ReviewerBottomBar:
def __init__(self, reviewer: Reviewer) -> None:
self.reviewer = reviewer
def replay_audio(card: Card, question_side: bool) -> None:
if question_side:
av_player.play_tags(card.question_av_tags())
@ -38,6 +39,7 @@ def replay_audio(card: Card, question_side: bool) -> None:
tags = card.question_av_tags() + tags
av_player.play_tags(tags)
class Reviewer:
"Manage reviews. Maintains a separate state."
@ -187,7 +189,7 @@ The front of this card is empty. Please run Tools>Empty Cards."""
q = c.q()
# play audio?
if self.autoplay(c):
if c.autoplay():
av_player.play_tags(c.question_av_tags())
else:
av_player.clear_queue_and_maybe_interrupt()
@ -209,7 +211,8 @@ The front of this card is empty. Please run Tools>Empty Cards."""
gui_hooks.reviewer_did_show_question(c)
def autoplay(self, card: Card) -> bool:
return self.mw.col.decks.confForDid(card.odid or card.did)["autoplay"]
print("use card.autoplay() instead of reviewer.autoplay(card)")
return card.autoplay()
def _drawFlag(self) -> None:
self.web.eval("_drawFlag(%s);" % self.card.userFlag())
@ -228,7 +231,7 @@ The front of this card is empty. Please run Tools>Empty Cards."""
c = self.card
a = c.a()
# play audio?
if self.autoplay(c):
if c.autoplay():
av_player.play_tags(c.answer_av_tags())
else:
av_player.clear_queue_and_maybe_interrupt()