Skip to content

SquareBar Visualizer

Gautam Chibde edited this page Aug 16, 2019 · 1 revision

Usage

add SquareBarVisualizer to you XML layout.

<com.chibde.visualizer.SquareBarVisualizer
    android:id="@+id/visualizer"
    android:layout_width="match_parent"
    android:layout_height="250dp"/>

In your java class

SquareBarVisualizer squareBarVisualizer = findViewById(R.id.visualizer);

// set custom color to the line.
squareBarVisualizer.setColor(ContextCompat.getColor(this, R.color.custom));

// define custom number of bars you want in the visualizer between (10 - 256).
squareBarVisualizer.setDensity(65);

// Set Spacing
squareBarVisualizer.setGap(2);

// Set your media player to the visualizer.
squareBarVisualizer.setPlayer(mediaPlayer.getAudioSessionId());

Note

Use of the visualizer requires the permission android.permission.RECORD_AUDIO so make sure to add it to your manifest file.

Clone this wiki locally