1 Star 1 Fork 0

FLUTTER组件 / record

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

Audio recorder from microphone to a given file path.

No external dependencies:

  • On Android, MediaRecorder is used.
  • On iOS, AVAudioRecorder is used.
  • On macOS, AVCaptureSession is used.
  • On web, well... your browser!

External dependencies:

  • On Windows and linux, encoding is provided by fmedia.
  • On linux, fmedia must be installed separately.

Options

  • bit rate (where applicable)
  • sampling rate
  • encoder
  • Number of channels
  • Input device selection

Platforms

Android

<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" />
  • min SDK: 19 (maybe higher => encoder dependent)

iOS

<key>NSMicrophoneUsageDescription</key>
<string>We need to access to the microphone to record audio file</string>
  • min SDK: 11.0

macOS

<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

Platform feature parity matrix

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

Encoding API levels documentation

Android

iOS

Usage

// 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();

Warnings

Be sure to check supported values from the given links above.

Roadmap

  • Allow to choose the capture device.
  • Format vs. container accuracy.
  • Bug fixes.
// Copyright 2022 openapi4j authors. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of openapi4j nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

将录音依赖库record 4.4.4放到当前插件,对android部分增加service 将录音功能放到其中 并且发起录音中的通知,增加存活率 展开 收起
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/flutter-assembly/record.git
git@gitee.com:flutter-assembly/record.git
flutter-assembly
record
record
master

搜索帮助