썸네일과 동영상을 같이 업로드 하는 부분을 구현 중인데요...
업로드 클래스가 파일 경로로 File 객체를 생성하여 첨부하면 올려주도록 되어있어서
썸네일의 경로를 알아낼 수 있다면 동영상처럼 썸네일 경로로 File 객체를 생성하여 첨부하면 될거 같은데
예제 소스를 찾아봐도 대부분 MediaStore.Video.Thumbnails.getThumbnail()를 이용하여 Bitmap 객체를 얻어내는
방법만 검색이 되서요... 이렇게 Bitmap을 얻게 되면 파일에 쓰고.... 그 경로로 첨부하여 보내고
다시 그 Bitmap파일을 삭제해줘야 해서요..
기본적으로 동영상 마다 썸네일을 가지고 있다고 알고 있어서...
걔네들의 경로만 얻어내면 좋을거 같은데...말이죠..
아 그리고 추가로 이 섬네일이란게 이미지 해상도가 얼마나 될까요....
제가 필요한건 꽤 큰 사이즈인데... 이럼 결국 제가 따로 썸네일을 큰 사이즈로 얻어내서 저장하고 보내고 지우는 식으로 해야하는건가요... ㅠ
땡큐 합니다~
private int retImageViewSetThumbnail = 0;
private String ImageViewSetThumbnail(String videoPath)
{
Log.d("TTTT","Step1");
//Step1 : 동영상경로로 동영상DB에 저장된 _id값 불러오기
Uri video = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
String[] projection = new String[]{MediaStore.Video.Media._ID};
String where = MediaStore.Video.Media.DATA+"=?";
String[] whereArgs = new String[]{videoPath};
Cursor media = mActivity.getContentResolver().query(video, projection, where, whereArgs, null);
if(!media.moveToFirst()){
retImageViewSetThumbnail = -1;
return null;
}
String videoId = media.getString(0);
Log.d("TTTT","Step2");
//Step2 : 동영상의 _id값으로 썸네일 DB에 저장된 해당 동영상의 썸네일 파일경로를 가져오기
Uri thumbnail = MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI;
projection = new String[]{MediaStore.Video.Thumbnails.DATA};
where = MediaStore.Video.Thumbnails.VIDEO_ID+"=?";
whereArgs = new String[]{videoId};
Cursor thumb = mActivity.getContentResolver().query(thumbnail, projection, where, whereArgs, null);
if(!thumb.moveToFirst()){
retImageViewSetThumbnail = -2;
return null;
}
String thumnailPath = thumb.getString(0);
Log.d("TTTT","Step3");
retImageViewSetThumbnail = 0;
return thumnailPath;
}




동영상 썸네일은 동영상의 크기에 맞춰서 되는 것 같습니다.
1280*720 동영상은 썸네일도 1280*720,
720*480 동영상의 썸네일은 720*480 인 것 같네요. (갤스와 넥서스원으로 테스트)
암튼 동영상 패스로 썸네일 패스를 알려면
ContentResolver에 쿼리를 2번 날려야 합니다. 조인이 안되서 그렇습니다.
1번째는 동영상의 패스로 동영상 DB에 저장된 의 _id 값을 가져와야 합니다.
String videoPath = 파일이름까지 포함된 절대 경로;
Uri video = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
String[] projection = new String[]{MediaStore.Video.Media._ID};
String where = MediaStore.Video.Media.DATA+"=?";
String[] whereArgs = new String[]{videoPath};
Cursor media = getContentResolver().query(video, projection, where, whereArgs, null);
media.moveToFirst();
String videoId = media.getString(0);
2번째는 동영상의 id 값으로 썸네일 DB에 저장된 해당 동영상의 썸네일 파일의 패스를 가져와야 합니다.
Uri thumbnail = MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI;
projection = new String[]{MediaStore.Video.Thumbnails.DATA};
where = MediaStore.Video.Thumbnails.VIDEO_ID+"=?";
whereArgs = new String[]{videoId};
Cursor thumb = getContentResolver().query(thumbnail, projection, where, whereArgs, null);
thumb.moveToFirst();
String path = thumb.getString(0);
Log.d("======================", "path:"+path);