2011-03-16 3 views
3

인 텐트를 사용하여 카메라 애플리케이션을 실행해야하는 애플리케이션에서 작업하고 있습니다. 카메라가 사진 또는 비디오 모드로 실행되고 지금까지 작동하고 결과 파일을 sdcard에 저장합니다. 이제는 문제가되는데, 새로운 사용자 정의 파일 이름을 지정하는 것은 그림의 의도에 맞게 작동하지만 캠코더의 의도에 맞게 작동하지 않는 것 같습니다. 사실, EXTRA_OUTPUT 또는 단순히 "출력"은 비디오 인 텐트에서 무시됩니다. 나는 다음과 같은 코드를 사용하고 있습니다 : 비디오에Android 맞춤 비디오 캡처 파일 경로가 작동하지 않습니다.

// makes new unique filenames like Picture_03161185528.jpg 
fileName = makeFileName("Picture")+".jpg"; 
path = (new StringBuilder()). 
      append(Environment.getExternalStorageDirectory()). 
      append("/"+fileName).toString(); 
File file = new File(path); 
Uri outputFileUri = Uri.fromFile(file); 
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
intent.putExtra("output", outputFileUri);   
mainActivity.startActivityForResult(intent, CAMERA_RESULT); 

(사용자 정의 파일 이름과 그림을 저장 포함한 모든 작품 궁금해) 사진에 대한

를 (이 비디오를 소요하지만 항상 기본 이름을 사용 등 VIDEO001, VIDEO002처럼이 아닌 사용자 정의 파일 이름은 내가

어떤 경우
// makes new unique filenames like Video_03161185528.3gp   
fileName = makeFileName("Video")+".3gp"; 
// even tried this hardwired filename...but nothing 
fileName = "video.3gp"; 
path = (new StringBuilder()). 
      append(Environment.getExternalStorageDirectory()). 
      append("/"+fileName).toString(); 
File file = new File(path); 
Uri outputFileUri = Uri.fromFile(file); 
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); 
// seems to be ignored, the file always get saved under default filename 
intent.putExtra("output", outputFileUri);  
// same as previous line...seems to be ignored 
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); 
mainActivity.startActivityForResult(intent, VIDEO_RESULT); 

가, 사진 의도 내 사용자 정의 파일 이름으로 사진 저장)이 필요하지만, 비디오 의도는 분명 그것을 무시하고 항상 사용하여 파일을 저장 디폴트의 ​​파일명 제 질문은 :

가) 나는이 작품을 사용자 정의 파일 이름을 사용하여 만들 수있는 방법이 있습니까? b) 또는 다음으로 사용할 수있는 기본 파일 이름을 미리 알 수있는 방법이 있습니까? c) 어떤 파일이 만들어 졌는지 확인하고 이름을 바꿀 수있는 다른 방법이 있습니까?

건배와 감사합니다!

아람

+0

이 문제에 대한 해결책을 찾았습니까? – Mohit

답변

0

나는 의도를 호출하기 전에 나에게 미래 영상의 URI를 제공하는 미디어 스토어 MediaStore에서 행을 삽입합니다. uri가 있으면 파일에서 원하는 모든 작업을 수행 할 수 있습니다.

ContentValues values = new ContentValues(); 
values.put(MediaStore.Video.Media.TITLE, "video name");         
values.put(MediaStore.Images.Media.DATE_TAKEN,System.currentTimeMillis());     
//videoUri = mediastore path  
videoUri = CaptureContentFragment.this.getActivity().getContentResolver().insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values);     
//create new Intent      
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); 
intent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri); 
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); 
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 20); 
CaptureContentFragment.this.getActivity().startActivityForResult(intent, TabsActivity.VIDEO_REQUEST_CODE); 
+0

작동합니까? – NitZRobotKoder

관련 문제