在我的应用程序中,我使用 AudioToolbox 框架,我需要播放循环可以吗?
这是 AVAudioplayer 代码,同时进行 2 次触摸时运行缓慢
- (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;
}
在视图didload
ViewDidLoad {
self.Note = [self getNoteFromFilename:@"Note" andoftype:@"wav"];
}
在 IBAction 中通过 this 调用它:
[Note prepareToPlay];
[Note play];
注意:我保留了所有按钮和 AVAudioPlayer