Can I play loops using Audio Toolbox?
in my app i use AudioTo开发者_Python百科olbox framework and i need to play a loop can i ?
this is the AVAudioplayer code that goes slowly with 2 touches simultaneously
- (AVAudioPlayer *)getNoteFromFilename:(NSString *)name andoftype:(NSString *)type{
NSString *soundPath = [[NSBundle mainBundle] pathForResource:name
ofType:type];
NSURL *fileURL = [NSURL fileURLWithPath:soundPath];
AVAudioPlayer *note = [[[AVAudioPlayer alloc] initWithContentsOfURL:fileURL
error:nil] autorelease];
return note;
}
in the viewdidload
ViewDidLoad {
self.Note = [self getNoteFromFilename:@"Note" andoftype:@"wav"];
}
calling it by this in IBAction :
[Note prepareToPlay];
[Note play];
NB: i have retaind all the button and the AVAudioPlayer
Use AVAudioPlayer instead. There you can easily loop using the numberOfLoops
property.
精彩评论