0

So I am displaying video files from specific folder when the folder is selected but in the video list I am showing file name with the video thumbnail and that's where the problem starts i am using this way to get the thumb

 Bitmap bmThumbnail = ThumbnailUtils.
            extractThumbnail(ThumbnailUtils.createVideoThumbnail(info.getFilename(),
                    MediaStore.Video.Thumbnails.MINI_KIND), 60, 60);
    if(bmThumbnail != null) {
        imageView.setImageBitmap(bmThumbnail);}

and even if I don't set the bitmap or not the process is taking way too much time to open the new fragment whereas just displaying the name is smooth if I call the following bitmap it takes around 6-7 sec to display the list. The following thing are happening in the adapter as I test the app in adapter then recycler view

so I would like to know what is the best way to do it .

For using image loader i need the url which is not there as i am getting the album art using the file url but it will not produce the album art url directly.

Neelay Srivastava
  • 1,041
  • 3
  • 15
  • 46
  • **Do not ever** use raw bitmaps to handle image loading in Android. There are tons of libraries especially crafted for that purpose (Glide, Picasso, ...) that will handle the work in a more efficient way (asynchronously btw) – Arthur Attout Aug 27 '19 at 22:13
  • I consider that as my first option but for that, i need the thumbnail url – Neelay Srivastava Aug 27 '19 at 22:19
  • I refered this https://stackoverflow.com/questions/38541928/load-image-with-picasso-to-a-bitmap-first at first then i came to ask – Neelay Srivastava Aug 27 '19 at 22:21

1 Answers1

1

Dealing with images and videos like that takes time. Particularly when dealing with a large group of them. It's unlikely you can speed up the operation but you can make it so your application doesn't have to wait for it by sending it to the background. I recommend Kotlin coroutines if you are up for converting to Kotlin. Otherwise I recommend making a thumbnail work manager

public class VideoThumbnailWorker extends Worker {

}

Eric Y
  • 1,677
  • 1
  • 12
  • 17
  • the issue is all this is in the adapter that is binding me otherwise i better use async task for this kind of thing – Neelay Srivastava Aug 27 '19 at 22:12
  • So what ? Having to deal with this in the adapter doesn't prevent you from using a `Worker` to handle your work asynchronously, as specified – Arthur Attout Aug 27 '19 at 22:16
  • try to understand worker thread is not able to interact with the ui thread and i am setting this even if i make a call there will be n no of the thread whenever the item is at a different position @ArthurAttout – Neelay Srivastava Aug 27 '19 at 22:32