在我的应用程序中,我使用AudioToolbox框架,我需要播放循环,可以吗?
这是同时进行两次触摸的AVAudioplayer代码,运行速度很慢
- (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;
}在视图中加载
ViewDidLoad {
self.Note = [self getNoteFromFilename:@"Note" andoftype:@"wav"];
}在IBAction中通过以下方式调用它:
[Note prepareToPlay];
[Note play];注:我保留了所有的按钮和AVAudioPlayer
发布于 2010-10-17 21:33:21
请改用AVAudioPlayer。在那里,您可以很容易地使用numberOfLoops属性进行循环。
https://stackoverflow.com/questions/3953358
复制相似问题