If I have a card with one missing audio file, or it can’t access the audio file for whatever reason (i.e. audio is an online link and there is no Internet) then MPV just completely gives up and no subsequent audio files on any subsequent cards will ever play. Killing MPV using the equivalent of Task Manager used to fix it. But now the only fix is to restart Anki.
This caused frustration while I was traveling today offline and every one of my cards had one field that used internet-based audio - it broke every audio (even files I downloaded) and obviously restarting the program was not feasible.
Maybe you’re using some old Anki version. Since Anki 25.02.6, playback of remote audio URLs via mpv has been disabled due to CVE-2025-62187. Instead, Anki will try to play the filename (the last part of the url) from the collection.media folder (if it exists).
Specially-crafted sound file references could cause files to be written to arbitrary locations on Windows & Linux.
References to audio files outside of the media folder are no longer allowed.
Maybe try updating to the latest Anki version (25.09.2) and use the Localize Media add-on to download remote audio files or use Find and Replace to replace [sound:https://upload.wikimedia.org/wikipedia/commons/0/0c/En-us-audio.ogg] with <audio src="https://upload.wikimedia.org/wikipedia/commons/0/0c/En-us-audio.ogg" controls></audio> (or edit the underlying HTML using the </> button at the right side of the field) to be able to play remote audio links in the latest Anki version.
To play the <audio> tag automatically, the following code could be added to the front or back template, but if some card also includes one or more [sound:...] tags, the audio will be played at the same time.
mpv –version reveals I have an earlier version of both mpv and FFmpeg but the most recent version of Anki.
I tried sudo apt update and then sudo apt install mpv, neither of those changed anything (it still thinks the old version I’m running is the newest). Does that mean I have to update my kernel? (I manually downgraded to an older one because I was having freezing issues)
edit: updating the Kernel does not unlock the new version. I am running Linux Mint 22.2
No, the kernel has nothing to do with it. You can only download a more recent version of mpv if the repositories of your distro ship newer versions. So if you want a newer mpv version, then you have to upgrade the entire OS. It doesn’t seem like there is a newer Linux Mint version available, though, which means the mpv version you currently have is the one you’re stuck with for now. This isn’t neccessarily a bad thing though; there is value in fixed release models (I use debian for that very reason).
Anyways, you can try this next:
Also try this if you haven’t already:
If only online files are affected, you might want to try downloading the files to solve your issue. I never used that addon, but this seems logical if you want to do it in batch:
(I wouldn’t recommend the other option posted by @kelciour where <audio> tags are used; mostly because it makes playing multiple audio files in succession more difficult to set up and it interferes with Ankis “unused file” detection)
Maybe the output will contain some useful information why there’s no sound.
It should be fine. Though the <audio> tag is not officially supported, the audio file will still be detected as “used” by Check Media and should be included in the exported apkg file as well.
I tried your code and it didn’t output anything in that folder (neither before nor after MPV breaks). Maybe there is a way to have it output directly in the console that appears?
Not sure if this is of any use - this started happening after I downloaded this conversion addon which switched my MP3’s to OPUS and JPG’s to AVIF.
Some of my media files are referenced on multiple cards and if one of those cards was not in the batch selection that I converted, the references would not change, causing a “missing media“ error to appear and all audio playback to stop. I have manually corrected the references on a lot of these cards, but the issue still persists sometimes.
Travelling again today (return trip from my original post)
All audio broke again even after switching to mplayer.
The problem is not with the Anki app itself but rather the addon that fetches Google TTS audio for the given field on the card. So maybe I should take it up with the addon developer.
However, this particular addon is linked on the official Anki documentation for Text to Speech voice creation…