Skip to content

aminnzo/waveform_audio_slider

Repository files navigation

MIT License Badge

This package is a minimal customization of the flutter_audio_waveforms package available on pub.dev.

Web Demo - Flutter Audio Waveforms Web Demo

Getting started

The package is a UI library for waveforms with an additional ability to show active track for playing audio.

So it relies on you to provide the necessary audio data which it needs to draw the waveform. The data we need is basically a list of points/samples that represents that audio.

You can use this audiowaveform program to get the audio json file which will provide us the samples. After installing this program on your machine, generate the json file for an audio by using this command in your terminal.

audiowaveform -i test.mp3 -o test.json

The generated data needs to be processed following some rules which are necessary to get the waveforms drawn properly. To process the data use this processor.

Once you have the processed data points list then you can just pass it down to any of the waveforms available and get started using them.

Check out this article for detailed introduction on this section.

Usage

 WaveformSlider(
    height: 60,
    width: MediaQuery.of(context).size.width * 0.7,
    scalingAlgorithmType: ScalingAlgorithmType.average,
    source: [],
    maxSamples: source.length,
    maxDuration: maxDuration,
    elapsedDuration: elapsedTime,
    waveformStyle: WaveformStyle(
      activeColor: Colors.blueAccent,
      inactiveColor: Colors.grey,
    ),
    elapsedIsChanged: (d) {
      setState(() {
      elapsedTime = d;
      });
    },
  )

Find detailed example here.

Properties

maxDuration:

Maximum duration of the audio.

elapsedDuration:

Elapsed Duration of the audio.

samples:

List of the audio data samples.

Check the Getting Started section on how to generate this.

height :

Waveform height.

width :

Waveform width.

Customization Options

inactiveColor :

Color of the inactive waveform.

activeColor :

Color of the active waveform.

More customization options coming soon!

About

Dart package that provides a slider in waveform style.

Topics

Resources

License

Stars

Watchers

Forks