So far I only found two ways:
- throw exception
- play nothing
ad.2. Pretty recent code (2010)
but does nothing, not sound at all.
ad.1. For example:
- Trouble playing wav in Java
- http://www.anyexample.com/programming/java/java_play_wav_sound_file.xml
- https://stackoverflow.com/a/2433454/210342
All I get is exception "Audio Device Unavailable". As this article (2008) -- lsof |grep snd — how to free a linux sound device -- explains Java has to get exclusive access to audio device.
However I cannot afford such condition. I use sound to notify myself on long running process (several hours), I cannot get rid of all sounds (including those forced via Flash ads) just to make Java comfy.
So for now I use total extreme -- I simply launch external program: https://stackoverflow.com/a/8370223/210342 . This is ugly as hell because well new program is launched just to make notification.
Question
Is there currently a way to play a WAV file:
- on Linux,
- in cooperative way (during Java playback there may be other audio played as well),
- which makes sound,
- in Java (no launching external programs)?
Java 1.6, openSUSE 11.4