Sound card detection - simple solution

Hello,

this goes to all who are interested. The question how to detect a sound card was brought up in the past, and I found a quite simple way to do it. To my knowledge, this was not posted before.

The following code returns true if a sound card is present and enabled. I tested it on a couple of machines, and it seems to work just fine. It even works in Applets.

import javax.sound.sampled.*;

private boolean detectSoundcard() {

Line.Info il = new Line.Info(TargetDataLine.class);

return AudioSystem.isLineSupported(il);

} // detectSoundCard

Comments are very welcome,

Stefan

[654 byte] By [Stefan Hoba] at [2007-9-26 8:15:29]
# 1
Does not seem to work :-(
sachinvaidya at 2007-7-1 18:44:42 > top of Java-index,Security,Cryptography...
# 2
I am trying to do the same sort of thing but with multiple sound cards. Do you by any chance know how to get a list of available sound cards on a machine and then choose which card the player will use? Your help is appreciated.
djhandy at 2007-7-1 18:44:42 > top of Java-index,Security,Cryptography...