Skip to content

Line Bar Visualizer

Gautam Chibde edited this page Apr 4, 2018 · 4 revisions

Usage

add LineBarVisualizer to you xml layout.

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

In your java class

LineBarVisualizer lineBarVisualizer = findViewById(R.id.visualizer);
mediaPlayer = MediaPlayer.create(this, R.raw.you_music);

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

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

// Set you media player to the visualizer. 
lineBarVisualizer.setPlayer(mediaPlayer.getAudioSessionId());

Density greater then 256

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