I writing an app where i want to display a list of YouTube videos. But I want the list to display the video title with some other info but also show a thumbnail of the video like it does when we go www.youtube.com
Can someone help me please on How to display the thumbnail for a video URL?
Clear YouTube App's Cache and Data Clearing cache and app data can sometimes fix issues like these so you can give it a shot. You can make this happen only on an Android phone since iPhone doesn't offer an option to clear the cache of a particular app.
With the Combination of Two Accepted Answer
How to make YouTube video thumbnails in android?
and
How to get video thumbnail of youtube video in android list in android?
Finally You just have to play with ID of YOUTUBE URL only.
I found one PHP Answer for same question in that they have described like:
Each YouTube video has 4 generated images. They are predictably formatted as follows:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg
, 2.jpg
, 3.jpg
) is:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
For the high quality version of the thumbnail use a url similar to this:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
There is also a medium quality version of the thumbnail, using a url similar to the HQ:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg
For the standard definition version of the thumbnail, use a url similar to this:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/sddefault.jpg
For the maximum resolution version of the thumbnail use a url similar to this:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg
All of the above urls are available over https too. Just change http
to https
in any of the above urls.
Additionally, the slightly shorter hostname i3.ytimg.com
works in place of img.youtube.com
in the example urls above.
I have one URL https://www.youtube.com/watch?v=-OKrloDzGpU
Now I will just take ID from URL i.e.: -OKrloDzGpU
// Picasso
Picasso.with(context)
.load("http://img.youtube.com/vi/-OKrloDzGpU/mqdefault.jpg")
.into(imageView);
// Glide
Glide.with(this)
.load("http://img.youtube.com/vi/-OKrloDzGpU/mqdefault.jpg")
.into(imageView);
Thank you. Hope it will helps you all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With