Question

I implemented Media Recorder to record the voice in android.I tried to limit the recording time to two mins by

     mRecorder.setMaxDuration(120000);

It works fine.But I want to show the alert if recording time exceeds 2 mins.I did not find any code or related tutorial regarding this.Can anyone help me?

Thanks!!!

Was it helpful?

Solution

From the docs for the setMaxDuration(...) method (see the bold text)...

Sets the maximum duration (in ms) of the recording session. Call this after setOutFormat() but before prepare(). After recording reaches the specified duration, a notification will be sent to the MediaRecorder.OnInfoListener with a "what" code of MEDIA_RECORDER_INFO_MAX_DURATION_REACHED and recording will be stopped. Stopping happens asynchronously, there is no guarantee that the recorder will have stopped by the time the listener is notified.

So basically all you need to do is implement an OnInfoListener and send your alert / notification from there.

OTHER TIPS

:)

mRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() {
        @Override
        public void onInfo(MediaRecorder mr, int what, int extra) {
            // TODO Auto-generated method stub

        }
    });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top