public void updateVoiceLevel(int level){
if(mDialog != null && mDialog.isShowing()){
mIcon.setVisibility(View.VISIBLE);
mVoice.setVisibility(View.VISIBLE);
mLable.setVisibility(View.VISIBLE);
int resId = mContext.getResources().getIdentifier("v"+level,
"drawable",mContext.getPackageName());
mVoice.setImageResource(resId);
}
}
public int getVioceLevel(int maxLevel) {
if (isPrepared) {
try {
// mMediaRecorder.getMaxAmplitude()范围在1-32767
// 此时范围为1-7,maxLevel为1-7
return maxLevel * mMediaRecorder.getMaxAmplitude() / 32768 + 1;
} catch (Exception e) {
}
}
return 1;
}
case MSG_VOICE_CHANGED:
mDialogManager.updateVoiceLevel(mAudioManager.getVioceLevel(7));
break;