问题
I've been researching for days to figure out how to resolve this with no luck. The PlayN JavaSound class uses the javax.sound.sampled.AudioSystem
class to play sounds, and the mp3 format does not seem to be supported.
javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input stream at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1102) at playn.java.JavaSound.init(JavaSound.java:71) ......
I cannot find a lot of information on playing mp3s in Java with the AudioSystem
class, so I am stuck. It seems like there is a new way to play mp3s in Java 7 with javafx.scene.media.MediaPlayer
, but I would like to know if anyone knows the answer to this.
回答1:
I needed to download a plugin (I think it was this one: http://www.oracle.com/technetwork/java/javase/download-137625.html ). I am not sure if this was the case because I did my setup without Maven.
回答2:
I used this dependency to setup the mp3spi library which may wrk for your mp3 files:
compile group: 'com.googlecode.soundlibs', name: 'mp3spi', version: '1.9.5-1'
来源:https://stackoverflow.com/questions/11174813/playn-mp3-support-unsupportedaudiofileexception