我试图在java ME 3.5 sdk模拟器上显示视频,但我不断获得不支持的媒体格式' video / mpeg-1',url =' null'例外。
我还尝试将'video/mpeg-1'
更改为'video/mpeg'
,但它仍然无法正常工作。但是,当我在Wireless toolkit 2.5模拟器上吃午餐时,它工作正常!
public void startApp() {
try {
if (error) {
return;
}
//display.setCurrent(list);
loadPlayer();
VideoControl videoControl = (VideoControl) player.getControl("javax.microedition.media.control.VideoControl");
if (videoControl == null) {
throw new Exception("No VideoControl!!");
}
videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, canvas);
videoControl.setDisplayFullScreen(true);
videoControl.setVisible(true);
display.setCurrent(canvas);
player.start();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void loadPlayer() throws Exception {
player = Manager.createPlayer(getClass().getResourceAsStream("/1.mpg"), "video/mpeg-1");
player.realize();
}