Results 1 to 1 of 1
Thread: duration of audio file
- 02-25-2011, 05:31 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 36
- Rep Power
- 0
duration of audio file
hi . i have my code below to get the duration of audio file.
but i get an exception error. can anyone fix the bug and help me in getting the duration of the audio file..
plssss..
Java Code:import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; import javax.sound.sampled.DataLine; import java.lang.*; import java.io.*; import javax.sound.sampled.*; public class Main { public static void main(String[] argv) throws Exception { File f1 = new File("c:/program files/java/jdk1.6.0/bin/demo.mp3"); AudioInputStream fis = AudioSystem.getAudioInputStream(f1); System.out.println("File AudioFormat: " + fis.getFormat()); AudioInputStream ais = AudioSystem.getAudioInputStream( AudioFormat.Encoding.PCM_SIGNED,fis); AudioFormat af = ais.getFormat(); // int frmlength = (int)ais.getByteLength(); System.out.println("AudioFormat: " + af.toString()); DataLine.Info info = new DataLine.Info(SourceDataLine.class,af); Clip clip = (Clip) AudioSystem.getLine(info); double durationInSecs = clip.getBufferSize() / (clip.getFormat().getFrameSize() * clip.getFormat().getFrameRate()); System.out.println("duration new : "+durationInSecs); } }Last edited by Saran185; 02-25-2011 at 05:33 AM.
Similar Threads
-
duration of the audio file
By Saran185 in forum Java AppletsReplies: 2Last Post: 02-14-2011, 05:31 AM -
Play Audio File
By YapperNico in forum New To JavaReplies: 0Last Post: 12-30-2010, 01:59 PM -
Get Duration of mov ,wmv files
By saurabh208 in forum New To JavaReplies: 7Last Post: 06-18-2010, 03:42 PM -
Is it possible to insert recorded audio data into an existing file?
By evan_earnest in forum Threads and SynchronizationReplies: 1Last Post: 01-31-2010, 03:40 AM -
How to calculate the sample rate of an audio file?
By arnab321 in forum CLDC and MIDPReplies: 0Last Post: 12-28-2008, 12:39 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks