audio_recorder 0.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 43

Audio recorder #

Record audio and store it locally

Usage #

To use this plugin, add audio_recorder as a dependency in your pubspec.yaml file.

Android #

Make sure you add the following permissions to your Android Manifest

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Example #

// Import package
import 'package:flutter_audio_recorder_plugin/flutter_audio_recorder_plugin.dart';

// Check permissions before starting
bool hasPermissions = await FlutterAudioRecorderPlugin.hasPermissions;

// Get the state of the recorder
bool isRecording = await FlutterAudioRecorderPlugin.isRecording;

// Start recording
await FlutterAudioRecorderPlugin.start(path: _controller.text, audioOutputFormat: AudioOutputFormat.AAC);

// Stop recording
Recording recording = await FlutterAudioRecorderPlugin.stop();
print("Path : ${recording.path},  Format : ${recording.audioOutputFormat},  Duration : ${recording.duration},  Extension : ${recording.extension},");

Encoding format #

For now, the plugin only use the AAC compression to encode audio. You can specify the extension of the output audio file in the file path that you give to the start method. The recognized extensions are :

  • .m4a
  • .mp4
  • .aac

If the file path does not finish with these extensions, the ".m4a" extension is add by default.

Exceptions #

The start method raise an exception if :

  • A file already exists at the given file path
  • The parent directory of the file path does not exist

Getting Started #

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:math';
import 'package:audio_recorder/audio_recorder.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin audio recorder'),
        ),
        body: new AppBody(),
      ),
    );
  }
}

class AppBody extends StatefulWidget{

  @override
  State<StatefulWidget> createState() => new AppBodyState();
}

class AppBodyState extends State<AppBody>{
  Recording _recording = new Recording();
  bool _isRecording = false;
  Random random = new Random();
  TextEditingController _controller = new TextEditingController();

  @override
  Widget build(BuildContext context) {
    return new Center(
      child: new Padding(
        padding: new EdgeInsets.all(8.0),
        child: new Column(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: <Widget>[
              new FlatButton(onPressed: _isRecording ? null : _start, child: new Text("Start"), color: Colors.green,),
              new FlatButton(onPressed: _isRecording ? _stop : null, child: new Text("Stop"), color: Colors.red,),
              new TextField(controller: _controller, decoration: new InputDecoration(hintText: 'Enter a custom path',),),
              new Text("File path of the record: ${_recording.path}"),
              new Text("Format: ${_recording.audioOutputFormat}"),
              new Text("Extension : ${_recording.extension}"),
              new Text("Audio recording duration : ${_recording.duration.toString()}" )
            ]),
      ),
    );
  }

  _start() async {
    try {
      if (await AudioRecorder.hasPermissions) {
        if (_controller.text != null && _controller.text != "") {
          await AudioRecorder.start(path: _controller.text, audioOutputFormat: AudioOutputFormat.AAC);
        } else {
          await AudioRecorder.start();
        }
        bool isRecording = await AudioRecorder.isRecording;
        setState(() {
          _recording = new Recording(duration: new Duration(), path: "");
          _isRecording = isRecording;
        });
      } else {
        Scaffold.of(context).showSnackBar(new SnackBar(content: new Text("You must accept permissions")));
      }
    } catch (e){
      print(e);
    }
  }

  _stop() async {
    var recording = await AudioRecorder.stop();
    bool isRecording = await AudioRecorder.isRecording;
    setState(() {
      _recording = recording;
      _isRecording = isRecording;
    });
    _controller.text = recording.path;
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  audio_recorder: ^0.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:audio_recorder/audio_recorder.dart';
  
Version Uploaded Documentation Archive
0.0.6 Sep 9, 2018 Go to the documentation of audio_recorder 0.0.6 Download audio_recorder 0.0.6 archive
0.0.5 Aug 16, 2018 Go to the documentation of audio_recorder 0.0.5 Download audio_recorder 0.0.5 archive
0.0.4 Jun 11, 2018 Go to the documentation of audio_recorder 0.0.4 Download audio_recorder 0.0.4 archive
0.0.3 Jun 11, 2018 Go to the documentation of audio_recorder 0.0.3 Download audio_recorder 0.0.3 archive
0.0.2 May 16, 2018 Go to the documentation of audio_recorder 0.0.2 Download audio_recorder 0.0.2 archive
0.0.1 Feb 8, 2018 Go to the documentation of audio_recorder 0.0.1 Download audio_recorder 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
85
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
43
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0