Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide Red Recording Status Bar In iOS App When Not Recording

I can't get the red "Recording" status bar to hide in my app when the app is in the background and not recording.

enter image description here

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?

Update

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.

like image 599
bendytree Avatar asked Jun 02 '13 01:06

bendytree


2 Answers

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]

like image 95
Mostafa Berg Avatar answered Sep 17 '22 13:09

Mostafa Berg


Try to set audio servicess off when you stop recording:

AudioSessionSetActive(false);
like image 28
BlueConga Avatar answered Sep 19 '22 13:09

BlueConga