cordova-plugin-nativeaudio
cordova-plugin-nativeaudio copied to clipboard
Play an array sound list
Hi! I have an array with some .mp3's id, for example:
$scope.list = ['bass', 'bass', 'bongo'];
And I want to play that sequence with a general form. I tried a forEach, like this:
angular.forEach($scope.list, function(value, key) { window.plugins.NativeAudio.play(value); });
But that plays all the audios at the same time. I tried using completeCallback and worked, but I had to put manually each element of the array. Is there any function or method to play one by one?
Sorry my bad english. Thanks!!
Finally a friend helped me. If it helps someone the solution is inserting the function "play" into a $timeout, and asigning an incremental variable at delay. Like this:
var delay = 0; angular.forEach($scope.list, function(value, key) { $timeout(function() { window.plugins.NativeAudio.play(value); }, delay); delay += 1000; //1s });
Sorry my bad english!!