搜索插件、代码仓与 APP 分类

插件详情v1.3.0

another_audio_recorder

(空安全 + V2) 支持录音、暂停、恢复、停止的音频录制插件,并提供对音频电平测量属性(平均功率、峰值功率)的访问。

AndroidiOS
近 30 天下载
437
喜欢数
31
Pub 分数
150

安装插件

flutter pub add another_audio_recorder

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Another Audio Recorder 是一个空安全的、版本 2 的 Flutter 插件,适用于 Android 和 iOS,可实现对音频录制的完全控制——包括开始录制、暂停、恢复和停止。它提供实时音频电平测量访问功能,包括平均功率和峰值功率,非常适合需要音频可视化或质量监控的应用程序。该插件轻量级、文档完善,并专为无缝集成到音乐、语音笔记或播客应用中而设计。

适合场景

  • 语音备忘录应用
  • 音频可视化工具
  • 播客录制功能
  • 实时音频电平监控
  • 语音转文本预处理

主要特点

  • 支持录制/暂停/继续/停止
  • 实时平均和峰值功率计量
  • 空安全且与 Dart 3 兼容
  • 跨平台(Android 和 iOS)
  • 简单的 API,带有回调事件

适合对象

  • 开发音频录制应用的开发者
  • 需要音频电平反馈的应用程序
  • 需要精确音频控制的项目
  • 面向移动平台的 Flutter 应用

使用建议

  • 在 Android 和 iOS 上需要运行时权限
  • 仅限音频录制——不支持播放
  • 可能需要额外处理以进行后台录音
  • 依赖于平台特定的原生代码

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

another_audio_recorder

pub version Awesome Flutter

ko-fi

English | 简体中文

Flutter Audio Record Plugin that supports Record Pause Resume Stop and provide access to audio level metering properties average power peak power

Works for both Android and iOS
Code Samples:

Installation

add another_audio_recorder to your pubspec.yaml

iOS Permission

  1. Add usage description to plist
<key>NSMicrophoneUsageDescription</key>
<string>Can We Use Your Microphone Please</string>
  1. Then use hasPermission api to ask user for permission when needed

Android Permission

  1. Add uses-permission to ./android/app/src/main/AndroidManifest.xml in xml root level like below
    ...
    </application>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    ...
</manifest>
  1. Then use hasPermission api to ask user for permission when needed

Configuration

iOS Deployment Target is 8.0 above
Android
  • AndroidX: use latest version (0.5.x)
  • Legacy Android: use old version (0.4.9)

Usage

Recommended API Usage: hasPermission => init > start -> (pause <-> resume) * n -> stop, call init again before start another recording

Always check permission first(it will request permission if permission has not been set to true/false yet, otherwise it will return the result of recording permission)
bool hasPermission = await AnotherAudioRecorder.hasPermissions;
Initialize (run this before start, so we could check if file with given name already exists)
var recorder = AnotherAudioRecorder("file_path.mp4"); // .wav .aac .m4a
await recorder.initialized;

or

var recorder = AnotherAudioRecorder("file_path", audioFormat: AudioFormat.AAC); // or AudioFormat.WAV
await recorder.initialized;
Sample Rate
var recorder = AnotherAudioRecorder("file_path", audioFormat: AudioFormat.AAC, sampleRate: 22000); // sampleRate is 16000 by default
await recorder.initialized;
Audio Extension and Format Mapping
Audio Format Audio Extension List
AAC .m4a .aac .mp4
WAV .wav
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.

Getting Started

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Credits

  • This plugin is based on the flutter_audio_recorder, because they stopped updating their plugin and answering/accepting PR's (https://github.com/rmbrone/flutter_audio_recorder)
  • @hnvn - Migrate to Android embedding v2 + Support AAC codec (https://github.com/rmbrone/flutter_audio_recorder/pull/52)
  • @PerrchicK - error handling instead of app crash (https://github.com/rmbrone/flutter_audio_recorder/pull/45/files)

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。