We are currently developing a game using XNA and we've stumbled upon a little sound problem.
When a system has no sound device plugged in (speakers, etc. -- when Win7 shows a red cross on the speaker icon) it crashes when trying to play/load the sound.
So, we would like to check if the system has the capacity of outputting sound. Is it possible in C#?
Press the Windows key + Pause key. In the window that appears, select Device Manager. Click the Arrow next to Sound, video and game controllers. Your sound card is in the list that appears.
Sound card settings can be found within your PC's control panel, or they are accessible through OTOsuite's Configuration Wizard. To check your sound cards are configured correctly, open Tools > Configuration Wizard select 'Configure' for PMM. Click 'Next' once.
Are you sure that it is actually crashing, and not simply throwing an unhandled exception?
In theory it should throw a NoAudioHardwareException
.
Try doing something with audio (SoundEffect.MasterVolume
comes to mind as a possibility, as it is a static method) and see if you can catch the exception. If you do catch an exception, simply do no further audio work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With