?? drmtestmidlet.java
字號:
/* This file was created by Carbide.j */
package drmtest;
import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class DrmTestMidlet extends MIDlet implements CommandListener {
private final Command openBrowserCmd = new Command("Open Browser",Command.OK,0);
private final Command openFileCmd = new Command("Open File",Command.OK,1);
private final Command playFileCmd = new Command("Play file",Command.OK,2);
private final Command exitCmd = new Command("Exit",Command.EXIT,1);
private final String url = "http://200.152.210.97/waptest/homolog/homologacao/wallpaper/025_sax480.dm";
private final String file = "file:///E:/Sounds/Digital/jack_aac_aac.dcf?drm=enc";
private final String mediaFile = "file:///E:/Sounds/Digital/jack_aac_aac.dcf";
private Form myForm = null;
public DrmTestMidlet() {
myForm = new Form("Download test");
myForm.append("Choose a download option");
myForm.addCommand(openBrowserCmd);
myForm.addCommand(openFileCmd);
myForm.addCommand(playFileCmd);
myForm.addCommand(exitCmd);
}
protected void startApp( ) throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(myForm);
myForm.setCommandListener(this);
}
protected void pauseApp( ) {
}
protected void destroyApp( boolean p1 ) throws MIDletStateChangeException {
}
/* (non-Javadoc)
* @see javax.microedition.lcdui.CommandListener#commandAction(javax.microedition.lcdui.Command, javax.microedition.lcdui.Displayable)
*/
public void commandAction(Command arg0, Displayable arg1) {
if(arg0 == openBrowserCmd) {
try {
System.out.println(System.getProperty("microedition.platform"));
platformRequest(url);
}
catch(Exception e) {
Alert error = new Alert("Error",e.toString(),null,AlertType.INFO);
Display.getDisplay(this).setCurrent(error,myForm);
}
}
else if(arg0 == exitCmd) {
notifyDestroyed();
}
else if(arg0 == openFileCmd) {
FileConnection fc = null;
try {
fc = (FileConnection)Connector.open(file,Connector.READ);
if(fc != null && fc.exists()) {
Alert error = new Alert("Success","File " + file + " opened",null,AlertType.INFO);
Display.getDisplay(this).setCurrent(error,myForm);
}
else {
throw new Exception("File not found");
}
}
catch(Exception e) {
Alert error = new Alert("Error",e.toString(),null,AlertType.INFO);
Display.getDisplay(this).setCurrent(error,myForm);
}
finally {
if(fc != null) {
try {
fc.close();
}
catch(Exception e) {}
}
}
}
else if(arg0 == playFileCmd) {
Player p = null;
try {
p = Manager.createPlayer(mediaFile);
p.start();
}
catch(Exception e) {
Alert error = new Alert("Error",e.toString(),null,AlertType.INFO);
Display.getDisplay(this).setCurrent(error,myForm);
}
finally {
if(p != null) {
try {
p.close();
}
catch(Exception e) {}
}
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -