MediaRecorder允许设置持续时间和文件大小,但我还没有弄清楚如何获取回调事件进行处理。我通过密切关注这里的文档来记录和运行:
http://developer.android.com/guide/topics/media/camera.html
我已经实现了MediaRecorder.OnInfoListener
,我猜这将是那个听取这两个事件的人。
public class CameraActivity extends Activity implements MediaRecorder.OnInfoListener {
/* code here */
}
我在我希望mMediaRecorder.setMaxDuration(5000);
最后,我已经为OnInfo监听器提供了所需的回调方法,但它似乎永远不会触发。
@Override
public void onInfo(MediaRecorder arg0, int arg1, int arg2) {
Log.i("CALLBACK", "Response Code: " + arg1);
}
答案 0 :(得分:0)
在实现MediaRecorder.OnInfoListener接口后将MediaRecoder侦听器设置为recorder.setOnInfoListener(this);
要获取maxDuration和maxFileSize回调,请使用onInfo回调,如下所示
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) {
Log.e("Maximum Duration Reached","Maximum Duration Reached");
}
if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED) {
Log.e("Maximum File size Reached","Maximum File size Reached");
}