AudioSystem.getAudioFileFormat not working with mp3 Java

534 views Asked by At

I am trying to convert an mp3 file into Audio Input Stream with Java. Following is the portion of my code.

 **File file = new File("/root/Desktop/files/Song1.mp3");
        AudioFileFormat baseFileFormat = null;
        AudioFormat baseFormat = null;
        baseFileFormat = AudioSystem.getAudioFileFormat(file);
        baseFormat = baseFileFormat.getFormat();
        AudioFileFormat.Type type = baseFileFormat.getType();
        float frequency = baseFormat.getSampleRate();
        System.out.println("Sample Rate: " + baseFormat.getSampleRate());
        System.out.println("Frame Size: " + baseFormat.getFrameSize());
        System.out.println("Frame Rate: " + baseFormat.getFrameRate());
        System.out.println("Sample Size In Bits: " + baseFormat.getSampleSizeInBits());
        AudioInputStream in = AudioSystem.getAudioInputStream(file);**

I have included the following Jars: jl1.0.1.jar, tritonus_share.jar, mp3spi1.9.5.jar

I am getting the following exception:

Exception in thread "main" javax.sound.sampled.UnsupportedAudioFileException:
file is not a supported file type.

Any sort of help in this regards would be appreciated.

0

There are 0 answers