I set up a Checkbox, If it is unchecked the mediaplayers should Immediately be unmuted, when checked immediately muted, now I have the problem that when I check / uncheck the checkbox the sound will not be muted / unmuted immediately but as recently I restart the activity... How can I set up that it willimmediately be muted?
Code of the muted section:
checkBoxmp.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
editor.putBoolean("playSounds", !isChecked);
editor.apply();
if (null != mp && null != mp2) {
if (!isChecked) {
mp.setVolume(1, 1);
mp2.setVolume(1, 1);
} else {
mp.setVolume(0, 0);
mp2.setVolume(0, 0);
}
}
}
});
Aucun commentaire:
Enregistrer un commentaire