0

i need to use different mp4 files dynamically in code and this is what i am trying to do :

    String video_name = "event_"+subCategoryClicked+currentPage;
    String videoFile = "android.resource://"+getPackageName()+"/raw/"+ video_name;
    Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail(videoFile,
            MediaStore.Images.Thumbnails.MINI_KIND);
    System.out.println(thumbnail);
    eventInfoImage.setImageBitmap(thumbnail);

i have double checked that there is a file named event_bloodtest1.mp4 in raw folder i suspect that the error is the path to raw folder. Its easier to find it with resource int ID but then i don't know how to get it dynamically

thx in advance=)!

Robinhiio
  • 105
  • 1
  • 11
  • what do you mean by dynamically? there are several video files in raw folder or you are changing the video file keeping name as the same? – Burak Day Jul 07 '16 at 14:36
  • yes there will be like 100 files :P with different "subCategoryClicked" example event_bloodtest1 event_bloodtest2 event_bloodtest3 event_hospital1 event_doctor1 event_doctor2 – Robinhiio Jul 07 '16 at 14:40
  • so you wanna iterate between the files with different names in a specific folder? – Burak Day Jul 07 '16 at 14:42
  • yes depending on which category and page the user clicks on there should show different animations in the image view – Robinhiio Jul 07 '16 at 14:43
  • I already do this with text Strings and Images in drawable folder but now i need a String to convert to Bitmap that's the problem – Robinhiio Jul 07 '16 at 14:43
  • Have you checked this?http://stackoverflow.com/questions/13562429/how-many-ways-to-convert-bitmap-to-string-and-vice-versa – Burak Day Jul 07 '16 at 14:46
  • the problem is i never get any bitmap. With standard .png i can do this: int resourceId = getApplicationContext().getResources().getIdentifier("event_"+subCategoryClicked+currentPage, "drawable", getPackageName()); eventInfoImage.setBackgroundResource(resourceId); But with mp4 file i need to convert it to bitmap and i can't do that with resourceID (for what i know) because the method requires a String and the String i provide: "android.resource://"+getPackageName()+"/raw/"+ video_name; returns null so i guess the path is wrong.. – Robinhiio Jul 07 '16 at 14:50

0 Answers0