You've already forked lazarus-ccr
Bugfix: Linux implementation fixed
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3668 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<Package Version="4">
|
<Package Version="4">
|
||||||
<Name Value="playwavepackage"/>
|
<Name Value="playwavepackage"/>
|
||||||
@ -51,6 +51,7 @@
|
|||||||
</UsageOptions>
|
</UsageOptions>
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
|
<DestinationDirectory Value="/home/gordon/Lazarusprojects/playsoundpackage/published"/>
|
||||||
</PublishOptions>
|
</PublishOptions>
|
||||||
</Package>
|
</Package>
|
||||||
</CONFIG>
|
</CONFIG>
|
||||||
|
@ -28,12 +28,16 @@ type
|
|||||||
{ Public declarations }
|
{ Public declarations }
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; reintroduce;
|
destructor Destroy; reintroduce;
|
||||||
|
// This is the default method
|
||||||
procedure Execute;
|
procedure Execute;
|
||||||
published
|
published
|
||||||
{ Published declarations }
|
{ Published declarations }
|
||||||
|
// This is normally set at runtime
|
||||||
property SoundFile: string read fPathToSoundFile write fPathToSoundFile;
|
property SoundFile: string read fPathToSoundFile write fPathToSoundFile;
|
||||||
|
// Default is Async
|
||||||
property PlayStyle: TPlayStyle read fPlayStyle write fPlayStyle default psASync;
|
property PlayStyle: TPlayStyle read fPlayStyle write fPlayStyle default psASync;
|
||||||
Property PlayCommand:String read fPlayCommand write fPlayCommand;
|
// This is automatically determined when the component loads
|
||||||
|
property PlayCommand:String read fPlayCommand write fPlayCommand;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
@ -53,7 +57,6 @@ function GetNonWindowsPlayCommand:String;
|
|||||||
Var szNonWindowsPlayCommand: string;
|
Var szNonWindowsPlayCommand: string;
|
||||||
begin
|
begin
|
||||||
szNonWindowsPlayCommand:='';
|
szNonWindowsPlayCommand:='';
|
||||||
{$IFNDEF WINDOWS}
|
|
||||||
// Try play
|
// Try play
|
||||||
if (FindDefaultExecutablePath('play') <> '') then
|
if (FindDefaultExecutablePath('play') <> '') then
|
||||||
szNonWindowsPlayCommand := 'play';
|
szNonWindowsPlayCommand := 'play';
|
||||||
@ -93,7 +96,6 @@ begin
|
|||||||
if (szNonWindowsPlayCommand = '') then
|
if (szNonWindowsPlayCommand = '') then
|
||||||
if (FindDefaultExecutablePath('afplay') <> '') then
|
if (FindDefaultExecutablePath('afplay') <> '') then
|
||||||
szNonWindowsPlayCommand := 'afplay';
|
szNonWindowsPlayCommand := 'afplay';
|
||||||
{$ENDIF}
|
|
||||||
Result:=szNonWindowsPlayCommand;
|
Result:=szNonWindowsPlayCommand;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -106,7 +108,7 @@ begin
|
|||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
fPlayCommand:='sndPlaySnd';
|
fPlayCommand:='sndPlaySnd';
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
fPlayCommand:=GetNonWindowsPlayCommand;
|
fPlayCommand:=GetNonWindowsPlayCommand; // Linux, Mac etc.
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
// About Dialog properties
|
// About Dialog properties
|
||||||
AboutBoxComponentName := 'PlaySound';
|
AboutBoxComponentName := 'PlaySound';
|
||||||
@ -157,7 +159,7 @@ begin
|
|||||||
// How to play in Linux? Use generic Linux commands
|
// How to play in Linux? Use generic Linux commands
|
||||||
// Use asyncprocess to play sound as SND_ASYNC
|
// Use asyncprocess to play sound as SND_ASYNC
|
||||||
// proceed if we managed to find a valid command
|
// proceed if we managed to find a valid command
|
||||||
if (fNonWindowsPlayCommand <> '') then
|
if (fPlayCommand <> '') then
|
||||||
begin
|
begin
|
||||||
if fPlayStyle = psASync then
|
if fPlayStyle = psASync then
|
||||||
begin
|
begin
|
||||||
@ -165,7 +167,7 @@ begin
|
|||||||
SoundPlayerAsyncProcess := Tasyncprocess.Create(nil);
|
SoundPlayerAsyncProcess := Tasyncprocess.Create(nil);
|
||||||
SoundPlayerAsyncProcess.CurrentDirectory := ExtractFileDir(szSoundFilename);
|
SoundPlayerAsyncProcess.CurrentDirectory := ExtractFileDir(szSoundFilename);
|
||||||
SoundPlayerAsyncProcess.Executable :=
|
SoundPlayerAsyncProcess.Executable :=
|
||||||
FindDefaultExecutablePath(fNonWindowsPlayCommand);
|
FindDefaultExecutablePath(fPlayCommand);
|
||||||
SoundPlayerAsyncProcess.Parameters.Clear;
|
SoundPlayerAsyncProcess.Parameters.Clear;
|
||||||
SoundPlayerAsyncProcess.Parameters.Add(szSoundFilename);
|
SoundPlayerAsyncProcess.Parameters.Add(szSoundFilename);
|
||||||
try
|
try
|
||||||
@ -182,7 +184,7 @@ begin
|
|||||||
SoundPlayerSyncProcess := Tprocess.Create(nil);
|
SoundPlayerSyncProcess := Tprocess.Create(nil);
|
||||||
SoundPlayerSyncProcess.CurrentDirectory := ExtractFileDir(szSoundFilename);
|
SoundPlayerSyncProcess.CurrentDirectory := ExtractFileDir(szSoundFilename);
|
||||||
SoundPlayerSyncProcess.Executable :=
|
SoundPlayerSyncProcess.Executable :=
|
||||||
FindDefaultExecutablePath(fNonWindowsPlayCommand);
|
FindDefaultExecutablePath(fPlayCommand);
|
||||||
SoundPlayersyncProcess.Parameters.Clear;
|
SoundPlayersyncProcess.Parameters.Clear;
|
||||||
SoundPlayerSyncProcess.Parameters.Add(szSoundFilename);
|
SoundPlayerSyncProcess.Parameters.Add(szSoundFilename);
|
||||||
try
|
try
|
||||||
@ -197,7 +199,7 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise Exception.CreateFmt('The play command %s does not work on your system',
|
raise Exception.CreateFmt('The play command %s does not work on your system',
|
||||||
[fNonWindowsPlayCommand]);
|
[fPlayCommand]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user