//开始录音
- (void)startRecording
{
AVAudioSession * session = [AVAudioSession sharedInstance];
NSError * sessionError;
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:&sessionError];
if(session == nil)
NSLog(@"Error creating session: %@", [sessionError description]);
else
[session setActive:YES error:nil];
}
//结束录音
- (void)stopRecording
{
//&& self.audioRecorder.isRecording
if (self.audioRecorder && self.recordingState == ECDialogLineRecordingStateRecording)
{
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayback error:nil]; //此处需要恢复设置回放标志,否则会导致其它播放声音也会变小
self.currentAudioTime = self.audioRecorder.currentTime;
[[self audioRecorder] stop];
}
}
网友评论