Playing sounds as Android Service with Delphi FMX

  

Have a project which accumulates data from a 3 Party Device to android Tablets / Phones
this is set to beep when a data packet is accepted and works fine until the App goes to the background
I thought that if I Created a service to make the sound this would be over come however I have found that I cant Address the FMX components from the Service so the present way that I am implementing the sound is not available
in the main app I Used
procedure PlayMedia(aFile: String);
var
l_mp: TMediaPlayer;
begin
l_mp := TMediaPlayer.Create(Application);
l_mp.FileName := System.IOUtils.TPath.Combine(System.IOUtils.TPath.GetDocumentsPath, aFile);

l_mp.Play;

end;

In the Service I Tried
procedure TDMSounds.PlaySound(afile: String);
var
Volume: Integer;
StreamType: Integer;
ToneType: Integer;
ToneGenerator: JToneGenerator;
RingToneMgr:JRingToneManager;
RingTone:JRingtone;
begin

Volume := TJToneGenerator.JavaClass.MAX_VOLUME;

StreamType := TJAudioManager.JavaClass.STREAM_SYSTEM;
ToneType := TJToneGenerator.JavaClass.TONE_DTMF_9;

ToneGenerator := TJToneGenerator.JavaClass.init(StreamType, Volume);
ToneGenerator.startTone(ToneType, 1000);

end;

carn’t seem to get a result from the service
any Ideas Greatly Appreciated

Comments are closed.