0

How can you play a sound file that resides in the solutions resources file?

Heres what I have.....

private void whiteKey1_Click(object sender, EventArgs e)
        {
            //If clicked
            System.Media.SoundPlayer player = new System.Media.SoundPlayer("WindowsPiano.Windows_XP_Ding.wav");
            player.Play();


        }

I'm making a virtual piano and when the key is pressed it plays a sound...

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by bbman
0
private void whiteKey1_Click(object sender, EventArgs e)
        {
            //If clicked
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.FileNameHere);
            player.Play();
        }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.