I am trying to play audio in an html file:
var soundFile = document.createElement("audio");
soundFile.preload = "auto";
var src = document.createElement("source");
src.src = url_of_mp3_file;
soundFile.appendChild(src);
soundFile.load();
soundFile.play();
It works, but i have some latency. I think this is because it needs some time to download full audio file (i am on a local Ethernet network).
Is there a better way to do that ? I mean for example, is it possible to pre-download all my audio files in browser local storage and then play on demand files from this location ?
** EDIT **
And i want to play 2 mono files at the same time: One file on Left channel and the other on right channel.
Thanks