List of usage examples for javax.sound.sampled DataLine.Info DataLine.Info
public Info(Class<?> lineClass, AudioFormat format)
From source file:org.snitko.app.playback.PlaySound.java
public void play(File inputFile) { try (final AudioInputStream in = AudioSystem.getAudioInputStream(inputFile)) { final AudioFormat outFormat = getOutFormat(in.getFormat()); final DataLine.Info info = new DataLine.Info(SourceDataLine.class, outFormat); try (final SourceDataLine sourceDataLine = (SourceDataLine) AudioSystem.getLine(info)) { if (sourceDataLine != null) { sourceDataLine.open(outFormat); sourceDataLine.start();//from w w w.j a v a 2 s . co m AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(outFormat, in); stream(audioInputStream, sourceDataLine); sourceDataLine.drain(); sourceDataLine.stop(); } } } catch (UnsupportedAudioFileException | LineUnavailableException | IOException e) { throw new IllegalStateException(e); } }