flutter_audio_desktop 0.0.8
flutter_audio_desktop: ^0.0.8 copied to clipboard

Flutter

A simple audio playback library for Flutter Desktop. Supports MP3, FLAC & WAV on Windows & Linux.

flutter_audio_desktop #

A simple 🎵 audio playback library for Flutter Desktop.

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

Feel free to open issue anytime.

⬇️ Install #

Mention in your pubspec.yaml requirements:

dependencies:
  ...
  flutter_audio_desktop: ^0.0.8

Fetch the dependencies by following command:

flutter pub get

📐 Usage #

Playing an audio file

// Start AudioPlayer and provide int for id.
var audioPlayer = new AudioPlayer(id: 0);

// 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.');
}

Playing an audio wave or noise

// New player for wave
AudioPlayer wavePlayer = new AudioPlayer(id: 1);

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

// Set frequency
wavePlayer.setWaveFrequency(frequency);

// Set amplitude
wavePlayer.setWaveAmplitude(amplitude);

// Set sample rate
wavePlayer.setWaveSampleRate(sampleRate)

// Set wave type
wavePlayer.setWaveType(type)

// New player for noise
AudioPlayer noisePlayer = new AudioPlayer(id: 2);

// Load noise
noisePlayer.loadNoise(seed, amplitude, type);

// Set seed
noisePlayer.setNoiseSeed(seed);

// Set amplitude
noisePlayer.setNoiseAmplitude(amplitude);

// Set noise type
noisePlayer.setNoiseType(type)

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

👌 Contributions #

Thanks a lot to @MichealReed for adding multiple player instances, along with wave & noise APIs to the project.

✔️ Progress #

The library is supported on Microsoft Windows & Linux.

PlatformStatus
Microsoft WindowsWorking
LinuxWorking
MacOSNot 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 for miniaudio.
17
likes
90
pub points
72%
popularity

A simple audio playback library for Flutter Desktop. Supports MP3, FLAC & WAV on Windows & Linux.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

Uploader

saini123hitesh@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_audio_desktop