Reputation: 2609
I am working on a project in which I am recording voice and uploading it to the server. The Uploaded file format is .caf (Core Audio Format)
Now, when I try to play this file from server using AVPLayer
then it is giving error message below.
Error Domain=AVFoundationErrorDomain Code=-11819 "Cannot Complete Action" UserInfo=0x2f31e0 {NSLocalizedRecoverySuggestion=Try again later., NSLocalizedDescription=Cannot Complete Action}
I have checked the file on the server and it is not corrupted.
My question is: can .caf file support streaming ? if not then in which format I need to convert my recorded file that support streaming ?
Upvotes: 0
Views: 505
Reputation: 3015
use this setting in AVAudioSession
use .mp4 for play audio both side:
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];
Upvotes: 2