1

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

Bob5421
  • 7,757
  • 14
  • 81
  • 175
  • 1
    Please refer - https://stackoverflow.com/questions/43816266/saving-audio-to-localstorage-for-playback – rajk Feb 09 '18 at 20:12
  • See my edit, i have forget something, my question is different – Bob5421 Feb 10 '18 at 15:48
  • Web Audio API allows control of left or right channel for rendering ... I take it you want to avoid other option of pre-processing both channels into one media file prior to rendering ? – Scott Stensland Feb 10 '18 at 16:41

0 Answers0