Audio from front being played on back

WHAT’S HAPPENING: Audio set in the front of card is being played on the back, but only in the preview screen. It ONLY happens while as a pop-out preview in the card browser. To be explicit:

  • It DOES NOT happen during normal reviews
  • It DOES NOT happen while editing the card template, i.e. “Card Types for %CARDNAME%” window
  • It DOES happen in preview windows, i.e. CTRL+SHIFT+P in card browser

OFFENDING CODE: I’ve written the following into my front card template.

<audio>[sound:_buffer70.mp3][sound:_wake1.mp3][sound:_buffer70.mp3][sound:_wake1.mp3][sound:_buffer70.mp3][sound:_wake2.mp3]</audio>

INTENT: What I’m trying to do is have audio not associated with any fields play at set intervals to ‘wake me up’ in cases were I get sidetracked start day dreaming during reviews, e.g. 7s silence, alert, 7s silence, alert, etc. And it does indeed work, but the behavior is wonky in preview windows - which happens to be very annoying while I’m editing cards after review sessions.

I’ll fully admit the code might be garbage; I just hacked stuff together until something worked. I was having trouble finding out how to use <audio> correctly, since every search engine I’ve tried has ignored the brackets and made searching about it impossible. I could share a few cards as examples, but I’m not sure if there’s a preferred sharing method on the forums.

Oh, and I don’t think it’ll matter, but here’s my debug info:

Anki 26.08.1 (39e4b0b4) (ao)
Python 3.13.13 Qt 6.11.1 PyQt 6.11.0
Platform: Linux-6.8.0-55-generic-x86_64-with-glibc2.42
===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Advanced Browser [‘874215009’, 2024-10-27T09:20, ‘None’, ‘’]
Advanced Copy Fields [‘1898445115’, 2024-01-08T11:01, ‘v0.4.01’, ‘’]
AnkiConnect [‘2055492159’, 2025-11-09T13:40, ‘None’, mod]
Customize Keyboard Shortcuts [‘24411424’, 2023-11-01T04:17, ‘None’, mod]
Reviewer Context Menu Search [‘359618071’, 2019-02-10T11:01, ‘None’, ‘’]
===IDs of active AnkiWeb add-ons===
1898445115 2055492159 24411424 359618071 874215009
===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])

You can start here to learn how to use the <audio> tag correctly – HTML audio tag . That might be enough to solve your issue, but if not, here are some other details that might be useful to someone helping you solve this –

  • Do you have other audio on your cards that is coming from the fields of your notes? Front or back template?
  • Do you use the {{FrontSide}} special field on your back template? Field Replacements - Anki Manual
  • What do you have set for Audio in your deck Options for the subdeck the card is actually in? Deck Options - Anki Manual

Thanks for the link. It indeed isn’t really enough, but it did answer some other things I was curious about, so I appreciate it. Part of what I feel lost about is I think Anki has some hidden/not exposed default styling/classes that might help here. Like, maybe there’s some <audio class="front"> or something. Since I’m not a webdev and am just stumbling my way through MDN Web Docs/W3 schools, I’m never really sure if my card design problems are CSS or Anki-specific (spoiler: they’re usually basic CSS issues :woozy_face:).

  1. I do. I have four templates total (listen-front/back & read-front/back). The three other templates use audio as referenced in the note’s fields. The template with the problematic code (listen-front) was previously completely silent with no reference to any audio whatsoever (hence me zoning out). The code in OP is the only audio in that template. The other templates use audio as shown below.
Summary

NOTE: live and kill are just styling classes for the audio buttons, since kill is just a blank mp3 to “kill” audio playback since I couldn’t figure out how to pause audio on Ankidroid.

<span class="live">
	{{aud-v}}
	{{#aud-m}}<audio autoplay>[sound:_buffer07.mp3]</audio>{{aud-m}}{{/aud-m}}
	{{#aud-s}}<audio autoplay>[sound:_buffer07.mp3]</audio>{{aud-s}}{{/aud-s}}</span>
<span class="kill">
	[sound:_buffer07.mp3]
</span>
  1. I do not use {{FrontSide}} at all (I generally desire much finer control). This is what’s curious, since the rear template is acting like it’s present. The front audio plays, then the the rest of the back template plays as normal.

    • Don’t play audio automatically: OFF
    • Skip question when replaying answer: ON

I’m not an Anki developer!
In the file “previewer.py”, in the function “_render_scheduled” I see:

if c.autoplay():
                self._web.setPlaybackRequiresGesture(False)
                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
                    question_audio = c.question_av_tags()
                    only_on_answer_audio = [
                        x for x in c.answer_av_tags() if x not in question_audio
                    ]
                    audio = question_audio + only_on_answer_audio
                elif self._state == "question":
                    audio = c.question_av_tags()
                else:
                    audio = c.answer_av_tags()
            else:
                audio = []
                self._web.setPlaybackRequiresGesture(True)

Here, the name “_show_both_sides” already suggests two sides.
But the name for this button is: “both_sides_button = QCheckBox(tr.qt_misc_back_side_only())”

When I change the line of code
audio = question_audio + only_on_answer_audio
to the line of code
audio = c.answer_av_tags()
it will work as you want.
But here’s the question: why was it done the way it is now?
I can’t answer that question; maybe the developer will read about it and say something. For now, I’ve only changed it through the addon and tested it.

Did you at least try using the HTML tags correctly and see if you got a different behavior?

I changed my addon Preview Slideshow (Shigeyuki) - mod kaiu 2026
https://ankiweb.net/shared/info/1188253433

Considered the possibility that the “{{FrontSide}}” field is not specified on the reverse side.

Code:

if c.autoplay():
            self._web.setPlaybackRequiresGesture(False)
            if self._show_both_sides:
                note = c.note()
                model = note.model()
                tmpl = model['tmpls'][c.ord]
                afmt = tmpl['afmt']
                if "{{FrontSide}}" in afmt:
                    # if we're showing both sides at once, remove any audio
                    # from the answer that's appeared on the question already
                    question_audio = c.question_av_tags()
                    only_on_answer_audio = [
                        x for x in c.answer_av_tags() if x not in question_audio
                    ]
                    audio = question_audio + only_on_answer_audio
                else:
                    audio = c.answer_av_tags()
            elif self._state == "question":
                audio = c.question_av_tags()
            else:
                audio = c.answer_av_tags()
        else:
            audio = []
            self._web.setPlaybackRequiresGesture(True)

Try it and check.
If this is how it’s supposed to be, the developers might need to change the code.

It looks like this is what you want to use instead:

<audio id="wake1"><source src="_wake1.mp3"></audio>
<audio id="wake2"><source src="_wake2.mp3"></audio>

<script>
{
  const wake1 = window.wake1;
  const wake2 = window.wake2;
  setTimeout(()=>{if (document.contains(wake1)) wake1.play()},   7000);
  setTimeout(()=>{if (document.contains(wake1)) wake1.play()},  14000);
  setTimeout(()=>{if (document.contains(wake2)) wake2.play()},  21000);
}
</script>

This avoids Anki’s audio handling altogether, so it should work the same in any mode (Note that stock [sound:..] tags on desktop are converted to hyperlinks with audio playback being handled by Anki in the background, outside of the card webpage, so mixing them with <audio> tags doesn’t make much sense in the first place).
You also don’t need silent audio files for padding here, since firing times are set explicitly and can be adjusted independently of each other.

Not sure if you wanted any styling with that, but the appearance can be adjusted as required too.