0

在我的应用程序中,我使用 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

4

1 回答 1

0

请改用AVAudioPlayer。在那里,您可以轻松地使用该numberOfLoops属性进行循环。

于 2010-10-17T13:33:20.783 回答