Tuesday, February 02, 2010

How to add sounds to your software

Hi there, in this tutorial you'll learn how to use sounds in your software. Let's get to it.

1. Open up Visual C# Express (or Visual Studio), and create a new Windows Form project. Name it SoundExercise.

2. Wait for the IDE to do it's loading and then click on your Form1 to select it. Press the F7 key to go into that Form1's code.

3. Add using System.Media; to the Form1's using statements. (This is so we can use the SoundPlayer class)

4. Create a SoundPlayer instance, and set the soundLocation to the ever-popular Windows "Ding" sound.
public partial class Form1 : Form
{
   public Form1()
   {
       InitializeComponent();
   }

   SoundPlayer My_JukeBox = new SoundPlayer(@"C:\WINDOWS\Media\ding.wav");
}

Read more: Dream.In.Code

Posted via email from jasper22's posterous