我有以下代码:
String fileName="D:/downloads/song.mp3";
File soundFile = new File(fileName);
AudioInputStream audioInputStream = null;
try {
audioInputStream = AudioSystem.getAudioInputStream(soundFile);
} catch (Exception ex) {
ex.printStackTrace();
}
但是代码引发了以下异常:
javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file
我该如何解决这个问题?
最佳答案
听起来您缺少 MP3 编解码器。看这个thread可能的解决方案。他们提到了一个可能了解更多的 Java 声音邮件列表 - http://java.sun.com/products/java-media/sound/list.html
关于java - 在 java 中加载 mp3 文件时面临的问题无法从输入文件中获取音频输入流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8624803/