I'm creating mediaPlayer with EQ, when I set the EQ bands it works fine. I have code that lists all presets, on change I want to set the preset to EQ, but I'm getting bad parameter value
.
This is what I have in my log:
09-29 14:29:24.810: W/System.err(27829): java.lang.IllegalArgumentException: AudioEffect: bad parameter value
09-29 14:29:24.835: W/System.err(27829): at android.media.audiofx.AudioEffect.checkStatus(AudioEffect.java:1259)
09-29 14:29:24.835: W/System.err(27829): at android.media.audiofx.Equalizer.usePreset(Equalizer.java:342)
getNumberOfPresets() returns 12 and preset to set for this example is 2 (but it happens for all values 0-11)
If I use setBandLevel()
before usePreset()
it's not throwing an exception, but i'm not sure if this is the right way to do it.
Edit: setBandLevel has nothing to do with the exception. It just pops out randomly, 80% of the tries.
Update: I noticed that this is happening on Samsung S3 devices (for now) only. Works fine on Asus TF101.
Any help is appreciated.
Here is the code:
mEqualizer = new Equalizer(0, mMediaPlayer.getAudioSessionId());
mEqualizer.setEnabled(true);
mEqualizer.usePreset((short)mEQPresetPos);