Android的:如何初始化MediaRecorder没有视频preVIEW有效的表面?初始化、表面、有效、视频

2023-09-05 02:44:38 作者:谁人骨

我建立一个摄像头的应用程序,其中的视频不断被捕获并保存到SD卡。的视频是短(数分钟),并且它们的长度是preset中与setMaxDuration()。

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().

在整个过程中正常工作,而主要活动是在前台。但是,当我去到另一个活动(如设置),在后台录像作品只有等到最大持续时间达到。该文件被保存,但一个新的序列不能启动 因为prepare()失败,显然是因为集previewDisplay()不喜欢没有一个适当的表面附加到。

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.

我试图用一个虚拟表面,虚拟SurfaceHolder,lockCanvas(),以及其他各种招数,但没有任何工程。有没有一种方法来初始化MediaRecorder没有有效的表面?

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?

推荐答案

不幸的是它仍然是你为了记录视频(Android SDK中1.6直通2.2)的要求,以preVIEW到一个有效的表面。有一个增强请求记录到取消这一限制的http:// code.google.com / P /安卓/问题/详细信息?ID = 9570

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