I want to create an application in which I want to play YouTube video. I want to get thumbnail from YouTube video URL which I have currently play in application and set it to image view. can any body help me with this.
You can use the youtubethumbnail. download tool to download the thumbnail of any YouTube video here. The tool is really simple and allows you to see online the 4 thumbnails in the 4 different qualities, you can copy the link of the image to the clipboard or you can directly download the image.
Use this url.. just replace with your youtude video id
String url = "https://img.youtube.com/vi/"+{ID}+"/0.jpg";
Glide.with(this).load(url).into(imageView);
Option 1 – Get the custom thumbnail in 320 x 180 small image resolution
http://img.youtube.com/vi/{ID}/mqdefault.jpg
Option 2 – Get the custom thumbnail in 480 x 360 standard image resolution
http://img.youtube.com/vi/{ID}/0.jpg
Option 3 – Get the custom thumbnail in 720p or 1080p HD image resolution
http://img.youtube.com/vi/{ID}/maxresdefault.jpg
OR
just use YoutubeThumbnail API
You can use YouTube API v3 to retrieve related video thumbnail info like title, image and length:
https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet&fields=items/snippet(title,thumbnails),items/contentDetails/duration&key={{ YOUR_API_KEY }}&id={{ YOUR_YOUTUBE_VIDEO_ID }}
Or this url
if you only want to get only thumbnail image with medium size:
https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet&fields=items/snippet(title,thumbnails/medium/url),items/contentDetails/duration&key={{ YOUR_API_KEY }}&id={{ YOUR_YOUTUBE_VIDEO_ID }}
Your response may look like this:
{
"items": [
{
"snippet": {
"title": "F..k This S..t I'm Out",
"thumbnails": {
"medium": {
"url": "https://i.ytimg.com/vi/5FjWe31S_0g/mqdefault.jpg"
}
}
},
"contentDetails": {
"duration": "PT25S"
}
}
]
}
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