konradowy
konradowy

Reputation: 1570

Disabling microphone programmatically

I wonder if there is any way to disable microphone programmatically (to get rid of the red bar in the background)?

I use OpenEars to listen for commands in the app. When I go to the background red bar appears (which is obvious, as microphone is active). The problem is that the microphone is active even when OpenEars is suspended. To avoid unnecessary questions I cannot stop OpenEars as it ends up with mixing audioSession with my other sources.

Upvotes: 3

Views: 2105

Answers (2)

Elias Limneos
Elias Limneos

Reputation: 960

I'm not sure if it falls into stopping OpenEars case per se, but have you tried switching AudioSessionCategory when your app goes into background/suspended mode? If you switch to a category that doesn't allow microphone input, my guess is it would stop the microphone. Then you could reset to the correct category when your app resumes.

Upvotes: 0

JAL
JAL

Reputation: 42479

The "red bar" will never disappear, even when the microphone is not in use by your application unless you explicitly stop the audio session. This is a security measure Apple has put in place to alert users of your application that it is listening to their microphone, even if you aren't doing anything with the microphone data at that exact moment.

If you are using AUAudioUnit, you may have some luck setting isInputEnabled to false.

Upvotes: 4

Related Questions