闂傚倸鍊峰ù鍥Υ閳ь剟鏌涚€n偅宕岄柡宀€鍠栭、娑樷堪閸愮偓姣夋俊鐐€戦崕濠氬箯閿燂拷 (0) +1 闂傚倷娴囧畷鍨叏瀹ュ拋鍚嬮柛鈩冾殢娴硷拷 (0) +1 闂傚倸鍊搁崐鎼併偑鐎涙ḿ顩查柣鎴f缁狀垶鏌ㄩ悤鍌涘 (0) +1
闂傚倸鍊峰ù鍥Υ閳ь剟鏌涚€n偅宕岄柡宀€鍠栭、娑樷堪閸愮偓姣夋俊鐐€戦崕鏌ュ垂閸ф钃熼柣鏃囥€€閸嬫挸鈽夊▍顓т簼閹便劑宕惰閺€鑺ャ亜閺囩偞顥為悗姘炬嫹闂傚倸鍊风粈渚€骞栭銈嗗仏妞ゆ劧绠戠壕鍧楁煕閹邦垼鍤嬮柤鏉挎健閺屾稑鈽夊▎鎰▏缂傚倷璁查弲鐘诲蓟閻旂⒈鏁嶆繝濠傚枤閺嗩厼顪冮妶鍐ㄥ姷闁瑰嚖鎷�>>

正在阅读:让JavaME程序真正Run Anywhere让JavaME程序真正Run Anywhere

2005-09-06 10:02 出处: 作者:tengshiquan 责任编辑:moningfeng

  下面利用反射机制来动态加载:

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 {
Class.forName(supportedPlayerTypes[i]); //加载当前的Player类型

playerType = i; //保存加载成功的类的类型
return;
} catch (Exception e) { //加载不成功,说明不支持,继续加载下一种
e.printStackTrace();
}
}
isSupportSound = false;
}



  2. 下面就可以根据在载成功的类型来加载可以播放的声音资源了

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");
break;
}
}

键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品
闂傚倸鍊风粈浣虹礊婵犲倴缂氱憸鏃堛€侀弽顓炲耿婵$偟绮弫鐘绘⒑闁偛鑻晶鎾煙椤旀娼愰柟宄版嚇瀹曘劍绻濋崒娆愭▕濠电姷顣藉Σ鍛村磻閹捐绠柨鐕傛嫹闂傚倸鍊烽悞锕傚箖閸洖纾块柟鎯版绾剧粯绻涢幋娆忕仼闁哄嫨鍎甸幃姗€鎮欓弶鍨彑婵炲瓨绮嶇划鎾诲蓟濞戙埄鏁冮柨婵嗘椤︺儵姊洪崨濠冾棖闁瑰嚖鎷�