21-07-2016, 08:29 PM
public
{ Public declarations }
procedure PlayAudio_android(myresource: string);
end;
var
Form3: TForm3;
switch:boolean=false;
i:integer;
implementation
{$R *.fmx}
{$R *.SmXhdpiPh.fmx ANDROID}
procedure TForm3.Button2Click(Sender: TObject);
begin
MediaPlayer1.Stop;
end;
procedure TForm3.Button3Click(Sender: TObject);
begin
i:=1;
;(PlayAudio_android('Resource_1
end;
procedure TForm3.PlayAudio_android(myResource: string);
var
Stream: TResourceStream;
myfile: string;
begin
Stream := TResourceStream.Create(HInstance, myresource, RT_RCDATA);
try
case i of
1: myfile := TPath.Combine(TPath.GetDocumentsPath, 'Track1.mp3') ; //your resource_1
2: myfile := TPath.Combine(TPath.GetDocumentsPath, 'mou3inewadih.3gp'); //your resource_2
end;
Stream.Position := 0;
Stream.SaveToFile(myfile);
MediaPlayer1.FileName := myfile;
MediaPlayer1.Play;
finally
Stream.Free;
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
begin
i:=2;
PlayAudio_android('Resource_2');
end;
end.
{ Public declarations }
procedure PlayAudio_android(myresource: string);
end;
var
Form3: TForm3;
switch:boolean=false;
i:integer;
implementation
{$R *.fmx}
{$R *.SmXhdpiPh.fmx ANDROID}
procedure TForm3.Button2Click(Sender: TObject);
begin
MediaPlayer1.Stop;
end;
procedure TForm3.Button3Click(Sender: TObject);
begin
i:=1;
;(PlayAudio_android('Resource_1
end;
procedure TForm3.PlayAudio_android(myResource: string);
var
Stream: TResourceStream;
myfile: string;
begin
Stream := TResourceStream.Create(HInstance, myresource, RT_RCDATA);
try
case i of
1: myfile := TPath.Combine(TPath.GetDocumentsPath, 'Track1.mp3') ; //your resource_1
2: myfile := TPath.Combine(TPath.GetDocumentsPath, 'mou3inewadih.3gp'); //your resource_2
end;
Stream.Position := 0;
Stream.SaveToFile(myfile);
MediaPlayer1.FileName := myfile;
MediaPlayer1.Play;
finally
Stream.Free;
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
begin
i:=2;
PlayAudio_android('Resource_2');
end;
end.