代码拉取完成,页面将自动刷新
Audio recorder from microphone to a given file path.
No external dependencies:
External dependencies:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!-- Optional, you'll have to check this permission by yourself. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<key>NSMicrophoneUsageDescription</key>
<string>We need to access to the microphone to record audio file</string>
<key>NSMicrophoneUsageDescription</key>
<string>We need to access to the microphone to record audio file</string>
In capabilities, activate "Audio input" in debug AND release schemes
min SDK: 10.15
Feature | Android | iOS | web | Windows | macOS | linux |
---|---|---|---|---|---|---|
pause/resume | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
amplitude(dBFS) | ✔️ | ✔️ | ✔️ | |||
permission check | ✔️ | ✔️ | ✔️ | ✔️ | ||
num of channels | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
device selection | (auto BT/mic) | ✔️ | ✔️ | ✔️ | ✔️ |
Encoder | Android | iOS | web | Windows | macOS | linux |
---|---|---|---|---|---|---|
aacLc | ✔️ | ✔️ | ? | ✔️ | ✔️ | ✔️ |
aacEld | ✔️ | ✔️ | ? | ✔️ | ||
aacHe | ✔️ | ✔️ | ? | ✔️ | ✔️ | ✔️ |
amrNb | ✔️ | ✔️ | ? | ✔️ | ||
amrWb | ✔️ | ✔️ | ? | ✔️ | ||
opus | ✔️ | ✔️ | ? | ✔️ | ✔️ | ✔️ |
vorbisOgg | ?(optional) | ? | ✔️ | ✔️ | ||
wav | ✔️ | ? | ✔️ | ✔️ | ||
flac | ✔️ | ? | ✔️ | ✔️ | ✔️ | |
pcm8bit | ✔️ | ✔️ | ? | ✔️ | ||
pcm16bit | ✔️ | ✔️ | ? | ✔️ |
For every encoder, you should be really careful with given sampling rates. For example, opus could or could not be recorded at 44100Hz.
If a given encoder is not supported when starting recording on platform, the fallbacks are:
Platform | encoder |
---|---|
Android | AAC LC |
iOS | AAC LC |
web | OPUS OGG (not guaranteed => choice is made by the browser) |
Windows | AAC LC |
macOS | AAC LC |
linux | AAC LC |
// Import package
import 'package:record/record.dart';
final record = Record();
// Check and request permission
if (await record.hasPermission()) {
// Start recording
await record.start(
path: 'aFullPath/myFile.m4a',
encoder: AudioEncoder.aacLc, // by default
bitRate: 128000, // by default
sampleRate: 44100, // by default
);
}
// Get the state of the recorder
bool isRecording = await record.isRecording();
// Stop recording
await record.stop();
Be sure to check supported values from the given links above.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。