try{ AudioInputStream stream = AudioSystem.getAudioInputStream( getClass.getResource(yourSong)); AudioFormat format = stream.getFormat(); if ( (format.getEncoding() == AudioFormat.Encoding.ULAW) || (format.getEncoding() == AudioFormat.Encoding.ALAW) ){ AudioFormat newFormat = new AudioFormat (AudioFormat.Encoding.PCM_SIGNED, format.getSampleRate(), format.getSampleSizeInBits()*2, format.getChannels(), format.getFrameSize()*2, format.getFrameRate(), true); stream = AudioSystem.getAudioInputStream(newFormat,stream); System.out.println("Converti en "+ newFormat); format = newFormat; }
DataLine.Info info = new DataLine.Info(Clip.class, format); if (!AudioSystem.isLineSupported(info)) { System.out.println("incompatible"); System.exit(2); } Clip clip = (Clip) AudioSystem.getLine(info); clip.addLineListener(this); clip.open(); double duration = clip.getBufferSize() / (format.getFrameSize() * format.getFrameRate()); System.out.println("ENFIN SIZE = "+df.foramt(duration)+"secs"); NB: df = eventuel decimalFormat... pffff''', voilou :'p
B@ron {EU.BELGIUM}
|