所以,我知道有很多解决方案,在那里为MediaRecorder启动时的误差,但大多围绕“启动失败:-19”,它已被链接到“NO_INIT” 看到这里在选择的答案评论 。 我还没有找到任何解决方案,甚至为-16解释。
如果有人知道在哪里可以找到这些错误代码的名称,或有一个解决方案用于代码-16请点击这里把答案! 下面是我使用的代码。 (HTC霹雳,股票)
mr.setVideoSource(MediaRecorder.VideoSource.CAMERA); //mr is my mediaRecorder
mr.setAudioSource(MediaRecorder.AudioSource.MIC);
mr.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
mr.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
mr.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
mr.setOutputFile(ParcelFileDescriptor.fromSocket(soc).getFileDescriptor()); //soc is a java.net.ServerSocket pointing to a port on the device
mr.setVideoSize(480,800);
mr.setVideoFrameRate(5);
mr.prepare();
mr.start(); //Crashes with "start failed: -16"
logcat的
07-11 10:14:34.879: V/MediaRecorderJNI(17939): JNIMediaRecorderListener::setCamera
07-11 10:14:34.879: V/MediaRecorderJNI(17939): process_media_recorder_call
07-11 10:14:47.549: V/MediaRecorderJNI(17939): setVideoSource(1)
07-11 10:14:47.549: V/MediaRecorderJNI(17939): getMediaRecorder E
07-11 10:14:47.559: V/MediaRecorderJNI(17939): process_media_recorder_call
07-11 10:14:47.559: V/MediaRecorderJNI(17939): setAudioSource(1)
07-11 10:14:47.559: V/MediaRecorderJNI(17939): getMediaRecorder E
07-11 10:14:47.559: V/MediaRecorderJNI(17939): process_media_recorder_call
07-11 10:14:47.559: V/MediaRecorderJNI(17939): setOutputFormat(0)
07-11 10:14:47.559: V/MediaRecorderJNI(17939): getMediaRecorder E
07-11 10:14:47.559: V/MediaRecorderJNI(17939): process_media_recorder_call
07-11 10:14:47.559: V/MediaRecorderJNI(17939): setVideoEncoder(0)
07-11 10:14:47.559: V/MediaRecorderJNI(17939): getMediaRecorder E
07-11 10:14:47.559: V/MediaRecorderJNI(17939): process_media_recorder_call
07-11 10:14:47.559: V/MediaRecorderJNI(17939): setAudioEncoder(0)
07-11 10:14:47.559: V/MediaRecorderJNI(17939): getMediaRecorder E
07-11 10:14:47.559: V/MediaRecorderJNI(17939): process_media_recorder_call
07-11 10:14:47.559: V/MediaRecorderJNI(17939): setVideoFrameRate(5)
07-11 10:14:47.559: V/MediaRecorderJNI(17939): getMediaRecorder E
07-11 10:14:47.559: V/MediaRecorderJNI(17939): process_media_recorder_call
07-11 10:14:47.559: V/MediaRecorderJNI(17939): setOutputFile
07-11 10:14:47.559: V/MediaRecorderJNI(17939): getMediaRecorder E
07-11 10:14:47.559: V/MediaRecorderJNI(17939): process_media_recorder_call
07-11 10:14:47.559: V/MediaRecorderJNI(17939): prepare
07-11 10:14:47.559: V/MediaRecorderJNI(17939): getMediaRecorder E
07-11 10:14:47.559: V/MediaRecorderJNI(17939): process_media_recorder_call
07-11 10:14:47.559: V/MediaRecorderJNI(17939): start
07-11 10:14:47.559: V/MediaRecorderJNI(17939): getMediaRecorder E
07-11 10:14:47.639: E/MediaRecorder(17939): start failed: -16
07-11 10:14:47.639: V/MediaRecorderJNI(17939): process_media_recorder_call
07-11 10:14:59.290: W/dalvikvm(17939): threadid=10: thread exiting with uncaught exception (group=0x4001d5a0)
更新12年7月11日下午2点21分 :Discoverd的错误代码-16实际上是-EBUSY。 扩大logcat的,包括一切,彻底梳理的Android源代码后,我发现,它关系到一个inablility调整(初始化)的相机设置,我不知道我在做什么错,但它的一个开端。 如果你有机会获得AOSP你可以看到错误来自/frameworks/av/media/libstagefright/CameraSource.cpp CameraSource :: ConfigureCamera