List of usage examples for javax.sound.sampled Clip getBufferSize
int getBufferSize();
From source file:Main.java
public static void main(String[] argv) throws Exception { DataLine.Info info = null;// w w w . j a va2 s . co m Clip clip = (Clip) AudioSystem.getLine(info); double durationInSecs = clip.getBufferSize() / (clip.getFormat().getFrameSize() * clip.getFormat().getFrameRate()); }
From source file:SimpleSoundPlayer.java
public double getDuration() { double duration = 0.0; if (currentSound instanceof Sequence) { duration = ((Sequence) currentSound).getMicrosecondLength() / 1000000.0; } else if (currentSound instanceof BufferedInputStream) { duration = sequencer.getMicrosecondLength() / 1000000.0; } else if (currentSound instanceof Clip) { Clip clip = (Clip) currentSound; duration = clip.getBufferSize() / (clip.getFormat().getFrameSize() * clip.getFormat().getFrameRate()); }/* w ww. jav a2s. com*/ return duration; }