即时通讯使用Windows 7,并可以在我的调音台“Java平台SE二进制”,但仍然没有声音似乎发挥。Java媒体框架-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性能与JMF版本。 MP3试图播放在VLC/WMP中工作正常,所以它不能成为文件。
该代码在运行时也不会引发异常或错误,它似乎不会播放声音。
有什么遗失的东西?喜欢拉声卡?例如。接管它,所以我可以播放它的声音?
林总的目标是要使用RTP/RTSP一个MP3流媒体服务,使任何链接,意见或tuturiols将使用IBM JMF Tuturiol和Java Demo
请询问是否需要更多的信息,是帮助作为即时通讯currelnt!
最新情况:
下载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。谢谢 – LmC
您的权利,我会更新我的问题 – LmC