I've seen a lot of question about playing .mp3 files using JLayer in Android, a lot of these questions have accepted answers meaning that they succeeded in using JLayer to process .mp3 files.
I downloaded the .jar
and imported it into my project. I then implemented the following to test if it is working:
AssetFileDescriptor assetFileDescriptor = getApplication().getAssets().openFd("testing.mp3");
FileDescriptor fileDescriptor = assetFileDescriptor.getFileDescriptor();
FileInputStream stream = new FileInputStream(fileDescriptor);
//JLayer below
Player player = new Player(stream);
player.play();
When I run my application I get the following error:
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/sound/sampled/AudioFormat;
I did some research and found that javax is not supported by android. I had a look through JLayer.jar and found that in JavaSoundAudioDevice.java
is the following imports:
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.DataLine.Info;
so, if javax is not supported by android and JLayer uses javax, how does other people get it working? - as shown in this question..