我使用下面的代码播放声音
NSURL* musicFile = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"01" ofType:@"mp3"]];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile error:nil];
[audioPlayer play];
我想在完成时自动重复这个声音文件?
答案 0 :(得分:18)
audioPlayer.numberOfLoops = someNumber;
或“无限”循环次数:
audioPlayer.numberOfLoops = -1;
答案 1 :(得分:0)
player.numberOfLoops = -1;
[player prepareToPlay];
[player play];