1
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 record
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
is equal to 60000
milesegundos call the stop
and the upload
.
I had arrived at this result here, but ta accepts the answer, thanks!
– Wallace Roberto