资源预览内容
第1页 / 共14页
第2页 / 共14页
第3页 / 共14页
第4页 / 共14页
第5页 / 共14页
第6页 / 共14页
第7页 / 共14页
第8页 / 共14页
第9页 / 共14页
第10页 / 共14页
亲,该文档总共14页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
外文翻译 中文+英文 14页2651字数外文文献:Develop Rich Multimedia Apps with J2METhe portability of J2ME across platforms can be used to create multimedia apps that take full advantage of the blistering connectivity speeds provided by 3G networks.Tuesday, March 03, 2009Sun Microsystems claims that Java ME is the most ubiquitous application platform for mobile devices, deployed on more than a billion sets. Apart from the great advantage of portability across devices along with robust security, Java ME provides a rich set of APIs for todays multimedia and web enabled mobile handsets. Some of the useful libraries/APIs provided by the Java ME platform are: Wireless Messaging API Mobile Media API JAXP XML Parser Location API Mobile 3D Graphics Payment API In the article “Creating Apps for Mobiles”, published in PCQ Jan09, we explored the J2ME development tools to create a simple application. We will continue the exploration by creating a tiny video player using the Mobile Media API。Mobile Media API (JSR 135)The Mobile Media API provides an interface to the multimedia capabilities of the mobile device running J2ME. This includes the speaker (or headset), microphone, LCD Screen (for video) and Camera (if available).The package name for the Mobile Media API is:javax.microedition.media.The building blocks of the system consist of -Manager, Player and Control. The Manager is the top level controller for the multimedia resources. J2ME applications use the Manager to create and manage Players and query status and properties of the Players. The Players actually play the multimedia content. The Control interface is used to implement the different controls a Player might have, such as VolumeControl to increase/decrease the volume.Create a tiny video player applicationIn this article we will go through the steps of creating a project using the Mobile Media API and then develop the code required to create the player. Please refer to the PCQ Jan 09 issue (also available online at pcquest.com) for the procedure to install the tools. You can test this application on the Emulator, but to use it on a mobile device, you will need a data connection such as GPRS or the blazing fast 3G.We will start by creating a project with the following details:The toolkit will create the project and show the paths where you have to create the source files.Creating the source file for PCQ_Player ApplicationWe now write the code to provide the desired functionality to your application:package com.j2me.part1;import javax.microedition.lcdui.*;import javax.microedition.midlet.MIDlet;import javax.microedition.media.*;import javax.microedition.media.control.*;public class PCQ_Player extends MIDlet implementsCommandListener private Display display;private Form form;VideoPlayer vPlayer;public PCQ_Player() display = Display.getDisplay(this);form = new Form(PCQ Player);public void startApp() form.addCommand( new Command( Exit, Command.EXIT, 1 );form.setCommandListener(this);vPlayer = new VideoPlayer(display, form, http:/createapoll.net/guest/R1.mpg);Thread runner = new Thread(vPlayer);runner.start();public void pauseApp() public void destroyApp(boolean unconditional) public void commandAction(Command command, Displayable disp) vPlayer.playerClose();destroyApp(true);notifyDestroyed();class VideoPlayer implements Runnable, PlayerListenerForm form;Player player;Display display;String url;public VideoPlayer(Display display, Form form, String url)this.display = display;this.form = form;this.url = url;public void run() try Alert alert = new Alert(Buffering .); /Download takes timealert.setTimeout(Alert.FOREVER); /so display messagedisplay.setCurrent(alert);player = Manager.createPlayer(url);player.addPlayerListener(this);player.setLoopCount(1); /Play only onceplayer.start(); / Start the playbackdisplay.setCurrent(form); catch(Exception e) Alert alert = new Alert(Failed to play video); /Display message in casealert.setTimeout(Alert.FOREVER); /there is an errordisplay.setCurrent(alert);public void playerUpdate(Player player, String event, Object eventData)if(event.equals(PlayerListener.STARTED)videoControl vControl = (VideoControl) player.getControl(VideoControl);form.append(Item)v Control.initDisplayMode(vControl.USE_GUI_PRIMITIVE, null); else if(event.equals(PlayerListener.CLOSED)form.deleteAll(); public void playerClose() player.close(); / close playbackCopy the above source code in Notepad and save this as PCQ_Player.java in the fully qualified source path, which is the path you copied in the previous step plus comj2mepart1. In my case the path isD:UsersSudipto Chanda j2mewtk 2.5.2 appsPCQ_Playersrc comj2me part1.Important: Make sure that you select Al
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号