Autoplay Audio is slow

Autoplay is still slow because we aren’t prefetching the audio file while the user is typing in the answer.

I’ve had to update the brute-force pre-load everything script.
There were some changes to data that was being returned in willShowNextQuestion.

Here is what works for me.

window.addEventListener('willShowNextQuestion', (ev) => {
  console.log(ev)
  if(ev["detail"]["subject"]["readings"]) {
    for(const reading of ev["detail"]["subject"]["readings"]) {
	  const pronunciation = reading["pronunciation"];
	  for(const source of pronunciation["sources"]) {
		var audio = source["url"];
		console.log("Pre-fetching " + audio);
        fetch(audio, {mode: 'no-cors'});
      }
    }
  }
})
1 Like