I'm trying to achieve something that I thought will be super easy but turns out it's not.
I'm playing with the source code of "react-native-audio" library. But you can assume I'm working natively for the sake of this question.
Here is a reference for the source code I'm playing with.
My goal is simple, I'm using AVAudioRecorder to record a meeting (should take 30min approximately). In case of an incoming call in the middle of the recording, I'd like my app to be able to "recover" by doing one of the following options:
1) "pause" the record on "incoming call" and "resume" when app is back to foreground.
2) on incoming call - close the current file, and when app is back to foreground start a new recording (part 2) with a new file.
Obviously option (1) is preferred.
Please note that I'm well aware of using AVAudioSessionInterruptionNotification and use it in my experiments with no luck so far, for example:
- (void) receiveAudioSessionNotification:(NSNotification *) notification
{
if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) {
NSLog(@"AVAudioSessionInterruptionNotification");
NSNumber *type = [notification.userInfo valueForKey:AVAudioSessionInterruptionTypeKey];
if ([type isEqualToNumber:[NSNumber numberWithInt:AVAudioSessionInterruptionTypeBegan]]) {
NSLog(@"*** InterruptionTypeBegan");
[self pauseRecording];
} else {
NSLog(@"*** InterruptionTypeEnded");
[_recordSession setActive:YES error:nil];
}
}
}
Please note I will set up a bounty for this question but the only acceptable answer will be for a real world working code, not something which "should work in theory". Many thanks for the help :)
from AVAudioRecorder - how to recover from incoming call
No comments:
Post a Comment