MediaRecorder.setMaxDuration(INT定时器),当计时器到期会发生什么 [英] MediaRecorder.setMaxDuration(int timer) what happens when timer expires

查看:1744
本文介绍了MediaRecorder.setMaxDuration(INT定时器),当计时器到期会发生什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据该文件,<一个href="http://developer.android.com/reference/android/media/MediaRecorder.html#setMaxDuration(int">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();
      }
   }
}

这篇关于MediaRecorder.setMaxDuration(INT定时器),当计时器到期会发生什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆