سؤال

I am working on a game, and want to switch sound to on and off using radio button. The sounds are running in my app in other options. when sound off radio button is pressed it should mute the sound until and unless sound on pressed. Can anyone help me out to solve this issue?

Thanks in advance

هل كانت مفيدة؟

المحلول

Try

AudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);

..this should mute the default music stream. Pass in false to enable it again.

نصائح أخرى

To disable sound you set it to True. To re enable sound, you set it to false. You can have a button for each or a toggle button.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top