Glide load thumbnail not working
Asked Answered
L

5

9

I'm using Glide to load thumbnail from videos but it doesn't seem to be working on my app. The ImageView is just empty for some reason.

Glide.with(context)
            .load(url)
            .asBitmap()
            .thumbnail(0.1f)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .into(target);

I added a listener, so I can figure out what is wrong but the Exception thrown is null.

I tried using ThumbnailUtils using the same url because I thought there might be something wrong with it but the thumbnail loads fine.

Anyone experiencing the same? I'm using a Nexus 7 (6.0.1)

Lancelle answered 5/2, 2016 at 10:40 Comment(0)
C
7

Even i stumbled upon the same situation. Somehow from the uri its not loading the image unless create a file instance using local file path. So to make it work i used it like below

Glide.with(mContext).load(Uri.fromFile(new File(path)).into(icon);

In the doc they are using the same approach. You can refer here : Glide - Videos

Apart from that i also noticed unusual behaviour of using the cache. If you are using cache strategy as DiskCacheStrategy.ALL or DiskCacheStrategy.SOURCE it doesn't load the thumbnail but if i am using DiskCacheStrategy.RESULT it works. Hope it helps

Cahier answered 5/4, 2016 at 10:42 Comment(2)
i'm using this solution from long time but still i'm searching for getting thumb for audioFileStealth
It doesn't work at 3.7.0 version. Also I can't use the latest version due to another glide bug. How can i solve it?Institutional
T
2

As explained in Glide documentation, this feature is only available for videos stored locally on the device.

Also, you should use a path like /storage/emulated/0/Pictures/example_video.mp4. Adding file:/// before this path won't work out either.

You can find more informations here : https://futurestud.io/blog/glide-displaying-gifs-and-videos

Cheers !

Triumvirate answered 9/3, 2016 at 23:20 Comment(2)
yup. I am loading thumbnail from videos in the device SD card, unfortunately it doesn't load at allLancelle
As far as i'm concerned, i don't use the .asBitmap() option. But i guess you already tried everything on that ... Is it linked to the Android version maybe ?Civilization
T
2

You can use override, which surely works:

Glide.with(context)
         .load(url)
         .crossFade()
         .override(width, height)
         .into(imageView);
Transmontane answered 16/9, 2016 at 7:42 Comment(0)
E
0
Glide.with(mcontext)
                .applyDefaultRequestOptions(RequestOptions.centerCropTransform()
                        .diskCacheStrategy(DiskCacheStrategy.RESOURCE))
                .load(videourl)
                .into(thumbnailimg);

Try using this code

Eddy answered 12/3, 2018 at 9:30 Comment(0)
F
0
@BindingAdapter("videoThumbnailFromUrl")
fun setImageFromVideoUrl(imageView: ImageView, url: String) {
   val thumb = 10000L
   val options = RequestOptions().frame(thumb)
   Glide.with(imageView.context).load(url).apply(options).placeholder(R.drawable.place_holder).into(imageView)
}
Filament answered 11/7, 2020 at 11:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.