Hi, I am trying to record a video into sdCard. But everytime I click on the Button to record, it shows "stopped unexpectedly" error. Not too sure where went wrong. I am not sure if setOutputFile's path is how I should indicate.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.camera);
cam = new cameraview(this);
((FrameLayout) findViewById(R.id.preview)).addView(cam);
// Create A Preview View
buttonClick = (Button) findViewById(R.id.buttonClick);
buttonClick.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if(toogleButtonFlag )
{
startRecording();
toogleButtonFlag = false;
}
else{
stopRecording();
toogleButtonFlag = true;
}
}
});
}
public void startRecording(){
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
recorder.setOutputFile("/sdcard/.3pg");
try{
recorder.prepare();
}
catch(IOException e)
{
e.printStackTrace();
recorder.reset();
recorder.release();
}
recorder.start(); // Recording is now started
}
public void stopRecording(){
recorder.stop();
recorder.reset();
recorder.release();
}