我正在做一个项目,在这个项目中,我录制声音并上传到服务器上。上传的文件格式是.caf (核心音频格式)
现在,当我尝试使用从服务器使用AVPLayer播放这个文件时,它在下面给出了错误消息。
Error Domain=AVFoundationErrorDomain Code=-11819 "Cannot Complete Action" UserInfo=0x2f31e0 {NSLocalizedRecoverySuggestion=Try again later., NSLocalizedDescription=Cannot Complete Action}
我已经检查了服务器上的文件,它没有损坏。
我的问题是:.caf文件能够支持流吗?如果没有,那么我需要以哪种格式转换支持流的录制文件?
发布于 2013-07-22 11:11:07
在AVAudioSession中使用此设置
使用.mp4播放音频双方:
AVAudioSession * audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: &error];
[audioSession setActive:YES error: &error];
NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
NSURL *recordedTmpFile = [NSURL fileURLWithPath:yourdirectorypath];
//file=[NSString stringWithFormat:@"%@",recordedTmpFile];
NSLog(@" filr url%@",recordedTmpFile);
// NSLog(@" filr url%@",file);
recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];
[recorder setDelegate:self];
[recorder prepareToRecord];
[recorder record];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; https://stackoverflow.com/questions/17785925
复制相似问题