music_player 0.1.5 copy "music_player: ^0.1.5" to clipboard
music_player: ^0.1.5 copied to clipboard

A flutter plugin to enable music playback with the native iOS and Android control centers.

example/lib/main.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'),
          ),
        ),
      ),
    );
  }
}
34
likes
40
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter plugin to enable music playback with the native iOS and Android control centers.

Repository (GitLab)
View/report issues

License

MIT (license)

Dependencies

crypto, flutter, flutter_cache_manager, meta, path, path_provider

More

Packages that depend on music_player