music_player 0.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

Music Player #

Gitlab Status Pub Status

A music player flutter plugin that uses the native api to show the currently playing track with cover image and controls.

This plugin is still in development.

Warning: This plugin is written in Swift and Kotlin, so make sure your project is setup to compile these languages.

The required iOS version for this plugin is 10.* because some features to control the audio playback have only been introduced there. The required Android version is Android 5.0 Lollipop (API 21) or higher

Usage #

A simple usage example

For Android make sure to add <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> and <service android:enabled="true" android:name="live.exit.musicplayer.MusicPlayerService" /> to the AndroidManifest.xml of your Flutter app.

0.1.4 #

  • Fix crash when starting playback on Android
  • Improve speed when starting playback on iOS
  • Show controls in compact view on Android
  • Make the Android notification dismissible when paused

0.1.3 #

  • Fix issue where MPRemoteCommandCenter controls didn't disappear when stopping audio on iOS
  • Add next and previous button functionality for iOS control center
  • Add support for the seek functionality in iOS control center

0.1.2 #

  • Tapping the notification in Android brings the Flutter activity to the foreground

0.1.1 #

  • Fix issue where some covers couldn't be displayed in iOS' command center (934942a)
  • Fix issue where iOS player would crash if the cover couldn't be submitted (b992174)

0.1.0 #

  • BREAKING: Use AndroidX to lower minSdkVersion 21
  • Notification icon can no longer be provided via the Flutter app
  • Add resources folder for all icons including the notification icon

0.0.8 #

  • Fix displaying cover on iOS
  • Implement stop functionality on iOS
  • Fix a bug where playback would stop when the Flutter activity stops on Android

0.0.7 #

  • Use a foreground service to ensure playback does not stop
  • Add possibility to use custom notification icon
  • Removed support libary
  • Increase minimum SDK version to Android 8.0 Oreo API 26 (should be decreased again using AndroidX)

0.0.6 #

  • Remove Playlist functionality (should be properly reimplemented in the future)
  • Fix example

0.0.5 #

  • Update code for cache manager
  • Start playback immediately on iOS

0.0.4 #

  • Update dependencies

0.0.3 #

  • Add possibility to seek on iOS.
  • Properly send the .onCompleted event on iOS.
  • Change name to Music Player.
  • Add iOS Control Center and Android Notification player controls
  • Add example
  • Add gitlab CI for dartfmt and dartanalyzer

0.0.2 #

  • Added more information to the project.

0.0.1 #

  • The initial release with a working version of the iOS player.

example/example.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:music_player/music_player.dart';

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

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

class _MyAppState extends State<MyApp> {
  MusicPlayer musicPlayer;

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Initializing the Music Player and adding a single [PlaylistItem]
  Future<void> initPlatformState() async {
    musicPlayer = MusicPlayer();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Music Player example app'),
        ),
        body: Center(
          child: RaisedButton(
            onPressed: () => musicPlayer.play(MusicItem(
                  trackName: 'Sample',
                  albumName: 'Sample Album',
                  artistName: 'Sample Artist',
                  url: 'https://goo.gl/5RQjTQ',
                  coverUrl: 'https://goo.gl/Wd1yPP',
                  duration: Duration(seconds: 255),
                )),
            child: Text('Play'),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  music_player: ^0.1.4

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

We analyzed this package on Nov 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

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 (flutter_cache_manager, path_provider).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
crypto ^2.0.6 2.1.3
flutter 0.0.0
flutter_cache_manager ^0.3.2 0.3.2 1.1.3
meta ^1.1.6 1.1.7 1.1.8
path ^1.6.2 1.6.4
path_provider ^0.5.0 0.5.0+1 1.4.4
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
convert 2.1.1
http 0.12.0+2
http_parser 3.1.3
pedantic 1.8.0+1
sky_engine 0.0.99
source_span 1.5.5
sqflite 1.1.7+2
string_scanner 1.0.5
synchronized 2.1.0+1
term_glyph 1.1.0
typed_data 1.1.6
uuid 2.0.4
vector_math 2.0.8
Dev dependencies
grinder ^0.8.3