iphone:AVAudioRecorder 录音总是返回 FALSE
<p><p>我正在使用 AVAudioRecorder 来录制声音,但是我遇到了问题。</p>
<p>调用方法后,recorder.recording的值一直返回FALSE,让我无法停止录音。</p>
<p>我在 iOS 5 上使用 XCode 4.2,我的 iPad 也是 iOS 5 上的 ipad 2。</p>
<p>这是我的代码:</p>
<pre><code> self.currentFileName = ;
NSURL *url = stringByAppendingPathComponent:currentFileName]];
NSError *err = nil;
AVAudioRecorder *aRecorder = [ initWithURL:url settings:recordingSettings error:&err];
if( err ){
NSLog(@"could not create a recorder: %@ %d %@", , , [ description]);
return;
}
self.startRecordingTime = ;
recordingLength = 0.0f;
//setup recorder and start recording
;
aRecorder.meteringEnabled = YES;
;
self.recorder = aRecorder;
BOOL test = recorder.recording;
;
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>尝试在 之后使用 AVAudioSession</p>
<pre><code> NSError *err = nil;
audioSession = ;
;
// route to speaker
UInt32 ASRoute = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(ASRoute), &ASRoute);
if (err)
{
NSLog(@"audioSession: %@ %d %@", , , [ description]);
}
;
</code></pre></p>
<p style="font-size: 20px;">关于iphone:AVAudioRecorder 录音总是返回 FALSE,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/7914712/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/7914712/
</a>
</p>
页:
[1]