I can't get the red "Recording" status bar to hide in my app when the app is in the background and not recording.
I happen to be using The Amazing Audio Engine, but I think this question could be tackled knowledge of that library. It gets setup like this:
audioController = [[AEAudioController alloc] initWithAudioDescription:desc inputEnabled:YES];
audioController.audioSessionCategory = kAudioSessionCategory_MediaPlayback;
When the user wants to record, I turn on the mic like this:
[audioController addInputReceiver:mic];
audioController.audioSessionCategory = kAudioSessionCategory_PlayAndRecord;
When the user wants to stop recording, I turn it off:
[audioController removeInputReceiver:mic];
audioController.audioSessionCategory = kAudioSessionCategory_MediaPlayback;
The problem is, when the app isn't recording & the user leaves the app, the red "Recording" status bar still shows up. I can't stop/dispose the audioController because the app may still be playing audio.
I don't want the red recording status bar to show if I'm not recording. Any ideas how to do this?
I setup the following block of code to run every 2 seconds in my app.
audioController.audioSessionCategory = kAudioSessionCategory_MediaPlayback;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError* error = nil;
[audioSession setActive:NO error: &error];
NSLog(@"error: %@", error);
[audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
This logs:
TAAE: Setting audio session category to MediaPlayback
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryEnableBluetoothInput) result 2003329396 77686174 what
Error Domain=NSOSStatusErrorDomain Code=560030580 "The operation couldn’t be completed. (OSStatus error 560030580.)"
Obviously it fails to disable the mic because of something TAAE is holding on to. I have not added any inputs to the controller, so I don't know what it could be.
Try to set audio servicess off when you stop recording:
AudioSessionSetActive(false);