精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2009-07-12
最后修改:2009-07-26
最近在研究J2ME实现RTSP协议,在索爱开发网站中看到一个类,但只能用于支持RTSP协议的手机,大部分手机需利用J2ME MMAPI实现,而对于自己实现的RTSP,虽然做了一些测试,调通了一点,但还没能真正运行,不知播放的效果如何,会不会像HTTP连接那么烂!
import javax.microedition.lcdui.*; import javax.microedition.midlet.*; import javax.microedition.media.*; import javax.microedition.media.control.*; /** * A simple example of the MMAPI (JSR 135) support for Streaming Video * with the Sony Ericsson V800. * * This code is part of the Tips & Tricks section at * www.SonyEricsson.com/developer * * COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2005. * The software is the copyrighted work of Sony Ericsson Mobile Communications AB. * The use of the software is subject to the terms of the end-user license * agreement which accompanies or is included with the software. The software is * provided "as is" and Sony Ericsson specifically disclaim any warranty or * condition whatsoever regarding merchantability or fitness for a specific * purpose, title or non-infringement. No warranty of any kind is made in * relation to the condition, suitability, availability, accuracy, reliability, * merchantability and/or non-infringement of the software provided herein. * */ public class StreamingVideo extends MIDlet implements CommandListener, PlayerListener, Runnable{ private Display myDisplay; private Form myForm; private Thread streamingThread; private Player myPlayer; private VideoControl vc; private boolean running=false; public StreamingVideo() { myDisplay = Display.getDisplay(this); myForm=new Form ("Streaming Test"); myForm.addCommand(new Command("Exit", Command.EXIT,0)); myForm.addCommand(new Command("Start", Command.OK,0)); myForm.setCommandListener(this); } protected void startApp() throws MIDletStateChangeException { myDisplay.setCurrent(myForm); streamingThread = new Thread(this); } protected void pauseApp() {} protected void destroyApp(boolean unconditional) { try { myPlayer.stop(); myPlayer.close(); } catch( Exception e ) { log("Exception: " + e.toString()); } } /** * Inits and starts the Player for Video Streaming */ private void startStreaming(){ try{ myPlayer = Manager.createPlayer("rtsp://yourServer/mobile/realmp3.3gp"); myPlayer.addPlayerListener(this); myPlayer.realize(); // Grab the video control and set it to the current display. vc = (VideoControl)myPlayer.getControl("VideoControl"); if (vc != null) { myForm.append((Item)vc.initDisplayMode(vc.USE_GUI_PRIMITIVE, null)); // sets the display size of the video. vc.setDisplaySize(120,160); } myPlayer.start(); }catch(Exception e){ log("Exception: " + e.toString()); myForm.append("Exception: " + e.toString()); } } public void commandAction(Command c, Displayable s){ if(c.getCommandType()==Command.EXIT){ running=false; notifyDestroyed(); }else{ streamingThread.start(); } } /** * PlayerListener Interface method, logs all player event. */ public void playerUpdate(Player player, String event, Object eventData){ log(" ** playerUpdate: " + event + " **"); } public void log(String msg){ System.out.println(msg); } public void run() { running=true; startStreaming(); while(running){ Thread.yield(); } } }
开发RTSP的相关资料: Experiments in Streaming Content in Java ME(1) http://fonter.iteye.com/blog/425372
keyRepeated和keyPressed处理 http://fonter.iteye.com/blog/433408 少用System.out.println()吗?http://fonter.iteye.com/blog/423871 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2009-07-13
你去看lg 手机的标准吧。支持 vedio stream ,我不晓得这个是不是 rstp。
有没有 好的 rstp 的 服务器端推荐? |
|
返回顶楼 | |
发表时间:2009-07-13
longzy 写道 你去看lg 手机的标准吧。支持 vedio stream ,我不晓得这个是不是 rstp。
有没有 好的 rstp 的 服务器端推荐? 现在好几款机子支持,要做到通用,还是得写CODE,我所知道的像N73, N80, N91, K750i, V800, Z520i, K600, Z800i等都支持RTSP,但目前我手头没有支持的手机,我下载了Helix Server做测试用的,那个比较好目前不是很清楚! |
|
返回顶楼 | |
浏览 6035 次