MediaRecorder video/audio recording

by Maurizio Bellemo » Thu, 06 Aug 2009 17:25:38 GMT


Sponsored Links
 i all,

I'm trying to create an application to save video recording on a file
in Android. The problem is that only for audio recording, it's fine,
but when I try to add the video part the prepare() fails. Below the
code....

public classTest extends Activity {
MediaRecorder mr;
File audiofile = null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Configuring audio/video access
try {
setStreaming();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

mr.stop();
mr.reset();
mr.release();
processaudiofile();
}

@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();

// Configuring audio/video access
try {
setStreaming();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Starting the MediaRecorder
mr.start();
}

// @Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();

// Starting the MediaRecorder
mr.start();
}

@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();

// Stopping MediaRecorder
mr.stop();
mr.reset();
mr.release();
processaudiofile();
}

private void setStreaming() throws IOException {
// Creating a MediaRecorder object
mr = new MediaRecorder();
// Configuring audio/video source (MIC and camera)
mr.setAudioSource(MediaRecorder.AudioSource.MIC);
//mr.setCamera(Camera.open());
mr.setVideoSource(MediaRecorder.VideoSource.DEFAULT);

// Configuring the output format
mr.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
// Configuring audio/video codecs
mr.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mr.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
// Setting the output file
if (audiofile == null) {
File sampleDir = Environment.getExternalStorageDirectory();
try
{
audiofile = File.createTempFile("moca", ".mp4", sampleDir);
}
catch (IOException e)
{
Log.e("ERROR","sdcard access error");
return;
}
}
mr.setOutputFile(audiofile.getAbsolutePath());
// the recorder is ready to register

mr.prepare();
mr.start();
}

protected void processaudiofile() {
ContentValues values = new ContentValu



Other Threads

1. Method called after release()

Hi, I'm getting this error ( in the end of this post)... which I guess
I understand it's because I'm calling something after releasing it..
but I can't find a wy to work it around... Here is the method:

public void surfaceDestroyed(SurfaceHolder holder) {
                mPreviewRunning = false;
                mCamera.stopPreview();
                mCamera.release();
        }

I've tried all combinations.. I've tried:
mCamera.setPreviewCallback(null);
This class, where the surfaceview is implemented can be accessed by 2
different classes.. one that doesnt implement surfaceview and other
that does.. the error just shows me when I go from the activity that
uses the camera to the activity that also uses camera.. I don't know
what else to do.. I've google it and can't find any answer. any
suggestion?


09-22 19:55:57.475: ERROR/AndroidRuntime(900):     Uncaught handler:
thread main exiting due to uncaught exception
09-22 19:55:57.605: ERROR/AndroidRuntime(900):
java.lang.RuntimeException: Method called after release()
09-22 19:55:57.605: ERROR/AndroidRuntime(900):     at
android.hardware.Camera.stopPreview(Native Method)
09-22 19:55:57.605: ERROR/AndroidRuntime(900):     at
com.pedroteixeira.thennnow.cameraView.surfaceDestroyed(cameraView.java:
184)
09-22 19:55:57.605: ERROR/AndroidRuntime(900):     at
android.view.SurfaceView.reportSurfaceDestroyed(SurfaceView.java:426)
09-22 19:55:57.605: ERROR/AndroidRuntime(900):     at
android.view.SurfaceView.updateWindow(SurfaceView.java:351)
09-22 19:55:57.605: ERROR/AndroidRuntime(900):     at
android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:
182)

-- 

2. How to make children of TableRow selectable

Hi,

I'm making a image gallery with infinite vertical and horizontal
scrolling. I put images inside a ListView to make a column, and put
the ListViews inside a TableRow. However, it seems that child views of
TableRow is not selectable and as a result I can't select the images
in my ListView (easily). Is there a way to pass the events down to
child views of TableRow so they can be selectable?

-- 

3. AutoCompleteTextView performance

4. How to access system MP3 / AAC decoder?

5. Content Delivery (Ringtones, Wallpaper, Games, etc)

6. App working but GoogleMap not coming (proxy settings working)

7. How to open a nested child PreferenceScreen