Reputation: 145
I'm developping in an application in Csharp and I want to read a sound file in an external sound card,is there a function which give me the possibility to play sound using the name of the sound card and the name of the audio file . So if I want to create 3 buttons and I have 3 sound cards and each button is related to a sound card (for example button1 is related to sound card1 ...) which code can help me to play an audio file in the specific sound card ??? Please give me a code,because I'm preparing a general alarm and such code will help me alot.
Thank you in advance
Upvotes: 0
Views: 2203
Reputation: 4565
I'm not aware of a way of doing this within .net framework. But you can use the direct sound api:
DirectSoundEnumerate to find available devices and then use the guid of the desired device in DirectSoundCreate.
Please, do not change the default device of the PC by messing around with the registry (or at all). This would be a major annoyance for your users.
Here's some sample code for playing a sound in DirectX natively.
You could check out Managed DirectX and/or XNA. It may make life easier for you by providing you with a managed wrapper for DirectSound.
Upvotes: 2