コード例 #1
0
 /// <summary>
 /// Called by the alert when it is stopped.
 /// </summary>
 protected override void OnStop()
 {
     if (sound != null)
     {
         sound.Close();
     }
     sound = null;
 }
コード例 #2
0
ファイル: Vibrator.cs プロジェクト: wnf0000/Wood
 public Vibrator()
 {
     vibrator = SystemSound.Vibrate;
     vibrator.CompletePlaybackIfAppDies = true;
     var cancel = false;
     AddMethod("vibrate", (core, args) =>
     {
         cancel = false;
         var pattern = args.GetPn<long[]>(0, null);
         if (pattern != null)
         {
             var repeat = args.GetPn(1, -1);
             var sleepArray = GetSleepArray(pattern);
             Task.Run(() =>
             {
                 for (int sleepIndex = 0; sleepIndex < sleepArray.Length; sleepIndex++)
                 {
                     if (cancel) break;
                     vibrator.PlaySystemSound();
                     if (sleepIndex == sleepArray.Length - 1)
                     {
                         if (repeat < 0) break;
                         sleepIndex = 0;
                     }
                 }
             });
         }
         else
         {
             //var duration = args.GetPn(0, 0);
             vibrator.PlaySystemSound();
         }
     });
     AddMethod("cancel", (core, args) =>
     {
         cancel = true;
         vibrator.Close();
     });
 }
コード例 #3
0
        public void StopSystemSound()
        {
            var sound = new SystemSound(1000);

            sound.Close();
        }
コード例 #4
0
ファイル: PlaySoundService.cs プロジェクト: aolserra/Sirene
 public void StopSystemSound()
 {
     sound.Close();
 }
コード例 #5
0
        public void DTMFPlayTone(string t, float reproduceSpeed)
        {
            if (!isPlaying)
            {
                isPlaying = true;

                switch (t)
                {
                case "0":
                    systemSound = new SystemSound(1200);
                    systemSound.PlayAlertSound();
                    StopSound(reproduceSpeed.ToString());
                    break;

                case "1":
                    systemSound = new SystemSound(1201);
                    systemSound.PlayAlertSound();
                    StopSound(reproduceSpeed.ToString());
                    break;

                case "2":
                    systemSound = new SystemSound(1202);
                    systemSound.PlayAlertSound();
                    StopSound(reproduceSpeed.ToString());
                    break;

                case "3":
                    systemSound = new SystemSound(1203);
                    systemSound.PlayAlertSound();
                    StopSound(reproduceSpeed.ToString());
                    break;

                case "4":
                    systemSound = new SystemSound(1204);
                    systemSound.PlayAlertSound();
                    StopSound(reproduceSpeed.ToString());
                    break;

                case "5":
                    systemSound = new SystemSound(1205);
                    systemSound.PlayAlertSound();
                    StopSound(reproduceSpeed.ToString());
                    break;

                case "6":
                    systemSound = new SystemSound(1206);
                    systemSound.PlayAlertSound();
                    StopSound(reproduceSpeed.ToString());
                    break;

                case "7":
                    systemSound = new SystemSound(1207);
                    systemSound.PlayAlertSound();
                    StopSound(reproduceSpeed.ToString());
                    break;

                case "8":
                    systemSound = new SystemSound(1208);
                    systemSound.PlayAlertSound();
                    StopSound(reproduceSpeed.ToString());
                    break;

                case "9":
                    systemSound = new SystemSound(1209);
                    systemSound.PlayAlertSound();
                    StopSound(reproduceSpeed.ToString());
                    break;

                case "#":
                    systemSound = new SystemSound(1211);
                    systemSound.PlayAlertSound();
                    StopSound(reproduceSpeed.ToString());
                    break;

                case "*":
                    systemSound = new SystemSound(1210);
                    systemSound.PlayAlertSound();
                    StopSound(reproduceSpeed.ToString());
                    break;

                default:
                    if (isPlaying)
                    {
                        systemSound = new SystemSound(1210);
                        systemSound.Close();
                    }
                    break;
                }

                isPlaying = false;
            }
        }
コード例 #6
0
 public void StopSound(string reproduceSpeed)
 {
     Thread.Sleep(int.Parse(reproduceSpeed));
     systemSound.Close();
     isPlaying = false;
 }