private int mStreamType = AudioManager.STREAM_MUSIC;
public void volumeUp() {
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); int currVol = am.getStreamVolume(mStreamType); int maxVol = am.getStreamMaxVolume(mStreamType);
if (currVol < maxVol) {
am.setStreamVolume(mStreamType, currVol + 1, AudioManager.FLAG_PLAY_SOUND); }
}
public void volumeDown() {
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); int currVol = am.getStreamVolume(mStreamType); if (currVol > 0) {
am.setStreamVolume(mStreamType, currVol - 1, AudioManager.FLAG_PLAY_SOUND); }
}
댓글 없음:
댓글 쓰기