Launch Anki with mplayer instead of mpv

I have encountered the bug described at Audio is broken

mplayer instead of mpv works for anki but causes problem (cpu overload) with some applications.
How could I use mplayer only for anki ?

Best regards,

1 Like

This simple add-on should make Anki fall back to mplayer:

from aqt import gui_hooks


def on_profile_did_open() -> None:
    from aqt.sound import av_player, mpvManager

    try:
        av_player.players.remove(mpvManager)
    except ValueError:
        pass


gui_hooks.profile_did_open.append(on_profile_did_open)
1 Like

Thanks for the answer. I wrote and loaded the addon but when I try to play a file, I got the message “no players found”.

Presumably you’d need something like the following as well

        mplayer = SimpleMplayerSlaveModePlayer(taskman, media_folder)
        av_player.players.append(mplayer)

Another alternative if you want to keep mpv installed would be to alias /bin/false to ‘mpv’, put it in a different folder, and put that folder at the top of the path prior to running Anki.

Thanks for the answer. So I need to add this code after the code proposed by Abdo ?

Here’s the updated code:

from aqt import gui_hooks, mw

def on_profile_did_open() -> None:
    from aqt.sound import av_player, mpvManager, SimpleMplayerSlaveModePlayer

    try:
        av_player.players.remove(mpvManager)
    except ValueError:
        pass

    mplayer = SimpleMplayerSlaveModePlayer(mw.taskman, mw.col.media.dir())
    av_player.players.append(mplayer)

gui_hooks.profile_did_open.append(on_profile_did_open)

3 Likes

Works perfectly! Many thanks.