?? playvediodemo.java
字號:
/*
* PlayVedioDemo.java
*
* Created on 2005年5月2日, 上午1:43
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
/**
*
* @author Liu Bin
* @version
*/
public class PlayVedioDemo extends MIDlet implements CommandListener {
private Display display;
//命令按鈕
private Command cmdPlay = new Command("播放", Command.OK, 1);
private Command cmdExit = new Command("退出", Command.STOP, 1);
Form form = new Form("視頻播放演示");
Player videoPlayer;
public PlayVedioDemo() {
form.addCommand(cmdPlay);
form.addCommand(cmdExit);
form.setCommandListener(this);
}
public void startApp() {
display = Display.getDisplay(this);
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
/**
* 命令按鈕事件
*/
public void commandAction(Command c, Displayable s) {
if (c == cmdExit) {
videoPlayer.close();
videoPlayer = null;
this.notifyDestroyed();
}
if (c == cmdPlay) {
try {
java.io.InputStream is = getClass().getResourceAsStream("/1.mpg");
System.out.println("已經(jīng)裝載Mpeg文件");
videoPlayer = Manager.createPlayer(is,"Video/mpeg");
System.out.println("已經(jīng)創(chuàng)建Player對象");
videoPlayer.realize();
//獲得視頻控制器
VideoControl vc = (VideoControl)videoPlayer.getControl("VideoControl");
Item videoItem = (Item)vc.initDisplayMode(
VideoControl.USE_GUI_PRIMITIVE, null);
form.append(videoItem);
videoPlayer.start();
} catch(Exception e) {
System.out.println("播放視頻異常:" + e.toString());
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -