在使用 Android 录制视频时,MediaRecorder
如何在录制的Toast
视频文件达到其最大大小并且文件正在保存(或即将保存)时检测并显示消息?
编辑:这是我目前拥有的代码,但尽管文件已成功保存,但未触发回调。
final Context activity=this.getBaseContext();
mediaRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() {
public void onInfo(MediaRecorder mr, int what, int extra) {
// TODO Auto-generated method stub
if(what==MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED)
Toast.makeText(activity, "There is no more space available. Video recording is stopped now.",2000).show();
}
});
// getBytesAvailable() returns bytes available on sdcard
mediaRecorder.setMaxFileSize(getBytesAvailable());
mediaRecorder.prepare();