音量调节

mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
//获得最大音量
maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
//获得当前音量
currentVolume = mAudioManager
.getStreamVolume(AudioManager.STREAM_MUSIC);
截取系统音量
public boolean dispatchKeyEvent(KeyEvent event) {
int action = event.getAction();
int keyCode = event.getKeyCode();
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
if (action == KeyEvent.ACTION_UP) {
seek.setProgress(currentVolume + 1);
}
return false;
// break;
case KeyEvent.KEYCODE_VOLUME_DOWN:
if (action == KeyEvent.ACTION_UP) {
seek.setProgress(currentVolume - 1);
// TODO
}
return false;
default:
return super.dispatchKeyEvent(event);
}

// return super.dispatchKeyEvent(event);
}

你可能感兴趣的:(UP)