📄 test4.java
字号:
package MidpDemo;
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.media.control.ToneControl;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class Test4 extends MIDlet implements CommandListener {
private Display display;
private Form form;
private Command cmdplay = new Command("播放", Command.OK, 3);
private byte[] sequence;
public Test4() {
form = new Form("试验音频器");
form.addCommand(cmdplay);
form.setCommandListener(this);
sequence = new byte[] { ToneControl.VERSION, 1, 67, 16, // The
69, 16, // hills
67, 8, // are
65, 8, // a -
64, 48, // live
62, 8, // with
60, 8, // the
59, 16, // sound
57, 16, // of
59, 32, // mu -
59, 32 // sic
};
display = display.getDisplay(this);
display.setCurrent(form);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
}
public void commandAction(Command c, Displayable arg1) {
try {
Player player = Manager.createPlayer(Manager.TONE_DEVICE_LOCATOR);
player.realize();
ToneControl ta = (ToneControl) player.getControl("ToneControl");
ta.setSequence(sequence);
player.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -