-
Notifications
You must be signed in to change notification settings - Fork 138
Line Visualizer
Gautam Chibde edited this page Apr 4, 2018
·
8 revisions
add LineVisualizer to you xml layout.
<com.chibde.audiovisulaizer.visualizer.LineVisualizer
android:id="@+id/visualizer"
android:layout_width="match_parent"
android:layout_height="250dp"/>
In your java class
LineVisualizer lineVisualizer = findViewById(R.id.visualizer);
mediaPlayer = MediaPlayer.create(this, R.raw.you_music);
// set custom color to the line.
lineVisualizer.setColor(ContextCompat.getColor(this, R.color.your_color));
// set the line with for the visualizer between 1-10 default 1.
lineVisualizer.setStrokeWidth(1);
// Set you media player to the visualizer.
lineVisualizer.setPlayer(mediaPlayer.getAudioSessionId());
Use of the visualizer requires the permission android.permission.RECORD_AUDIO so make sure to add it to your manifest file.