kplayer 0.4.2 icon indicating copy to clipboard operation
kplayer: ^0.4.2 copied to clipboard

audio player that support all platforms.

kplayer #

Flutter player (currently only audio)

online preview: Go live

sopport #

no action required, just add package and use it

packages has wrapper #

by default kplayer use audioplayers package

  • recommended: audioplayers (kplayer_with_audioplayers)
  • not updated: just_audio (kplayer_with_just_audio)
  • deprecated: dart_vlc (kplayer_with_dart_vlc)

Getting Started #


void main() {
  Player.boot(); //add this  line (optional)

Play from assets:

var player = Player.asset("/assets/sound.mp3");

Play from network:

var player ="");

Play from file:

var player = Player.file("C/.../sound.mp3");

Play from bytes: // beta

var player = Player.bytes(fileAsBytes);


var player = Player.create(asset: PlayerMedia.asset("/assets/sound.mp3"), autoPlay: true, once: true)

you have also:

var player = Player.asset("/assets/sound.mp3");

// info
var package   = player.package;   // "current_apaptive_package_name"
var position  = player.position;  // setter an getter like seek()
var duration  = player.duration;  // getter (Duration are unmodifiable)
var status    = player.status;    // current status (playing, paused, ...)
var loop      = player.loop;      // bool
var playing   = player.playing;
var volume    = player.volume;    // get current volume
var speed     = player.speed;     // get current speed (playback rate)
// streams;;;;;;

// control (all async);
player.setPosition(Duration(seconds: 10));

player.player; // the native player

// all players
PlayerController.players; // List<PlayerController>
// dispose all players

// all other players
player.others; // List<PlayerController>

// example pause all other players
player.others.forEach((player) => player.pause());

// Widgets
PlayerBar(player: player, options: []);
  player: player,
  rebuild: (event, oldEvent) => event != oldEvent, // by default it will rebuild when event changed
  builder: (context, event){
  return // TODO

mixins #

you can use PlayerStateMixin on State to get full access player state and handle streams dispose automatically

class MyPage extends StatefulWidget {
  final PlayerController player;
  const MyPage({super.key, required this.player});
  _MyPageState createState() => _MyPageState();
class _MyPageState extends State<MyPage> with PlayerStateMixin {
  void initState() {
  Widget build(BuildContext context) {
    return // TODO

  void onPlayingChanged(bool playing) {
    print('onPlayingChanged $playing');
  void onPositionChanged(Duration position) {
    print('onPositionChanged $position');
  void onDurationChanged(Duration duration) {
    print('onDurationChanged $duration');
  void onStatusChanged(PlayerStatus status) {
    print('onStatusChanged $status');
  void onEvent(PlayerStatus status) {
    print('onStatusChanged $status');

QA #

how to add options on setting menu? #

Just add widgets to player bar options, example:

PlayerBar(player: player, options: [
         secondary: const Icon(Icons.brightness_2),
         title: const Text("Dark mode"),

how to controll auto playing? #

use autoPlay param:

var player = Player.asset("/assets/sound.mp3",autoPlay: false);

use only one player #

currently you need to dispose the previous player for example:

var player = Player.asset("/assets/sound.mp3",autoPlay: false);
// ...
player ="");

but i plan it to add somthing like player.reuse() to re use player by defrent source also i will add Player.disposeAll() to easly dispose All players

acces to all players #

you can acces to all players by PlayerController.players return List<PlayerController>

Source code #

check the repository on github (

Check list #

  • add disposeAll, pauseAll, playAll
  • add setMedia
  • replace setters with async methods
  • add more widget
  • support playLists
  • add style option and sub widget

Support ☺️ #

Coffee for my mind:

E n g o j :)