flutter_sound_lite 5.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 82

Flutter Sound #

pub version

This plugin provides simple recorder and player functionalities for both Android and iOS platforms.

<br/><br/>

Demo

Features #

  • Play and Record sounds or music with various codecs. (See the supported codecs here)
  • Play local or remote files specified by their URL.
  • The App playback can be controled from the device lock screen or from an Apple watch
  • Handle playback stream from native (To sync exact time with bridging). [Not sure to understand what it means!]

Flutter Sound branches #

We actually maintain two branches for Flutter Sound :

  • The V4 branch (the version ^4.0.0)
  • The master branch (actually the version ^5.0.0)

We do not expect that everybody will switch today from 4.x.x to 5.x.x.

V4 is our stable branch, and will be maintained as long as everybody will not have switch to V5 : in other words V4 is our LTS version (Long Term Support).

Migration Guides #

Free Read #

Medium Blog. [This link is probably obsolete!]

SDK requirements #

  • Flutter Sound requires an iOS 9.3 SDK (or later)
  • Flutter Sound requires an Android 24 (or later)

Installation #

Here is a guide for Flutter Sound installation

Flutter Sound API #

Flutter Sound is composed with 4 modules :

To use Flutter Sound you just do :

import 'package:flutter_sound/flutter_sound.dart';

This will export all the necessaries dart interfaces.

Examples (Demo Apps) #

Flutter Sound comes with two Demo/Examples :

  • Demo1 app is a small demonstration of what we can do with Flutter Sound. This Demo App is a kind of exerciser which try to implement the major Flutter Sound features. This Demo does not use the Flutter Sound UI Widgets
  • Demo2 app is an example of what can be done using the Flutter Sound UI Widgets

License #

Flutter Sound is copyrighted by Dooboolab (2018, 2019, 2020) Flutter Sound is released under a license with a copyleft clause: the LGPL-V3 license. This means that if you modify some of Flutter Sound code you must be publish your modifications under the LGPL license too.

Contributions #

Flutter Sound is a free and Open Source project. Several contributors have already contributed to Flutter Sound. Specially :

  • @hyochan who is the Flutter Sound father
  • @salvatore373 who wrote the Track Player
  • @bsutton who wrote the UI Widgets
  • @larpoux who add several codec supports

We really need your contributions. Pull Requests are welcome and will be considered very carefully.

Bugs, Features Requests, documentation inaccurate, help needed, ... #

We use Github actively.

When you fill an issue, we try to answer something in less than 48h. Of course, this will not mean that your issue will be fixed in 48h. But you will know that we confirm (or not) your issue and what answer you can expect. Maintenance is our priority. We try to make it perfect.

TODO #

  • [ ] Record and playback raw PCM both on Android and iOS
  • [ ] Record OPUS on Android
  • [ ] Record MP3 both on Android and iOS
  • [ ] Record raw PCM to a Dart Stream instead of a file
  • [ ] Playback raw PCM from a Dart Stream instead of a file
  • [ ] Streaming records to Speech to Text
  • [ ] More support for the Apple Watch
  • [ ] Tests unit to avoid any regression
  • [ ] Flutter Web App support
  • [ ] Flutter Sound port to React Native
  • [ ] Better UI Widget
  • [ ] Lock screen control between two sounds.

Help Maintenance #

My friend Hyo has been maintaining quite many repos these days and he is burning out slowly. If you could help him cheer up, buy him a cup of coffee will make his life really happy and get much energy out of it. As a side effect, we will know that Flutter Sound is important for you, that you appreciate our job and that you can show it with a little money. <br/> Buy Me A Coffee Paypal

5.1.1 #

  • Fix various bugs in UI Widget #407
  • Add a button Pause/Resume in UI Widget Recorder
  • Add a button Pause/Resume in UI Widget Player

5.1.0 #

  • Add a semaphore so that the App cannot do several call to Flutter Sound at the same time 374
  • On iOS : the "NowPlaying" info on the lockscreen is removed when the sound is finished or when the App does a stopPlayer(). Add parameter removeUIWhenStopped to startPlayerFromTrack(). (iOS only).
  • On iOS : the "NowPlaying" progress bar on the lockscreen is uptodated when the App does a seekToPlayer() #364
  • On iOS : Add parameter defaultPauseResume to startPlayerFromTrack(). (iOS only).
  • On iOS : Add API verb getProgress(). (iOS only).
  • On iOS : Add API verb getPlayerState(). (iOS only).
  • On iOS : Add API verb nowPlaying(). (iOS only).
  • On iOS : Add API verb setUIProgressBar(). (iOS only). 376
  • Fixes bug #380, #385
  • Fixes bug "AudioFlags and AudioSource not work as expect " #366, #372, #381
  • New parameters in the SoundPlayerUI constructors for specifying colors, text style and slider style. #397

5.0.2 #

Error returns from iOS in FlutterSoundPlayer.m was wrong : #350

5.0.1 #

  • Flutter Sound V5 is published under the LGPL license.

5.0.0 #

  • New API documentation
  • Changed the global enums names to CamelCase, to be conform with Google recommandations
  • Remove the OS dependant parameters from startRecorder()
  • Add a new parameter to startPlayer() : the Audio Focus requested
  • Support of new codecs, both for Android and iOS.
  • Remove the authorization request from startRecorder()
  • Remove the NULL posted when the player or the recorder is closed.
  • The Audio Focus is NOT automaticaly abandoned between two startPlayer() or two startRecorder()

4.0.7 Patch to avoid problems when the App does s stopPlayer() during a startPlayer() 374 #

4.0.6 Error returns from iOS in FlutterSoundPlayer.m was wrong : #350 #

4.0.5 #

  • Fix as bug in the Focus gain, on iOS #324

4.0.4+1 #

  • Fix a bug in resumeRecorder() on Android : the dbPeak Stream was not restored after a resume()
  • Fix a bug in resumeRecorder() : the returned value was sometimes a boolean instead of a String.

4.0.3+1 #

  • Check the Initialization Status, before accessing Flutter Sound Modules #307
  • Fixes : Pausing a recording doesn't 'pause' the duration. #278
  • Fix a crash that we had when accessing the global variable AndroidActivity from BackGroundAudioSerice.java #317

4.0.1+1 #

  • "s.static_framework = true" in flutter_sound.podspec

4.0.0 #

  • Adds pedantic lints and major refactoring of example with bug fixes. #279
  • Native code is directely linked with FFmpeg. Flutter Sound App does not need any more to depends on flutter_ffmpeg #265 and 273
  • Add a new parameter in the Track structure : albumArtFile
  • A new flutter plugin is born : flutter_sound_lite #291
  • Adds a new parameter whenPaused: to the startPlayerFromTrack() function. #314
  • Fix bug for displaying a remote albumArt on Android. #290

3.1.10 #

  • Trying to catch Android crash during a dirty Timer. #289

3.1.9 #

  • Trying to fix the Android crash when AndroidActivity is null #296

3.1.8 #

  • Fix a bug ('async') when the app forget to initalize its Flutter Sound module. #287

3.1.7 #

  • Codec PCM for recorder on iOS
  • Optional argument requestPermission before startRecorder() so that the App can control itself the recording permissions. #283

3.1.6+1 #

  • Fix a bug when initializing for Flutter Embedded V1 on Android #267
  • Add _removePlayerCallback, _removeRecorderCallback() and _removeDbPeakCallback() inside release() #248
  • Fix conflict with permission_handler 5.x.x #274
  • On iOS, setMeteringEnabled:YES is called during setDbLevelEnabled() #252, #251
  • The call to initialize() is now optional 271
  • README : #265

3.1.5 #

3.1.4 #

  • Change dependecies in range
    permission_handler: ">=4.0.0 <5.0.0"
    flutter_ffmpeg: ">=0.2.0 <1.0.0"
    

3.1.3 #

  • The isRecording variable is false when the recorder is paused #266

3.1.2 #

  • Flutter Sound depends on permission_handler: ^4.4.0 #263

3.1.0 #

  • flutter_sound modules are re-entrant #250 and #232
    • We can open several FlutterSoundPlayer at the same time
    • We can open several FlutterSoundRecorder at the same time
  • Add new API verbs : #244
    • flutterSoundHelper.getLastFFmpegReturnCode()
    • flutterSoundHelper.getLastFFmpegCommandOutput()
    • flutterSoundHelper.FFmpegGetMediaInformation() which return info on the given record
    • flutterSoundHelper.duration() which return the number of milli-seconds for the given record
  • Add new API verbs : ##242
    • FlutterSoundRecorder.pauseRecorder()
    • FlutterSoundRecorder.resumeRecorder()
  • flutter_sound is now compatible with permission_handler 5.x.x #259
  • API to control the audiofocus #219
  • API to set the audio-category (i.e. duck-others) #219
  • AndroidX and Android embbeded-V2 support #203
  • Add a parameter to startPlayer to specify a callback when the song is finished #215
  • License is now LGPL 3.0 instead of MIT

3.0.0+1 #

3.0.0 #

2.1.1 #

2.0.5 #

  • Hotfix #221
  • Use AAC-LC format instead of MPEG-4 #209

2.0.4 #

  • OGG/OPUS support on iOS #199

2.0.3 #

  • Resolve #194
    • stopReocorder resolve path.
  • Resolve #198
    • Improve static handler in android.

2.0.1 #

  • Add compatibility for android sdk 19.
  • Add androidx compatibility.
  • Resolve #193
    • Restore default startRecorder

1.9.0 #

  • Fix issue #175
    • add functions . isEncoderSupported(t_CODEC codec); . isDecoderSupported(t_CODEC codec);
    • add property 'audioState'
    • check if codec is really supported before doing 'startRecorder'
    • modify the example app : disable buttons when the button is not compatible with the current state
    • in the example, add sound assets encoded with the various encoder
    • modify the example to play from assets
    • modify the example to allow selection of various codec

1.7.0 #

  • startPlayerFromBuffer, to play from a buffer #170

1.6.0 #

  • Set android default encoding option to AAC.
  • Fix android default poor sound.

1.5.2 #

  • Postfix GetDirectoryType to avoid conflicts #147

1.5.1 #

  • Set android recorder encoder default value to AndroidEncoder.DEFAULT.

1.5.0 #

  • Use NSCachesDirectory instead of NSTemporaryDirectory #141

1.4.8 #

1.4.7 #

  • Resolve few issues on ios record path.
  • Resolve issue playing status so player can resume.
  • Resolve #134
  • Resolve #135

1.4.4 #

  • Stopped recording generating infinite db values #131

1.4.3 #

  • Improved db calcs #123

1.4.2 #

  • Fixed 'mediaplayer went away with unhandled events' bug #104

1.4.1 #

  • Fixed 'mediaplayer went away with unhandled events' bug #83

1.4.0 #

  • AndroidX compatibility improved #68
  • iOS: Fixes for seekToPlayer #72
  • iOS: Setup configuration for using bluetooth microphone recording input #73

1.3.6 #

  • Android: Adds a single threaded command scheduler for all recording related commands.
  • Switch source & target compability to Java 8
  • Bump gradle plugin version dependencies

1.3.+ #

  • Support db/meter #41
  • Show wrong recorder timer text #47
  • Add ability to specify Android & iOS encoder #49
  • Adjust db range and fix nullable check in ios #59
  • Android: Recording operations on a separate command queue #66
  • Android: Remove reference to non-AndroidX classes which improves compatibility

1.2.+ #

  • Fixed sound distorting when playing recorded audio again. Issue #14.
  • Fixed seekToPlayer for android. Issue #10.
  • Expose recorder sampleRate and numChannel.
  • Do not append tmp when filePath provided in ios.
  • Resolve regression issue in 1.2.3 which caused in 1.2.2.
  • Reduce the size of audio file in 1.2.4. Related #26.
  • Fixed recording issue in android in 1.2.5.
  • Changed seekToPlayer to place exact secs instead adding it.
  • Fix file URI for recording and playing in iOS.

1.1.+ #

  • Released 1.1.0 with beautiful logo from mansa.
  • Improved readme.
  • Resolve #7.
  • Fixed missing break in switch statement.

1.0.9 #

  • Reimport intl which is needed to format date in Dart.

1.0.8 #

  • Implemented setVolume method.
  • Specific error messages given in android.
  • Manage ios player thread when audio is not loaded.

1.0.7 #

  • Safer handling of progressUpdate in ios when audio is invalid.

1.0.6 #

  • Fixed bug in platform specific code.

1.0.5 #

  • Fixed pug in seekToPlayer in ios.

1.0.3 #

  • Added license.

1.0.0 #

  • Released preview version for audio recorder and player.

example/lib/main.dart

/*
 * Copyright 2018, 2019, 2020 Dooboolab.
 *
 * This file is part of Flutter-Sound.
 *
 * Flutter-Sound is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3 (LGPL-V3), as published by
 * the Free Software Foundation.
 *
 * Flutter-Sound is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Flutter-Sound.  If not, see <https://www.gnu.org/licenses/>.
 */


import 'package:flutter/material.dart';

import 'demo_util/demo3_body.dart';

/// demonstrates the recording widget linked to a playback widget.
void main() {
  runApp(MyApp());
}

/// Example app.
class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter Sound'),
        ),
        body: MainBody(),
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_sound_lite: ^5.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:flutter_sound_lite/flutter_sound.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
86
Health:
Code health derived from static analysis. [more]
76
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
82
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Android

Because:

  • package:flutter_sound_lite/flutter_sound.dart that imports:
  • package:flutter_sound_lite/src/ui/sound_recorder_ui.dart that imports:
  • package:flutter_sound_lite/src/ui/recorder_playback_controller.dart that imports:
  • package:flutter_sound_lite/src/ui/sound_player_ui.dart that imports:
  • package:flutter_sound_lite/src/ui/slider.dart that imports:
  • package:flutter_sound_lite/src/flutter_sound_player.dart that imports:
  • package:flutter_sound_lite/src/session.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: Linux

Package does not support Flutter platform Linux

Because:

  • package:flutter_sound_lite/flutter_sound.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:flutter_sound_lite/flutter_sound.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:flutter_sound_lite/flutter_sound.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform iOS

Because:

  • package:flutter_sound_lite/flutter_sound.dart that imports:
  • package:flutter_sound_lite/src/ui/sound_recorder_ui.dart that imports:
  • package:flutter_sound_lite/src/ui/recorder_playback_controller.dart that imports:
  • package:flutter_sound_lite/src/ui/sound_player_ui.dart that imports:
  • package:flutter_sound_lite/src/ui/slider.dart that imports:
  • package:flutter_sound_lite/src/flutter_sound_player.dart that imports:
  • package:flutter_sound_lite/src/session.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: Linux

Package does not support Flutter platform macOS

Because:

  • package:flutter_sound_lite/flutter_sound.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • flutter_sound_lite that is a package requiring null.

Health suggestions

Fix lib/src/flutter_sound_player.dart. (-9.99 points)

Analysis of lib/src/flutter_sound_player.dart reported 21 hints, including:

line 333 col 29: This function has a return type of 'Future

line 409 col 11: 'await' applied to 'void', which is not a 'Future'.

line 570 col 14: The value of the local variable 'fromURI' isn't used.

line 598 col 6: Don't explicitly initialize variables to null.

line 599 col 6: Don't explicitly initialize variables to null.

Fix lib/src/ui/sound_player_ui.dart. (-6.31 points)

Analysis of lib/src/ui/sound_player_ui.dart reported 13 hints, including:

line 46 col 7: This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: SoundPlayerUI._backgroundColor, SoundPlayerUI._iconColor, SoundPlayerUI._disabledIconColor, SoundPlayerUI._textStyle, SoundPlayerUI._titleStyle, SoundPlayerUI._sliderThemeData

line 93 col 7: Don't explicitly initialize variables to null.

line 94 col 7: Don't explicitly initialize variables to null.

line 95 col 7: Don't explicitly initialize variables to null.

line 130 col 7: Don't explicitly initialize variables to null.

Fix lib/src/session.dart. (-3.93 points)

Analysis of lib/src/session.dart reported 8 hints, including:

line 22 col 8: Unused import: 'dart:convert'.

line 24 col 8: Unused import: 'dart:io'.

line 25 col 8: Unused import: 'dart:io'.

line 26 col 8: Unused import: 'dart:typed_data'.

line 28 col 8: Unused import: 'package:path/path.dart'.

Fix additional 21 files with analysis or formatting issues. (-6.94 points)

Additional issues in the following files:

  • lib/src/flutter_sound_recorder.dart (7 hints)
  • lib/src/ui/sound_recorder_ui.dart (4 hints)
  • lib/src/flutter_sound_helper.dart (2 hints)
  • lib/src/ui/recorder_playback_controller.dart (1 hint)
  • lib/flutter_sound.dart (Run flutter format to format lib/flutter_sound.dart.)
  • lib/src/flutter_ffmpeg.dart (Run flutter format to format lib/src/flutter_ffmpeg.dart.)
  • lib/src/ui/grayed_out.dart (Run flutter format to format lib/src/ui/grayed_out.dart.)
  • lib/src/ui/local_context.dart (Run flutter format to format lib/src/ui/local_context.dart.)
  • lib/src/ui/slider.dart (Run flutter format to format lib/src/ui/slider.dart.)
  • lib/src/ui/slider_position.dart (Run flutter format to format lib/src/ui/slider_position.dart.)
  • lib/src/ui/temp_file_system.dart (Run flutter format to format lib/src/ui/temp_file_system.dart.)
  • lib/src/ui/tick_builder.dart (Run flutter format to format lib/src/ui/tick_builder.dart.)
  • lib/src/util/ansi_color.dart (Run flutter format to format lib/src/util/ansi_color.dart.)
  • lib/src/util/enum_helper.dart (Run flutter format to format lib/src/util/enum_helper.dart.)
  • lib/src/util/format.dart (Run flutter format to format lib/src/util/format.dart.)
  • lib/src/util/local_date.dart (Run flutter format to format lib/src/util/local_date.dart.)
  • lib/src/util/local_time.dart (Run flutter format to format lib/src/util/local_time.dart.)
  • lib/src/util/log.dart (Run flutter format to format lib/src/util/log.dart.)
  • lib/src/util/log_level.dart (Run flutter format to format lib/src/util/log_level.dart.)
  • lib/src/util/recorded_audio.dart (Run flutter format to format lib/src/util/recorded_audio.dart.)
  • lib/src/util/stack_trace_impl.dart (Run flutter format to format lib/src/util/stack_trace_impl.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (logger, recase).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
flutter_spinkit ^4.0.0 4.1.2+1
intl ^0.16.1 0.16.1
logger ^0.7.0+2 0.7.0+2 0.9.1
path >=1.0.0 <2.0.0 1.7.0
path_provider >=1.0.0 <2.0.0 1.6.11
provider ^4.1.0 4.3.1
recase ^2.0.1 2.0.1 3.0.0
synchronized ^2.2.0 2.2.0+1
uuid ^2.0.4 2.2.0
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
file 5.2.1
meta 1.1.8 1.2.2
nested 0.0.4
path_provider_linux 0.0.1+2
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
xdg_directories 0.1.0
Dev dependencies
effective_dart ^1.0.0
flutter_test