I already wrote the same code but it still does not work. It conflicts with flash player and with mplayer (in any mode).<br><br><div class="gmail_quote">2009/10/14 Paulo Levi <span dir="ltr"><<a href="mailto:i30817@gmail.com">i30817@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I was just looking at this problem a while ago... opening the java<br>
sound audio engine instead of the default one might be a solution.<br>
Actually right now i'm using the method bellow, however, there are<br>
still some errors on a test machine that exhibited errors before (but<br>
no exception anymore) - the errors come in a Fedora (Pulse-Audio)<br>
linux. Obviously if it can't open the mixer it will try to open the<br>
java sound audio engine one - that should take take of one of the<br>
errors java not playing, but still might cause the second - native<br>
applications not playing.<br>
Actually the guy that is running the tests for me in that machine<br>
reports that audio is inaudible still, but no exception is raised if i<br>
use this.<br>
<br>
/**<br>
* Lines can fail to open because they are already in use.<br>
* Java sound uses OSS and some linuxes are using pulseaudio.<br>
* OSS needs exclusive access to the line, and pulse audio<br>
* highjacks it. Try to open another line.<br>
* @param format<br>
* @return a open line<br>
* @throws IllegalStateException if it can't open a dataline for the<br>
* audioformat.<br>
*/<br>
private SourceDataLine getSourceDataLine(AudioFormat format) {<br>
Exception audioException = null;<br>
try {<br>
DataLine.Info info = new<br>
DataLine.Info(SourceDataLine.class, format);<br>
<br>
for (Mixer.Info mi : AudioSystem.getMixerInfo()) {<br>
SourceDataLine dataline = null;<br>
try {<br>
Mixer mixer = AudioSystem.getMixer(mi);<br>
dataline = (SourceDataLine) mixer.getLine(info);<br>
dataline.open(format);<br>
dataline.start();<br>
return dataline;<br>
} catch (Exception e) {<br>
audioException = e;<br>
}<br>
if (dataline != null) {<br>
try {<br>
dataline.close();<br>
} catch (Exception e) {<br>
}<br>
}<br>
}<br>
} catch (Exception e) {<br>
throw new IllegalStateException("Error trying to aquire<br>
dataline.", e);<br>
}<br>
if (audioException == null) {<br>
throw new IllegalStateException("Couldn't aquire a<br>
dataline, this computer doesn't seem to have audio output?");<br>
} else {<br>
throw new IllegalStateException("Couldn't aquire a<br>
dataline, probably because all are in use. Last exception:",<br>
audioException);<br>
}<br>
}<br>
</blockquote></div><br><br clear="all"><br>-- <br>-----------------------------------------------------------------<br>Всего наилучшего<br><br> <y6erGn0m.<br>