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>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
@ -31,17 +31,20 @@
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="3">
|
||||
<RequiredPackages Count="4">
|
||||
<Item1>
|
||||
<PackageName Value="poweredby"/>
|
||||
<PackageName Value="RunTimeTypeInfoControls"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="playwavepackage"/>
|
||||
<MaxVersion Release="1"/>
|
||||
<PackageName Value="poweredby"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="LCL"/>
|
||||
<PackageName Value="playwavepackage"/>
|
||||
<MaxVersion Release="1"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item4>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
|
@ -7,7 +7,7 @@ uses
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, poweredby, umainform
|
||||
Forms, runtimetypeinfocontrols, poweredby, umainform
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
@ -1,29 +1,29 @@
|
||||
object mainform: Tmainform
|
||||
Left = 415
|
||||
Height = 129
|
||||
Height = 257
|
||||
Top = 305
|
||||
Width = 241
|
||||
Width = 352
|
||||
BorderIcons = [biSystemMenu]
|
||||
Caption = 'mainform'
|
||||
ClientHeight = 129
|
||||
ClientWidth = 241
|
||||
ClientHeight = 257
|
||||
ClientWidth = 352
|
||||
DefaultMonitor = dmPrimary
|
||||
OnCreate = FormCreate
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '1.1'
|
||||
LCLVersion = '1.2.4.0'
|
||||
object cmd_Async: TButton
|
||||
Left = 16
|
||||
Left = 264
|
||||
Height = 25
|
||||
Top = 16
|
||||
Top = 180
|
||||
Width = 75
|
||||
Caption = 'Play Async'
|
||||
OnClick = cmd_AsyncClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object BitBtn1: TBitBtn
|
||||
Left = 152
|
||||
Left = 264
|
||||
Height = 30
|
||||
Top = 88
|
||||
Top = 216
|
||||
Width = 75
|
||||
DefaultCaption = True
|
||||
Kind = bkClose
|
||||
@ -31,19 +31,31 @@ object mainform: Tmainform
|
||||
TabOrder = 1
|
||||
end
|
||||
object cmd_Sync: TButton
|
||||
Left = 152
|
||||
Left = 264
|
||||
Height = 25
|
||||
Top = 16
|
||||
Top = 148
|
||||
Width = 75
|
||||
Caption = 'Play Sync'
|
||||
OnClick = cmd_SyncClick
|
||||
TabOrder = 2
|
||||
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
|
||||
About.Description.Strings = (
|
||||
'Plays WAVE sounds in Windows or Linux'
|
||||
)
|
||||
About.Title = 'About PlaySound'
|
||||
About.Title = 'About About PlaySound'
|
||||
About.Height = 400
|
||||
About.Width = 400
|
||||
About.Font.Color = clNavy
|
||||
@ -56,7 +68,8 @@ object mainform: Tmainform
|
||||
About.ComponentName = 'PlaySound'
|
||||
About.LicenseType = abLGPL
|
||||
SoundFile = '/home/gordon/development/lazarus/'
|
||||
left = 91
|
||||
top = 53
|
||||
PlayCommand = 'sndPlaySnd'
|
||||
left = 4
|
||||
top = 8
|
||||
end
|
||||
end
|
||||
|
@ -5,7 +5,7 @@ unit umainform;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||
Classes, SysUtils, FileUtil, RTTIGrids, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, Buttons, uplaysound;
|
||||
|
||||
type
|
||||
@ -17,6 +17,7 @@ type
|
||||
cmd_Async: TButton;
|
||||
cmd_Sync: TButton;
|
||||
playsound1: Tplaysound;
|
||||
TIPropertyGrid1: TTIPropertyGrid;
|
||||
procedure cmd_AsyncClick(Sender: TObject);
|
||||
procedure cmd_SyncClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<Package Version="4">
|
||||
<Name Value="playwavepackage"/>
|
||||
@ -22,7 +22,7 @@
|
||||
</CompilerOptions>
|
||||
<Description Value="Simple component to play wave files under Windows or Linux"/>
|
||||
<License Value="LGPLv2"/>
|
||||
<Version Release="1"/>
|
||||
<Version Release="3"/>
|
||||
<Files Count="2">
|
||||
<Item1>
|
||||
<Filename Value="uplaysound.pas"/>
|
||||
|
@ -14,10 +14,11 @@ type
|
||||
Tplaysound = class(TAboutPlaySound)
|
||||
private
|
||||
{ Private declarations }
|
||||
{$IFDEF LINUX}
|
||||
{$IFNDEF WINDOWS}
|
||||
SoundPlayerAsyncProcess: Tasyncprocess;
|
||||
SoundPlayerSyncProcess: Tprocess;
|
||||
{$ENDIF}
|
||||
fPlayCommand:String;
|
||||
fPathToSoundFile: string;
|
||||
fPlayStyle: TPlayStyle;
|
||||
protected
|
||||
@ -32,13 +33,14 @@ type
|
||||
{ Published declarations }
|
||||
property SoundFile: string read fPathToSoundFile write fPathToSoundFile;
|
||||
property PlayStyle: TPlayStyle read fPlayStyle write fPlayStyle default psASync;
|
||||
Property PlayCommand:String read fPlayCommand write fPlayCommand;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
{$IFDEF LINUX}
|
||||
{$IFNDEF WINDOWS}
|
||||
const // Defined in mmsystem
|
||||
SND_SYNC = 0;
|
||||
SND_ASYNC = 1;
|
||||
@ -47,12 +49,65 @@ const // Defined in mmsystem
|
||||
resourcestring
|
||||
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);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
fPlayStyle := psASync;
|
||||
fPathToSoundFile := ProgramDirectory;
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
fPlayCommand:='sndPlaySnd';
|
||||
{$ELSE}
|
||||
fPlayCommand:=GetNonWindowsPlayCommand;
|
||||
{$ENDIF}
|
||||
// About Dialog properties
|
||||
AboutBoxComponentName := 'PlaySound';
|
||||
AboutBoxWidth := 400;
|
||||
@ -60,7 +115,7 @@ begin
|
||||
AboutBoxBackgroundColor := clCream;
|
||||
//AboutBoxFontName (string)
|
||||
//AboutBoxFontSize (integer)
|
||||
AboutBoxVersion := '0.0.2';
|
||||
AboutBoxVersion := '0.0.3';
|
||||
AboutBoxAuthorname := 'Gordon Bamber';
|
||||
AboutBoxOrganisation := 'Public Domain';
|
||||
AboutBoxAuthorEmail := 'minesadorada@charcodelvalle.com';
|
||||
@ -70,7 +125,7 @@ end;
|
||||
|
||||
destructor Tplaysound.Destroy;
|
||||
begin
|
||||
{$IFDEF LINUX}
|
||||
{$IFNDEF WINDOWS}
|
||||
FreeAndNil(SoundPlayerSyncProcess);
|
||||
FreeAndNil(SoundPlayerAsyncProcess);
|
||||
{$ENDIF}
|
||||
@ -87,9 +142,7 @@ end;
|
||||
procedure Tplaysound.PlaySound(const szSoundFilename: string);
|
||||
var
|
||||
flags: word;
|
||||
szNonWindowsPlayCommand: string;
|
||||
begin
|
||||
szNonWindowsPlayCommand := '';
|
||||
{$IFDEF WINDOWS}
|
||||
if fPlayStyle = psASync then
|
||||
flags := SND_ASYNC or SND_NODEFAULT
|
||||
@ -103,47 +156,8 @@ begin
|
||||
{$ELSE}
|
||||
// How to play in Linux? Use generic Linux commands
|
||||
// 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
|
||||
if (szNonWindowsPlayCommand <> '') then
|
||||
if (fNonWindowsPlayCommand <> '') then
|
||||
begin
|
||||
if fPlayStyle = psASync then
|
||||
begin
|
||||
@ -151,7 +165,7 @@ begin
|
||||
SoundPlayerAsyncProcess := Tasyncprocess.Create(nil);
|
||||
SoundPlayerAsyncProcess.CurrentDirectory := ExtractFileDir(szSoundFilename);
|
||||
SoundPlayerAsyncProcess.Executable :=
|
||||
FindDefaultExecutablePath(szNonWindowsPlayCommand);
|
||||
FindDefaultExecutablePath(fNonWindowsPlayCommand);
|
||||
SoundPlayerAsyncProcess.Parameters.Clear;
|
||||
SoundPlayerAsyncProcess.Parameters.Add(szSoundFilename);
|
||||
try
|
||||
@ -168,7 +182,7 @@ begin
|
||||
SoundPlayerSyncProcess := Tprocess.Create(nil);
|
||||
SoundPlayerSyncProcess.CurrentDirectory := ExtractFileDir(szSoundFilename);
|
||||
SoundPlayerSyncProcess.Executable :=
|
||||
FindDefaultExecutablePath(szNonWindowsPlayCommand);
|
||||
FindDefaultExecutablePath(fNonWindowsPlayCommand);
|
||||
SoundPlayersyncProcess.Parameters.Clear;
|
||||
SoundPlayerSyncProcess.Parameters.Add(szSoundFilename);
|
||||
try
|
||||
@ -183,7 +197,7 @@ begin
|
||||
end
|
||||
else
|
||||
raise Exception.CreateFmt('The play command %s does not work on your system',
|
||||
[szNonWindowsPlayCommand]);
|
||||
[fNonWindowsPlayCommand]);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user