Android Cannot Initialize Visualizer Engine, Error: -4
Solution 1:
After reading the documentation:
public Visualizer (int audioSession)
Added in API level 9
Class constructor.
Parameters
audioSession system wide unique audio session identifier. If audioSession is not 0, the visualizer will be attached to the MediaPlayer or AudioTrack in the same audio session. Otherwise, the Visualizer will apply to the output mix.
Are you sure you want 0 ?
Update
Looking further into the error:
public static final int ERROR_BAD_VALUE
Added in API level 9
Operation failed due to bad parameter value.
Constant Value: -4 (0xfffffffc)
That is the error your're getting, it is likely you have something bad in the configuration of the Visualizer, double check the content in your setupVisualizer method.
Solution 2:
You cannot get Visualizer to run on all platforms. It is one of the least tested objects in Android and should not have been released imho. You absolutely need to catch exceptions wherever you touch it.
Visualizer is most likely one of the most complex and undocumented classes you will ever use. It has DSP and FFT weirdness combined with arcane error handling.
Eg. You should always also instantiate an Equalizer when using Visualizer, in order to bypass volume controls.
You should never instantiate object dependencies in the declaration section of a class. This makes it difficult to catch exceptions, and also makes dependency injection difficult.
You should instantiate objects in the constructor or init method of a class so that you can catch exceptions and also support testing mocks for dependency injection.
Solution 3:
Add permission in manifest file
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
If added then check,
Goto AppInfo for this app; navigate to permissions; ensure all permissions that this app has requested has been granted.
Post a Comment for "Android Cannot Initialize Visualizer Engine, Error: -4"