?? audiomidlet.java
字號(hào):
package com.j2medev.chapter5;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class AudioMIDlet extends MIDlet implements CommandListener{
private Display display = null;
private Form main = null;
private AudioPlayer player = null;
private Command exitCommand = new Command("Exit",Command.EXIT,1);
private Command stopCommand = new Command("stop",Command.OK,2);
private Command startCommand = new Command("record",Command.OK,1);
private Command playCommand = new Command("Play",Command.OK,1);
public void startApp() {
if(display == null){
display = Display.getDisplay(this);
main = new Form("Audio Record");
main.append("Press record to start record your audio");
main.addCommand(exitCommand);
main.addCommand(startCommand);
main.setCommandListener(this);
}
display.setCurrent(main);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
if(player != null)
player.release();
}
public void setCurrent(Displayable displayable){
if(displayable instanceof Alert){
Alert a = (Alert)displayable;
display.setCurrent(a,main);
}else{
display.setCurrent(displayable);
}
}
public void commandAction(Command command, Displayable displayable) {
if(command == exitCommand){
destroyApp(false);
notifyDestroyed();
}else if(command == startCommand){
main.deleteAll();
main.append("Press stop to stop the record");
main.addCommand(stopCommand);
main.removeCommand(startCommand);
if(player == null){
player = new AudioPlayer(this);
}
player.startRecord();
}else if(command == stopCommand){
main.deleteAll();
main.append("press play to listen your voice");
main.removeCommand(stopCommand);
main.addCommand(playCommand);
player.stopRecord();
}else if(command == playCommand){
main.removeCommand(playCommand);
player.playRecord();
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -