I am using the HTML5 FileReader and File API to make a offline music player. This also includes a basic playlist feature.
Now, when the user selects multiple files, I am retrieving those files as an ArrayBuffer.
Problem is, I want to store these returned files into a normal array so that they can be used in the playlist later.
How can I achieve that in Javascript?
function load_files(){
var files = document.getElementById('file').files;
var k = files.length;
for (var i = 0; i < k; i++) {
var reader = new FileReader();
reader.onload = function(e) {
playlist[i] = this.result;
};
reader.readAsArrayBuffer(this.files[i]);
alert(song_counter);
initSound(playlist[song_counter]);
}
}