简体   繁体   中英

Mute the sound “beep” by MediaRecorder start/stop Android 6

How to remove the sound "beep" when the video recording starts using MediaRecorder? To solve this problem I use the following method:

private int[] audioStreams = new int[] { AudioManager.STREAM_ALARM,
            AudioManager.STREAM_DTMF, AudioManager.STREAM_MUSIC,
            AudioManager.STREAM_RING, AudioManager.STREAM_SYSTEM,
            AudioManager.STREAM_VOICE_CALL,AudioManager.STREAM_NOTIFICATION, AudioManager.RINGER_MODE_SILENT};

for (int i = 0; i < numStreams; i++) 
{
    audioManager.setStreamVolume(audioStreams[i], 0, 0);
}

But this method works for me only for android versions below 6. Is there a working mode for a android Marshmallow and above? Thanks.

I just tried on Android 6.1:

((AudioManager)context.getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_SYSTEM,true);

and it works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM