如何播放音乐,以便在结束后自动播放音乐?
问题描述:
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,使其在结束后自动重播? 我正在使用上面的代码。
请人帮忙。
答
的AVAudioPlayerDelegate得到了一个方法
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
声音播放完毕后调用。您必须实施此方法,然后才能够再次播放声音。