I am using the following implementation in some JS code to get durations of audio files loaded in: http://jsfiddle.net/derickbailey/s4P2v/ (Taken from https://lostechies.com/derickbailey/2013/09/23/getting-audio-file-information-with-htmls-file-api-and-audio-element/.)
My implementation is the same, even using createObjectURL
. It works with MP3, AAC (.m4a), and FLAC fine, but not ALAC (also .m4a).
let length = 0;
let url = URL.createObjectURL(file);
let audio = new Audio(url);
audio.addEventListener('loadeddata', function () {
length = audio.duration;
}
Does anyone know how I can get the duration of ALAC files using pure JavaScript? I am not using any frameworks and am new to JS.
Thanks