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:
wp_xxyyzz
2016-06-14 10:38:28 +00:00
parent 4493e26898
commit 726606df8c
4 changed files with 32 additions and 7 deletions

View File

@ -72,7 +72,7 @@ type
TVpTimeFormat = (tf24Hour, tf12Hour);
TVpPlaySoundMode = (psmSync, psmASync);
TVpPlaySoundMode = (psmSync, psmAsync, psmStop);
{ XML definitions }
DOMString = WideString;

View File

@ -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;

View File

@ -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

View File

@ -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.