0

I am writing a mediaplayer app for private use in Delphi XE10 for Android. I would like to use the android equalizer but don't know really how. The JEqualizer interface is exposed in Androidapi.JNI.Media (as are other soundfx functions). I have two specific problems:

1.) I am not very advanced in creating delphi objects from android interfaces. Am right just to do the following:

var
   equ : jequalizer; 
begin
equ := tjequalizer.wrap((sharedactivitycontext.getsystemservice(tjcontext.JavaClass.AUDIO_SERVICE) as ILocalObject).getobjectid);

2.) To create the equalizer I need the audiosession of the mediaplayer, which is not exposed in the Delphi mediaplayer object. Any idea how I could get that?

Ken White
  • 123,280
  • 14
  • 225
  • 444
Andre Ruebel
  • 518
  • 3
  • 12

1 Answers1

0

After a lot of experimenting with failures I finally found the answer myself. The first part of the answer is that it does not seem to be possible to use the audio effects with the delphi tmediaplayer object. However: It is possible if you create the android mediaplayer yourself. In that case of course the resulting app will not be cross-platform anymore. So for everyone who might need it, here is the solution as code for the bassboost effect:

var  //shoud be no local variables of course, but defined in your forms scope
    mp: JMediaPlayer;
    bb: JBassboost;
begin
  mp := tjmediaplayer.Create;
  mp.reset;
  mp.setdatasource(StringToJString(Edit1.text)); // in edit1.text I have the path to an mp3 file
  mp.prepare;
  mp.start;  //now the mediaplayer is playing music
  bb := tjbassboost.javaclass.init(0, mp.getAudioSessionId);
  bb.setEnabled(true);
  bb.setStrength(1000); //value 0-1000. now the effect is applied
end;  
Andre Ruebel
  • 518
  • 3
  • 12