Android-youtube-player: Getting thumbnail without cueing video

Created on 12 May 2018  路  6Comments  路  Source: PierfrancescoSoffritti/android-youtube-player

Hi there!
First of all, I absolutely love your library, I am currently using it in my wip mobile app.
My app allows users to browse a library of movies /tv shows/ people associated with cinema. When I open a movie, I cue the YouTube player and then let the user click to start it.
Problem is, when I browse through multiple entries, I end up eating quite a lot of ram, and i suspect the culprit is continuous cueing of movies.
Is there a way to download the movies' thumbnail without cueing the video? Would you consider implementing it in one of your future releases?
XOXO

question

All 6 comments

Hi! It looks like the YouTube IFrame API doesn't offer this functionality, it is easily achievable using the YouTube Data API though.
I don't think it is a good idea to integrate it into the library, it would require the library to handle a lot of cases that are outside the scope of playing videos from YouTube.

My suggestion is to do it yourself outside the player. You could use the YouTube Data API to download the thumbnail of your videos then display the downloaded thumbnails over each player, with a play icon. You could then remove the thumbnail when the play button is pressed, to reveal the underlying player and start playing the video.

Hope this helps!

You could even define this behavior in a custom UI for the player.

Okay then. I'll try that, thanks for a quick answear though!

Ok, good luck!
let me know if you need any help. It may be interesting to add this as an example in the sample app!

Also, consider leaving a star on github if you find the library useful :)

Hi i've found a solution for this based on this stackoverflow question

So if i need a thumbnail you can use Picasso or Glide

For get the thumbnail i use this code:


String video_id = "ALZHF5UqnU4"; //You can get the video also in OnVideoId() listener

String fullsize_path_img = "https://img.youtube.com/vi/"+video_id+"/0.jpg";
String firstThumb_path_img = "https://img.youtube.com/vi/"+video_id+"/1.jpg";
String secondThumb_path_img = "https://img.youtube.com/vi/"+video_id+"/2.jpg";
String thirdThumb_path_img = "https://img.youtube.com/vi/"+video_id+"/3.jpg";

/*

You can use any method for get the image and this is the fastest and simple way of doing

*/

Picasso.get().load(fullsize_path_img).into(my_imageView);

Hope to help!

thanks!

Was this page helpful?
0 / 5 - 0 ratings