flutter_audio_as_service 0.0.3 copy "flutter_audio_as_service: ^0.0.3" to clipboard
flutter_audio_as_service: ^0.0.3 copied to clipboard

discontinued
outdated

A plugin, that allows audio playback as Android service.

flutter_audio_as_service 0.0.3 #

A plugin by Tailosive Development (@TailosiveDev) created by Karol Wąsowski (@KarolWasowski) Licensed under the BSD License

Pull requests are welcome.

The plugin is Android only as of now.

Usage #

  1. Before you begin Add this permission to AndridManifest.xml:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

Make sure your app uses Java8 by adding this code into your app-level build.gradle into the android section:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

Enable androidx support in your app.

Add the service to AndroidMainfest.xml

<manifest>
  ...
  <application>
    ...
    ...
    <service 
      android:name="net.tailosive.flutter_audio_as_service.AudioService"/>
  </application>
</manifest>
  1. Usage To start playback initialize the player with the following:
FlutterAudioAsService.init("Title", "Author", audioSource, appIcon, albumCover);

audioSource is a string - could be both a url or a file directory.

How to properly set appIcon and albumCover:

  • put the desired .png image into android/src/main/res/drawable/
  • if your resource is app_icon.png then set the appIcon value to be "app_icon"
  • the value can be null

Playback is controlled with the following functions:

FlutterAudioAsService.pause();
FlutterAudioAsService.resume();

During playback you may also seek with:

FlutterAudioAsService.seekBy(Duration(seconds: 30));
FlutterAudioAsService.seekTo(Duration(minutes: 15, seconds: 47));

To stop playback and destroy the service run:

FlutterAudioAsService.stop();
  1. Features The plugin supports audio playback as an Android service with caching functionality included. It uses ExoPlayer with MediaSession API and rich notification controls.
1
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A plugin, that allows audio playback as Android service.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_audio_as_service