第一次接触这东西,不知道具体的代码流程是什么样的, 希望各位朋友能给个简单的小例子借鉴一下,先谢谢啦。

解决方案 »

  1.   

    public class Player
        {
            static AutoResetEvent _playEvent = new AutoResetEvent(true);
            /// <summary>
            /// 播放声音文件
            /// </summary>
            /// <param name="fileName">声音文件的名称</param>
            public static void Play(string fileName)
            {
                _playEvent.WaitOne();
                try
                {
                    string applicationDirectory = Directory.GetCurrentDirectory();
                    applicationDirectory += @"\GC_Sound\";
                    if (File.Exists(applicationDirectory + fileName))
                    {
                        SoundPlayer _currentPlayer = new SoundPlayer(applicationDirectory + fileName);
                        _currentPlayer.Load();
                        if (_currentPlayer.IsLoadCompleted == true)
                            _currentPlayer.PlaySync();
                    }
                }
                finally
                {
                    _playEvent.Set();
                }
                
            }
        }
    我写的播放文件的类。
    static AutoResetEvent _playEvent = new AutoResetEvent(true);
    用来线程同步的信号量,你可以不用管它。他的作用是,限制必须在播放一段声音之后,再去播放另外一段声音。
      

  2.   

    windows Media player
    private AxMediaPlayer.AxMediaPlayer axWindowsMediaPlayer1; 
    if(openFileDialog1.ShowDialog()==DialogResult.OK) 
      { 
          axWindowsMediaPlayer1.FileName = openFileDialog1.FileName; 
      }       
    http://topic.csdn.net/u/20091205/22/42b20870-34dc-4b30-9465-1b618e260b03.html
      

  3.   

    你添加系统的播放器吧,WindowsMediaPlayer,托出来用就可以了,你为它设置一个音乐的播放路径就可以了如:
     this.axWindowsMediaPlayer1.URL = str1;//str1音乐文件的绝对路径
     this.axWindowsMediaPlayer1.Ctlcontrols.play();