public void mediaPlayer(final String path, final JPanel panel) {
new Thread() {
public void run() {
try {
Player p = Manager.createRealizedPlayer(new File(path).toURL());
Component ctrlpanel = p.getControlPanelComponent();
Component player = p.getVisualComponent();
player.setBounds(10, 20, 300, 170);
ctrlpanel.setBounds(10, 191, 300, 20);
panel.add(player);
panel.add(ctrlpanel);
panel.repaint();
p.start();
System.out.println(" Player Started");
} catch (NoPlayerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CannotRealizeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}.start();
我尝试代码播放视频文件,但出现了一些错误。
Unable to handle format: MPEG, 352x288, FrameRate=25.0, Length=152064
Failed to realize: com.sun.media.PlaybackEngine@c7f314
Error: Unable to realize com.sun.media.PlaybackEngine@c7f314
javax.media.CannotRealizeException
at javax.media.Manager.blockingCall(Manager.java:2005)
at javax.media.Manager.createRealizedPlayer(Manager.java:528)
at buffer.Action$1.run(Action.java:74)