danielstern/ngAudio

No ability to load multiple links in loop

Closed this issue · 2 comments

I would like to load a series of audios in loop, because i need duration of each file.
_.map(data, function(r) { var a = ngAudio.load(l); return a; });
Unfortunately it returns series of audios with the same duration and the same sound. (sound of the last one)

Happy to look at a PR for this

nbstr commented
// SOUNDS
var _snd_list = [
    "open.mp3",
    "close.mp3"
];
$rootScope.SND = {};
for(var e in _snd_list){
    $rootScope.SND[_snd_list[e]] = ngAudio.load("snd/"+_snd_list[e]);
}

then, when I try to play one of them,

$rootScope.SND["close.mp3"].play();
$rootScope.SND["open.mp3"].play();

they both play the same close.mp3 sound..
is there a callback after a file is loaded ? Or am I doing something wrong ?
(if you ask, I noticed a delay when I play the sounds immediately without preloading them, they are very light (<1s) and I'd like to preload the 5 of them before playing them)