作者:朱克鋒
郵箱:[email protected]
轉載請注明出處:http://blog.csdn.net/linux_zkf
和播放音樂執行個體幾乎沒有差別僅僅添加一行代碼
- (BOOL) prepAudio
{
NSError *error;
NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mp3"];
if (![[NSFileManager defaultManager] fileExistsAtPath:path])
{
return NO;
}
self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path]error:&error];
if (!self.player)
{
NSLog(@"Error: %@", [error localizedDescription]);
return NO;
}
[self.player prepareToPlay];
//就是這行代碼啦
[self.player setNumberOfLoops:1000000];
}