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
So, thanks to AT answer I drifted from JMF to JMF problems, and that led me to VLC-J. And this is the answer — in order to use multimedia in Java program simply don’t use Java (pity, btw. that Java in year 2012 does not have reliable multimedia layer, gee.).
Marking as solved, because VLC-J allowed me to play audio without problem.
Main project site:
http://code.google.com/p/vlcj/
Minimal playback program:
http://code.google.com/p/vlcj/source/browse/trunk/vlcj/src/test/java/uk/co/caprica/vlcj/test/minimalmp3/Mp3Test.java