none
Playing a sound and the addition of a "snooze" feature... RRS feed

  • Question

  •         private void OurTimerCallback(object source, ElapsedEventArgs e)
            {
    
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {      
                    string tAlarm = dataGridView1.Rows[i].Cells["Alarm"].Value.ToString();
                    tAlarm = tAlarm.Replace(" ", ":00 ");
    
                    if (DateTime.Now.ToString("hh:mm:ss tt").Equals(tAlarm))
                    {
                        MessageBox.Show("Sound alarm...");
                    }
                }
            }

    So a little background.... The code above is the timer tick or elapsed event of my timer which is set to tick at a one second interval. The function is comparing the current time against a list of times located in one column of my Data Grid View. If there is a match then "MessageBox.Show("Sound alarm...");".

    I have it in mind to replace "MessageBox.Show("Sound alarm...");" with a function that plays a sound file (alarm1.wav) however I am thinking that the design should allow for certain features. One of them would be I wouldn't want alarm1.wav to continue on indefinitely. At some point such as after fifteen minutes approximately it should shut itself off. As well I am thinking it would also be good to add a snooze feature so the sound (alarm1.wav) can be silenced for a period of time like three minutes or so before it goes on sounding an alarm again.

    I would absolutely love to hear any of your ideas on how to implement such features...

    Thank you in advance for any replies and I send my best regards to this forum and its members.

    Monday, October 29, 2012 7:17 PM

Answers

All replies