Results 1 to 2 of 2
- 07-06-2010, 02:30 AM #1
Member
- Join Date
- Jun 2008
- Posts
- 87
- Rep Power
- 0
Can not get the way to remove the exception help plzz
This is my code for reading mp3 files but unfortunately i am getting an exception plz help me
Java Code:import java.io.File; import java.io.IOException; import javax.sound.sampled.*; public class JLayerPlayer { public static void main(String[] args) { AudioInputStream din = null; try { File file = new File("D:\\Music\\Songs\\Fun Converted\\Aal Izz Well.mp3"); AudioInputStream in = AudioSystem.getAudioInputStream(file); AudioFormat baseFormat = in.getFormat(); AudioFormat decodedFormat = new AudioFormat( AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false); din = AudioSystem.getAudioInputStream(decodedFormat, in); DataLine.Info info = new DataLine.Info(SourceDataLine.class, decodedFormat); SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info); if(line != null) { line.open(decodedFormat); byte[] data = new byte[4096]; // Start line.start(); int nBytesRead; while ((nBytesRead = din.read(data, 0, data.length)) != -1) { line.write(data, 0, nBytesRead); } // Stop line.drain(); line.stop(); line.close(); din.close(); } } catch(Exception e) { e.printStackTrace(); } finally { if(din != null) { try { din.close(); } catch(IOException e) { } } } } }
here is the exception
Java Code:javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1170) at JLayerPlayer.main(JLayerPlayer.java:12)
- 07-06-2010, 02:38 AM #2
Member
- Join Date
- Jun 2008
- Posts
- 87
- Rep Power
- 0
Similar Threads
-
Doubt Plzz Solve it
By ravjot28 in forum New To JavaReplies: 3Last Post: 06-27-2008, 04:14 AM -
Trouble with factory method - unhandled exception type Exception
By desmond5 in forum New To JavaReplies: 1Last Post: 03-08-2008, 06:41 PM -
how to remove an old version of JDK
By tommy in forum New To JavaReplies: 2Last Post: 07-30-2007, 08:59 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks