c#使用System.Media.SoundPlayer播放资源文件中的wav文件

c#使用System.Media.SoundPlayer播放资源文件中的wav文件
创建:
System.Media.SoundPlayer soundplayer = new System.Media.SoundPlayer();
初始化路径:
soundplayer.SoundLocation = Application.StartupPath + “\” + “DateSource” + “\” + “sound.wav”;
事件中打开:
1)同步播放:
soundplayer.Load();
soundplayer.Play();
2)异步播放:
soundplayer.LoadAsync();
soundplayer.PlaySync();
3)循环播放:
soundplayer.Load();
soundplayer.PlayLooping();
事件中关闭:
soundplayer.Stop();

猜你喜欢

转载自blog.csdn.net/qq_30725967/article/details/85259787