I am trying to record and saave mp3 file so I use the following code
NSString* d = @" ar/mobile/Applications/86F15C5E-66EC-4071-95EB-96CDE64B5948/Library/Application Support/P/5720/5720/Report/Report0.mp3"
NSURL *soundFileURL = [NSURL fileURLWithPath:d];
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:44100.0],
AVSampleRateKey,
nil];
NSError *error = nil;
audioRecorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error];
if (error)
{
NSLog(@"error: %@", [error localizedDescription]);
} else {
[audioRecorder prepareToRecord];
}
and to start record I use
[audioRecorder record];
for mp3 I got error error: The operation couldn't be completed. (OSStatus error 1718449215.)
and if I saved it as wav nothing be recorded , and the file be 0 byte
am I missing something , any idea how to solve that
you're not showing the way Dpath is defined...
NSString * filePath = [NSHomeDirectory()stringByAppendingPathComponent: [NSString stringWithFormat:@"Documents/%@.mp3",songTitle]];
// more code
recorder = [[AVAudioRecorder alloc] initWithURL: [NSURL fileURLWithPath:filePath settings: recordSettings error: nil];
perhaps save it to the documents folder? Isn't that the correct legal path?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.