Question

How do you get the TargetDataLine from the Speakers? I know how to do it for Microphones, but I can't figure it out for speakers. Any ideas?

Was it helpful?

Solution

TargetDataLine is for reading data which does not make sense for speakers.

SourceDataLine is used to send data to speakers. You can get this from AudioSystem.getLine() or a Mixer.

You need DataLine.Info which is something like this:

   DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);

audioFormat is an AudioFormat instance - you can get this from an AudioInputStream instance getFormat() call or just construct a new instance of AudioFormat.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top