Skip to content Skip to sidebar Skip to footer

The Audio Volume Is Zero?

I have an application with a mute button. I have been stuck on this for 4 and a half hours now, so I am plain desperate. I am trying to have the volume mute when user clicks mute a

Solution 1:

I found the issue. I have changed STRAM_MUSIC to STREAM_RING, and the variable userVolumeOnStart.userVolume changes successfully!

Solution 2:

btn_mute.setOnCheckedChangeListener(new OnCheckedChangeListener() {

@OverridepublicvoidonCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stubAudioManageraudio= (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            if(isChecked) {
                btn_mute.setBackgroundResource(R.drawable.mute_bt);
                audio.setStreamMute(AudioManager.STREAM_MUSIC, true);
            } else {
                btn_mute.setBackgroundResource(R.drawable.volume_bt);
                audio.setStreamMute(AudioManager.STREAM_MUSIC, false);
            }
        }
    });

Post a Comment for "The Audio Volume Is Zero?"