4

I am using the following code to open the Equalizer in the App.

Intent intent = new Intent( );
intent.setAction("android.media.action.DISPLAY_AUDIO_EFFECT_CONTROL_PANEL");
if (intent.resolveActivity( getActivity().getPackageManager()) != null )
{
   startActivityForResult( intent , 100 );
}
else
{
   JBUtils.getInstance().showCustomToast( getActivity() , R.string.equalizer_notfound);
}

And added the permission

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

After user changes the Equalizer settings how to apply equalizer settings in the currently playing audio file.We are using the Exoplayer for playing the music file.

Thanks in Advance.

Community
  • 1
  • 1
Prateek
  • 306
  • 4
  • 17

2 Answers2

1

Please look at this issue (closed):

https://github.com/google/ExoPlayer/issues/252

There's an interesting example about using Equalizer in ExoPlayer. I didn't try it yet but it seems an interesting starting point to integrate standard Equalizer in ExoPlayer.

Let me know if it works!

Here is the example I would start with:

audioRenderer = new MediaCodecAudioTrackRenderer(......){

private Equalizer equalizer;

@Override
public void onAudioSessionId ( int audioSessionId){
    releaseEqualizer();
    equalizer = new Equalizer(...,audioSessionId);
    // Configure equalizer here.
    equalizer.setEnabled(true);
}

@Override
public void onDisabled () {
    releaseEqualizer();
}

private void releaseEqualizer () {
    if (equalizer != null) {
        equalizer.release();
        equalizer = null;
    }
}
};

Moreover there seems to be some issue with the equalizer. You can try to enable the workaround (disabled by default) in AudioTrack, setting the following flag to true:

public static boolean enablePreV21AudioSessionWorkaround = false;

Manuela
  • 462
  • 6
  • 18
0

You have to provide the your package name and current Media Player audio session id as extra before starting the activity. Add the below code before calling startActivityForResult.

intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, player.getAudioSessionId());

where player is an instance of MediaPlayer.

Ishaan
  • 3,658
  • 2
  • 23
  • 39