Control autoplay for each audio tag

I want to be able to control the autoplay feature for each independent audio tag.

I’ve seen some solutions using javascript to control which audio files gets autoplayed, but there’s no way to check whether or not a certain audio file has stopped playing, so this solution does not work if you want to play more than one audio file.

A new audio tag syntax might be appropriate.
For example:
[!sound:audio.mp3] → audio will never autoplay
[@sound:audio.mp3] → audio will always autoplay

There’s this pull request proposing something similar: Added arguments as [sound:filename|argument1 argument2...] by evandrocoan · Pull Request #540 · ankitects/anki · GitHub
But it doesn’t seem to be going anywhere from what I can see.

4 Likes

I’d like to bump this thread since I recently saw the need for such a functionality.

Has this been put on the docket or has it been forgotten about? - Just asking, because this really would be a useful feature.

There are more suggestions out there than resources available, so it may be some time before a given suggestion is implemented, and some may never be.

I think this is a great idea, because I have cards where I want audio every time as well as cards where I only want audio when I need it. Something like {{tts zh_CN autoplay=true voices=Apple_Tingting:Word}}, where the default is the existing deck setting, would be pretty helpful.

The current solution for me has been to turn off autoplay for all cards and to use this javascript to autoplay audio on particular cards. (If you go through the thread, there are solutions for more complex situations.) The main problem for me is that the javascript causes the mobile app to lag a bit, and maybe it takes a bit longer to play on desktop too.