Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to mute a call while recording the sound in android

I want to build a app where I want to modulate the sound in a call.I have written a code that record the sound nd play it in different pitch.Now I want this feature while calling.I want to mute the call record the sound then play it with diff pitch.How to mute the call but still record the audio.

like image 355
Artim Arka Avatar asked Mar 16 '23 12:03

Artim Arka


1 Answers

This answer works to mute your microphone during a call:

Boolean isMuted = false;

Then in your event, say an onClick

AudioManager audioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
if(!isMuted){

   if((audioManager.getMode()== AudioManager.MODE_IN_CALL)||(audioManager.getMode()== AudioManager.MODE_IN_COMMUNICATION)){
   audioManager.setMicrophoneMute(true);
  }
  isMuted = true;

 }else{

  if((audioManager.getMode()== AudioManager.MODE_IN_CALL)||(audioManager.getMode()== AudioManager.MODE_IN_COMMUNICATION)){
    audioManager.setMicrophoneMute(false);
    }
  isMuted = false;
 }

Remember to enable permissions in your manifest:

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
like image 50
Sweetie Anang Avatar answered Apr 15 '23 01:04

Sweetie Anang