Windows 7을 사용하고 있으며 사운드 믹서에서 "Java Platform SE Binary"를 사용할 수 있지만 사운드가 재생되지 않는 것 같습니다.Java Media Framework - MP3 문제
내 코드는 다음과 같습니다
import javax.media.*;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLExc;
public class SimpleAudioPlayer {
private Player audioPlayer = null;
public SimpleAudioPlayer(URL url) throws IOException, NoPlayerException,
CannotRealizeException {
audioPlayer = Manager.createRealizedPlayer(url);
}
public SimpleAudioPlayer(File file) throws IOException, NoPlayerException,
CannotRealizeException {
this(file.toURL());
}
public void play() {
audioPlayer.start();
}
public void stop() {
audioPlayer.stop();
audioPlayer.close();
}
public static void main(String[] args) {
try{
File audioFile = new File("/t.mp3");
SimpleAudioPlayer player = new SimpleAudioPlayer(audioFile);
System.out.println();
System.out.println("-> Playing file '" +
audioFile.getAbsolutePath() + "'");
System.out.println(" Press the Enter key to exit");
player.play();
// wait for the user to press Enter to proceed.
System.in.read();
System.out.println("-> Exiting");
player.stop();
}catch(Exception ex){
ex.printStackTrace();
}
System.exit(0);
}
}
에서 Windows의 preformance JMF 버전을 사용합니다. MP3 메신저 VLC/WMP에서 잘 작동하도록 노력하므로 파일이 될 수 없습니다.
코드는 실행시 예외 나 오류를 발생시키지 않으며 사운드를 재생하지 못합니다.
뭔가 빠졌습니까? 사운드 카드를 당기는 것처럼? 예 : 그것을 이어 받아 내가 소리를 낼 수 있을까?
임 전반적인 목표는 그래서 어떤 링크, 조언이나 tuturiols 더 이상 정보가 필요한 요청하시기 바랍니다 IBM JMF Tuturiol 및
Java Demo를 사용하여 메신저 currelnt으로 도움이 될 것 RTP/RTSP를 사용하여 MP3 스트리밍 서비스이다!
UPDATE-
다운로드 WAV FILE 하고 재생하는 듯 내가 어떻게 MP3 파일을 재생 할 수 있습니까? 여전히 같은 문제가이 코드를 시도하고
추가 형식 : 오류 그게 전부
import java.io.File;
import javax.media.Format;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.PlugInManager;
import javax.media.format.AudioFormat;
public class SimpleAudioPlayer {
public static void main(String[] args) {
Format input1 = new AudioFormat(AudioFormat.MPEGLAYER3);
Format input2 = new AudioFormat(AudioFormat.MPEG);
Format output = new AudioFormat(AudioFormat.LINEAR);
PlugInManager.addPlugIn(
"com.sun.media.codec.audio.mp3.JavaDecoder",
new Format[]{input1, input2},
new Format[]{output},
PlugInManager.CODEC
);
try {
Player player = Manager.createPlayer(new MediaLocator(new File("/t.mp3").toURI().toURL()));
player.start();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
}
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]
!
나는이에 어떤 전문가는 아니지만, 내가 VLC 자체 코덱 (안 OS 것들)와 함께 제공 알고
나는 이것이 당신이 필요하다고 생각합니다. 문제를 해결하기 위해'.wav' 파일을 재생 해 보셨습니까? –아직 시도하지 않습니다. 나는 또 다른 MP3를 시도하고 그것은 코덱 excpeiton을 주었지만 이것은 단지 notihng를 보여줍니다. 아프지 마십시오 .wav를 시도해보고 몇 분 안에 답장 해주세요. – LmC
맞습니다. 내 질문을 업데이트 할 것입니다. – LmC