JMF를 사용하여 Java에서 MP3 파일을 재생하려고하면 오류가 발생합니다. 나는 WAV 파일로 시도하고 잘 작동합니다.JMF로 Java에서 MP3를 재생할 때 포맷 오류가 발생했습니다.
import javax.media.*;
import java.net.URL;
class mp3 extends Thread {
private URL url;
private Player playMP3;
public mp3(String mp3) {
try {
this.url = new URL(mp3);
} catch (java.net.MalformedURLException e) {
System.out.println(e.getMessage());
}
}
public void run() {
try {
MediaLocator mediaLocator = new MediaLocator(url);
playMP3 = Manager.createPlayer(mediaLocator);
} catch (java.io.IOException | NoPlayerException e) {
System.out.println(e.getMessage());
}
playMP3.addControllerListener(new ControllerListener() {
public void controllerUpdate(ControllerEvent e) {
if (e instanceof EndOfMediaEvent) {
playMP3.stop();
playMP3.close();
}
}
});
playMP3.realize();
playMP3.start();
}
}
public class PlayMP3 {
public static void main(String[] args) {
mp3 t = new mp3("file:///C://TestMP3Player//music.wav"); // Works well
// mp3 t = new mp3("file:///C://TestMP3Player//music.mp3"); // Doesn't work (error below)
t.start();
System.out.println("Playing song...");
}
}
그리고 오류 (this post과 동일) : 내가 제대로 JMF를 설치 한 경우 나도 몰라
Playing song... Unable to handle format: mpeglayer3, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 16000.0 frame rate, FrameSize=32768 bits Failed to realize: [email protected] Error: Unable to realize [email protected]
Process finished with exit code 0
은 여기 내 (this tutorial 기준) 코드입니다.
이 실수를 무엇의 생각 : 난 그냥 이런 인 IntelliJ에서 프로젝트 의존성의 JAR 파일이 들어있는 JMF-2.1.1e\lib
디렉토리를 추가?
도움 주셔서 감사합니다.