Skip to content

A simple 🎵 audio playback library for Flutter Desktop.

License

Notifications You must be signed in to change notification settings

MichealReed/flutter_audio_desktop

 
 

Repository files navigation

A simple yet functional 🎶 audio library for Flutter Desktop.

Right now, as it is just a start, it supports MP3, FLAC & WAV playback. I'll try to increase the domain of support formats with time & plan is to provide metadata of a track aswell.

Feel free to open issue anytime.

⬇️ Install

Mention in your pubspec.yaml requirements:

dependencies:
  ...
  flutter_audio_desktop: ^0.0.7

📐 Usage

// Start AudioPlayer and provide int for id.
// Note: You must provide new IDs to additional instances.
var audioPlayer = new AudioPlayer(id: 0);

// See a list of available system audio devices.
// You can then change the device with setDevice,
// and the ID included in the returned map.
Map<String, dynamic> result = await audioPlayer.getDevices();
// or if you don't need to refresh, access from
audioPlayer.devices

// Load audio file
audioPlayer.load('/home/alexmercerind/music.mp3');

// Start playing loaded audio file.
audioPlayer.play();

// Get audio duration.
print('Duration Of Track: ${audioPlayer.getDuration()}');

// Change playback volume.
audioPlayer.setVolume(0.5);
print('Changed volume to 50%.');

// Change playback position.
audioPlayer.setPosition(Duration(seconds: 10));

// Get playback position.
print('Position of playback after skipping 10 seconds: ${audioPlayer.getPosition()}');

Timer(Duration(seconds: 10), () {

    // Pause the playback.
    audioPlayer.pause();
    print('Playback of audio stopped after 10 seconds.');
}

// Load wave
audioPlayer.loadWave(amplitude, frequency, type)

// Set frequency
audioPlayer.setWaveFrequency(double frequency);

// Set Amplitude
audioPlayer.setWaveAmplitude(double amplitude);

// Set Sample Rate
audioPlayer.setWaveSampleRate(int sampleRate)

You can see this simple example app, if you are confused with the usage.

❤️ Like the library?

Feel free to use in your Flutter Desktop app. Consider ⭐ starring the repository if you want to show YOUR SUPPORT to the development & appreciate the effort.

✔️ Progress

The library is supported on Microsoft Windows & Linux.

Platform Status
Microsoft Windows Working
Linux Working
MacOS Not Working

🔧 How It Works ?

One word, C++. It calls native methods using dart's MethodChannel. It uses miniaudio from David Reid.

I wrote this simple wrapper in C++ around his library to get this working.

There is not any audio playback library for Flutter Desktop at the moment, so I decided to write one myself.

💌 Thanks to David Reid.

About

A simple 🎵 audio playback library for Flutter Desktop.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 58.8%
  • Dart 24.7%
  • CMake 14.0%
  • C 2.5%