Hello all,
I am building a camera app, where photos and videos are continuously being captured and saved to the SD card. The videos are short (few minutes), and their length are preset with setMaxDuration(). When MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED is reached, the video is saved, and a new sequence is initialized with something like: mMediaRecorder = new MediaRecorder(); mMediaRecorder.setVideoSource (MediaRecorder.VideoSource.CAMERA); mMediaRecorder.setOutputFormat (MediaRecorder.OutputFormat.THREE_GPP); mMediaRecorder.setVideoFrameRate(20); mMediaRecorder.setVideoSize(176, 144); mMediaRecorder.setVideoEncoder (MediaRecorder.VideoEncoder.H263); mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface()); mMediaRecorder.setMaxDuration(1000 * Integer.valueOf (videoLength)); mMediaRecorder.setOnInfoListener(videoInfoListener); mMediaRecorder.setOutputFile("/sdcard/test.3gp"); mMediaRecorder.prepare(); mMediaRecorder.start(); I also have a SurfaceHolder mSurfaceHolder, set up like: mPreview = (SurfaceView) findViewById(R.id.preview); mSurfaceHolder = mPreview.getHolder(); mSurfaceHolder.addCallback(this); mSurfaceHolder.setType (SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); public void surfaceCreated(SurfaceHolder holder) { mSurfaceHolder = holder; } public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { } public void surfaceDestroyed(SurfaceHolder holder) { mSurfaceHolder = null; } 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. setPreviewDisplay() needs to be there, but it doesn't like not having a proper surface to attach to. I tried to use a dummy Surface, a dummy SurfaceHolder, or reuse the Camera with mMediaRecorder.setCamera(), but nothing works. Is there a way to initialize MediaRecorder in the background? Thanks and regards, Robert --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---