Answer the question
In order to leave comments, you need to log in
How to play sound in JAVA?
AudioFormat audioFormat = new AudioFormat(8000, 16, 1, true, false);
private TargetDataLine targetDataLine;
private SourceDataLine sourceDataLine;
private Object sourceDataLineMutex;
private DataLine.Info targetInfo;
private DataLine.Info sourceInfo;
...
AccessController.doPrivileged(
new PrivilegedAction<Void>() {
@Override
public Void run() {
try {
targetDataLine = (TargetDataLine) AudioSystem.getLine(targetInfo);
targetDataLine.open(audioFormat);
} catch (LineUnavailableException e) {
logger.error("target line unavailable", e);
return null;
} catch (SecurityException e) {
logger.error("security exception", e);
return null;
} catch (Throwable t) {
logger.error("throwable " + t.getMessage());
return null;
}
targetDataLine.start();
synchronized (sourceDataLineMutex) {
try {
sourceDataLine = (SourceDataLine) AudioSystem.getLine(sourceInfo);
sourceDataLine.open(audioFormat);
} catch (LineUnavailableException e) {
logger.error("source line unavailable", e);
return null;
}
sourceDataLine.start();
}
return null;
}
});
Answer the question
In order to leave comments, you need to log in
https://github.com/ccidral/tomighty/issues/17
Solved by switching to oracle jdk 7 latest versions
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question