Thursday, 8 April 2021

How to display 2 BarVisualizers?

I am using the library audio-visualizer-android. I am getting BarVisualizer from the constructor of my class and use the following code to display the BarVisualizer:

int audioSessionId = mediaPlayer.getAudioSessionId();
if (audioSessionId != -1) {
    _barTop.setAudioSessionId(audioSessionId);
}

Well, that works fine but what I want is to display 2 BarVisualizers. This is what I have tried:

int audioSessionId = mediaPlayer.getAudioSessionId();
if (audioSessionId != -1) {
    _barTop.setEnabled(false);
    _barBottom.setEnabled(false);
    _barTop.setAudioSessionId(audioSessionId);
    _barBottom.setAudioSessionId(audioSessionId);
}

It gives me the error:

java.lang.IllegalStateException: setCaptureSize() called in wrong state: 2

When using only 1 of them, it works fine but by using both of them, I get the error and the app crashes.



from How to display 2 BarVisualizers?

No comments:

Post a Comment