anarchuser / mic_stream

Flutter plugin to get an infinite audio stream from the microphone
https://pub.dev/packages/mic_stream
GNU General Public License v3.0
101 stars 69 forks source link

MicStream.microphone() silences audio player plugins #66

Open asmodeoux opened 1 year ago

asmodeoux commented 1 year ago

I'm trying to use this mic stream in an app and play some sound effects at the same time. But once the mic stream initializes and starts listening, all the sound effects are silenced. I tried just_audio and audioplayers libs and both fail to play any sound when this mic plugin is active. This behavior is only in iOS, in Android both audio input and output work well at the same time. What might be wrong and how can I fix it?

asmodeoux commented 1 year ago

I found what's causing this, the plugin sets the AudioCategory in iOS to record-only, while I think it should be playAndRecord, or maybe even configurable: try audioSession.setCategory(AVAudioSession.Category.playAndRecord, mode: .measurement, options: [.defaultToSpeaker, .mixWithOthers])

anarchuser commented 1 year ago

hey, thank you for taking your time to look into this yourself already.

It's very likely that changing the category will resolve this issue. I cannot reliably test this, though, and therefore cannot fix this myself. I'd appreciate if you can fix this, make sure it runs, and open a PR. I'm happy to help with anything in the process, as long as it isn't platform-specific.