本文介绍了Media Recorder有时无法录制通话以录制对方语音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,有一个功能可以记录语音电话,并且效果很好.但是在(Samsung s7,s8)上进行测试时,效果并不理想.该应用程序只能记录呼叫者的语音,而不能记录来自另一端的语音.下面是我要检查的代码,请提出解决方案

In my application there is a feature to record voice calls and it works perfectly well. But when tested on (Samsung s7, s8 ) it doesn’t work well. The application is able to record only callers voice not the voice from the other end. Below is my code to check please suggest a solution

MediaRecd = new MediaRecorder();
            MediaRecd.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL
            );

            MediaRecd.setAudioChannels(ConstantVariables.audioChannels);//monoRecording

   MediaRecd.setAudioEncodingBitRate(64);
            MediaRecd.setAudioSamplingRate(44100);


            MediaRecd.setOutputFormat(output_formats[pos]);//.mp3
            MediaRecd.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);//I already try with all possible CAMCORDER , MIC , Default etc etc but none was working
            MediaRecd.setOutputFile(Currentfilename);

            try {
                MediaRecd.prepare();
                MediaRecd.start();


            } catch (Exception e) {
                MediaRecd.reset();
                MediaRecd.release();
                MediaRecd = null;

            }

请帮助

推荐答案

AudioSource.VOICE_CALL在某些android设备中不起作用,因此代替VOICE_CALL

AudioSource.VOICE_CALL is not working in some android devices soinstead of VOICE_CALL use below

首先尝试MediaRecorder.AudioSource.CAMCORDER

 MediaRecd = new MediaRecorder();
        MediaRecd.setAudioSource(MediaRecorder.AudioSource.CAMCORDER
        );

如果上述方法不起作用,请使用MediaRecorder.AudioSource.MIC

If above is not working than use MediaRecorder.AudioSource.MIC

MediaRecd = new MediaRecorder();
        MediaRecd.setAudioSource(MediaRecorder.AudioSource.MIC
        );

这篇关于Media Recorder有时无法录制通话以录制对方语音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 16:54