java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -3 at android.media.audiofx.Visualizer.<init>(Visualizer.java:218) at com.gauravk.audiovisualizer.base.BaseVisualizer.setAudioSessionId(BaseVisualizer.java:196) at com.andruid.magic.makeitspeak.activity.DetailsActivity.onAudioSessionId(DetailsActivity.java:146) at com.google.android.exoplayer2.SimpleExoPlayer$ComponentListener.onAudioSessionId(SimpleExoPlayer.java:1306) at com.google.android.exoplayer2.audio.AudioRendererEventListener$EventDispatcher.lambda$audioSessionId$5$AudioRendererEventListener$EventDispatcher(AudioRendererEventListener.java:164) at com.google.android.exoplayer2.audio.-$$Lambda$AudioRendererEventListener$EventDispatcher$a1B1YBHhPRCtc1MQAc2fSVEo22I.run(Unknown Source:4) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:7000) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
I am using exoplayer to play my audio file in Activity. I used the below code to get audio session id.
exoPlayer.addAudioListener(this);
@Override
public void onAudioSessionId(int audioSessionId) {
Timber.tag(TAG).d("audio session id: %d", audioSessionId);
binding.visualizer.setAudioSessionId(audioSessionId);
}
Above code gives an error for all visualizers.
java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -3 at android.media.audiofx.Visualizer.<init>(Visualizer.java:218) at com.gauravk.audiovisualizer.base.BaseVisualizer.setAudioSessionId(BaseVisualizer.java:196) at com.andruid.magic.makeitspeak.activity.DetailsActivity.onAudioSessionId(DetailsActivity.java:146) at com.google.android.exoplayer2.SimpleExoPlayer$ComponentListener.onAudioSessionId(SimpleExoPlayer.java:1306) at com.google.android.exoplayer2.audio.AudioRendererEventListener$EventDispatcher.lambda$audioSessionId$5$AudioRendererEventListener$EventDispatcher(AudioRendererEventListener.java:164) at com.google.android.exoplayer2.audio.-$$Lambda$AudioRendererEventListener$EventDispatcher$a1B1YBHhPRCtc1MQAc2fSVEo22I.run(Unknown Source:4) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:7000) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)