The tonysound.cs class gives you the ability to add Wav sound to your Windows forms. Simply include the tonysound.cs in your project folder. This is my first article, so please don't beat me up too bad.
Including the code in your form
Add the tonysound.cs file to your project. Then at the top of the calling form, for example,
form1, type the following line to use the
using tonysound; is included, then simply play the sound by calling:
Note: You can pass as many flags as you want, but if you're playing a file then you need to do something like I have in my code:
The first parameter of
Sound.Play is the filename. The filename can be the actual path, for example c:\\sound.wav, or it can simply be a Wav file that is in the same directory as the exe. The second is the flag for playing the sound. You can play a null sound to turn off the sound as follows:
NOTE: You must include either
PlaySoundFlags.SND_RESOURCE in order to actually play the song. The remaining flags are optional.
List of PlaySoundFlags and their use:
These are changes to my previous post, thanks to the suggestions.