gpt4 book ai didi

android - 使用 Flutter 录音

转载 作者:行者123 更新时间:2023-12-01 15:26:12 27 4
gpt4 key购买 nike

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

最佳答案

您可以使用 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},");

关于android - 使用 Flutter 录音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58471609/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com