Flutter plugin that can support audio recording and level metering
flutter_audio_recorder
Flutter Audio Record Plugin that supports Record
Pause
Resume
Stop
and provide access to audio level metering properties average power
peak power
(currently for iOS only)
Installation
add flutter_audio_recorder
to your pubspec.yaml
iOS Permission
add usage description to plist
<key>NSMicrophoneUsageDescription</key>
<string>Can We Use Your Microphone Please</string>
Usage
Init (run this before start
, so we could check if file with given name already exists)
var recorder = FlutterAudioRecorder("filename", AudioFormat.AAC);
await _recorder.initialized;
or
var recorder = FlutterAudioRecorder("filename.mp4"); // .wav .aac .m4a
await _recorder.initialized;
Start recording
await recorder.start();
var recording = await recorder.current(channel: 0);
Get recording details
var current = await recording.current(channel: 0);
// print(current.status);
You could use a timer to access details every 50ms(simply cancel the timer when recording is done)
new Timer.periodic(tick, (Timer t) async {
var current = await recording.current(channel: 0);
// print(current.status);
setState(() {
});
});
Recording
Name | Description |
---|---|
path | String |
extension | String |
duration | Duration |
audioFormat | AudioFormat |
metering | AudioMetering |
status | RecordingStatus |
Recording.metering
Name | Description |
---|---|
peakPower | double |
averagePower | double |
isMeteringEnabled | bool |
Recording.status
Unset
,Initialized
,Recording
,Paused
,Stopped
Pause
await _recorder.pause();
Resume
await _recorder.resume();
Stop (after stop
, run init
again to create another recording)
var result = await _recorder.stop();
File file = widget.localFileSystem.file(result.path);
Example
Please check example app using Xcode.