站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2ME 专题NOKIA的SOUND怎么运行不起?

NOKIA的SOUND怎么运行不起?

摘要: NOKIA的SOUND怎么运行不起?


我看了那个NOKIA3100的UI设计,但运行时没声音,是不是这个声音只能在真机才能发声啊??在模拟器里说什么GAMEING API not support,究竟什么原因啊,NOKIA自带的DEMO不会有错吧!


import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import com.nokia.mid.ui.DeviceControl;
import com.nokia.mid.sound.Sound;
public class GamingCoverTestMIDlet extends MIDlet
implements CommandListener {
protected Command runCommand;
protected Command exitCommand;
protected List list;
public GamingCoverTestMIDlet() {}
protected void pauseApp() {}
protected void startApp() throws javax.microedition.midlet.
MIDletStateChangeException {
runCommand = new Command("Run", Command.SCREEN, 1);
exitCommand = new Command("Exit", Command.EXIT, 1);
String sequences[] = {
"Stop", "Sequence 1", "Sequence 2", "Sequence 3",
"Sequence 4", "Sequence 5", "Sequence 6", "Sequence 7",
"Sequence 8", "Sequence 9", "Sequence 10", "Sequence 11",
"Sequence 12", "Sequence 13", "Sequence 14"};
list = new List("Select sequence", List.IMPLICIT, sequences, null);
list.addCommand(runCommand);
list.addCommand(exitCommand);
list.setCommandListener(this);
Display.getDisplay(this).setCurrent(list);
}
public void commandAction(Command cmd, Displayable d) {
if (cmd == runCommand) {
Alert alert = new Alert("");
int index = list.getSelectedIndex();
try {
DeviceControl.setLights(1, index);
alert.setString("Sequence: " + index);
Display.getDisplay(this).setCurrent(alert);
if (index == 1) {
byte[] soundData = {
(byte) 0x02, (byte) 0x4A, (byte) 0x3A, (byte) 0x51,
(byte) 0xD1, (byte) 0x95, (byte) 0xCD, (byte) 0xD0,
(byte) 0x08, (byte) 0x00, (byte) 0x1B, (byte) 0x20,
(byte) 0x55, (byte) 0x05, (byte) 0x90, (byte) 0x61,
(byte) 0x05, (byte) 0x60, (byte) 0x55, (byte) 0x85,
(byte) 0x50, (byte) 0x54, (byte) 0x85, (byte) 0x40,
(byte) 0x82, (byte) 0x08, (byte) 0x49, (byte) 0x90,
(byte) 0x00};
Sound sound = new Sound(soundData, Sound.FORMAT_TONE);
sound.setGain(100);
sound.play(1);
}
}
catch (java.lang.IllegalArgumentException iae) {
alert.setString("Gaming Cover API Extension not Supported");
Display.getDisplay(this).setCurrent(alert);
}
}
else if (cmd == exitCommand) {
notifyDestroyed();
}
}
protected void destroyApp(boolean parm1) throws
MIDletStateChangeException {
}
}



报告楼主,程序没错。
DeviceControl.setLights(1, index);
这句惹的祸,导致产生"Gaming Cover API Extension not Supported".
改成
DeviceControl.setLights(0, index);
即可。

注意,不要在其他开发包和WTK里面测试。否则可能会出现nokia库的问题。
在midpX模拟器和nokia3250真机上运行成功。


↑返回目录
前一篇: 在CMD下如何运行模拟器?请高人指点。
后一篇: 锚(anchor)的问题