MediaRecorder 准备失败
我是新来的。我一直在尝试使用 Android 模拟器创建一个视频捕获应用程序,但没有取得太大成功。据我所知,并浏览了互联网上的所有示例和代码(本网站和其他网站),我肯定还缺少一个步骤。
我尝试在 JonPro 制作的该线程末尾附近使用此示例: http://www.anddev.org/viewtopic.php?p=24723# 24723
,我尝试过自己制作,但媒体记录器总是会在准备阶段失败,并显示最无用的“准备失败”消息。我不知道我错过了什么。我似乎有正确的权限,并且根据模拟器安装了SDCard。我应该使用 2.1 以外的 Android SDK 版本吗?
尽管该论坛中的代码声称可以工作,但我发现缺少这一行: 记录器.setCamera(相机);
但仍然没有喜悦,日志显示: “获取相机(0x16b70)参数失败” 当调用prepare()但它仍然没有意义,因为预览可以,但没有录制!任何帮助或建议将不胜感激。
编辑:任何人都可以确认这适用于 SDK 和模拟器吗?或者我是在浪费时间试图让它在这个版本中工作。我能否获得准备功能的源代码,因为它是开源的?
I'm new here. I have been trying to create a video capture app using the android emulator without much success. As far as I know and looking through all the samples and code on the internet (this site and others), I must still be missing a step.
I've tried using this sample near the end of this thread made by JonPro:
http://www.anddev.org/viewtopic.php?p=24723#24723
and I've tried making my own but the media recorder would always fail on the prepare stage with the most unhelpful message of 'prepare failed'. I have no clue what I am missing. I seem to have the correct permissions and a SDCard is mounted according to the emulator. Should I be using a android SDK version other than 2.1?
Even though the code in that forum claims to work, I figured out that this line was missing:
recorder.setCamera(camera);
But still no joy as the logs shows that:
'Failed to get camera(0x16b70) parameters'
when prepare() is called but it still doesn't make sense as the preview is okay, but no recording! Any help or suggestions will be appreciated.
Edit: Can anyone confirm that this can work for the SDK and the emulator? or I'm I wasting my time trying to get this to work in this version. Am I able to get the source code for the prepare function as it is OpenSource?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决此问题的方法是必须在准备之前设置 mCameraDevice.unlock()。重要的是,这是在 mCameraDevice.setPreviewDisplay(mHolder); 之后设置的。
示例:
BR
PN
The fix for this problem is mCameraDevice.unlock() must be set before prepare. It's important that this is set after mCameraDevice.setPreviewDisplay(mHolder);
example:
BR
P.N
这对我有帮助。调试期间查看 logcat
this helped for me. Look in logcat during debug