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.
Resolved, see edit 2
The bar will never disappear as long as the mic is in use, recording or not. it's a security measure to allow the user to know that an app is listening to the microphone, not to show that the phone is recording.
The only way to get it gone is to remove the mic from the input receivers
I see that your mic isn't being removed, there has to be some bug.
Point is, you cannot hide the Red bar as long as the microphone is opened..
if you want to temporarily disable it, you can try this maybe ?
[audioController setInputEnabled:NO]
What are you trying to accomplish anyway? there might be a better way to handle things
Edit 1: Added other workarounds
I didn't know that setInputEnabled was readonly, sorry.
Well, another thing to try is to stop the controller completely, try this:
[audioController stop]
if not, try to release it if you're not using ARC, or simply
audioController = Nil;
Hope that fixes the issue. but I rather try to find out why it's not removing mic
from the input receivers.. perhaps mic
is Nil when you call [audioController removeInputReceiver:mic]
??
Edit 2:Added solution
The problem arises when you initialize with inputEnabled
set to YES
, since it's readOnly
, you can't disable the input, the only way is to actually release audioController
.
if you're using ARC, just set it to Nil
, if not, just [audioController release]
Try to set audio servicess off when you stop recording:
AudioSessionSetActive(false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With