Thursday, September 28, 2023

Flutter plugin to Visualize the audio being played

A Flutter plugin to Visualize the audio being played (only android).

Checkout recent plugin post

Usage

Install

Add this to your pubspec.yaml

dependencies: flutter_visualizers: ^0.0.2

Import

import 'package:flutter_visualizers/flutter_visualizers.dart';

Example

Firstly, get a audioSessionID from your native android.

player.getAudioSessionId()

Simply Include this code in body

new Visualizer(
        builder: (BuildContext context, List<int> wave) {
          return new CustomPaint(
            painter: new LineVisualizer(
              waveData: wave,
              height: MediaQuery.of(context).size.height,
              width : MediaQuery.of(context).size.width,
              color: Colors.blueAccent,
            ),
            child: new Container(),
          );
        },
        id: playerID,
      )

Here playerId is the AudioSessionId which id needed to initialize the Visualizer. (Required Audio Recording Permission in Android)See the Complete Example

Sample

Video