Android 노트:볼륨, Audio Manager

1430 단어 AudioManager소리
관련 코드:
private AudioManager audioManager;//      
private int maxVolume;//     
private int currentVolume;//     
//         
private void listenVolumeSeekBar()
{
    audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);//     
    maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);//       
    currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);//       
    mVolumesetting_seekBar.setMax(maxVolume);
    mVolumesetting_seekBar.setProgress(currentVolume);
    mVolumesetting_seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
    {
        @Override
        public void onStopTrackingTouch(SeekBar seekBar)
        {
                                    
        }
                                
        @Override
        public void onStartTrackingTouch(SeekBar seekBar)
        {
                                    
        }
                                
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
        {
            audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, progress, AudioManager.FLAG_ALLOW_RINGER_MODES);
        }
    });
}

본고는'하늘에 흔적은 없지만 나는 날아간다'블로그에서 나온 것으로 작가에게 연락하세요!

좋은 웹페이지 즐겨찾기