C#添加声音(简单)
这是我找到的答案
System.Media.SoundPlayer player = new SoundPlayer(); player.SoundLocation = "c:\\test.wav"; //这里是文件路径 player.LoadAsync(); player.PlayLooping(); //asynchronous (loop)playing in new thread Thread.Sleep(5000); player.Stop();
//实例化和启动,test为方法名Thread thread1 =new Thread(test);thread1.Start();//这是停止线程try{if (thread1.IsAlive) { thread1.Abort(); }}