Playing audio on desktop works fine with normal “toggle play audio player” workflow. But once it comes to iOS, it doesn’t work. I’m suspecting pre-loading audio might help in this case, but I’m not experienced with JS. I looked at a few stack overflow, here’s what I have so far, and it’s throwing errors:
var audioFiles = [
“test_audio.wav”, “test_audio2.wav”,
];
function preloadAudio(url) {
var audio = new Audio();
audio.addEventListener(‘canplaythrough’, loadedAudio, false);
audio.src = url;
audio.load();
}
for (var i in audioFiles) {
preloadAudio(audioFiles[i]);
}
Links I looked at: