-
Notifications
You must be signed in to change notification settings - Fork 137
Bar Visualizer
Gautam Chibde edited this page Apr 4, 2018
·
7 revisions
<com.chibde.audiovisulaizer.visualizer.BarVisualizer
android:id="@+id/visualizer"
android:layout_width="match_parent"
android:layout_height="250dp"/>
In your java class
BarVisualizer barVisualizer = findViewById(R.id.visualizer);
mediaPlayer = MediaPlayer.create(this, R.raw.you_music);
// set custom color to the line.
barVisualizer.setColor(ContextCompat.getColor(this, R.color.you_color));
// define custom number of bars you want in the visualizer between (10 - 256).
barVisualizer.setDensity(70);
// Set your media player to the visualizer.
barVisualizer.setPlayer(mediaPlayer.getAudioSessionId());
Use of the visualizer requires the permission android.permission.RECORD_AUDIO so make sure to add it to your manifest file.