Search code examples
javaandroidandroid-mediaplayervoice-recording

Play recorded voice simultaneously in the earphones


I am new to programming but till now I have came across the basic of it. Currently I am using Android Studio. I tried many a times on web for how can I play recorded voice simultaneously while its continuing to record. The recorded voice should be played in the earphones.That's what i have done in my main_activity.java file. Also I was unable to find how can a button be a perfect round, like in the FM application in the android. I don't know how to do that. Can anyone help me.

package com.theapptree.thesoundjeez.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;

/**
 * This class shows how to run Sound Recorder activity
 * @author The Developer's Info
 */
public class MainActivity extends Activity {
    private static final int REQUEST_CODE_RECORD = 0;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button startRecording = (Button) findViewById(R.id.button);
        startRecording.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent recordIntent = new Intent(
                        MediaStore.Audio.Media.RECORD_SOUND_ACTION);
                startActivityForResult(recordIntent, REQUEST_CODE_RECORD);

            }
        });
    }
}


Solution

  • I can't post this as a comment, but from what I know of audio, unless the speakers are far away from the microphone (like in earbuds or a gymnasium) or you will run the risk of creating feedback or recording audio you are playing again.

    EDIT: Ok I am assuming you have two different methods, one for capturing audio and one for playing audio. If this is the case you may need to condense them to one method, especially if you are always recording audio while playing a song and vice-versa.