【问题标题】:Voice Call Recording on Android Lollipop and higher version not workingAndroid Lollipop 和更高版本上的语音通话录音不起作用
【发布时间】:2016-04-01 18:20:24
【问题描述】:

我在 android lollipop 和更高版本中录制语音通话时遇到问题。通过此代码,我可以录制我的声音,但无法录制其他人的声音。

    public void startRecording() {
    if (recording == false) {


        Log.e("here", "--------Recorder_Sarted------" + fname);
        SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy");
        int randomPIN = (int) (Math.random() * 9000) + 1000;
        recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
        recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        String file = Environment.getExternalStorageDirectory().toString();
        String filepath = file + "/Aeris/Recording";
        File dir = new File(filepath);
        dir.mkdirs();
        Log.e("here ", "----------------" + sdf.format(Calendar.getInstance().getTime()) + " " + fname + " " + type);
        filepath += "/" + type + "-" + fname + "-" + sdf.format(Calendar.getInstance().getTime()) + "-" + randomPIN + ".3gp";
        recorder.setOutputFile(filepath);

        try {
            recorder.prepare();
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        recorder.start();
        recording = true;
    }
}

此代码在 android lollipop 版本下运行良好。 请帮我解决这个问题

【问题讨论】:

    标签: android voice-recording


    【解决方案1】:

    将 AudioSource VOICE_COMMUNICATION 更改为 MIC(麦克风)

    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
    

    在 Moto g2(Android 6.0)、lenovo (Android 5.0) 中测试,运行良好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-26
      • 2014-10-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多