Results 1 to 2 of 2
  1. #1
    ravjot28 is offline Member
    Join Date
    Jun 2008
    Posts
    87
    Rep Power
    0

    Default 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)

  2. #2
    ravjot28 is offline Member
    Join Date
    Jun 2008
    Posts
    87
    Rep Power
    0

Similar Threads

  1. Doubt Plzz Solve it
    By ravjot28 in forum New To Java
    Replies: 3
    Last Post: 06-27-2008, 04:14 AM
  2. Replies: 1
    Last Post: 03-08-2008, 06:41 PM
  3. how to remove an old version of JDK
    By tommy in forum New To Java
    Replies: 2
    Last Post: 07-30-2007, 08:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •