battlefield_learner
battlefield_learner

Reputation: 43

Java - getting error with audio input stream for opening mp3 file

I am trying to convert mp3 to wav file and I need the below lines of code to be able to proceed with the conversion post opening the mp3 file, however I get error -

    AudioFileFormat inputFileFormat = AudioSystem.getAudioFileFormat(new      File("C:/dg.mp3"));
    AudioInputStream ais = AudioSystem.getAudioInputStream(new File("C:/dg.mp3"));

Error:

javax.sound.sampled.UnsupportedAudioFileException: file is not a supported file type at javax.sound.sampled.AudioSystem.getAudioFileFormat(Unknown Source) at MP3toWav.main(MP3toWav.java:10)

Any help on this is appreciated? I have searched a lot but unable to get any answers for my problem!

Upvotes: 1

Views: 3597

Answers (3)

Los Hermanos
Los Hermanos

Reputation: 1

With default Java API you can only open .aiff, .au or .wav files. You could try to convert your .mp3 to a .wav file and then use your new .wav file.

Upvotes: 0

Kumar
Kumar

Reputation: 3990

With default Java API, you can open a .wav file. But cannot open an Mp3 file. Use JMF for open a mp3 file.

Upvotes: 1

ortis
ortis

Reputation: 2223

You cannot open mp3 file with the default Java Audio API. You will have to use external API like Mp3agic

Upvotes: 0

Related Questions