public class Jmftest extends JFrame {
Jmftest() {
String filename;
JFileChooser of = new JFileChooser("E:/");;
int n = of.showOpenDialog(null);
if(n == JFileChooser.APPROVE_OPTION) {
filename = of.getSelectedFile().getAbsolutePath();
Player p;
try {
p = Manager.createPlayer(new MediaLocator("file:"+filename));
p.prefetch();
p.start();
}
catch (java.io.IOException ioe) {
System.out.println(ioe.toString());
}
catch (NoPlayerException npe) {
System.out.println(npe.toString());
}
}
}
public static void main(String[] args) {
new Jmftest();
}
} JMF 2.1.1e ,MP3 Plugin都安装了,而且能运行wav文件,运行MP3就出现:Unable to handle format: mpeglayer3, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 16000.0 frame rate, FrameSize=32768 bits
Failed to realize: com.sun.media.PlaybackEngine@1808199
Error: Unable to realize com.sun.media.PlaybackEngine@1808199
Jmftest() {
String filename;
JFileChooser of = new JFileChooser("E:/");;
int n = of.showOpenDialog(null);
if(n == JFileChooser.APPROVE_OPTION) {
filename = of.getSelectedFile().getAbsolutePath();
Player p;
try {
p = Manager.createPlayer(new MediaLocator("file:"+filename));
p.prefetch();
p.start();
}
catch (java.io.IOException ioe) {
System.out.println(ioe.toString());
}
catch (NoPlayerException npe) {
System.out.println(npe.toString());
}
}
}
public static void main(String[] args) {
new Jmftest();
}
} JMF 2.1.1e ,MP3 Plugin都安装了,而且能运行wav文件,运行MP3就出现:Unable to handle format: mpeglayer3, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 16000.0 frame rate, FrameSize=32768 bits
Failed to realize: com.sun.media.PlaybackEngine@1808199
Error: Unable to realize com.sun.media.PlaybackEngine@1808199
只支持avi wav等简单音频文件格式
可第二天就正常播放了。
PS. 你运行过 java com.sun.media.codec.audio.mp3.JavaDecoder 没?
1.首先重装jdk,下最新安装版的。然后把环境变量配好,确保java能够运行。(不要用以前已安装好的,然后改一下环境变量路径,那样不行,好像找不到注册表。一定要重新安装)
2.安装jmf,安装到jre下。
3.重起电脑后安装jmf mp3插件,也是安装到jre下
4.在CMD中运行java com.sun.media.codec.audio.mp3.JavaDecoder测试能否成功
5. File f=new File("e:/a.mp3");
Player p=Manager.createRealizedPlayer(f.toURI().toURL());
p.prefetch();
p.start();
6.终于成功!
我昨天在家时也这样弄过,但没成功,可能是那个jdk版本不是最新的缘故