954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Playing a soundfile in resources

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...

nsutton
Light Poster
46 posts since Apr 2010
Reputation Points: 10
Solved Threads: 2
 
private void whiteKey1_Click(object sender, EventArgs e)
        {
            //If clicked
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.FileNameHere);
            player.Play();
        }
bbman
Junior Poster
182 posts since May 2010
Reputation Points: 22
Solved Threads: 10
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: