mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
fix autoplaying of audio in preview screen, and drop extend_and_play()
This commit is contained in:
parent
218c033104
commit
3b8f851854
2 changed files with 13 additions and 14 deletions
|
@ -1686,9 +1686,6 @@ where id in %s"""
|
||||||
# need to force reload even if answer
|
# need to force reload even if answer
|
||||||
txt = c.q(reload=True)
|
txt = c.q(reload=True)
|
||||||
|
|
||||||
question_audio = []
|
|
||||||
if self._previewBothSides:
|
|
||||||
question_audio = c.question_av_tags()
|
|
||||||
if self._previewState == "answer":
|
if self._previewState == "answer":
|
||||||
func = "_showAnswer"
|
func = "_showAnswer"
|
||||||
txt = c.a()
|
txt = c.a()
|
||||||
|
@ -1697,12 +1694,19 @@ where id in %s"""
|
||||||
bodyclass = theme_manager.body_classes_for_card_ord(c.ord)
|
bodyclass = theme_manager.body_classes_for_card_ord(c.ord)
|
||||||
|
|
||||||
if self.mw.reviewer.autoplay(c):
|
if self.mw.reviewer.autoplay(c):
|
||||||
# if we're showing both sides at once, play question audio first
|
if self._previewBothSides:
|
||||||
av_player.play_tags(question_audio)
|
# if we're showing both sides at once, remove any audio
|
||||||
# then play any audio that hasn't already been played
|
# from the answer that's appeared on the question already
|
||||||
answer_audio = c.answer_av_tags()
|
question_audio = c.question_av_tags()
|
||||||
unplayed_audio = [x for x in answer_audio if x not in question_audio]
|
only_on_answer_audio = [
|
||||||
av_player.extend_and_play(unplayed_audio)
|
x for x in c.answer_av_tags() if x not in question_audio
|
||||||
|
]
|
||||||
|
audio = question_audio + only_on_answer_audio
|
||||||
|
elif self._previewState == "question":
|
||||||
|
audio = c.question_av_tags()
|
||||||
|
else:
|
||||||
|
audio = c.answer_av_tags()
|
||||||
|
av_player.play_tags(audio)
|
||||||
|
|
||||||
txt = self.mw.prepare_card_text_for_display(txt)
|
txt = self.mw.prepare_card_text_for_display(txt)
|
||||||
gui_hooks.card_will_show(
|
gui_hooks.card_will_show(
|
||||||
|
|
|
@ -99,11 +99,6 @@ class AVPlayer:
|
||||||
self._stop_if_playing()
|
self._stop_if_playing()
|
||||||
self._play_next_if_idle()
|
self._play_next_if_idle()
|
||||||
|
|
||||||
def extend_and_play(self, tags: List[AVTag]) -> None:
|
|
||||||
"""Add extra tags to queue, without clearing it."""
|
|
||||||
self._enqueued.extend(tags)
|
|
||||||
self._play_next_if_idle()
|
|
||||||
|
|
||||||
def stop_and_clear_queue(self) -> None:
|
def stop_and_clear_queue(self) -> None:
|
||||||
self._enqueued = []
|
self._enqueued = []
|
||||||
self._stop_if_playing()
|
self._stop_if_playing()
|
||||||
|
|
Loading…
Reference in a new issue