简体   繁体   English

在Visual C#中播放声音

[英]Playing sounds in Visual C#

I want to add sound effects to my Visual C# program. 我想为我的Visual C#程序添加声音效果。 What's the simplest way to do this? 最简单的方法是什么?

System.Media.SoundPlayer sound = new System.Media.SoundPlayer(@"ringout.wav");
sound.PlaySync();

使用System.Media.SoundPlayer从.NET应用程序中播放WAV。

您可以在启动时将wav文件加载到内存中,然后在某些事件上播放它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM