Hello, as the title says I want to limit the recording of my code:
private void startRecording() {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
}
private void stopRecording() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
uploadAudio();
}
This is where I give the order to write
mImageMic.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
startRecording();
mRelative.setVisibility(View.GONE);
mTextGravando.setVisibility(View.VISIBLE);
mTextGravando.setText("Gravando...");
mCronometro.setVisibility(View.VISIBLE);
//Parte Importante
mCronometro.setBase(SystemClock.elapsedRealtime());
mCronometro.start();
return true;
case MotionEvent.ACTION_UP:
stopRecording();
mRelative.setVisibility(View.VISIBLE);
mTextGravando.setVisibility(View.GONE);
mCronometro.setVisibility(View.GONE);
//Parte Importante
mCronometro.stop();
return true;
}
return false;
}
});
I thought of something like mCronometro
equals 60000
milliseconds to call stop
and upload
.