当前位置: 首页 > news >正文

使用索爱V800开发流媒体应用程序

作者:mingjava 文章来源:http://developer.sonyericsson.com

索尼爱立信的V800手机可以支持流媒体的播放,使用非常简单。如果你曾经使用MMAPI播放过声音或者做过照相应用的话,那么上手非常快。

你要做的就是根据指定的URL来创建一个Player,然后启动这个Player。URL的格式如下:rtsp://MyServer/myVideo.3gp。下面的代码例子演示了如何使用:
private void startStreaming(){
try{
myPlayer = Manager.createPlayer("rtsp://MyServer/MyFile.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());
}

}
我们需要注意的是进行连接服务器的时候必须在单独线程中处理,而不能在主线程。因为这样会堵塞系统。接下来你要做的就是构建一个支持RTSP的流媒体服务器,放置一个3gp格式的文件在服务器上。下面的代码演示了如何使用V800开发流媒体应用。
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import java.io.*;
import javax.microedition.lcdui.game.*;


/**
* 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.
*
* Written by Jöns Weimarck, January 2005
*/
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://MyServer/MyFile.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());
}

}

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();
}
}
}

原文请参考:go streaming with v800

相关文章:

  • 读取索爱手机固件版本信息和IMEI号
  • react jsx中使用map
  • 在基于MIDP的应用程序上使用JDBC
  • react 表单使用受控组件的思想
  • 索爱部分机型支持同时播放多个声音
  • react状态提升 两个子组件状态共享 让子组件状态提升 通过公有父组件props的方法传递回调函数执行改变( handleChange(e) { // 之前的代码: this.setSt)
  • SonyEricsson发布更好支持企业级应用的新JSR
  • react 状态提升的总结
  • Java 3D(JSR184)文件压缩
  • 组合vs继承
  • 使用JSR-184里的Sprite3D对象
  • react 思想 划分组件 以及state的判断
  • 跨域携带cookie
  • Java 3D 绘图性能
  • 前端单例模式的应用场景
  • CentOS7简单部署NFS
  • css属性的继承、初识值、计算值、当前值、应用值
  • Java,console输出实时的转向GUI textbox
  • java第三方包学习之lombok
  • k8s 面向应用开发者的基础命令
  • Laravel5.4 Queues队列学习
  • PHP 7 修改了什么呢 -- 2
  • RxJS: 简单入门
  • TCP拥塞控制
  • vue总结
  • 关于for循环的简单归纳
  • 技术攻略】php设计模式(一):简介及创建型模式
  • 开发基于以太坊智能合约的DApp
  • 开放才能进步!Angular和Wijmo一起走过的日子
  • 算法---两个栈实现一个队列
  • 王永庆:技术创新改变教育未来
  • 好程序员web前端教程分享CSS不同元素margin的计算 ...
  • ​【已解决】npm install​卡主不动的情况
  • # include “ “ 和 # include < >两者的区别
  • # 睡眠3秒_床上这样睡觉的人,睡眠质量多半不好
  • ###C语言程序设计-----C语言学习(6)#
  • #在线报价接单​再坚持一下 明天是真的周六.出现货 实单来谈
  • (1)(1.13) SiK无线电高级配置(五)
  • (Note)C++中的继承方式
  • (定时器/计数器)中断系统(详解与使用)
  • (附源码)springboot家庭装修管理系统 毕业设计 613205
  • (附源码)计算机毕业设计ssm-Java网名推荐系统
  • (算法)求1到1亿间的质数或素数
  • (转)http协议
  • (转载)PyTorch代码规范最佳实践和样式指南
  • .Net 6.0 处理跨域的方式
  • .Net CF下精确的计时器
  • .net core使用ef 6
  • .NET 命令行参数包含应用程序路径吗?
  • .NET3.5下用Lambda简化跨线程访问窗体控件,避免繁复的delegate,Invoke(转)
  • .NET下的多线程编程—1-线程机制概述
  • @Transactional类内部访问失效原因详解
  • [] 与 [[]], -gt 与 > 的比较
  • [《百万宝贝》观后]To be or not to be?
  • [AutoSAR系列] 1.3 AutoSar 架构