Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display thumbnail of YouTube Videos in Android

Tags:

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?

like image 755
Chandu Avatar asked Sep 06 '11 18:09

Chandu


People also ask

Why YouTube thumbnail is not showing in mobile?

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.


1 Answers

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.

Example:

I have one URL https://www.youtube.com/watch?v=-OKrloDzGpU

Now I will just take ID from URL i.e.: -OKrloDzGpU

Medium Image: http://img.youtube.com/vi/-OKrloDzGpU/mqdefault.jpg

enter image description here

HD Image: http://img.youtube.com/vi/-OKrloDzGpU/hqdefault.jpg

enter image description here

Load Images in Android using Glide or Picasso:

// 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.

like image 189
Pratik Butani Avatar answered Oct 12 '22 23:10

Pratik Butani