Android中,我想使用MediaRecord录像,并让它在Service中实现。主要问题是它的预览画面,好像使用MediaRecord就一定要设置setPreviewDisplay(),否则就不能开始预览或录像。但是如果在Service中实例化SurfaceView的话,那么它的预览画面应该是不能在Activity上显示的吧?。这个我实验过了。
MediaRecord录像我已经在另外一个Thread中实现好了。但是我需要在Service中实现。不知道有没有什么好的方案。 还有一问题,使用Android parcelable 可以把一个类似于SurfaceView的包装到Intent并发给Service吗?还是只能传递自定义的简单Object?
MediaRecord录像我已经在另外一个Thread中实现好了。但是我需要在Service中实现。不知道有没有什么好的方案。 还有一问题,使用Android parcelable 可以把一个类似于SurfaceView的包装到Intent并发给Service吗?还是只能传递自定义的简单Object?
解决方案 »
- Android推送用哪种协议比较好?
- Android SDK 在 PC机上 运行adb shell 不成功(环境变量已经配好了)
- 求助:自定义View 中的的OnkeyListener问题!!
- Android下搭建WebService服务
- Google Play In-app Billing 如何测试帐单信息
- Android cookie的问题,新手求助~~~
- android-Conversion to Dalvik format failed with error 1
- 非Activity的类中,如何才能调用AlertDialog
- 请一些过来人,为我这个萌新解答一些疑惑,真的超级感谢大家!
- volley框架
- 【100分求答案】问个关于notification和activity的小白问题,求指点
- 能否仅在jni中获取系统时间(不调用java部分代码)
camera=Camera.open();
camera.setDisplayOrientation(90);
recorder = new MediaRecorder();
camera.unlock();
recorder.setCamera(camera); recorder.setPreviewDisplay( videoholder.getSurface());
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
//recorder.setVideoSize(465,615);
//recorder.setVideoSize(100,100);
recorder.setVideoFrameRate(24);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
recorder.setOutputFile(filePath);
recorder.prepare();
handler.postDelayed(task, 1000);
recorder.start();这是我的源码..
关键是这句必须得要阿。recorder.setPreviewDisplay( videoholder.getSurface());
没有解决。使用录像时只能通过先预览打开它,然后再用其他Activity覆盖它,这是录像仍在继续,因为录像是另外线程。我把录像的launchmode设置为singleTask。但是再回到录像的Activity就看不到预览画面了,不知您有没解决这个问题?