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.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.