List of usage examples for javax.sound.sampled Clip getFormat
AudioFormat getFormat();
From source file:Main.java
public static void main(String[] argv) throws Exception { DataLine.Info info = null;//from ww w. j a v a 2s . c o 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()); }//from w w w . ja va2 s . c om return duration; }