This is the code I have right now for pausing a recording when a user receives a phone call and resuming it after they hang up.
- (void)handleAudioSessionInterruption:(NSNotification *)notification
{
NSNumber *interruptionType = [[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey];
switch (interruptionType.unsignedIntegerValue) {
case AVAudioSessionInterruptionTypeBegan:{
_currentAudioSessionMode = EXAVAudioSessionModeInactive;
if (_audioRecorder.recording) {
[_audioRecorder pause];
[self demoteAudioSessionIfPossible];
}
} break;
case AVAudioSessionInterruptionTypeEnded:{
_currentAudioSessionMode = EXAVAudioSessionModeActive;
if (_audioRecorder && !_audioRecorder.recording) {
if (_allowsAudioRecording) {
[self promoteAudioSessionIfNecessary];
_audioRecorderShouldBeginRecording = true;
[_audioRecorder record];
}
_audioRecorderShouldBeginRecording = false;
}
} break;
default:
break;
}
What I would like to achieve is to keep recording, but capture pure silence while a user is on a phone call. This is how it works on Android and we care about the correct duration of the recording. Any idea how to do it?