在Android中录制声音时是否可以使通话静音 [英] is it possible to mute a call while recording the sound in android

查看:579
本文介绍了在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.

推荐答案

此答案可在通话过程中使您的麦克风静音:

This answer works to mute your microphone during a call:

Boolean isMuted = false;

然后在您的活动中说一个onClick

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" />

这篇关于在Android中录制声音时是否可以使通话静音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆