有关流媒体播放

wfl5841314 wfl5841314 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
最近在做一个流媒体播放的东西,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
高手指点一下,谢谢
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
wfl5841314
J2ME 13,096 成员 26,491 内容