views:

608

answers:

3

Hello all,

I am building a camera app, where videos are continuously being captured and saved to the SD card. The videos are short (few minutes), and their length are preset with setMaxDuration().

The whole process works fine, while the main activity is in the foreground. But, when I go to another activity (e.g. settings), the video recording works in the background only until max duration is reached. The file is saved, but a new sequence can not be started because prepare() fails, apparently because setPreviewDisplay() doesn't like not having a proper surface to attach to.

I tried to use a dummy Surface, a dummy SurfaceHolder, lockCanvas(), and various other tricks, but nothing works. Is there a way to initialize MediaRecorder without a valid surface?

Thanks and regards, Robert

A: 

Oops, I have a feeling we are working on a similar application LOL. I am stuck with the same exact problem.

BeMeCollective
A: 

Are you implementing Surface callbacks?

Why do you need to initialize MediaRecorder without a valid surface?

Are you supposed to be recording even when you leave the main activity? or does recording stop before the other acitivty is spawned?

Namratha
Yes, I have implemented the Surface callbacks. Everything works fine when there is a valid preview surface. But, I want to record even when I leave the main activity. The app should be able to start video recording, regardless if the preview surface is visible or not. But, everything I tried just suggests this is not yet possible with Android. Anybody can prove me wrong?
Robert
A: 

Unfortunately it is still a requirement for you to preview onto a valid surface in order to record video (Android SDK 1.6 thru 2.2). There is an enhancement request logged to remove this restriction http://code.google.com/p/android/issues/detail?id=9570

tardate