0

I want to show thumbnail before playing video.My video is in /res/raw folder.I am trying following method to get Real path of my video file.But getContentResolver().query(contentUri, proj , null, null, null) this returning null without any exception.

@SuppressWarnings("deprecation")
public String getRealPathFromURI(Uri contentUri) {      
    String[] proj = { MediaStore.Images.Media.DATA };
    Cursor cursor = getContentResolver().query(contentUri, proj , null, null, null);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}

Am I missing something? Any permission in Manifest?

Ahmad
  • 69,608
  • 17
  • 111
  • 137
Amol Dadas
  • 799
  • 2
  • 8
  • 17

1 Answers1

0

I am trying following method to get Real path of my video file.

There is no "real path" to your video, because it is not a file. It is an entry in the APK.

I want to show thumbnail before playing video

Since the video is a resource, prepare your own thumbnail on your development machine and package that as a resource as well.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Uri videoURI = Uri.parse("android.resource://" + getPackageName() +"/" +R.raw.grilled_daily_sandwich); MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(this, videoURI); Bitmap bitmap = retriever .getFrameAtTime(200000,MediaMetadataRetriever.OPTION_PREVIOUS_SYNC); BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap); videoView.setBackgroundDrawable(bitmapDrawable); not workoing always. http://stackoverflow.com/questions/6367019/how-to-get-video-thumb-nail-from-raw-folder-video-on-android – Amol Dadas Jun 29 '14 at 07:20