0

I am recording the audio for incomming calls , the recording the audio the files are created but there is no audio in that file it simply creates files.When i played the recorded audio file, the error shown as " mediaplayer doesn't supports this type of audio ". please help me how to solve this and what issue is occurring in this

The code for recording audio

  try {
                f1 = File.createTempFile("Sound", ".mp3", dir);
            } catch (IOException e) {
                e.printStackTrace();
            }
            fileName = f1.getName();
            mediaRecorder = new MediaRecorder();
            mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
            mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
            mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
            mediaRecorder.setOutputFile(f1.getAbsolutePath());
            try {
                mediaRecorder.prepare();
                mediaRecorder.start();
                recordstarted = true;

            } catch (IllegalStateException | IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
Prabha Karan
  • 1,309
  • 3
  • 17
  • 35

0 Answers0