-
Notifications
You must be signed in to change notification settings - Fork 6
/
uSounds.pas
59 lines (52 loc) · 1.32 KB
/
uSounds.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
unit uSounds;
interface
uses FMX.Media, System.IOUtils;
procedure PlaySound(mediaplayer, secours: TMediaPlayer; volume : single = 0.5);
procedure RePlaySound(mediaplayer: TMediaPlayer; volume : single = 0.5);
function GetAppResourcesPath:string;
implementation
procedure PlaySound(mediaplayer, secours: TMediaPlayer; volume : single = 0.5);
begin
if mediaplayer.State = TMediaState.Playing then begin
if secours.State <> TMediaState.Playing then begin
secours.FileName := mediaplayer.FileName;
secours.CurrentTime := 0;
secours.Play;
end else begin
mediaplayer.CurrentTime := 0;
mediaplayer.Play;
end;
end else begin
mediaplayer.CurrentTime := 0;
mediaplayer.Play;
end;
end;
procedure RePlaySound(mediaplayer: TMediaPlayer; volume : single = 0.5);
begin
if mediaplayer.State = TMediaState.Stopped then begin
mediaplayer.CurrentTime := 0;
mediaplayer.Play;
end;
end;
function GetAppResourcesPath:string;
{$IFDEF MSWINDOWS}
begin
result := TPath.GetDirectoryName(ParamStr(0));
end;
{$ENDIF MSWINDOWS}
{$IFDEF MACOS}
begin
result := TPath.GetHomePath;
end;
{$ENDIF MACOS}
{$IFDEF LINUX}
begin
result := TPath.GetDirectoryName(ParamStr(0));
end;
{$ENDIF LINUX}
{$IFDEF ANDROID}
begin
result := TPath.GetDocumentsPath;
end;
{$ENDIF ANDROID}
end.