in my project I have multiple recordings taken from the iPhones microphone which I loop with this code
-(IBAction)loop1{
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:temporaryRecFile error:&error];
audioPlayer.numberOfLoops = 100;
[audioPlayer play];
}
and stop with this code
-(IBAction)loopstop1{
audioPlayer.numberOfLoops = 0;
[audioPlayer stop];
}
When more than one recording is looping however this stop method only stops the last recording that was set to loop, I’m wondering if there is anyway to break out of all audio loops, or break these specific loops, as I am only managing to stop the last recording I have looped.
thanks for any help or advice
What I would do :
NSMutableArrayto hold theaudioPlayersAdd your
AVAudioPlayerobjects to your arrayPass an index to each of the start / stop functions, to know which
audioPlayerto start/stop.Hint : To stop all of them, just call the
stopmethod on each of your loops store in theloopsArray