native_audio 0.0.14

Native Audio #

An audio plugin for Flutter which makes use of the native Android and iOS audio players, handling playback, notifications and external controls (such as bluetooth).

Getting Started #

This plugin works on both Android and iOS, however the following setup is required for each platform.

Android #

Prerequisite #

1. Application #

Create or modify the Application class as follows:

import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.GeneratedPluginRegistrant
import com.danielgauci.native_audio.NativeAudioPlugin

class Application : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {

    override fun onCreate() {

    override fun registerWith(registry: PluginRegistry) {

This must be reflected in the application's AndroidManifest.xml. E.g.:


Note: Not calling NativeAudioPlugin.setPluginRegistrant will result in an exception being thrown when audio is played.

2. Service & Permissions

Add the following lines to your AndroidManifest.xml to register the background service for geofencing:

<receiver android:name="">
        <action android:name="android.intent.action.MEDIA_BUTTON" />

<service android:name="com.danielgauci.native_audio.AudioService">
        <action android:name="android.intent.action.MEDIA_BUTTON" />
        <action android:name="" />

As well as the following lines to setup the permissions required:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

iOS #

Prerequisite #

  • Flutter Project minimum iOS 10
  • Flutter Project minimum build Swift 4.2

No additional setup is required for iOS 🍏

0.0.14 #

  • Fix iOS notification seek bar
  • Android Notification fixes and improvements
  • Improve ReadMe with prerequisites

0.0.13 #

  • Register method call handler on play instead of on initialization to ensure that the channel has not been taken over since initialization. This also opens up the possibility of having multiple instances of NativeAudio.

0.0.12 #

  • [Android] Support Android 10 media notification seek bar, fix by (YaarPatandarAA)[]
  • [Android] Support Samsung metadata, fix by (YaarPatandarAA)[]

0.0.11 #

  • Fix changelog formatting

0.0.10 #

  • [Android] Allow Media Controls show in compact notification, fix by (YaarPatandarAA)[]
  • [iOS] Improve loading times on iOS 10 and newer, fix by (YaarPatandarAA)[]
  • [iOS] Show artwork in Command Center, fix by (YaarPatandarAA)[]

0.0.9 #

  • [Android] Optimize progress updates

0.0.8 #

  • [Android] Fix MediaPlayer not being released [Android]

0.0.7 #

  • [Android] Properly handle Audio Focus
  • [Android] Pause playback when Bluetooth device disconnected
  • [Android] Pause playback when headset disconnected
  • [Android] Bump minSdk to 21

0.0.6 #

  • Fixed issue causing playback not to stop when Android notification is dismissed

0.0.5 #

  • Fixed issue causing Android notification to re-appear when closed

0.0.4 #

  • Initial iOS support

0.0.3 #

  • Change package name from studio.darngood to com.danielgauci

0.0.2 #

  • Fix NPE due to incorrect context
  • Throw exception if pluginRegistrantCallback is not set
  • Clean up unused constants

0.0.1 #

  • Initial release


native_audio_example #

Demonstrates how to use the native_audio plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

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

Use this package as a library

1. Depend on it

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

  native_audio: ^0.0.14

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:native_audio/native_audio.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health issues and suggestions

Document public APIs. (-1 points)

21 out of 21 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/native_audio.dart.

Run flutter format to format lib/native_audio.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies