Giter Site home page Giter Site logo

lostifor / fluttermusicplayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from boyan01/flutter-music-player

0.0 0.0 0.0 3.32 MB

fork1

License: MIT License

Ruby 1.47% Objective-C 0.46% Java 0.43% Kotlin 50.73% Dart 27.73% Swift 17.72% AIDL 1.47%

fluttermusicplayer's Introduction

flutter_music_player

NOTE: this project is extremely experimental.

Media session framework plugin for flutter, make it easy to implement music play by flutter.

  • ios support
  • media style notification.
  • basic media control.
  • tracking player status change.

Getting Started

1. Requirements

  • flutter: 1.20.x stable version
  • android: kotlin 1.4.0
  • ios: 10.0

2. Simple Use Case.

// Create Player instance.
MusicPlayer player = MusicPlayer();
 
// audio list
final medias = [
  MusicMetadata(
    title: "Zhu Lin Jian",
    subtitle: "Zhu Lin Jian - SanWu marblue",
    mediaId: "bamboo",
    mediaUri: "asset:///tracks/bamboo.mp3",
    iconUri: "https://via.placeholder.com/150/FFCA28/000000/?text=bamboo",
  ),
  MusicMetadata(
    title: "Rise",
    subtitle: "Rise - The Glitch Mob",
    mediaId: "rise",
    mediaUri: "asset:///tracks/rise.mp3",
    iconUri: "https://via.placeholder.com/150/4CAF50/FFFFFF/?text=Rise",
  ),
  MusicMetadata(
    title: "Cang",
    subtitle: "Cang - xu meng yuan",
    mediaId: "hide",
    mediaUri: "asset:///tracks/hide.mp3",
    iconUri: "https://via.placeholder.com/150/03A9F4/000000/?text=Cang",
  ),
];

PlayQueue queue = PlayQueue(queueTitle: "Simple Test", queueId: "test1", queue: medias);

// Perform play operation.
player.playWithQueue(queue, metadata: medias.first);

3. Background Control.

add a method named playerBackgroundService to your lib/maim.dart.

  • playerBackgroundService is background service FlutterEngin entry point.
@pragma("vm:entry-point")
void playerBackgroundService() {
  runBackgroundService(
    playUriInterceptor: (mediaId, fallbackUrl) async {
      debugPrint("get media play uri : $mediaId , $fallbackUrl");
      if (mediaId == 'rise') return "asset:///tracks/rise.mp3";
      return fallbackUrl;
    },
    imageLoadInterceptor: (metadata) async {
      debugPrint("load image for ${metadata.mediaId} , ${metadata.title}");
      if (metadata.mediaId == "bamboo") {
        final data = await rootBundle.load("images/bamboo.jpg");
        return Uint8List.view(data.buffer);
      }
      return null;
    },
    playQueueInterceptor: ExamplePlayQueueInterceptor(),
  );
}

Thanks

thanks jorgenhenrichsen/SwiftAudio for iOS support.

thanks JetBrain provide open source lincese AppCode for iOS programming.

fluttermusicplayer's People

Contributors

boyan01 avatar xsahil03x avatar mdddj avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.