You've already forked lazarus-ccr
tvplanit: Introduce new datastore event OnPlaySound in order to play alarm sounds on non-Windows systems. If not assigned on Windows the mmsystem routine is used.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4736 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -72,6 +72,8 @@ type
|
|||||||
|
|
||||||
TVpTimeFormat = (tf24Hour, tf12Hour);
|
TVpTimeFormat = (tf24Hour, tf12Hour);
|
||||||
|
|
||||||
|
TVpPlaySoundMode = (psmSync, psmASync);
|
||||||
|
|
||||||
{ XML definitions }
|
{ XML definitions }
|
||||||
DOMString = WideString;
|
DOMString = WideString;
|
||||||
|
|
||||||
@ -96,6 +98,9 @@ type
|
|||||||
|
|
||||||
TVpGetEditorCaption = procedure(var Caption : string) of object;
|
TVpGetEditorCaption = procedure(var Caption : string) of object;
|
||||||
|
|
||||||
|
TVpPlaySoundEvent = procedure(Sender: TObject; const AWavFile: String;
|
||||||
|
AMode: TVpPlaySoundMode) of object;
|
||||||
|
|
||||||
{ XML exceptions }
|
{ XML exceptions }
|
||||||
EXML = class (Exception);
|
EXML = class (Exception);
|
||||||
|
|
||||||
|
@ -210,6 +210,7 @@ type
|
|||||||
FOnAlert : TVpEventEvent;
|
FOnAlert : TVpEventEvent;
|
||||||
FOnResourceChange : TVpResourceEvent;
|
FOnResourceChange : TVpResourceEvent;
|
||||||
FOnDateChanged : TVpDateChangedEvent;
|
FOnDateChanged : TVpDateChangedEvent;
|
||||||
|
FOnPlaySound : TVpPlaySoundEvent;
|
||||||
|
|
||||||
procedure dsOnTimer(Sender: TObject);
|
procedure dsOnTimer(Sender: TObject);
|
||||||
procedure dsDoOnAlert(Event: TVpEvent);
|
procedure dsDoOnAlert(Event: TVpEvent);
|
||||||
@ -258,6 +259,7 @@ type
|
|||||||
procedure PostTasks; virtual; abstract;
|
procedure PostTasks; virtual; abstract;
|
||||||
procedure PostResources; virtual; abstract;
|
procedure PostResources; virtual; abstract;
|
||||||
procedure RegisterWatcher (Watcher : THandle);
|
procedure RegisterWatcher (Watcher : THandle);
|
||||||
|
procedure PlaySound(const AWavFile: String; APlaySoundMode: TVpPlaySoundMode);
|
||||||
property Loading : Boolean
|
property Loading : Boolean
|
||||||
read FLoading write FLoading;
|
read FLoading write FLoading;
|
||||||
property Resource: TVpResource
|
property Resource: TVpResource
|
||||||
@ -290,6 +292,8 @@ type
|
|||||||
read FOnDisconnect write FOnDisconnect;
|
read FOnDisconnect write FOnDisconnect;
|
||||||
property OnResourceChange: TVpResourceEvent
|
property OnResourceChange: TVpResourceEvent
|
||||||
read FOnResourceChange write FOnResourceChange;
|
read FOnResourceChange write FOnResourceChange;
|
||||||
|
property OnPlaySound: TVpPlaySoundEvent
|
||||||
|
read FOnPlaySound write FOnPlaySound;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -383,7 +387,7 @@ implementation
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
VpSR, VpConst, VpMisc, VpResEditDlg, VpAlarmDlg,
|
VpSR, VpConst, VpMisc, VpResEditDlg, VpAlarmDlg,
|
||||||
{$IFNDEF LCL}
|
{$IFDEF WINDOWS}
|
||||||
mmSystem,
|
mmSystem,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
VpDlg, VpSelResDlg;
|
VpDlg, VpSelResDlg;
|
||||||
@ -601,23 +605,22 @@ end;
|
|||||||
|
|
||||||
procedure TVpCustomDataStore.dsDoOnAlert(Event: TVpEvent);
|
procedure TVpCustomDataStore.dsDoOnAlert(Event: TVpEvent);
|
||||||
begin
|
begin
|
||||||
if Event.AlertDisplayed then Exit;
|
if Event.AlertDisplayed then
|
||||||
|
Exit;
|
||||||
|
|
||||||
if Assigned(FOnAlert) then
|
if Assigned(FOnAlert) then
|
||||||
FOnAlert(Self, Event)
|
FOnAlert(Self, Event)
|
||||||
else begin
|
else begin
|
||||||
{Ding!}
|
{Ding!}
|
||||||
if FPlayEventSounds then begin
|
if FPlayEventSounds then begin
|
||||||
{$IFNDEF LCL}
|
if FileExists(Event.DingPath) then
|
||||||
if FileExists(Event.AlarmWavPath) then
|
|
||||||
{ if the event has a sound of its own, then play that one. }
|
{ if the event has a sound of its own, then play that one. }
|
||||||
SndPlaySound(PChar(Event.AlarmWavPath), snd_Async)
|
PlaySound(Event.DingPath, psmASync)
|
||||||
else if FileExists(FDefaultEventSound) then
|
else if FileExists(FDefaultEventSound) then
|
||||||
{ otherwise, if there is a default sound assigned, then play that one }
|
{ otherwise, if there is a default sound assigned, then play that one }
|
||||||
SndPlaySound(PChar(FDefaultEventSound), snd_Async)
|
PlaySound(FDefaultEventSound, psmASync)
|
||||||
else
|
else
|
||||||
{ otherwise just ding }
|
{ otherwise just ding }
|
||||||
{$ENDIF}
|
|
||||||
Beep;
|
Beep;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -869,7 +872,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
|
procedure TVpCustomDatastore.PlaySound(const AWavFile: String;
|
||||||
|
APlaySoundMode: TVpPlaySoundMode);
|
||||||
|
begin
|
||||||
|
if Assigned(FOnPlaySound) then
|
||||||
|
FOnPlaySound(Self, AWavFile, APlaySoundMode)
|
||||||
|
else begin
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
case APlaySoundMode of
|
||||||
|
psmSync : SndPlaySound(PChar(AWavFile), SND_SYNC);
|
||||||
|
psmASync : SndPlaySound(PChar(AWavFile), SND_ASYNC);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{=====}
|
||||||
|
|
||||||
|
|
||||||
{ TVpResourceCombo }
|
{ TVpResourceCombo }
|
||||||
|
Reference in New Issue
Block a user