Exemple #1
0
        static private void Play()
        {
            if (_playList.Count > 0)
            {
                // Try to get the first item under a lock.
                int           index = -1;
                PlayAlarmItem item  = null;
                lock (_lock)
                {
                    if (_playList.Count > 0)
                    {
                        index = _playList.Count - 1;
                        item  = (PlayAlarmItem)_playList[index];
                        _playList.Remove(item);
                    }
                }

                if (null != item)
                {
                    _mediaPlayer.Source = MediaSource.CreateFromStorageFile(item.AlarmFile);
                    _mediaPlayer.Play();

                    // If the item needs to be played continuously, then add it back to the list.
                    if (item.IsContinuousAlarm)
                    {
                        _playList.Add(item);
                    }
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Cancel the alarm by the id provided.
 /// </summary>
 /// <param name="alarmId"></param>
 static public void CancelAlarm(Int64 alarmId)
 {
     lock (_lock)
     {
         PlayAlarmItem item = _playList.Find((entry) => entry.AlarmId == alarmId);
         if (null != item)
         {
             _playList.Remove(item);
         }
     }
 }
Exemple #3
0
        static public void PlayAnnouncement(IStorageFile myAnnouncement, bool isContinuousAlarm, Int64 announcementId)
        {
            PlayAlarmItem item = new PlayAlarmItem(myAnnouncement, isContinuousAlarm, announcementId);

            lock (_lock)
            {
                _playList.Add(item);
            }

            // Start a background timer job to signal the alarm.
            // Start this timer job 3 seconds later, so that the system as a few seconds to start up.
            _timerRecurringAlarm.Change(3000, 3000);
        }