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
100 stars 68 forks source link

MissingPluginException on macOS #30

Closed peacememories closed 2 years ago

peacememories commented 2 years ago

Hi, thanks for creating this library :)

I'm running into a bit of a problem with this package on macOS. When I try to get the microphone, i get the following error:

MissingPluginException(No implementation found for method requestPermissions on channel flutter.baseflow.com/permissions/methods)

Looking into permission_handler it seems it does not have support for macOS, so that might be the reason?

anarchuser commented 2 years ago

thanks for bringing this up, I'll have a look later.

anarchuser commented 2 years ago

I can't seem to find a permission plugin for macOS. Could it be possible that macOS permissions can be handled through the iOS part and that the problem is something else? Either way, the error is definitely raised by permission_handler.

If you can find a way to permit macOS to record audio I'm happy to update this plugin

peacememories commented 2 years ago

Phew, I'm actually pretty new to Flutter and macOS development, so I might take a while^^ I guess one way to check is to create a fork that does not try to use permission_handler when running on macOS and see what happens?

peacememories commented 2 years ago

So I loaded mic_stream from disk and changed the permissionStatus getter to just return true. This apparently works on macOS 12.1, the microphone activates and I get some samples.

The samples I get are kinda weird, with my bluetooth headset I got very quiet samples, but I could see changes when I screamed at the laptop (it didn't actually seem to use my headset? it's weird). When I disconnected the headset I got stronger samples, but it looked more like white noise.

But all of that does not seem like it's a permission problem. It might be, though, that it just works because Android Studio already has microphone permissions for whatever reason...

anarchuser commented 2 years ago

thanks for trying it out.

The plugin uses the default microphone on a given system; for phones that usually suffices. Maybe you want to check which device exactly records the samples, e.g., by producing loud noise with all possible mics physically separated. That may also give a hint about the white noise with your headset disconnected.

Regarding Android Studio... well, it might do some weird stuff. Suggestion: uninstall the test app and reinstall it not with AS but with the flutter CLI directly. I think flutter run should do the magic. Reinstalling ought to clear any permission statūs. Relatedly, does the error appear every run?

anarchuser commented 2 years ago

I've integrated and published @superkeka 's fix in version 0.5.4. Please update your pubspec.yaml, run flutter pub upgrade and verify that it works now.