Android: two copies of the media recorder at the same time

Can I run two instances of the Android MediaRecorder class at the same time? for instance

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 the second start () is called, I just want to know, because the start process has already been called, or is there some other problem. Also, the second instance of the media recorder is initialized and used in a separate stream.

 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. 
+6
source share
1 answer

according to the documentation :

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

My unsuccessful attempts failed.

0
source

All Articles