You've already forked lazarus-ccr
tvplanit: In WavDlg play sound asynchronously and add option to turn it off.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4746 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -72,7 +72,7 @@ type
|
||||
|
||||
TVpTimeFormat = (tf24Hour, tf12Hour);
|
||||
|
||||
TVpPlaySoundMode = (psmSync, psmASync);
|
||||
TVpPlaySoundMode = (psmSync, psmAsync, psmStop);
|
||||
|
||||
{ XML definitions }
|
||||
DOMString = WideString;
|
||||
|
@ -892,7 +892,8 @@ begin
|
||||
{$IFDEF WINDOWS}
|
||||
case APlaySoundMode of
|
||||
psmSync : SndPlaySound(PChar(AWavFile), SND_SYNC);
|
||||
psmASync : SndPlaySound(PChar(AWavFile), SND_ASYNC);
|
||||
psmAsync : SndPlaySound(PChar(AWavFile), SND_ASYNC);
|
||||
psmStop : SndPlaySound(nil, 0);
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
@ -102,6 +102,7 @@ object FrmSoundDialog: TFrmSoundDialog
|
||||
Caption = 'OkBtn'
|
||||
Default = True
|
||||
ModalResult = 1
|
||||
OnClick = OkBtnClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object CancelBtn: TButton
|
||||
@ -113,6 +114,7 @@ object FrmSoundDialog: TFrmSoundDialog
|
||||
Cancel = True
|
||||
Caption = 'CancelBtn'
|
||||
ModalResult = 2
|
||||
OnClick = CancelBtnClick
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
|
@ -62,12 +62,16 @@ type
|
||||
CBDefault: TCheckBox;
|
||||
OkBtn: TButton;
|
||||
CancelBtn: TButton;
|
||||
procedure CancelBtnClick(Sender: TObject);
|
||||
procedure CBDefaultClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure OkBtnClick(Sender: TObject);
|
||||
procedure PlayButtonClick(Sender: TObject);
|
||||
private
|
||||
FOnPlaySound: TVpPlaySoundEvent;
|
||||
function FindFileItem(AFilename: String): TListItem;
|
||||
procedure PlaySound;
|
||||
procedure StopSound;
|
||||
public
|
||||
DingPath: string;
|
||||
MediaFolder: String;
|
||||
@ -88,6 +92,11 @@ uses
|
||||
{$R *.dfm}
|
||||
{$ENDIF}
|
||||
|
||||
procedure TFrmSoundDialog.CancelBtnClick(Sender: TObject);
|
||||
begin
|
||||
StopSound;
|
||||
end;
|
||||
|
||||
procedure TFrmSoundDialog.CBDefaultClick(Sender: TObject);
|
||||
begin
|
||||
ShellTreeview.Visible := not CBDefault.Checked;
|
||||
@ -126,17 +135,24 @@ begin
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
procedure TFrmSoundDialog.OkBtnClick(Sender: TObject);
|
||||
begin
|
||||
StopSound;
|
||||
end;
|
||||
|
||||
procedure TFrmSoundDialog.PlayButtonClick(Sender: TObject);
|
||||
begin
|
||||
DingPath := GetSelectedFileName;
|
||||
if Assigned(FOnPlaySound) then begin
|
||||
PlayButton.Enabled := false;
|
||||
FOnPlaySound(self, DingPath, psmSync);
|
||||
PlayButton.Enabled := true;
|
||||
end;
|
||||
PlaySound;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TFrmSoundDialog.PlaySound;
|
||||
begin
|
||||
if Assigned(FOnPlaySound) then
|
||||
FOnPlaySound(self, DingPath, psmAsync);
|
||||
end;
|
||||
|
||||
procedure TFrmSoundDialog.Populate;
|
||||
begin
|
||||
TabSheet1.Caption := RSSelectASound;
|
||||
@ -160,5 +176,11 @@ begin
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TFrmSoundDialog.StopSound;
|
||||
begin
|
||||
if Assigned(FOnPlaySound) then
|
||||
FOnPlaySound(self, '', psmStop);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Reference in New Issue
Block a user