在 Android 2.2 上,代码在 2.3 上运行良好,但它在 MediaRecorder.start() 处崩溃。日志和代码本身如下。如您所见,它没有提供太多信息,日志给出“启动失败-2147483648”消息。我已经尝试了很多年,但无法弄清楚这一点,我做错了什么?
mediaRecorder = new MediaRecorder();
try {
camera.unlock();
mediaRecorder.setCamera(camera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
mediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
mediaRecorder.setPreviewDisplay(cameraPreview.getHolder().getSurface());
mediaRecorder.prepare();
mediaRecorder.start(); // thats the line code fails
fightTimer.start();
}
catch (RuntimeException ex) {
Toast.makeText(this,"Sorry, camera is currently not available"+ex.toString(), 2000).show();
}
catch (IOException ex) {
Toast.makeText(this,"Sorry, camera is currently not available"+ex.toString(), 2000).show();
}
并记录
08-13 06:34:56.914: I/MediaRecorderJNI(2256): prepare: surface=0x2bb230 (identity=13)
08-13 06:34:57.764: E/MediaRecorder(2256): start failed: -2147483648