Play A Sound Alert/beep On Delphi XE5/Android Platform
Is there any way to play a sound alert/beep on Delphi XE5/Android platform? What I'm trying to achieve is how to play system alert/beep sound like Windows application using Beep fu
Solution 1:
I ended up using resource files to play my custom audio file.
Steps:
- From Delphi IDE click on "Project".
- Then select "Resources and Images...".
- Choose your media file and set it as RCDATA.
- Remember your resource identifier.
Note: Make sure the media type is supported by TMediaPlayer otherwise it won't work.
Delphi Procedure:
procedure PlayAudio(ResourceID: string);
var
ResStream: TResourceStream;
TmpFile: string;
begin
ResStream := TResourceStream.Create(HInstance, ResourceID, RT_RCDATA);
try
TmpFile := TPath.Combine(TPath.GetTempPath, 'tmp.mp3');
ResStream.Position := 0;
ResStream.SaveToFile(TmpFile);
MediaPlayer1.FileName := TmpFile;
MediaPlayer1.Play;
finally
ResStream.Free;
end;
end;
Usage:
PlayAudio('Resource_1');
Post a Comment for "Play A Sound Alert/beep On Delphi XE5/Android Platform"