【发布时间】:2014-05-10 05:17:42
【问题描述】:
我正在使用 AVAudioRecorder 录制音频,它录制流畅,我可以播放或获取我正在使用以下代码初始化 AVAudioRecorder 的保存文件
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,
[NSNumber numberWithInt:AVAudioQualityLow], AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16], AVEncoderBitRateKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithFloat:16000], AVSampleRateKey,
nil];
NSArray *searchPaths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath_ = [searchPaths objectAtIndex: 0];
NSString *pathToSave = [documentPath_ stringByAppendingPathComponent:[self dateString]];
self.pathfinal = pathToSave;
NSURL *url = [NSURL fileURLWithPath:pathToSave];
recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];
if (!recorder)
{
return NO;
}
recorder.delegate = self;
recorder.meteringEnabled = YES;
if (![recorder prepareToRecord])
{
return NO;
}
if (![recorder record])
{
return NO;
}
但是我的一些客户在停止录制(将保存在磁盘上的步骤)时遇到问题,它不会保存任何创建文件的内容,但每次录制时都没有数据。
但是当使用不同的 iPhone 时,这不是问题。 iPhone 有 2gb 可用硬盘空间。知道是什么原因造成的吗?
【问题讨论】:
标签: ios objective-c avaudiorecorder