mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 15:17:12 -05:00
play audio once for each template, not once on open
This commit is contained in:
parent
94311153c8
commit
f01d1f9142
1 changed files with 4 additions and 13 deletions
|
|
@ -99,7 +99,7 @@ class CardLayout(QDialog):
|
||||||
def setupCards(self):
|
def setupCards(self):
|
||||||
self.needFormatRebuild = False
|
self.needFormatRebuild = False
|
||||||
self.updatingCards = False
|
self.updatingCards = False
|
||||||
self.playedAudio = False
|
self.playedAudio = {}
|
||||||
# replace with more appropriate size hints
|
# replace with more appropriate size hints
|
||||||
for e in ("cardQuestion", "cardAnswer"):
|
for e in ("cardQuestion", "cardAnswer"):
|
||||||
w = getattr(self.form, e)
|
w = getattr(self.form, e)
|
||||||
|
|
@ -274,16 +274,7 @@ order by n""", id=card.id)
|
||||||
self.saveCard()
|
self.saveCard()
|
||||||
|
|
||||||
def renderPreview(self):
|
def renderPreview(self):
|
||||||
if self.card:
|
c = self.card
|
||||||
c = self.card
|
|
||||||
else:
|
|
||||||
# we'll need to generate one
|
|
||||||
cards = self.deck.previewFact(self.fact)
|
|
||||||
if not cards:
|
|
||||||
ui.utils.showInfo(_("No cards to preview."),
|
|
||||||
parent=parent)
|
|
||||||
return
|
|
||||||
pass
|
|
||||||
styles = (self.deck.rebuildCSS() +
|
styles = (self.deck.rebuildCSS() +
|
||||||
("\nhtml { background: %s }" % c.cardModel.lastFontColour))
|
("\nhtml { background: %s }" % c.cardModel.lastFontColour))
|
||||||
styles = runFilter("addStyles", styles, c)
|
styles = runFilter("addStyles", styles, c)
|
||||||
|
|
@ -297,10 +288,10 @@ order by n""", id=card.id)
|
||||||
c)
|
c)
|
||||||
+ "</body></html>")
|
+ "</body></html>")
|
||||||
clearAudioQueue()
|
clearAudioQueue()
|
||||||
if not self.playedAudio:
|
if c.id not in self.playedAudio:
|
||||||
playFromText(c.question)
|
playFromText(c.question)
|
||||||
playFromText(c.answer)
|
playFromText(c.answer)
|
||||||
self.playedAudio = True
|
self.playedAudio[c.id] = True
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
modified = False
|
modified = False
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue