How can I stop AVAudioPlayer from repeating before it reaches the end of my data?
问题 I'm playing looped sound with AVAudioPlayer by setting the numberOfLoops property to -1. And I want to control the loop rate programmatically, so I'm loading my audio data like this: NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"Click" ofType:@"aif"]; NSMutableData *soundData = [NSMutableData dataWithContentsOfFile:soundFilePath]; And then changing its length before initializing the audio player: int loopDuration = .5; // seconds int desiredDataLength = loopDuration * 2 *