I have a Java application whose interface is highly dependent on sound. On Windows and OS X, everything works fine; on Linux, however, the application requires exclusive access to the sound device, it drops LineUnavailableExceptionand the sound is not heard. I am using Kubuntu 9.10.
This means that no other application can play sound while the program is running and cannot even hold the audio device when the program starts. This is naturally unacceptable.
Here is the code I use to play audio:
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file);
Clip clip = AudioSystem.getClip();
clip.open(audioInputStream);
clip.start();
this.wait((clip.getMicrosecondLength() / 1000) + 100);
clip.stop();
Am I doing something wrong? Is using Java to play audio on Linux a lost cause?