开发者

How to add audio file to my form?

I want to add an audio file to my form so that when any button event occurs, if anything is clicked then the audio file will play.

开发者_JAVA百科

How can I do this?


code for adding audio?

private void playSoundFromResource(){
    SoundPlayer sndPing = new SoundPlayer(SoundRes.GetType(), "Ping.wav");
    sndPing.Play();
}


Well, a much more better way to write your code is to put the following code in form1.cs

private void Form1_Load(object sender, EventArgs e)
    {
        SoundPlayer Mcd = new SoundPlayer(@"C:\Users\Mcd\Desktop\abcd.wav");
        Mcd.PlayLooping();
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜