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];当我测试的时候发现amr格式没办法播放。AVAudioPlayer初始化为空,错误代码如下2015-01-12 17:52:10.862 AudioRecorder[4178:215524] The operation couldn’t be completed. (OSStatus error 2003334207.)
除了转换音频格式之外,有没有办法直接播放amr格式的文件。。
[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];当我测试的时候发现amr格式没办法播放。AVAudioPlayer初始化为空,错误代码如下2015-01-12 17:52:10.862 AudioRecorder[4178:215524] The operation couldn’t be completed. (OSStatus error 2003334207.)
除了转换音频格式之外,有没有办法直接播放amr格式的文件。。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货