0

I need to display the YouTube's video thumbnail image for every video searched or featured. I just need the syntax and method to implement it in my java swing application.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Ramsey
  • 33
  • 7

2 Answers2

3

You can load the thumbnails directly via web request. Take a look at How do I get a YouTube video thumbnail from the YouTube API?

EDIT

Here are some sample links:

https://img.youtube.com/vi/<video-id>/default.jpg
https://img.youtube.com/vi/<video-id>/hqdefault.jpg
- or -
https://img.youtube.com/vi/<video-id>/maxresdefault.jpg
Florian Berger
  • 329
  • 3
  • 18
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/18746587) – Egon Feb 07 '18 at 09:08
  • 1
    You are right. I just edited the answer and added some sample links. Thanks for the hint. – Florian Berger Feb 07 '18 at 15:42
0

Assuming you get the SearchListResponse from youtube v3 data api. Now you can easily fetch the thumb url using following code.

SearchListResponse response = // data fetched from yt data api.
java.util.List<SearchResult> searchResultList = response.getItems();
for (SearchResult sr : searchResultList) {
   String thumburl = sr.getSnippet().getThumbnails().getDefault().getUrl();
//for high resolution you can use:  sr.getSnippet().getThumbnails().getHigh().getUrl();
}

related links. https://developers.google.com/youtube/v3/docs/search/list

MD Ruhul Amin
  • 4,386
  • 1
  • 22
  • 37