ส่วนใหญ่ฉันต้องการทราบว่ามีความขัดแย้งพื้นฐานที่ทำให้ฉันไม่สามารถแบ่งปันทรัพยากรเดียวกันกับห้องสมุดได้หรือไม่ หากเป็นเช่นนั้น ฉันจำเป็นต้องใช้แนวทางอื่น
เป้าหมายของฉันคือการมีวิดีโอคุณภาพต่ำโดยที่ข้อมูลเมตาของตัวตรวจจับบันทึกไว้ในเวลาเดียวกัน เพื่อที่ฉันจะสามารถดำเนินการภายหลังและตัดส่วนได้โดยไม่ล่าช้ามากนัก
อ้างอิงจาก CameraDetectorDemo - ตัวตรวจจับกล้อง
ฉันได้เริ่มต้น MediaRecorder แล้ว แต่จะบันทึกหน้าจอสีดำหากฉันสตาร์ทก่อนตัวตรวจจับ และมันจะหยุดทำงานเมื่อสตาร์ท (ด้วยรหัส -19) หากฉันสตาร์ทหลังจากตัวตรวจจับ เครื่องมือตรวจจับกำลังแนบตัวอย่าง ซึ่งอาจเกี่ยวข้องกับสิ่งนั้น
ฉันได้เพิ่มปุ่มบางปุ่มเพื่อควบคุมฟังก์ชันเหล่านี้:
protected void cameraInit() {
String state = Environment.getExternalStorageState();
if (!Environment.MEDIA_MOUNTED.equals(state)) {
Log.d(LOG_TAG, "Drive not mounted - cannot write video");
return;
}
File file = new File(getExternalFilesDir(Environment.DIRECTORY_MOVIES), "demo.gp3");
Log.d(LOG_TAG, String.format("Camera Initializing. Setting output to: %s", file.getAbsolutePath()));
// Set sources
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
// Set profile
recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
// Set output profile
recorder.setOutputFile(file.getAbsolutePath());
// Set preview output
recorder.setPreviewDisplay(cameraPreview.getHolder().getSurface());
try {
this.recorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "IO exception on camera Initialization");
e.printStackTrace();
} catch (IllegalStateException e) {
// This is thrown if the previous calls are not called with the
// proper order
Log.e(LOG_TAG, "Failed to initialize things properly :( ");
e.printStackTrace();
}
}
protected void cameraStart() {
Log.d(LOG_TAG, "Camera Start");
this.recorder.start();
}
protected void cameraStop() {
Log.d(LOG_TAG, "Camera Stop");
this.recorder.stop();
}