Try to make the default engine the java audio engine... I think i had a test case to see if it worked around here... replace the string for the wav file, and also, probably the "Java Sound Audio Engine" is not the correct name string in the comparator ... you'll have to see. I can't test this now since i don't have a linux here this fails handy.
import java.io.Closeable; import java.io.File; import java.io.IOException;
import java.util.Arrays; import java.util.Comparator; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.LineListener; import javax.sound.sampled.Mixer; import javax.sound.sampled.Mixer.Info; import javax.sound.sampled.SourceDataLine; import javax.sound.sampled.UnsupportedAudioFileException; import marytts.util.data.audio.MonoAudioInputStream; import marytts.util.data.audio.StereoAudioInputStream; public class SoundPlayer implements Runnable, Closeable { public static final int MONO = 0; public static final int STEREO = 3; public static final int LEFT_ONLY = 1; public static final int RIGHT_ONLY = 2; public enum Status { WAITING, PLAYING }; private final LineListener lineListener; private final int outputMode; private volatile Status status = Status.WAITING; private volatile AudioInputStream ais; private volatile SourceDataLine line; private volatile boolean exitRequested; private volatile boolean isPaused; private volatile boolean isCancelled; public static void main(String ... args) throws Exception{ SoundPlayer p = new SoundPlayer(new File("shoeshineshop.wav")); p.run(); } /** * AudioPlayer which can be used if audio stream is to be set separately, using setAudio(). * */ public SoundPlayer() { this.outputMode = MONO; this.lineListener = null; } public SoundPlayer(File audioFile) throws IOException, UnsupportedAudioFileException { this.ais = AudioSystem.getAudioInputStream(audioFile); this.outputMode = MONO; this.lineListener = null; initAudioInputStream(ais.getFormat()); } public SoundPlayer(AudioInputStream ais) { this.ais = ais; this.outputMode = MONO; this.lineListener = null; initAudioInputStream(ais.getFormat()); } public SoundPlayer(File audioFile, LineListener lineListener) throws IOException, UnsupportedAudioFileException { this.ais = AudioSystem.getAudioInputStream(audioFile); this.lineListener = lineListener; this.outputMode = MONO; initAudioInputStream(ais.getFormat()); } public SoundPlayer(AudioInputStream ais, LineListener lineListener) { this.ais = ais; this.lineListener = lineListener; this.outputMode = MONO; initAudioInputStream(ais.getFormat()); } public SoundPlayer(File audioFile, SourceDataLine line, LineListener lineListener) throws IOException, UnsupportedAudioFileException { this.ais = AudioSystem.getAudioInputStream(audioFile); this.line = line; this.lineListener = lineListener; this.outputMode = MONO; initAudioInputStream(ais.getFormat()); } public SoundPlayer(AudioInputStream ais, SourceDataLine line, LineListener lineListener) { this.ais = ais; this.line = line; this.lineListener = lineListener; this.outputMode = MONO; initAudioInputStream(ais.getFormat()); } /** * * @param audioFile * @param line * @param lineListener * @param outputMode if MONO, force output to be mono; if STEREO, force output to be STEREO; * if LEFT_ONLY, play a mono signal over the left channel of a stereo output, or mute the * right channel of a stereo signal; if RIGHT_ONLY, do the same with the right output channel. * @throws IOException * @throws UnsupportedAudioFileException */ public SoundPlayer(File audioFile, SourceDataLine line, LineListener lineListener, int outputMode) throws IOException, UnsupportedAudioFileException { this.ais = AudioSystem.getAudioInputStream(audioFile); this.line = line; this.lineListener = lineListener; this.outputMode = outputMode; initAudioInputStream(ais.getFormat()); } /** * * @param ais * @param line * @param lineListener * @param outputMode if MONO, force output to be mono; if STEREO, force output to be STEREO; * if LEFT_ONLY, play a mono signal over the left channel of a stereo output, or mute the * right channel of a stereo signal; if RIGHT_ONLY, do the same with the right output channel. */ public SoundPlayer(AudioInputStream ais, SourceDataLine line, LineListener lineListener, int outputMode) { this.ais = ais; this.line = line; this.lineListener = lineListener; this.outputMode = outputMode; initAudioInputStream(ais.getFormat()); } private void initAudioInputStream(AudioFormat audioFormat) { if (audioFormat.getChannels() == 1) { if (outputMode != MONO) { ais = new StereoAudioInputStream(ais, outputMode); audioFormat = ais.getFormat(); } } else { assert audioFormat.getChannels() == 2 : "Unexpected number of channels: " + audioFormat.getChannels(); if (outputMode == MONO) { ais = new MonoAudioInputStream(ais); } else if (outputMode == LEFT_ONLY) { ais = new StereoAudioInputStream(ais, outputMode); } else if (outputMode == RIGHT_ONLY) { ais = new StereoAudioInputStream(ais, outputMode); } else { assert outputMode == STEREO : "Unexpected output mode: " + outputMode; } } } public void setAudio(AudioInputStream audio) { if (status == Status.PLAYING) { throw new IllegalStateException("Cannot set audio while playing"); } initAudioInputStream(audio.getFormat()); this.ais = audio; } /** * Queries cancelled state. */ public boolean isPaused() { return isPaused; } public void setPaused(boolean pause) { if (line != null) { if (pause) { isPaused = true; exitRequested = true; } else { isPaused = false; exitRequested = false; } } } public void cancel() { isPaused = false; exitRequested = true; isCancelled = true; } public boolean isCancelled() { return isCancelled; } public SourceDataLine getLine() { return line; } public void close() { if (line != null) { line.close(); } } @Override protected void finalize() throws Throwable { close(); } /** * Lines can fail to open because they are already in use. * Java sound uses OSS and some linuxes are using pulseaudio. * OSS needs exclusive access to the line, and pulse audio * highjacks it. Try to open another line. * @param format * @return a open line * @throws IllegalStateException if it can't open a dataline for the * audioformat. */ private SourceDataLine getSourceDataLine(AudioFormat format) { Exception audioException = null; try { DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); Mixer.Info [] arr = AudioSystem.getMixerInfo(); Arrays.sort(arr, new Comparator() { public int compare(Object o1, Object o2) { Mixer.Info m1 = (Info) o1; Mixer.Info m2 = (Info) o2; if("Java Sound Audio Engine".equals(m1.getName())) return -1; if("Java Sound Audio Engine".equals(m2.getName())) return 1; return 0; } }); for (Mixer.Info mi : arr) { SourceDataLine dataline = null; try { Mixer mixer = AudioSystem.getMixer(mi); dataline = (SourceDataLine) mixer.getLine(info); dataline.open(format); dataline.start(); System.out.println(mi.getName()); return dataline; } catch (Exception e) { audioException = e; } if (dataline != null) { try { dataline.close(); } catch (Exception e) { } } } } catch (Exception e) { throw new IllegalStateException("Error trying to aquire dataline.", e); } if (audioException == null) { throw new IllegalStateException("Couldn't aquire a dataline, this computer doesn't seem to have audio output?"); } else { throw new IllegalStateException("Couldn't aquire a dataline, probably because all are in use. Last exception:", audioException); } } public void run() { status = Status.PLAYING; isCancelled = false; AudioFormat audioFormat = ais.getFormat(); DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat); try { if (line == null) { boolean bIsSupportedDirectly = AudioSystem.isLineSupported(info); if (!bIsSupportedDirectly) { AudioFormat sourceFormat = audioFormat; AudioFormat targetFormat = new AudioFormat( AudioFormat.Encoding.PCM_SIGNED, sourceFormat.getSampleRate(), sourceFormat.getSampleSizeInBits(), sourceFormat.getChannels(), sourceFormat.getChannels() * (sourceFormat.getSampleSizeInBits() / 8), sourceFormat.getSampleRate(), sourceFormat.isBigEndian()); ais = AudioSystem.getAudioInputStream(targetFormat, ais); audioFormat = ais.getFormat(); } line = getSourceDataLine(audioFormat); if (lineListener != null) { line.addLineListener(lineListener); } } line.open(audioFormat); } catch (Exception e) { e.printStackTrace(); return; } int nRead = 0; byte[] abData = new byte[1056]; // needs to be a multiple of 4 and 6, to support both 16 and 24 bit stereo boolean startResume; do { startResume = false; line.start(); while (nRead != -1 && !exitRequested) { try { nRead = ais.read(abData, 0, abData.length); } catch (IOException e) { e.printStackTrace(); } if (nRead >= 0) { line.write(abData, 0, nRead); } } if (exitRequested && !isPaused) { //cancel line.stop(); line.flush(); } else if (isPaused) { line.stop(); line.drain(); try { while (isPaused) { Thread.sleep(20); } startResume = true; } catch (InterruptedException ex) { //if interrupted... cancel(); } } if (!exitRequested) { line.drain(); } //System.out.println("EXITREQ " + exitRequested + " RESUME " + startResume + " IS PAUSED " + isPaused); } while (startResume); exitRequested = false; status = Status.WAITING; } }