MediaRecorder.setMaxDuration(INT定时器),当计时器到期会发生什么计时器、定时器、发生、MediaRecorder

2023-09-13 00:12:01 作者:我酷你随意

根据该文件,http://developer.android.com/reference/android/media/MediaRecorder.html#setMaxDuration(int)

在定时器超时后录音停止。

the recording stops when the timer expires.

驻足,做他们的意思是它在内部调用recorder.stop(),然后调用recorder.start之前恢复状态的应用程序是()?

By stop, do they mean it calls internally recorder.stop() and then restores the state the app was in before calling recorder.start()?

推荐答案

我发现,我要实现MediaRecorder.OnInfoListener和手动停止录制,在这一点上。一旦做到这一点,在MediaRecorder返回到初始状态,一切正常安装的,必须以重新开始记录再次完成。

I have found that I have to implement MediaRecorder.OnInfoListener and manually stop the recording at that point. Once that is done, the MediaRecorder goes back to the initial state and all of the normal setup has to be done again in order to start recording again.

public class VideoCapture extends Activity implements MediaRecorder.OnInfoListener { 

   public void startVideoRecording() {
      // Normal MediaRecorder Setup
      recorder.setMaxDuration(10000); // 10 seconds
      recorder.setOnInfoListener(this);
   }

   public void onInfo(MediaRecorder mr, int what, int extra) { 
      if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) {
         Log.v("VIDEOCAPTURE","Maximum Duration Reached"); 
         mr.stop();
      }
   }
}