【问题标题】:Couldn't hear incoming voice in recorded calls in android 7?在 android 7 的通话录音中听不到来电?
【发布时间】:2017-11-22 13:07:28
【问题描述】:

我正在开发一个Android 用于记录通话的应用程序。 这是我的代码 sn-p。

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

这对于低于 android 7 的设备非常有效,但是当我使用Android 7 移动设备时我只能听到传出的声音而听不到传入的声音

谁能帮我解决它?

【问题讨论】:

    标签: android android-7.0-nougat mediarecorder call-recording


    【解决方案1】:

    按原样使用VOICE_COMMUNICATION 作为音频源 用于语音通信(如 VoIP)的麦克风音频源,as described on Android Developers site.

    我尝试使用VOICE_CALL(使用音频上行和下行录制)但它只能由系统组件使用,所以麦克风是录制音频的唯一选项。

    尝试:
    1:通话时音量调高。
    2. 不要使用耳机,因为在某些情况下麦克风不会录制音频[没试过这个]。 3. 适用于 Moto G4 Play,Android 7.1.1 版本(大多数摩托罗拉手机都有两个麦克风):

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

    【讨论】:

    • 我认为问题出在您使用的手机上,因为您可以录制传出的声音。手机上的麦克风放置方式使其无法在正常模式下录制来电。你试过使用免提吗?
    【解决方案2】:

    好吧,问题在于您只使用该代码记录麦克风输入,这显然只是传出的声音。要同时录制传入的声音,您还必须录制系统声音。

    要录制系统声音,您需要用谷歌搜索一下。以下是一些可以帮助您入门的 stackoverflow 链接:

    最后,您还必须将两个音轨合并到一个文件中,才能将整个通话合二为一。

    【讨论】:

    • 那一定有不同的原因,因为您发布的代码只记录麦克风输入声音。
    【解决方案3】:
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    

    试试这个

    【讨论】:

    • 在像素 2 中用 Android P 试过这个,输出文件没有任何内容。
    【解决方案4】:

    这段代码就像是使用 API 25 构建的 Android 7 的魅力,

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

    【讨论】:

    • 以异常“启动失败”结束。在像素 2 中使用 Android P。
    猜你喜欢
    • 2023-03-17
    • 2018-03-15
    • 1970-01-01
    • 1970-01-01
    • 2019-04-14
    • 1970-01-01
    • 2012-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多