Delphi XE Can’t play sounds on Android device

  

I use TMediaPlayer and the following procedure:

procedure TForm1.PlayAudio(ResourceID: string);
var
ResStream: TResourceStream;
TmpFile: string;
begin
ResStream := TResourceStream.Create(HInstance, ResourceID, RT_RCDATA);
try

//TmpFile := TPath.Combine(TPath.GetTempPath, ‘tmp.wav’);
TmpFile :=(System.IOUtils.TPath.GetDocumentsPath + System.SysUtils.PathDelim + ‘tmp.wav’);

ResStream.Position := 0;
ResStream.SaveToFile(TmpFile);
MediaPlayer1.FileName := TmpFile;

MediaPlayer1.Play;

finally
ResStream.Free;
end;
end;

To play sounds from my resources like this: PlayAudio(‘Resource_1’); which are .wav and .mp3

It works fine on Windows but when I deploy it on Android it won’t play any sounds, and I still can’t find well explained way to play sounds on android from my resources. What is the best way to do so?

Comments are closed.