mmapi 在j2me polish中的应用
近日工作中,要在j2me polish项目里实现mmapi, 其中的视频的实现在j2me polish与一般j2me项目里是不同的,弄了一天都不能播放。后来在网上问了一个高手才知道,下面我们看看Video Play 在polish中的实现:
j2me里实现mmapi的基本解释我不多说了,不了解的可以参考 http://hi.baidu.com/cobalt/blog/item/fdb457c25e4c0237e4dd3b71.html 里边讲得很详细的,我们主要看看实现mmapi video的播放的代码:
java 代码:
try { System.out.println("~~~~~~~~~~"+getClass().getResourceAsStream("/3.mpg"));InputStream is = getClass().getResourceAsStream("/3.mpg");Player p = Manager.createPlayer(is, "video/mpeg");p.realize();// Grab the video control and set it to the current display.VideoControl vc = (VideoControl)p.getControl("VideoControl");if (vc != null) {javax.microedition.lcdui.Form form = new javax.microedition.lcdui.Form("Video form");javax.microedition.lcdui.Item videoItem = (javax.microedition.lcdui.Item)vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null);form.append(videoItem);display.setCurrent(form);}p.start();} catch (IOException ioe) {} catch (MediaException me) { }