搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。