0

I busy working on Android call recorder, When I make a call the recorder shows it is recording, after I drop the call, it saves the file, but the saved file is 0 KB

Has any one come across with the same problem, please help me on this.

Here is my code for recording

recorder = new MediaRecorder();             
                    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
                    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
                    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);                
                    myFileName = getFilename();
                    recorder.setOutputFile(myFileName);             
                    volume = (AudioManager) getSystemService(Context.AUDIO_SERVICE);                
                    //set the volume a bit high for good sound 
                    int volume_level = volume.getStreamVolume(AudioManager.STREAM_VOICE_CALL);//get the current volume set
                    int max_volume = volume.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);//set volume to maximum
                    if (volume_level < max_volume) {volume.setStreamVolume(AudioManager.STREAM_VOICE_CALL, max_volume, AudioManager.FLAG_SHOW_UI);//set volume to maximum
                    }
                    //Log.d(tag, myFileName);
                    Log.d(tag, "File path = " + myFileName);
King
  • 234
  • 1
  • 17
  • Call recording is restricted in AOS so maybe thats why you a getting zero file as a result. http://stackoverflow.com/questions/14728615/audiosource-voice-call-not-working-in-android-4-0-but-working-in-android-2-3 – Stan Apr 08 '15 at 13:58
  • @Stan, But when I use the `recorder.setAudioSource(MediaRecorder.AudioSource.MIC);` it works fine and the size of the shows, I can also listen to the audio, just that with the MIC, I only hear my voice, not of the other party(person). The problem lies in the VOICE_CALL. – King Apr 08 '15 at 14:14
  • 1
    Sure you can record from MIC but not from VOICE_CALL, UPLINK etc. – Stan Apr 08 '15 at 14:51
  • @Stan I tested using the MIC, CAMCORDER, with the MIC like I said I hear my voice alone, but the weird part is that I only hear my voice when I start to test for the first time with the first call, with the second call and so fourth I can be able to hear both parties(What met be the cause to this?). With the CAMCORDER i hear both parties, my side and the other party's side(person), but the problem with the CAMCORDER the volume is low, that I struggle to hear the other side, but my voice is clear. The UPLINK and DOWNLINK do not work for me, of which UPLINK and DOWNLINK makes VOICE_CALL. – King Apr 10 '15 at 10:57

1 Answers1

1

Okay I guess I find the solution to my problem, I managed to get it to recorder using combination of DOWNLINK + UPLINK, at first I tested it using the DOWNLINK | UPLINK recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_UPLINK | MediaRecorder.AudioSource.VOICE_DOWNLINK);, maybe that is why it did not work for me.

So my solution was just to change one line of code from recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL); To

recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_DOWNLINK + MediaRecorder.AudioSource.VOICE_UPLINK);//test using the addition sign

And it was able to recorder, and save the valid file with the size.

Not sure why

recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_UPLINK | MediaRecorder.AudioSource.VOICE_DOWNLINK); 

did not work in my case.

For those who might face the same issue, just play around with your code and see what changes it might bring.

King
  • 234
  • 1
  • 17