Topic: Reminder with Text and Sound alert

I have tried to put together a simple reminder app with text pop and sound alerts. Separately they seems to be working but when I want both text and sound alerts on it doesn't work. Text alert message pops up but sound alert only plays after closing text alert popup closed. I was trying to have sound alert playing while text alert popup displayed.


Please see the sample project below:

Post's attachments

Attachment icon ReminderTSA.zip 10.87 kb, 363 downloads since 2019-04-27 

Adam
God... please help me become the person my dog thinks I am.

Re: Reminder with Text and Sound alert

Check it out

procedure OnTimer;
var
    sMessage: string;
begin
   if frmRemider.cBoxPlaySound.Checked = True then
   begin
       SoundFile := SQLExecute('SELECT message FROM reminder WHERE strftime(''%d.%m.%Y %H:%M'', datetime) = strftime(''%d.%m.%Y %H:%M'', ''now'', ''localtime'') ');
       Mediaplayer.PlayFile(frmRemider.edSoundFile.Text);
   end;

   if frmRemider.cBoxShowTextPop.Checked = True then
   begin
       sMessage := SQLExecute('SELECT message FROM reminder WHERE strftime(''%d.%m.%Y %H:%M'', datetime) = strftime(''%d.%m.%Y %H:%M'', ''now'', ''localtime'') ');
       if sMessage<>'' then ShowMessage(sMessage);
   end;

   Mediaplayer.Stop;
end;

ShowMessage shows modal windows, it's mean that script stop working and wait when this windows will be closed, so just first play sound, after that show message.

Dmitry.

Re: Reminder with Text and Sound alert

Thank you very much Dmitry.............
Truly appreciated................

Adam
God... please help me become the person my dog thinks I am.

4 (edited by AD1408 2019-05-04 08:38:42)

Re: Reminder with Text and Sound alert

I couldn't get the sound alert of the remainders work properly..


I get an error "Cannot determine the device type from the given filename extension"


Could anybody help to resolve the issue please.


Sample project is attached:

Post's attachments

Attachment icon ReminderTSA2.zip 42.68 kb, 337 downloads since 2019-05-03 

Adam
God... please help me become the person my dog thinks I am.

Re: Reminder with Text and Sound alert

could anybody put the following into MVD script please:


if the task due date + task due time = the current date + current time then
play alert sound file (.mp3 or .wav) specified

Adam
God... please help me become the person my dog thinks I am.

Re: Reminder with Text and Sound alert

Adam,
The reason you were getting the error was because your SELECT was not working properly and the SoundFile variable was empty. A couple of things needed to be considered. If the program is run and the due date and time have already passed, the alerts should be initiated. Also, if you have multiple reminders, you cannot use the form fields to look at the checkboxes for playing the sound and showing a  message because the form is only going to show the last record edited. So you have to store the play sound and show message in each reminder record and then select reminders having the Boolean fields checked. Once a reminder has been initiated, then it is turned off so it does not keep repeating. Hopefully the revised project is closer to what you want or at least gets you headed in the right direction.

Post's attachments

Attachment icon ReminderTSA2_Revised.zip 620.42 kb, 443 downloads since 2019-05-06 

Re: Reminder with Text and Sound alert

Thank you so much EHW.....
Truly appreciated..............

Adam
God... please help me become the person my dog thinks I am.

8 (edited by ekuaeshun13 2019-09-12 16:24:51)

Re: Reminder with Text and Sound alert

PM family, please how do I play an embed sound file from the database
I don't want to play from the sound_filename but play the sound data embed in the database.
Thank you

Re: Reminder with Text and Sound alert

ekuaeshun13 wrote:

PM family, please how do I play an embed sound file from the database
I don't want to play from the sound_filename but play the sound data embed in the database.
Thank you

Example

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
    sFile: string;
begin
    try
        sFile := SaveFileFromDataBase ('tablename','fieldname', Form1.TableGrid1.dbItemID); // save sound file from database
    except
    end;

    if FileExists(sFile) then
    begin
        MediaPlayer.PlayFile(sFile); // play
    end;
end;

procedure Form1_OnShow (Sender: TObject; Action: string);
begin
    MediaPlayer.OnNotify := @MediaPlayer_OnNotify; // create event
end;

procedure MediaPlayer_OnNotify (Sender: string);
begin
  if MediaPlayer.NotifyValue=nvSuccessful then // if play is finished
  begin
    if FileExists(MediaPlayer.FileName) then DeleteFile(MediaPlayer.FileName); // delete sound file
  end;
end;
Dmitry.

Re: Reminder with Text and Sound alert

Thank you so much Dmitry
The code did it like magic
Thank you