1

AVAudioPlayer *myExampleSound;

NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@"myaudiofile" ofType:@"caf"];

myExampleSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:myExamplePath] error:NULL];

myExampleSound.delegate = self;

[myExampleSound play];

如何播放 myExampleSound 以使其在结束后自动重播?我正在使用上面的代码。

任何人请帮忙。

4

1 回答 1

1

AVAudioPlayerDelegate 有一个方法

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag

在声音播放完毕后调用。你必须实现这个方法,然后你才能再次播放你的声音。

于 2010-04-01T15:00:31.083 回答