有关流媒体播放
最近在做一个流媒体播放的东西,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
高手指点一下,谢谢