有关流媒体播放
最近在做一个流媒体播放的东西,Darwin Streaming Server已经弄好了,运行的时候可以看到RTP数据包的传送,可是不能在WTK模拟播放出来,为什么?
这是一部分代码:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
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://localhost:554/sample_100kbit.mov");
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://localhost:554/sample_100kbit.mov创建Player
高手指点一下,谢谢
这是一部分代码:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
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://localhost:554/sample_100kbit.mov");
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://localhost:554/sample_100kbit.mov创建Player
高手指点一下,谢谢
...全文
相关推荐
java实现流媒体播放
Java实现流媒体实时播放,计算机网络的大作业,拿出来跟大家分享,不要怪分太多,都是精华,因为我也没分下其他资源了才上传的
在线流媒体播放器
在线流媒体播放器,实现对在线流媒体的缓冲,播放,断网重连等功能,可以应用与直播
android 实现播放 mms流媒体
简单的实现了android 对mms协议的流媒体的播放。源代码提供给大家。如果哪位朋友能实现改进更多的功能。希望能联系我。联系方式:33948107.谢谢了。
C#播放流媒体demo
C#播放流媒体demo, 并附有测试地址,代码经多次检查暂无发现问题。
RTSP流媒体客户端(播放器)demo
播放器主要用来对遵循 RTSP 标准协议的码流进行实时播放以及码流录制。 播放器核心为两个 DLL,分别为网络 DLL 以及播放 DLL。网络 DLL 基于 Live555 开发,主要对码流的获取以及链路的管理进行控制;播放 DLL 基于 ffmpeg 以及 DirectX 开发,主要对实时码流以及本地的音视频的文件进行解码播放和控制。 特别说明:本资源为demo程序,不含源代码,需要源码可联系开发者(见资源里文档说明)。


J2ME
