?? audiomidlet.java
字號:
package com.j2medev.chapter7;
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){
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();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -