There are 1 code examples for javax.sound.sampled.DataLine.Info.
The API names are highlighted below.
You can use
button
to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.
Project Name: rssowl.ui Package: org.rssowl.ui.internal.util
Source Code: AudioUtils.java (Click to view .java file)
Method Code:
private static void doPlay(String file) throws javax.sound.sampled.UnsupportedAudioFileException, IOException, javax.sound.sampled.LineUnavailableException {
javax.sound.sampled.AudioInputStream inS=null;
try {
inS=javax.sound.sampled.AudioSystem.getAudioInputStream(new File(file));
javax.sound.sampled.AudioFormat audioFormat=inS.getFormat();
javax.sound.sampled.DataLine.Info info=new javax.sound.sampled.DataLine.Info(javax.sound.sampled.SourceDataLine.class,audioFormat);
javax.sound.sampled.SourceDataLine line=(javax.sound.sampled.SourceDataLine)javax.sound.sampled.AudioSystem.getLine(info);
line.open(audioFormat);
line.start();
int read=0;
byte[] buf=new byte[1024];
while ((read=inS.read(buf,0,buf.length)) != -1 && !Controller.getDefault().isShuttingDown()) line.write(buf,0,read);
line.drain();
line.close();
}
finally {
if (inS != null) inS.close();
}
}