With some help here and on Reddit, I got much closer to my little goal which is to emulate the behavior of the Glossika app with my own soundfiles + subtitles in Anki.
-
I discovered the Auto-advance feature the other day, which has an option to “wait for audio”
-
I have the code bellow that allows to play a given mp3 n times (specified in a {{Repeat}} ) with a specific playbackRate (specified in {{Speed}} ). With the little modulo 2 mechanics I’m even able to alternate unmuted and muted audio, to give myself enough time to repeat.
This way for instance, I can review older cards only a couple times each time with normal or faster speed, and spend more time on newer cards with slower speed and 4-5 repetitions each. So just the way I would do in Glossika, but actually smarter.
This repeating / muting / playback systems works great when I preview the card on both Desktop and AnkiMobile.
But there is another problem I cannot figure out… (see below)
<div style='font-family: Hoefler Text; font-size: 27px;'>{{Hanzi}}</div>
<div style='font-family: Hoefler Text; font-size: 17px;'>{{Pinyin}}</div>
<audio controls id="player">
<script>
{
const audios = Array({{Repeat}} * 2).fill(`{{Audio}}`);
const player = document.getElementById("player");
let index = 0;
player.addEventListener("ended", () => {
if (++index < audios.length) {
player.src = audios[index];
player.muted = index % 2;
player.playbackRate = {{Speed}}
player.play();
} else {
// If there are no more audio files, make it possible to play from
// the first file again when the play button is clicked.
index = 0;
player.src = audios[index];
}
});
// play the first audio file
player.src = audios[index];
player.playbackRate = {{Speed}}
player.play();
}
</script>
For some reason I can’t seem to reconcile these two solutions. Either on Anki Desktop or Mobile (on iOS), turning on the Auto-advance just jumps to the next cards instantly, without waiting for Audio.
@dae is Auto-advance only aware about the default audio tag (drag and drop, with [Audio:foo.mp3] in the card) and not html audio elements way?
Do you see any way around it? I understand from many older posts here that the default one has limitations, but maybe that’s not the case anymore?
Otherwise, would this justify to introduce a little more flexibility on orchestrating time with the Auto-advance, or some way to do this in the card definition (some kind of “wait” and “force next” events) would be very relevant for language practice.
For instance, after my 3 audios (and 3 muted audios interleaved), I would probably like to add 1-2 seconds to breathe before the next card.
Thanks in advance for your help !