Option controlling autoplay of audio dropped into card editing window

As suggested in another thread, I’m making this thread to see if there is any interest in an option like this.

2.1.33 saw a relatively minor temporary change to how pasting audio into a field on a flashcard worked. Previously, Anki would play the audio pasted into a field automatically, but in 2.1.33 the audio would no longer play when doing this. This change was reverted in 2.1.34.

I use Anki to learn foreign languages, and I often make flashcards on the go when I come cross an unknown word while watching something, for example. Adding the audio means I’ll have to wait for the audio clip to finish playing before I can get back to whatever I was doing. I think this is a fairly compelling argument against this functionality, especially as a language learner.

Perhaps I’m missing something, but I don’t see the benefits of having the autoplay functionality there, other than double checking that you have the right clip, and that the clip sounds good, but in the few instances that you’d want to do this, you are literally one click away from being able to do this anyway even if the functionality isn’t there: the preview button.

You could of course argue that one can turn off audio from Anki in the volume mixer (on Windows-based OSes, at least), and I have actually done this from time to time, but it means one has to go into the volume mixer and mute/unmute Anki every time you want to engage in TL content or rep cards in Anki. This is a obviously a bigger inconvenience than just pressing an additional button (see previous paragraph).

If, for whatever reason, this functionality has to stay, an option to enable/disable it would be nice.

1 Like

I’ve just implemented this here.


if @dae thinks this is a worthwhile addition, I can open a pull request.


That page is getting a bit big again, and it may make more sense to split it out into a separate “Editing” tab. But so far we’ve only heard from one user - if a lot of demand doesn’t present itself, it may end up being better done in an add-on, as every option we add makes the UI more complicated, and adds to the maintenance burden.


This looks like a nice solution, though I understand dae’s concern with settings bloat. Excuse my ignorance (I’m not very familiar with the workings of GitHub), but is there any way I can implement the code you’ve linked to on my own? I couldn’t find any of the files mentioned on the page you linked to. Or is the only way for me to do this via an add-on?

May I ask why the current functionality is there? Like I outlined in the original post, I don’t understand the benefits of the audio playing automatically. If you want to hear what it looks like, you can just preview the card.

Using this is a bit complicated since you have to build dependencies and run from source.

I think this can be done with an add-on. I’ll do that and return to you later.


Copy the code below to a file named __init__.py and put it in a folder called something like editor_no_autoplay, then copy that folder to your addons21 folder found in Anki’s data folder.

import html
import urllib.parse

from aqt.editor import Editor, pics

def myFnameToLink(self, fname: str) -> str:
    ext = fname.split(".")[-1].lower()
    if ext in pics:
        name = urllib.parse.quote(fname.encode("utf8"))
        return '<img src="%s">' % name
        return "[sound:%s]" % html.escape(fname, quote=False)

Editor.fnameToLink = myFnameToLink

Having it autoplay allows users to confirm they selected the correct file. People are used to it, and complained when the behaviour changed.


Thank you so much for going above and beyond just to help out a stranger like me. I tested it out, and it works perfectly.

1 Like

@abdo , do you think a checkbox on the Recorder UI a good idea? Each time it pop up, user can choose whether to replay it.


I feel it’s more appropriate as an option in the preferences instead. The user will be busy speaking when this dialog is shown and they may not feel like checking boxes.
But as dae said above, there is not much demand for an option for controlling autoplay yet.

@abdo How about put three button, “Save & Replay” “Save” “Cancel”


Maybe this is better, though it still require the user to think about what button to click when they’re busy speaking. An option in the preferences makes more sense for me.
Anyway, that’s something for dae to decide and you can see his reply about adding a new option above.

1 Like

this code doesnt work . i add python file to addons21 but the package aqt cant be imported .

how can i solve this issue ?

Hmm, works for me. Could you copy the whole error message and post it here? What is your Anki version?

1 Like

so i opened python file with vscode . and i get this error . conda cant find the module aqt . i tried to download with pip but result is same .

The code is not meant to be run as a stand-alone program, so import errors are expected here. Do you have any problems using it with Anki as described above? what are you trying to accomplish? you can make sure the code works by recording audio in Anki’s note editor and seeing that there is no autoplay.