0

I have a Linux single board computer and want to select the audio output device from a java code to play the music (Raspberry Pi 4B can play audio through 3,5 mm jack, HDMI1 and HDMI2. Is it possible to get the array of all this devices to play the sound and select one of them from Java? To play audio I use either LibGDX sound API or javax.sound.sampled.Clip class. Both play the sound through the 3,5 mm jack and ignore the default sound output in the OS.

1 Answers1

0

AudioSystem.getMixerInfo() and check playback here Java select audio device and play .mp3 There are also java bindings here for JACK audio https://github.com/jaudiolibs/jnajack

londonBadger
  • 611
  • 2
  • 5
  • 5
  • thanks, I can get list of all devices. I have 6 devices on my PC and 4 devices on my RPi. But when I try to call the next code: Clip shotClip = AudioSystem.getClip(infos[1]) the game falls. The console output is: java.lang.IllegalArgumentException: Line unsupported: interface Clip supporting format PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian – Alexander Gorodilov Jun 01 '23 at 09:21
  • Is it this? https://stackoverflow.com/questions/5808560/error-playing-sound-java-no-line-matching-interface-clip-supporting-format – londonBadger Jun 01 '23 at 22:19