Reputation: 8202
I been trying to figure out how to stream mic data from the android to flutter. I found some example code on how to query mic in chucks but I do not know a way to get the data onto flutter.
I am not sure which classes to look in flutter
https://docs.flutter.io/flutter/services/EventChannel/receiveBroadcastStream.html
I wonder if anyone can help me point to the right direction.
Upvotes: 4
Views: 4819
Reputation: 8202
I been digging through example plugins in flutter github and found this.
https://github.com/flutter/plugins/tree/master/packages/sensors
Unfortunately for me, EventChannel documentation is sparse. I do not believe we can pass streams from flutter to the platform so I can replay whatever I recorded in a feedback loop.
Event callback. Supports dual use: Producers of events to be sent to Flutter act as clients of this interface for sending events. Consumers of events sent from Flutter implement this interface for handling received events (the latter facility has not been implemented yet).
https://docs.flutter.io/javadoc/io/flutter/plugin/common/EventChannel.EventSink.html
The process is similar to creating a methodchannel, but I need to create an onCancel and onListen in android. Within the onListen, I must create also listener that could receive events. If I want to create audio events, I must use setPositionNotificationPeriod(int) and OnRecordPositionUpdateListener(listener).
https://developer.android.com/reference/android/media/AudioRecord.html
On flutter I must create a broadcast stream event
https://github.com/flutter/plugins/blob/master/packages/sensors/lib/sensors.dart
I manage to write my own terrible plugin that is android only atm. If anyone needs it I wonder what permissive license I should add
https://github.com/hungrymonkey/mic_stream
Upvotes: 7