An 🎡 audio playback library for Flutter Desktop. Supports Windows & Linux. Based on miniaudio.

Overview

βœ’ libwinmedia is sequel to this project.

It provides network playback, better format support, control & features.















An audio playback library for Flutter Desktop.

Feel free to open issue anytime.

Installing

Mention in your pubspec.yaml:

dependencies:
  ...
  flutter_audio_desktop: ^0.1.0

Using

// Create new instance.
var audioPlayer = new AudioPlayer(id: 0)
..stream.listen(
  (Audio audio) {
    // Listen to playback events.
  },
);
// Load audio source
audioPlayer.load(
  new AudioSource.fromFile(
    new File('/home/alexmercerind/music.mp3'),
  ),
);
// Start playback.
audioPlayer.play();
// Get audio duration.
audioPlayer.audio.duration;
// Change playback volume.
audioPlayer.setVolume(0.5);
// Change playback position.
audioPlayer.setPosition(Duration(seconds: 10));
// Get playback position.
audioPlayer.audio.position;
Timer(Duration(seconds: 10), () {
    // Pause playback.
    audioPlayer.pause();
}
// Few other things.
audioPlayer.audio.file;
audioPlayer.audio.isPlaying;
audioPlayer.audio.isCompleted;
audioPlayer.audio.isStopped;

Other classes & methods are documented in their docstrings very well.

See this example for a better overview.

Windows

Linux

Support

If you want to be kind to me, then consider buying me a coffee.

Thankyou!

Progress

Platform Status
Linux Working
Microsoft Windows Working
MacOS Learn More

License

I don't want to put any restrictions on how you distribute your Flutter Desktop apps, so this library comes under very permissive software, MIT license.

Since, other libraries like libvlcpp or libvlc come under GPL & LGPL licenses respectively, so there will be many restrictions if I plan to use them.

Thus, this project uses miniaudio and miniaudio_engine from David Reid under MIT license.

Acknowledgments

Comments
  • Could you collaborate with this repository?

    Could you collaborate with this repository?

    It would make me very happy to be able to use assets_audio_player with its implementation on Windows.

    In assets_audio_player supported by Mac, you can parse the operation for implementation.

    I hope I can count on you @alexmercerind for this collaboration.

    https://github.com/florent37/Flutter-AssetsAudioPlayer/issues/386 https://github.com/florent37/Flutter-AssetsAudioPlayer

    enhancement 
    opened by DomingoMG 14
  • Checked out github version today and got following error

    Checked out github version today and got following error

    Building Windows application... C:\flutter\musicplayer\windows\flutter\ephemeral.plugin_symlinks\flutter_audio_desktop\audioplayer\audioplayer.hpp(7,10): fatal error C1083: Cannot open include file: 'miniaudio/miniaudio.h': No such file or directory [C:\flutter\musicplayer\build\windows\plugins\flutter_audio_desktop\flutter_audio_desktop_plugin.vcxproj] Exception: Build process failed.

    question 
    opened by syleishere 9
  • Using 2nd instance of AudioPlayer crashes the app

    Using 2nd instance of AudioPlayer crashes the app

    Whenever I try to use 2 instances of AudioPlayer on the same screen it crashes the app without any errors in the logs. It happens both on 0.0.7 and 0.0.8 with distinct ids passed to AudioPlayer's constructors.

    opened by gkovac42 9
  • Audio doesn't work for release build

    Audio doesn't work for release build

    Hello, I'd like to say that the plugin is great and works just as expected when running an app from the IDE (Android Studio) but for some reason whenever I run a release build (produced with flutter build windows) there is no sound at all and no errors to go by. Am I missing something?

    opened by GrimDevStudio 8
  • Include miniaudio.h

    Include miniaudio.h

    Given the license of miniaudio, it would make sense to include the file here directly. Currently, users are required to find the file and copy it to their temporary pubspec folder before they can use this package. Bots could probably automate updates to the file here from the main repository, but manual may be better for now.

    invalid 
    opened by MichealReed 7
  • Audio auto loop play

    Audio auto loop play

    when audio file duration is less than 1 sec ,AudioPlayer play file in loop.

    static void play(var file) async {
      await _audioPlayer.load(AudioSource.fromFile(file));
      await _audioPlayer.play();
    }
    

    music_file.zip

    opened by yiky84119 6
  • Method setPosition() unstable

    Method setPosition() unstable

    Hi, @alexmercerind Thanks for the plugin, it is simple, but decent and worked well. I find that when the duration in setPosition() is longer more than like 20 mins or tap fast forward many times in short time, the plugin will crash. Also change position take too long time and have some noisy sound.

    image

    bug 
    opened by stonega 6
  • When play() is executes it shows audio channels instead of playing audio

    When play() is executes it shows audio channels instead of playing audio

    Hello, I'm trying to use your plugin in my Windows app, but when i run the play() the terminal displays my audio channels instead of playing actual sounds as follows. Is there any way to choose channel while playing?

    0 - LG IPS FULLHD (2- NVIDIA High Definition Audio)
    1 - Headset (MDR-ZX330BT Hands-Free AG Audio)
    2 - Headphones (MDR-ZX330BT Stereo)
    3 - Speakers (Realtek(R) Audio)
    
    bug 
    opened by humble-git 5
  • Playing multiple audio files

    Playing multiple audio files

    I am forced to open another issue as my previous one was brashly closed without a proper explanation or solution, and has only left me confused. (https://github.com/alexmercerind/flutter_audio_desktop/issues/21)

    How am I to play multiple audio files if I'm not supposed to call load on the same instance of AudioPlayer twice and creating multiple instances of AudioPlayer crashes the app?

    duplicate invalid 
    opened by gkovac42 3
  • Set device to system default in constructor.

    Set device to system default in constructor.

    Miniaudio has https://github.com/mackron/miniaudio/issues/126, which we can use to automatically set the playback device to the system default. Will implement this as soon as https://github.com/alexmercerind/flutter_audio_desktop/pull/10 lands.

    enhancement 
    opened by MichealReed 3
  • Support Multiple Players

    Support Multiple Players

    I have a PR ready to go to add support for multiple audio players, it based off of my other PR for wave generation though so I will need to wait for that to land. I added an id parameter to all of the C++ functions, but in dart it is only required when instantiating the object. To do this, I changed argument handling so we can easily send maps from dart to C++;

    I.E

        audioPlayer = new AudioPlayer(id: 0, debug: true);
        audioPlayer2 = new AudioPlayer(id: 1, debug: true);
    

    You can preview the changes here: https://github.com/MichealReed/flutter_audio_desktop/tree/multiple_streams

    Feel free to add feedback if something should change before this lands. I can only test on Windows at the moment, but Linux should work the same.

    enhancement 
    opened by MichealReed 3
  • [Windows]Incompatible with package file_picker_cross

    [Windows]Incompatible with package file_picker_cross

    If I use flutter_audio_desktop 0.1.0(just depend in pubspec.yaml) and any recent version of file_picker_cross together inside one project, once file picker is called, the program will run into stuck - "not responding", the file chooser window is not shown yet. You need to force close it.

    flutter_audio_desktop 0.0.8 works fine. Maybe there are some conflicts of platform-specific codes in v0.1.0. But I haven't found it out. And Linux not tested. I will also create an issue at file_picker_cross project (https://gitlab.com/testapp-system/file_picker_cross/-/issues/41)

    Minimal example

    pubspec.yaml

    dependencies:
      # skip default deps
      flutter_audio_desktop: 0.1.0
      file_picker_cross: 4.3.0
    
    dependency_overrides:
      path_provider: ^2.0.0
    

    main.dart

    import 'package:file_picker_cross/file_picker_cross.dart';
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Test',
          home: Scaffold(
            appBar: AppBar(title: Text("Test")),
            body: Center(
              child: ElevatedButton(
                onPressed: () async {
                  final res = await FilePickerCross.importFromStorage();
                  print(res.path);
                },
                child: Text('import file'),
              ),
            ),
          ),
        );
      }
    }
    

    hope the new project flutter_vlc publish soon, even in beta, is there any plan when to publish?

    opened by narumi147 5
  • Linux build fails

    Linux build fails

    When I try to build for Linux (from Linux), I get this output:

    Launching lib/main.dart on Linux in debug mode...
    /home/me/git/feeel/linux/flutter/ephemeral/.plugin_symlinks/flutter_audio_desktop/linux/../audioplayer/audioplayer.hpp:119:29: error: expected ';' at end of declaration
    /home/me/git/feeel/linux/flutter/ephemeral/.plugin_symlinks/flutter_audio_desktop/linux/../audioplayer/audioplayer.hpp:122:18: error: use of undeclared identifier 'durationPCMFrame'
    /home/me/git/feeel/linux/flutter/ephemeral/.plugin_symlinks/flutter_audio_desktop/linux/../audioplayer/audioplayer.hpp:125:39: error: use of undeclared identifier 'durationPCMFrame'
    /home/me/git/feeel/linux/flutter/ephemeral/.plugin_symlinks/flutter_audio_desktop/linux/../audioplayer/audioplayer.hpp:135:29: error: expected ';' at end of declaration
    /home/me/git/feeel/linux/flutter/ephemeral/.plugin_symlinks/flutter_audio_desktop/linux/../audioplayer/audioplayer.hpp:138:18: error: use of undeclared identifier 'positionPCMFrame'
    /home/me/git/feeel/linux/flutter/ephemeral/.plugin_symlinks/flutter_audio_desktop/linux/../audioplayer/audioplayer.hpp:141:39: error: use of undeclared identifier 'positionPCMFrame'
    Building Linux application...                                           
    Exception: Build process failed
    

    It seems __int64 isn't being recognized by the compiler in these lines of code: unsigned __int64 durationPCMFrame; unsigned __int64 positionPCMFrame;

    What can I do about this?

    opened by 12people 16
  • Replay or not replay, that is the question.

    Replay or not replay, that is the question.

    For some files, the player replays the audio indefinitely, for some others, it plays just once. I could not figure out what is the pattern here.

    I am using the example project and running it on Windows.

    Flutter version: 2.0.0 Dart version: 2.12.0 Compiler: Visual Studio Community 2019 16.9.1

    You can access the audio samples below.

    samples.zip

    bug 
    opened by elnurvl 5
  • Audio Devices in time real not working

    Audio Devices in time real not working

    I am trying to create a drop down menu where you change the sound card and make it change in the player, but it doesn't work for me.

    I have to assign it manually on the system for it to apply.

    The storageCache is a storage to know if there is a sound card configured by the user, otherwise it will be obtained by default.

    Example: IMAGE ALT TEXT HERE

    improvement 
    opened by DomingoMG 1
Releases(v0.1.0)
  • v0.1.0(Mar 5, 2021)

    This version of flutter_audio_desktop brings & changes:

    • Now you can listen to playback events using stream (a broadcast stream) inside AudioPlayer. This was a great problem in earlier version as one always needs to trigger UI updates whenever playback progresses, ends etc.
    • One of the big problems in earlier version was that there was no way to detect if an audio playback has ended after completion. Resulting in issues like #25 & #26. Now audio.isCompleted stores bool if an audio has ended, same can be accessed from stream.
    • Now you can provide any random id while creating new instance of AudioPlayer, this was a big problem earlier as new id had to be consecutive to earlier one.
    • Now you can access same instance of AudioPlayer even if you make new constructor, by providing same id.
    • Now asset files can be played & loaded into AudioPlayer using load method.
      • AudioSource class has two static methods
        • AudioSource.fromFile to load an audio file.
        • AudioSource.fromAsset to load an audio asset.
    • Now audio field stores Audio object, inside the AudioPlayer class & contains following fields to get information about current playback.
      • file: Current loaded File.
      • isPlaying : Whether file is playing.
      • isCompleted: Whether file is ended playing.
        • By default once playback is ended, stop method is called & AudioPlayer is reverted to initial configuration.
      • isStopped: Whether file is loaded.
      • position: Position of current playback in Duration.
      • duration: Duration of current file in Duration.
    • Now contructor of AudioPlayer no longer calls async methods, which could result in false assertions.
    • Now ma_resource_manager is used from miniaudio_engine with MA_DATA_SOURCE_FLAG_STREAM flag.
      • This will improve general performance during playback, as whole file will not be loaded into memory.
    • Structure of code improved & separated into various files & classes.
    • Now device handling is present in an entirely separate class AudioDevices.
    • Improvements to how methods are identified & called in method channel. flutter_types.hpp improves code readability.
    • Other bugs that randomly caused termination after false assertions are also fixed to an extent.
    • Removed wave & noise APIs temporarily. Apologies to everyone & MichealReed.

    NOTES

    • I hurried a bit with this release at the end, so queues are still unimplemented.
    • I have found a different approach for this plugin, so I'll spend time on that in future.

    Thankyou everyone.

    Source code(tar.gz)
    Source code(zip)
Owner
Hitesh Kumar Saini
Flutter & React.js developer. Writes C++, Dart, JS & Python. Maintains few utility libraries. Designs beautiful UIs.
Hitesh Kumar Saini
🎡 A cross-platform media playback library for C/C++ with good number of features (only Windows & Linux).

libwinmedia A cross-platform media playback library for C/C++ & Flutter with good number of features. Example A very simple example can be as follows.

Harmonoid 38 Nov 2, 2022
A Flutter plugin to read πŸ”– metadata of 🎡 media files. Supports Windows, Linux & Android.

flutter_media_metadata A Flutter plugin to read metadata of media files. A part of Harmonoid open source project ?? Install Add in your pubspec.yaml.

Harmonoid 60 Dec 2, 2022
A clean front-end plugin to Volumio, the Linux distribution for music playback. Volumio Touch Display Lite is written in Flutter and runs on flutter-pi.

EN | δΈ­ζ–‡ Touch Display Lite plugin for Volumio 3 Feng Zhou, 2021-12 Touch Display Lite is a clean and fast user interface for Volumio 3, the Linux dist

Feng Zhou 5 Jul 26, 2022
Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size.

desktop_window Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size. Usage import 'package:desktop_window/desktop_window.dart

ChunKoo Park 72 Dec 2, 2022
File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.

A package that allows you to use the native file explorer to pick single or multiple files, with extensions filtering support.

Miguel Ruivo 987 Jan 6, 2023
Flutter on Windows, MacOS and Linux - based on Flutter Embedding, Go and GLFW.

go-flutter - A package that brings Flutter to the desktop Purpose Flutter allows you to build beautiful native apps on iOS and Android from a single c

null 5.5k Jan 6, 2023
Flutter library for window blur & transparency effects for on Windows & Linux. πŸ’™

flutter_acrylic Window blur & transparency effects for Flutter on Windows & Linux Installation Mention in your pubspec.yaml. dependencies: ... flu

Hitesh Kumar Saini 437 Dec 31, 2022
A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter

quick_usb A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter Usage List devices List devices with additional description Get device

Woodemi Co., Ltd 39 Oct 1, 2022
A simple-to-use flutter update package for Windows, MacOS, and Linux.

Updat - The simple-to-use, flutter-based desktop update package Updat is a simple-to-use reliable flutter-native updater that handles your application

Eduardo M. 14 Dec 21, 2022
A cross-platform app ecosystem, bringing iMessage to Android, PC (Windows, Linux, & even macOS), and Web!

BlueBubbles Android App BlueBubbles is an open-source and cross-platform ecosystem of apps aimed to bring iMessage to Android, Windows, Linux, and mor

BlueBubbles 318 Jan 8, 2023
A pure Dart implementation of Firebase with initial support aimed at FlutterFire for Linux & Windows.

FlutterFire Desktop A work in progress pure Dart implementation of Firebase with initial support aimed at FlutterFire for Linux & Windows. A FlutterFi

Invertase 293 Jan 4, 2023
TinyPNG4Flutter - A TinyPNG Compress Image Desktop GUI For Flutter. Support macOS and windows

TinyPNG4Flutter A TinyPNG Compress Image Desktop GUI For Flutter. Support macOS

ι€Έι£Ž 20 Dec 8, 2022
A Dart FFI package to send πŸ’¬ toasts on Windows. Written in C++, based on WinToast.

desktoasts A Dart package to send native ?? toasts on Windows. Installation For Flutter dependencies: ... desktoasts: ^0.0.2 For Dart CLI here Sup

Hitesh Kumar Saini 37 Mar 7, 2022
A tutorial for creating an Ubuntu Linux Flutter app, using the yaru theme

Building a Yaru app with Flutter Summary URL https://github.com/ubuntu/user_manager Category Environment Linux Status Feedback Link Author Frederik Fe

Ubuntu 22 Dec 21, 2022
Embedded Linux embedding for Flutter

Embedded Linux (eLinux) embedding for Flutter This project was created to develop non-official embedded Linux embeddings of Flutter. This embedder is

Sony 918 Dec 30, 2022
A flutter application to monitor your Linux PC statistic.

Linux Stats App A flutter application to monitor your Linux PC statistic. Screenshots Installation Download or clone the repository: $ git clone https

Malte2036 7 Dec 17, 2022
Embedded Flutter runtime targeting Embedded Linux with Wayland

ivi-homescreen IVI Homescreen for Wayland Strongly Typed (C++) Lightweight Clang 11 Release Stripped = 151k GCC 9.3 Release Stripped = 168k Source run

null 172 Jan 6, 2023
A small karaoke app made in Flutter for Linux

Karaoke app for linux A small karaoke/lyrics display for the currently running VLC song. Video: Make sure the songs have metadata (at least title and

Wazzaps 63 Jan 7, 2023
A package which provides most of the window decorations from linux themes.

Window Decorations A package which provides most of the window decorations from linux themes. Features Easier to use and implement Native looking wind

Prateek SU 20 Dec 21, 2022