Hello everyone, thanks for all your work at first.
I have multiple audios in one card, and I want to automatically replay one specific audio in a loop.
A simple
<audio id="audioreplay" src="{{audiofile}}.mp3" autoplay loop></audio>
(referred to as tag_a latter) should do the work, and it works when I uncheck Don't play audio automatically option of my deck, but the other audio files with [sound:xxx] format also are played once.
I don’t want the other audio to play, thus I check Don't play audio automatically option. However, my tag_a won’t get played.
I searched for several days and tried some js codes like
var replayer = document.getElementById("audioreplay");
replayer.play();
which also not worked.
And the error I got is Uncaught (in promise) DOMException: play() can only be initiated by a user gesture.
According to https://forums.ankiweb.net/t/is-it-possible-to-load-audio-dynamically-with-javascript/13011/6, and the newest code: https://github.com/ankitects/anki/blob/main/qt/aqt/reviewer.py#L372, when audio automatically play is off, the play() will failed since self.web.setPlaybackRequiresGesture(True).
So how to get my play() call to work? Can you give me some suggestions? Maybe self.web.setPlaybackRequiresGesture(True) should be removed in anki code?
I know I can add a button and call play() in it’s click function, but I just want to this audio play automatically when I click show answer.
Thanks for reading!