'How to check microphone is already been use or not flutter?

I am building a chat application in which I am sending voice messages. Now when I am calling or any other mobile app is using a microphone then my chat app voice record does not work. How I can check the status of the microphone in a flutter whether it's already in use or not. Thanks



Solution 1:[1]

You can try to check flutter audio_session

interceptSession = await AudioSession.instance;
AudioSession.instance.then((audioSession) async {
  await audioSession.configure(AudioSessionConfiguration(
      avAudioSessionCategory: AVAudioSessionCategory.playAndRecord));
});

await interceptSession.interceptSession.setActive(true);

Solution 2:[2]

This plugin informs the operating system of the nature of your audio app (e.g. game, media player, assistant, etc.) and how your app will handle and initiate audio interruptions (e.g. phone call interruptions). It also provides access to all of the capabilities of AVAudioSession on iOS and AudioManager on Android, providing for discoverability and configuration of audio hardware.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 dannyxu