使用 Flutter 录音

Dev*_*dwa 5 android voice-recording ios dart flutter

我正在尝试使用 Flutter 构建一个应用程序,其中将包含录音机。我如何访问录音机?请帮我找出它的包、依赖项和代码。

小智 5

您可以使用audio_recorder包:

https://pub.dev/packages/audio_recorder

// Import package
import 'package:audio_recorder/audio_recorder.dart';

// Check permissions before starting
bool hasPermissions = await AudioRecorder.hasPermissions;

// Get the state of the recorder
bool isRecording = await AudioRecorder.isRecording;

// Start recording
await AudioRecorder.start(path: _controller.text, audioOutputFormat: AudioOutputFormat.AAC);

// Stop recording
Recording recording = await AudioRecorder.stop();
print("Path : ${recording.path},  Format : ${recording.audioOutputFormat},  Duration : ${recording.duration},  Extension : ${recording.extension},");
Run Code Online (Sandbox Code Playgroud)