欢迎指教,tengshiquan@yahoo.com.cn
"Write once,run anywhere" 是java的口号,但在J2ME平台上做的应用,要想不改动代码就run anywhere,难度是很大的。假如要把一个应用程序做到让大多数的机型都适用,就要考虑到方方面面,其难度是相当大的。
// Player types
static final int STANDARD = 0; //For MIDI
static final int NOKIA = 1; //For ott
static final int SAMSUNG = 2; //For mmf
static final int NEC = 3; //For MIDI
static final String[] supportedPlayerTypes = {
"javax.microedition.media.Player", //STANDARD API
"com.nokia.mid.sound.Sound", // Nokia
"com.samsung.util.AudioClip", //samsung
"com.nec.media.AudioClip", //nec
};
public void determinePlayerType() {
// use most -> less use
isSupportSound = true;
for (int i = 0; i < supportedPlayerTypes.length; i++) {
// try to load a PRoper sound Player
try {
public void createPlayer(String name) {
if (!isSupportSound)
return;
switch (playerType) {
case STANDARD: // for MIDI
case NEC:
createPlayerFactory("/" + name + ".mid");
break;
case NOKIA: //for ott
createPlayerFactory("/" + name + ".ott");
break;
case SAMSUNG: // for mmf
createPlayerFactory("/" + name + ".mmf");
新闻热点
疑难解答