29,027
社区成员
发帖
与我相关
我的任务
分享
if (self.avPlay.playing) {
[self.avPlay stop];
return;
}
NSError* error;
NSString* path=[NSString stringWithFormat:@"%@/test.amr",[[NSBundle mainBundle] resourcePath]];
NSURL* temUrl=[NSURL fileURLWithPath:path];
NSData*data =[NSData dataWithContentsOfFile:path];
// AVAudioPlayer *player = [[AVAudioPlayer alloc]initWithData:data error:&error];
AVAudioPlayer *player = [[AVAudioPlayer alloc]initWithContentsOfURL:temUrl error:&error];
// AVAudioPlayer *player = [[AVAudioPlayer alloc]initWithContentsOfURL:urlPlay error:&error];
if (!player) {
NSLog(@"%@",[error localizedDescription]);
}
self.avPlay = player;
[player release];
[self.avPlay play];