http://expert.csdn.net/Expert/topic/2913/2913257.xml?temp=.6179926

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/2914/2914933.xml?temp=.9197199
      

  2.   

    C#中没有声音类。播放声音请参阅API!
    比如:
    [DllImport("Winmm.dll")]
    public static extern long PlaySound(string name,long  module,long flag);
    播放声音
    using System;
    using System.Runtime.InteropServices;class musicplay{
    [DllImport("winmm.dll")]
    private static extern long mciSendString(string lpstrCommand,string lpstrReturnString,long length,long hwndcallback);
    public musicplay(string name){
    filename=name;
    }
    public void play(){
    t=mciSendString(@"open " + filename,m,0,0);
        t=mciSendString(@"play " + filename + @" wait",m,0,0);
    t=mciSendString(@"close " + filename,m,0,0);
    }
    private string filename;
    private string m=@"                                  ";
    private long t;
    }

    class test{
    static void Main(){
    Console.WriteLine("请输入你要播放的歌曲的路径");
    musicplay mpl=new musicplay(Console.ReadLine());
    mpl.play();
    Console.WriteLine("播放完毕,再见"); }
    }
      

  3.   

    我以前在VB里面用的方法,这里也可以用
    在工具栏添加/移除项,选COM组件,添加Microsoft MultiMedia Control 6.0
    然后把这个控件添加到你的FORM中去,你可以设置它的VISIBLE属性为FALSE
    写函数PlayMusic()
    private void PlayMusic()
    {
      this.AxMMControl1.DeviceType = "Sequencer"     '如果是WAV或AVI应该用"avivideo"
      this.AxMMControl1.FileName = "D:\University\Software\Media\main.mid"
      this.AxMMControl1.Command = "Open"
      this.AxMMControl1.Command = "play"
    }
    在FORM LOAD里调用PLAYMUSIC函数
    这样你的FORM启动起来就会自动播放音乐了.
    如果你想让它循环播放,在该控件的DONE方法里添加以下代码
    this.AxMMControl1.Command = "close"
    this.PlayMusic()