Couldn't hear incoming voice in recorded calls in android 7?

假如想象 提交于 2019-12-18 12:34:33

问题


I am developing an Android app for recording calls. This is my code snippet.

    recorder = new MediaRecorder();
    recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
    recorder.setOutputFile(file_path);

This is working perfectly for devices below android 7, but when I use Android 7 mobile devices I can hear only outgoing voice but cannot hear incoming voice.

Can anyone help me in fixing it?


回答1:


Use VOICE_COMMUNICATION as AudioSource as it is microphone audio source tuned for voice communications such as VoIP, as described on Android Developers site.

I tried using VOICE_CALL(Uses audio uplink and downlink recording) but it can be used only by system components only, So mic is only option to record audio.

TRY:
1: Sliding up the volume during call.
2. DO NOT use headphones as audio will not be recorded by mic in some cases[Haven't tried this]. 3. Works on Moto G4 Play, Android version 7.1.1(most of Motorola phones have two mics):

recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION); recorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);




回答2:


Well, the problem is that you only record the microphone input with that code, which is obviously just the outgoing voice. To also record the incoming voice, you'd have to also record system sound.

To record system sound, you'll have to google a bit. Here are some stackoverflow links that should get you started:

  • android get device overall audio output in pcm
  • How to record phone calls in android?

In the end, you'd also have to merge the two soundtracks into one file to have the whole call as one.




回答3:


recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

try using this




回答4:


this code works like a charm for Android 7 built with API 25,

recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
recorder.setAudioSamplingRate(8000);
recorder.setAudioEncodingBitRate(12200);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);


来源:https://stackoverflow.com/questions/47435539/couldnt-hear-incoming-voice-in-recorded-calls-in-android-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!