My goal is to play mp3 file with Java. With every approach I took, it always fails with a LineUnavailableException .
AudioInputStream inputStream = AudioSystem.getAudioInputStream(new URL("http://localhost:8080/agriserver/facebook/sound/test6.mp3")); Clip clip = AudioSystem.getClip(info); clip.open(inputStream); clip.start();
Failed to fix the error:
- Use the mp3 plugin for Sun.
- Use third-party Jlayer library
- Using the third-party Tritonus library
- Transcode mp3 using Sony Sound Forge, Adobe Sound Booth, no luck.
- Recode mp3 with different encoding rates and sample rate
- Try using JMF
- Use random mp3 from the Internet, which plays perfectly in other applications.
- Read messages with the same error. None of the messages has an answer that helped solve the problem.
Here is the exception:
Exception in thread "main" javax.sound.sampled.LineUnavailableException: line with format MPEG1L3 48000.0 Hz, unknown bits per sample, stereo, unknown frame size, 41.666668 frames / second, not supported.
at com.sun.media.sound.DirectAudioDevice $ DirectDL.implOpen (DirectAudioDevice.java:494)
at com.sun.media.sound.DirectAudioDevice $ DirectClip.implOpen (DirectAudioDevice.java:1280)
at com.sun.media.sound.AbstractDataLine.open (AbstractDataLine.java:107)
at com.sun.media.sound.DirectAudioDevice $ DirectClip.open (DirectAudioDevice.java:1061)
at com.sun.media.sound.DirectAudioDevice $ DirectClip.open (DirectAudioDevice.java:1151)
at Demo.playMp3 (Demo.java:83)
source share