简体   繁体   中英

android: convert mp3 to wav using Jlayer

I need to convert mp3 to wav in android and i found that it can be possible using Jlayer. To do this, i coded below, and it looks working for a long time about 30seconds with no error, but the wav file haven't created anywhere. could you advise for me?

Converter converter = new Converter(); converter.convert(sourceName, destinationName);

ps. The souceName path is /mnt/sdcard/mp3/xxx.mp3 and the destinationName path is /mnt/sdcard/mp3/xxx.wav

please, help

Do you add permission at AndroidManifest? < uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

It could be a variety of things.

You might have a permissions issue: make sure you have

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

in your Android Manifest.

Or it could be the device you're testing on. "/mnt/sdcard" is NOT guaranteed to exist within the Android file system. It is present on most devices, but you shouldn't rely on it. What you should be using is Environment.getExternalStorageDirectory() which will return the correct path to external storage.

Or you might be eating any errors JLayer throws. It crashes if the input path isn't correct, or if the file isn't actually an MP3 file.

I'm going to guess it's a permissions error.

Edit: Also you should remove the JLayer tag, it refers to a Swing window decorator and not the MP3 library from JavaZoom :/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM