Reputation: 4781
I need to be able to raise different types of audio notifications to the user. I need an "ok" and an "error" type sounds, I was hoping to be able to raise a simple beep and a critical stop type sound but I can only find the Beep() command which doesn't allow for differing sounds. Is there a library that does what I need or will I need to roll my own using the system wavs.
Upvotes: 0
Views: 274
Reputation: 25166
You can use the managed SystemSounds class to play most of the default sounds. Use it like this:
' Plays the sound associated with the Exclamation system event.
SystemSounds.Exclamation.Play()
This API simply encapsualtes the Windows API function MessageBeep, that you could also use. Take a look here to see its pinvoke signature.
Upvotes: 1
Reputation: 12589
Since you're in VB.Net, you've got the My namespace to play with, and if you look under My.Computer.Audio you'll find the PlaySystemSound command. This allows you to play whatever sound the user has setup for:
There's Intellisense and an enumeration that allows you to select the one you want, then it's just one line of code: My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
Upvotes: 0
Reputation: 9986
See Beep(int frequency, int duration);
Beep( 750, 300 );
dwFreq [in] The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
dwDuration [in] The duration of the sound, in milliseconds.
This article is in C#, but see if it helps.
Upvotes: 2