安卓:媒体录像机在同一时间两个实例 [英] Android: Two instances of Media recorder at same time

查看:132
本文介绍了安卓:媒体录像机在同一时间两个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以运行Android MediaRecorder类的两个实例在同一时间?例如

 公共MediaRecorder mrec1;
公共MediaRecorder mrec2;


mrec1.setCamera(mCamera);
mrec1.set previewDisplay(surfaceHolder.getSurface());
mrec1.setVideoSource(MediaRecorder.VideoSource.CAMERA)
。
。
。
。
mrec2.setAudioSource(MediaRecorder.AudioSource.MIC);
mrec2.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mrec2.setAudioEn codeR(MediaRecorder.AudioEn coder.AMR_NB);
。
。
。
。
。mrec1 prepare();
。mrec2 prepare();
mrec1.start();
mrec2.start();
 

我得到这个错误时,第二次启动()被调用我只是想知道的是,因为已经有一个称为启动过程或者有一些其他的问题。也第二媒体记录器实例被初始化并在一个单独的线程中使用。

  11月四号至22日:08:45.869:E / MediaRecorder(7742):启动失败:-2147483648
十一月4日至22日:08:45.869:W / dalvikvm(7742):主题ID = 9:线程退出与未捕获的异常(组= 0x40018578)
十一月4日至22日:08:45.869:E / AndroidRuntime(7742):致命异常:螺纹10
十一月4日至22日:08:45.869:E / AndroidRuntime(7742):java.lang.RuntimeException的:启动失败。
 

解决方案

根据的文档

  

在除不必要的资源(如存储器和实例   codeCS)召开之际,未能如果立即调用此方法   MediaRecorder对象不再需要,也可能导致持续   电池消耗的移动设备,并记录失败   其他应用程序如果同一codeC没有多个实例   在设备上的支持。即使在同一codeC多个实例   支持,一些性能下降可预期时   不必要多个实例被用于同时

我的尝试失败导致没有任何。

Can i run two instances of Android MediaRecorder class at the same time? For example

public MediaRecorder mrec1 ;
public MediaRecorder mrec2 ;


mrec1.setCamera(mCamera);
mrec1.setPreviewDisplay(surfaceHolder.getSurface());
mrec1.setVideoSource(MediaRecorder.VideoSource.CAMERA)
.
.
.
.
mrec2.setAudioSource(MediaRecorder.AudioSource.MIC);
mrec2.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mrec2.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
.
.  
.
.
mrec1.prepare();
mrec2.prepare();
mrec1.start();
mrec2.start();

I get this error when second start() is called i just want to know is it because there is already a start process called or there is some other problem. Also the second media recorder instance is initialized and used in a separate thread.

04-22 11:08:45.869: E/MediaRecorder(7742): start failed: -2147483648
04-22 11:08:45.869: W/dalvikvm(7742): threadid=9: thread exiting with uncaught exception  (group=0x40018578)
04-22 11:08:45.869: E/AndroidRuntime(7742): FATAL EXCEPTION: Thread-10
04-22 11:08:45.869: E/AndroidRuntime(7742): java.lang.RuntimeException: start failed.

解决方案

according to documentation:

In addition to unnecessary resources (such as memory and instances of codecs) being held, failure to call this method immediately if a MediaRecorder object is no longer needed may also lead to continuous battery consumption for mobile devices, and recording failure for other applications if no multiple instances of the same codec are supported on a device. Even if multiple instances of the same codec are supported, some performance degradation may be expected when unnecessary multiple instances are used at the same time.

My unsuccessful attempts led to nothing either.

这篇关于安卓:媒体录像机在同一时间两个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆