Visualizer class exception for Windows Visualizer

I use the AndroidFX Visualizer class in my demo FFT reader application, but when I try to create an object of this class, this is a Runtime exception ( java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -1 ). The Player class is my custom class for controlling playback and using the same Player class that I implemented the equalizer class and works great. Do I need to add any permissions to the manifest file?

 Player mediaPlayer = Player.GetInstance(); mediaPlayer.LoadFile("song.mp3"); mediaPlayer.Play(); try{ visual = new Visualizer(mediaPlayer.GetAudioSessionID()); // this line causing Exception visual.setEnabled(true); visual.setCaptureSize(Visualizer.getCaptureSizeRange()[1]); } catch(Exception ex) { Log.e("Visual Ex", ex.getMessage()); } 
+8
android visualization audio
source share
2 answers

This is due to my stupid mistake, this function requires permission <uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission> . thanks

+27
source share

I know this is a very late answer, but I also struggled with this problem and I want to share my experience.

First, as the answer mentioned above, permission

 <uses-permission android:name="android.permission.RECORD_AUDIO"/> 

and if sound source 0 is used ( Visualizer(0); //system mix ),

 <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/> 

. After adding permissions to my application and installing the (new compiled) application again, my application still crashed. I found out that the device needs to be restarted in order to use Visualizer without any exceptions (for some reason). Therefore, if you are developing an application and get this exception, you may need to reboot after adding permissions to the application .

+4
source share

All Articles