大家帮帮我,一个关于视频播放的问题

Z_Beginner 2006-02-18 10:30:08
我想试试播放视频的程序
程序如下:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import java.util.Vector;
import java.io.*;

public class test extends MIDlet implements CommandListener,Runnable{
private Command exitCommand = new Command("退出",Command.EXIT,1);
private Command playCommand = new Command("播放",Command.ITEM,1);
private Display display;
private List mMainScreen;
private Form myForm;
public test(){
myForm = new Form("WindowsMediaPlayer");
}
public void startApp(){
display = Display.getDisplay(this);
if(mMainScreen==null){
mMainScreen = new List("视频播放",List.IMPLICIT);
mMainScreen.append("资源获取",null);
mMainScreen.addCommand(playCommand);
mMainScreen.addCommand(exitCommand);
mMainScreen.setCommandListener(this);
}
display.setCurrent(mMainScreen);
}
public void pauseApp(){}
public void destroyApp(boolean u){}
public void run(){
playFromResource();
}
public void commandAction(Command c,Displayable s){
if(c==exitCommand){
notifyDestroyed();
}else if(c==playCommand){
Form waitForm = new Form("正在下载...");
display.setCurrent(waitForm);
Thread t = new Thread(this);
t.start();
}
}
private void playFromResource(){
try{
InputStream in = getClass().getResourceAsStream("/1.mpg");
Player player = Manager.createPlayer(in,"video/mpeg");
player.realize();
VideoControl vc = (VideoControl)player.getControl("VideoControl");
Item it = (Item)vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE,null);
myForm.append(it);
player.start();
}catch(Exception e){System.out.println("error");}
myForm.addCommand(exitCommand);
display.setCurrent(myForm);
}
}

但是一点击播放加载一会儿,模拟器就关闭了,不知是怎么回事。希望指教
...全文
147 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
Z_Beginner 2006-02-24
up
回复
Z_Beginner 2006-02-22
为什么 ?
回复
bdwer 2006-02-21
用真机试试看!
回复
Z_Beginner 2006-02-20
请教等待中
回复
追求自由 2006-02-19
没用过
回复
Z_Beginner 2006-02-19
up
回复
相关推荐
发帖
J2ME
创建于2007-09-28

1.3w+

社区成员

Java J2ME
申请成为版主
帖子事件
创建了帖子
2006-02-18 10:30
社区公告
暂无公告