Ejemplo n.º 1
0
 public void PlayFileAudio(string file)
 {
     lock (_lock) {
         string audio_file = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\" + file;
         sp.SoundLocation = audio_file;
         lock (_lock) {
             _playFlag = playOpt.play;
         }
     }
 }
Ejemplo n.º 2
0
        private bool initPlayAudio()
        {
            bool   rs         = false;
            string audio_file = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\提示音.wav";

            //string audiofile_scanok = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\叮.wav";
            if (System.IO.File.Exists(audio_file) /*&&
                                                   * System.IO.File.Exists(audiofile_scanok)*/)
            {
                //System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
                sp = new System.Media.SoundPlayer();
                sp.SoundLocation = audio_file;
                rs = true;
                playAudioThread = new Thread(new ThreadStart(delegate {
                    while (playRunFlag)
                    {
                        if (_playFlag == playOpt.play)
                        {
                            sp.PlaySync();
                            sp.SoundLocation = audio_file;
                            lock (_lock) {
                                _playFlag = playOpt.stop;
                            }
                        }
                        else if (_playFlag == playOpt.stop)
                        {
                            sp.Stop();
                            Thread.Sleep(10);
                        }
                        else if (_playFlag == playOpt.sleep)
                        {
                            Thread.Sleep(10);
                        }
                    }
                }));
                playAudioThread.Start();
            }
            return(rs);
        }
Ejemplo n.º 3
0
 /*
  * public void PlayeFileAudio(string file) {
  *  lock (_lock) {
  *      sp.SoundLocation = file;
  *      _playFlag = playOpt.play;
  *  }
  * }
  * */
 public void PlayFileAudio()
 {
     lock (_lock) {
         _playFlag = playOpt.play;
     }
 }