0

Relevant code:

YouTubeThumbnailView first_video = (YouTubeThumbnailView) findViewById(R.id.main_video);

first_video.initialize(Config.YOUTUBE_API, new YouTubeThumbnailView.OnInitializedListener() {
        @Override
        public void onInitializationSuccess(YouTubeThumbnailView youTubeThumbnailView, YouTubeThumbnailLoader youTubeThumbnailLoader) {
            final String video = getResources().getString(R.string.principal_funcoes);

            youTubeThumbnailLoader.setVideo(video);
        }

The time it takes for the method 'youTubeThumbnailLoader.setVideo(String s)" to work is absurd. It takes 30+ seconds for a thumbnail to show up, with full cabled connection (100mbps).

It's definitely impossible for a user to wait more than 2 seconds for the thumbnail to show up, and have a completely blank screen while he waits for that to happen.

What can I do to load the video thumbnail any faster, or at least make YouTubeThumbnailView show a loading image while it fetches the thumbnail?

LeoColman
  • 6,950
  • 7
  • 34
  • 63
  • Have you tried choosing what [resolution](http://stackoverflow.com/a/2108248/5995040) of the thumbnail you will use? And see if it loads the same as the other resolutions? – Mr.Rebot Oct 24 '16 at 08:00

1 Answers1

1

You can use direct youtube api urls for getting youtube thumbnails and they are way to faster too. here are urls you can try.

Start:-- It is only give you default size thumbnails.

https://ytimg.googleusercontent.com/vi/<insert-youtube-video-id-here>/default.jpg

For the high quality version of the thumbnail use a url similar to this:

https://ytimg.googleusercontent.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:

https://ytimg.googleusercontent.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg

For the standard definition version of the thumbnail, use a url similar to this:

https://ytimg.googleusercontent.com/vi/<insert-youtube-video-id-here>/sddefault.jpg

For the maximum resolution version of the thumbnail use a url similar to this:

https://ytimg.googleusercontent.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg

It helps me to develop youtube application, Hope it also help you.

Kumar
  • 1,187
  • 18
  • 31