You've already forked lazarus-ccr
V0.0.3 PlayCommand property added
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3562 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<Version Value="9"/>
|
<Version Value="9"/>
|
||||||
@@ -31,17 +31,20 @@
|
|||||||
<FormatVersion Value="1"/>
|
<FormatVersion Value="1"/>
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="3">
|
<RequiredPackages Count="4">
|
||||||
<Item1>
|
<Item1>
|
||||||
<PackageName Value="poweredby"/>
|
<PackageName Value="RunTimeTypeInfoControls"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
<Item2>
|
<Item2>
|
||||||
<PackageName Value="playwavepackage"/>
|
<PackageName Value="poweredby"/>
|
||||||
<MaxVersion Release="1"/>
|
|
||||||
</Item2>
|
</Item2>
|
||||||
<Item3>
|
<Item3>
|
||||||
<PackageName Value="LCL"/>
|
<PackageName Value="playwavepackage"/>
|
||||||
|
<MaxVersion Release="1"/>
|
||||||
</Item3>
|
</Item3>
|
||||||
|
<Item4>
|
||||||
|
<PackageName Value="LCL"/>
|
||||||
|
</Item4>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="2">
|
<Units Count="2">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
|
@@ -7,7 +7,7 @@ uses
|
|||||||
cthreads,
|
cthreads,
|
||||||
{$ENDIF}{$ENDIF}
|
{$ENDIF}{$ENDIF}
|
||||||
Interfaces, // this includes the LCL widgetset
|
Interfaces, // this includes the LCL widgetset
|
||||||
Forms, poweredby, umainform
|
Forms, runtimetypeinfocontrols, poweredby, umainform
|
||||||
{ you can add units after this };
|
{ you can add units after this };
|
||||||
|
|
||||||
{$R *.res}
|
{$R *.res}
|
||||||
|
@@ -1,29 +1,29 @@
|
|||||||
object mainform: Tmainform
|
object mainform: Tmainform
|
||||||
Left = 415
|
Left = 415
|
||||||
Height = 129
|
Height = 257
|
||||||
Top = 305
|
Top = 305
|
||||||
Width = 241
|
Width = 352
|
||||||
BorderIcons = [biSystemMenu]
|
BorderIcons = [biSystemMenu]
|
||||||
Caption = 'mainform'
|
Caption = 'mainform'
|
||||||
ClientHeight = 129
|
ClientHeight = 257
|
||||||
ClientWidth = 241
|
ClientWidth = 352
|
||||||
DefaultMonitor = dmPrimary
|
DefaultMonitor = dmPrimary
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '1.1'
|
LCLVersion = '1.2.4.0'
|
||||||
object cmd_Async: TButton
|
object cmd_Async: TButton
|
||||||
Left = 16
|
Left = 264
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 16
|
Top = 180
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = 'Play Async'
|
Caption = 'Play Async'
|
||||||
OnClick = cmd_AsyncClick
|
OnClick = cmd_AsyncClick
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object BitBtn1: TBitBtn
|
object BitBtn1: TBitBtn
|
||||||
Left = 152
|
Left = 264
|
||||||
Height = 30
|
Height = 30
|
||||||
Top = 88
|
Top = 216
|
||||||
Width = 75
|
Width = 75
|
||||||
DefaultCaption = True
|
DefaultCaption = True
|
||||||
Kind = bkClose
|
Kind = bkClose
|
||||||
@@ -31,19 +31,31 @@ object mainform: Tmainform
|
|||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object cmd_Sync: TButton
|
object cmd_Sync: TButton
|
||||||
Left = 152
|
Left = 264
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 16
|
Top = 148
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = 'Play Sync'
|
Caption = 'Play Sync'
|
||||||
OnClick = cmd_SyncClick
|
OnClick = cmd_SyncClick
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
|
object TIPropertyGrid1: TTIPropertyGrid
|
||||||
|
Left = 4
|
||||||
|
Height = 238
|
||||||
|
Top = 8
|
||||||
|
Width = 252
|
||||||
|
DefaultValueFont.Color = clWindowText
|
||||||
|
Filter = [tkInteger, tkChar, tkEnumeration, tkFloat, tkSet, tkMethod, tkSString, tkLString, tkAString, tkWString, tkVariant, tkArray, tkRecord, tkInterface, tkClass, tkObject, tkWChar, tkBool, tkInt64, tkQWord, tkDynArray, tkInterfaceRaw, tkProcVar, tkUString, tkUChar, tkHelper]
|
||||||
|
Indent = 16
|
||||||
|
NameFont.Color = clWindowText
|
||||||
|
TIObject = playsound1
|
||||||
|
ValueFont.Color = clMaroon
|
||||||
|
end
|
||||||
object playsound1: Tplaysound
|
object playsound1: Tplaysound
|
||||||
About.Description.Strings = (
|
About.Description.Strings = (
|
||||||
'Plays WAVE sounds in Windows or Linux'
|
'Plays WAVE sounds in Windows or Linux'
|
||||||
)
|
)
|
||||||
About.Title = 'About PlaySound'
|
About.Title = 'About About PlaySound'
|
||||||
About.Height = 400
|
About.Height = 400
|
||||||
About.Width = 400
|
About.Width = 400
|
||||||
About.Font.Color = clNavy
|
About.Font.Color = clNavy
|
||||||
@@ -56,7 +68,8 @@ object mainform: Tmainform
|
|||||||
About.ComponentName = 'PlaySound'
|
About.ComponentName = 'PlaySound'
|
||||||
About.LicenseType = abLGPL
|
About.LicenseType = abLGPL
|
||||||
SoundFile = '/home/gordon/development/lazarus/'
|
SoundFile = '/home/gordon/development/lazarus/'
|
||||||
left = 91
|
PlayCommand = 'sndPlaySnd'
|
||||||
top = 53
|
left = 4
|
||||||
|
top = 8
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -5,7 +5,7 @@ unit umainform;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, FileUtil, RTTIGrids, Forms, Controls, Graphics, Dialogs,
|
||||||
StdCtrls, Buttons, uplaysound;
|
StdCtrls, Buttons, uplaysound;
|
||||||
|
|
||||||
type
|
type
|
||||||
@@ -17,6 +17,7 @@ type
|
|||||||
cmd_Async: TButton;
|
cmd_Async: TButton;
|
||||||
cmd_Sync: TButton;
|
cmd_Sync: TButton;
|
||||||
playsound1: Tplaysound;
|
playsound1: Tplaysound;
|
||||||
|
TIPropertyGrid1: TTIPropertyGrid;
|
||||||
procedure cmd_AsyncClick(Sender: TObject);
|
procedure cmd_AsyncClick(Sender: TObject);
|
||||||
procedure cmd_SyncClick(Sender: TObject);
|
procedure cmd_SyncClick(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<Package Version="4">
|
<Package Version="4">
|
||||||
<Name Value="playwavepackage"/>
|
<Name Value="playwavepackage"/>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Description Value="Simple component to play wave files under Windows or Linux"/>
|
<Description Value="Simple component to play wave files under Windows or Linux"/>
|
||||||
<License Value="LGPLv2"/>
|
<License Value="LGPLv2"/>
|
||||||
<Version Release="1"/>
|
<Version Release="3"/>
|
||||||
<Files Count="2">
|
<Files Count="2">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="uplaysound.pas"/>
|
<Filename Value="uplaysound.pas"/>
|
||||||
|
@@ -14,10 +14,11 @@ type
|
|||||||
Tplaysound = class(TAboutPlaySound)
|
Tplaysound = class(TAboutPlaySound)
|
||||||
private
|
private
|
||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
{$IFDEF LINUX}
|
{$IFNDEF WINDOWS}
|
||||||
SoundPlayerAsyncProcess: Tasyncprocess;
|
SoundPlayerAsyncProcess: Tasyncprocess;
|
||||||
SoundPlayerSyncProcess: Tprocess;
|
SoundPlayerSyncProcess: Tprocess;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
fPlayCommand:String;
|
||||||
fPathToSoundFile: string;
|
fPathToSoundFile: string;
|
||||||
fPlayStyle: TPlayStyle;
|
fPlayStyle: TPlayStyle;
|
||||||
protected
|
protected
|
||||||
@@ -32,13 +33,14 @@ type
|
|||||||
{ Published declarations }
|
{ Published declarations }
|
||||||
property SoundFile: string read fPathToSoundFile write fPathToSoundFile;
|
property SoundFile: string read fPathToSoundFile write fPathToSoundFile;
|
||||||
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;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{$IFDEF LINUX}
|
{$IFNDEF WINDOWS}
|
||||||
const // Defined in mmsystem
|
const // Defined in mmsystem
|
||||||
SND_SYNC = 0;
|
SND_SYNC = 0;
|
||||||
SND_ASYNC = 1;
|
SND_ASYNC = 1;
|
||||||
@@ -47,12 +49,65 @@ const // Defined in mmsystem
|
|||||||
resourcestring
|
resourcestring
|
||||||
C_UnableToPlay = 'Unable to play ';
|
C_UnableToPlay = 'Unable to play ';
|
||||||
|
|
||||||
|
function GetNonWindowsPlayCommand:String;
|
||||||
|
Var szNonWindowsPlayCommand: string;
|
||||||
|
begin
|
||||||
|
szNonWindowsPlayCommand:='';
|
||||||
|
{$IFNDEF WINDOWS}
|
||||||
|
// Try play
|
||||||
|
if (FindDefaultExecutablePath('play') <> '') then
|
||||||
|
szNonWindowsPlayCommand := 'play';
|
||||||
|
// Try aplay
|
||||||
|
if (szNonWindowsPlayCommand = '') then
|
||||||
|
if (FindDefaultExecutablePath('aplay') <> '') then
|
||||||
|
szNonWindowsPlayCommand := 'aplay -q';
|
||||||
|
// Try paplay
|
||||||
|
if (szNonWindowsPlayCommand = '') then
|
||||||
|
if (FindDefaultExecutablePath('paplay') <> '') then
|
||||||
|
szNonWindowsPlayCommand := 'paplay';
|
||||||
|
// Try mplayer
|
||||||
|
if (szNonWindowsPlayCommand = '') then
|
||||||
|
if (FindDefaultExecutablePath('mplayer') <> '') then
|
||||||
|
szNonWindowsPlayCommand := 'mplayer -really-quiet';
|
||||||
|
// Try CMus
|
||||||
|
if (szNonWindowsPlayCommand = '') then
|
||||||
|
if (FindDefaultExecutablePath('CMus') <> '') then
|
||||||
|
szNonWindowsPlayCommand := 'CMus';
|
||||||
|
// Try pacat
|
||||||
|
if (szNonWindowsPlayCommand = '') then
|
||||||
|
if (FindDefaultExecutablePath('pacat') <> '') then
|
||||||
|
szNonWindowsPlayCommand := 'pacat -p';
|
||||||
|
// Try ffplay
|
||||||
|
if (szNonWindowsPlayCommand = '') then
|
||||||
|
if (FindDefaultExecutablePath('ffplay') <> '') then
|
||||||
|
szNonWindowsPlayCommand := 'ffplay -autoexit -nodisp';
|
||||||
|
// Try cvlc
|
||||||
|
if (szNonWindowsPlayCommand = '') then
|
||||||
|
if (FindDefaultExecutablePath('cvlc') <> '') then
|
||||||
|
szNonWindowsPlayCommand := 'cvlc -q --play-and-exit';
|
||||||
|
// Try canberra-gtk-play
|
||||||
|
if (szNonWindowsPlayCommand = '') then
|
||||||
|
if (FindDefaultExecutablePath('canberra-gtk-play') <> '') then
|
||||||
|
szNonWindowsPlayCommand := 'canberra-gtk-play -c never -f';
|
||||||
|
// Try Macintosh command?
|
||||||
|
if (szNonWindowsPlayCommand = '') then
|
||||||
|
if (FindDefaultExecutablePath('afplay') <> '') then
|
||||||
|
szNonWindowsPlayCommand := 'afplay';
|
||||||
|
{$ENDIF}
|
||||||
|
Result:=szNonWindowsPlayCommand;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
constructor Tplaysound.Create(AOwner: TComponent);
|
constructor Tplaysound.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
fPlayStyle := psASync;
|
fPlayStyle := psASync;
|
||||||
fPathToSoundFile := ProgramDirectory;
|
fPathToSoundFile := ProgramDirectory;
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
fPlayCommand:='sndPlaySnd';
|
||||||
|
{$ELSE}
|
||||||
|
fPlayCommand:=GetNonWindowsPlayCommand;
|
||||||
|
{$ENDIF}
|
||||||
// About Dialog properties
|
// About Dialog properties
|
||||||
AboutBoxComponentName := 'PlaySound';
|
AboutBoxComponentName := 'PlaySound';
|
||||||
AboutBoxWidth := 400;
|
AboutBoxWidth := 400;
|
||||||
@@ -60,7 +115,7 @@ begin
|
|||||||
AboutBoxBackgroundColor := clCream;
|
AboutBoxBackgroundColor := clCream;
|
||||||
//AboutBoxFontName (string)
|
//AboutBoxFontName (string)
|
||||||
//AboutBoxFontSize (integer)
|
//AboutBoxFontSize (integer)
|
||||||
AboutBoxVersion := '0.0.2';
|
AboutBoxVersion := '0.0.3';
|
||||||
AboutBoxAuthorname := 'Gordon Bamber';
|
AboutBoxAuthorname := 'Gordon Bamber';
|
||||||
AboutBoxOrganisation := 'Public Domain';
|
AboutBoxOrganisation := 'Public Domain';
|
||||||
AboutBoxAuthorEmail := 'minesadorada@charcodelvalle.com';
|
AboutBoxAuthorEmail := 'minesadorada@charcodelvalle.com';
|
||||||
@@ -70,7 +125,7 @@ end;
|
|||||||
|
|
||||||
destructor Tplaysound.Destroy;
|
destructor Tplaysound.Destroy;
|
||||||
begin
|
begin
|
||||||
{$IFDEF LINUX}
|
{$IFNDEF WINDOWS}
|
||||||
FreeAndNil(SoundPlayerSyncProcess);
|
FreeAndNil(SoundPlayerSyncProcess);
|
||||||
FreeAndNil(SoundPlayerAsyncProcess);
|
FreeAndNil(SoundPlayerAsyncProcess);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@@ -87,9 +142,7 @@ end;
|
|||||||
procedure Tplaysound.PlaySound(const szSoundFilename: string);
|
procedure Tplaysound.PlaySound(const szSoundFilename: string);
|
||||||
var
|
var
|
||||||
flags: word;
|
flags: word;
|
||||||
szNonWindowsPlayCommand: string;
|
|
||||||
begin
|
begin
|
||||||
szNonWindowsPlayCommand := '';
|
|
||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
if fPlayStyle = psASync then
|
if fPlayStyle = psASync then
|
||||||
flags := SND_ASYNC or SND_NODEFAULT
|
flags := SND_ASYNC or SND_NODEFAULT
|
||||||
@@ -103,47 +156,8 @@ begin
|
|||||||
{$ELSE}
|
{$ELSE}
|
||||||
// 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
|
||||||
// Try play
|
|
||||||
if (FindDefaultExecutablePath('play') <> '') then
|
|
||||||
szNonWindowsPlayCommand := 'play';
|
|
||||||
// Try aplay
|
|
||||||
if (szNonWindowsPlayCommand = '') then
|
|
||||||
if (FindDefaultExecutablePath('aplay') <> '') then
|
|
||||||
szNonWindowsPlayCommand := 'aplay -q ';
|
|
||||||
// Try paplay
|
|
||||||
if (szNonWindowsPlayCommand = '') then
|
|
||||||
if (FindDefaultExecutablePath('paplay') <> '') then
|
|
||||||
szNonWindowsPlayCommand := 'paplay';
|
|
||||||
// Try mplayer
|
|
||||||
if (szNonWindowsPlayCommand = '') then
|
|
||||||
if (FindDefaultExecutablePath('mplayer') <> '') then
|
|
||||||
szNonWindowsPlayCommand := 'mplayer -really-quiet ';
|
|
||||||
// Try CMus
|
|
||||||
if (szNonWindowsPlayCommand = '') then
|
|
||||||
if (FindDefaultExecutablePath('CMus') <> '') then
|
|
||||||
szNonWindowsPlayCommand := 'CMus ';
|
|
||||||
// Try pacat
|
|
||||||
if (szNonWindowsPlayCommand = '') then
|
|
||||||
if (FindDefaultExecutablePath('pacat') <> '') then
|
|
||||||
szNonWindowsPlayCommand := 'pacat -p ';
|
|
||||||
// Try ffplay
|
|
||||||
if (szNonWindowsPlayCommand = '') then
|
|
||||||
if (FindDefaultExecutablePath('ffplay') <> '') then
|
|
||||||
szNonWindowsPlayCommand := 'ffplay -autoexit -nodisp ';
|
|
||||||
// Try cvlc
|
|
||||||
if (szNonWindowsPlayCommand = '') then
|
|
||||||
if (FindDefaultExecutablePath('cvlc') <> '') then
|
|
||||||
szNonWindowsPlayCommand := 'cvlc -q --play-and-exit ';
|
|
||||||
// Try canberra-gtk-play
|
|
||||||
if (szNonWindowsPlayCommand = '') then
|
|
||||||
if (FindDefaultExecutablePath('canberra-gtk-play') <> '') then
|
|
||||||
szNonWindowsPlayCommand := 'canberra-gtk-play -c never -f ';
|
|
||||||
// Try Macintosh command?
|
|
||||||
if (szNonWindowsPlayCommand = '') then
|
|
||||||
if (FindDefaultExecutablePath('afplay') <> '') then
|
|
||||||
szNonWindowsPlayCommand := 'afplay';
|
|
||||||
// proceed if we managed to find a valid command
|
// proceed if we managed to find a valid command
|
||||||
if (szNonWindowsPlayCommand <> '') then
|
if (fNonWindowsPlayCommand <> '') then
|
||||||
begin
|
begin
|
||||||
if fPlayStyle = psASync then
|
if fPlayStyle = psASync then
|
||||||
begin
|
begin
|
||||||
@@ -151,7 +165,7 @@ begin
|
|||||||
SoundPlayerAsyncProcess := Tasyncprocess.Create(nil);
|
SoundPlayerAsyncProcess := Tasyncprocess.Create(nil);
|
||||||
SoundPlayerAsyncProcess.CurrentDirectory := ExtractFileDir(szSoundFilename);
|
SoundPlayerAsyncProcess.CurrentDirectory := ExtractFileDir(szSoundFilename);
|
||||||
SoundPlayerAsyncProcess.Executable :=
|
SoundPlayerAsyncProcess.Executable :=
|
||||||
FindDefaultExecutablePath(szNonWindowsPlayCommand);
|
FindDefaultExecutablePath(fNonWindowsPlayCommand);
|
||||||
SoundPlayerAsyncProcess.Parameters.Clear;
|
SoundPlayerAsyncProcess.Parameters.Clear;
|
||||||
SoundPlayerAsyncProcess.Parameters.Add(szSoundFilename);
|
SoundPlayerAsyncProcess.Parameters.Add(szSoundFilename);
|
||||||
try
|
try
|
||||||
@@ -168,7 +182,7 @@ begin
|
|||||||
SoundPlayerSyncProcess := Tprocess.Create(nil);
|
SoundPlayerSyncProcess := Tprocess.Create(nil);
|
||||||
SoundPlayerSyncProcess.CurrentDirectory := ExtractFileDir(szSoundFilename);
|
SoundPlayerSyncProcess.CurrentDirectory := ExtractFileDir(szSoundFilename);
|
||||||
SoundPlayerSyncProcess.Executable :=
|
SoundPlayerSyncProcess.Executable :=
|
||||||
FindDefaultExecutablePath(szNonWindowsPlayCommand);
|
FindDefaultExecutablePath(fNonWindowsPlayCommand);
|
||||||
SoundPlayersyncProcess.Parameters.Clear;
|
SoundPlayersyncProcess.Parameters.Clear;
|
||||||
SoundPlayerSyncProcess.Parameters.Add(szSoundFilename);
|
SoundPlayerSyncProcess.Parameters.Add(szSoundFilename);
|
||||||
try
|
try
|
||||||
@@ -183,7 +197,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',
|
||||||
[szNonWindowsPlayCommand]);
|
[fNonWindowsPlayCommand]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user