1

I am trying to create a video thumbnail for a file : 1- the file is located on YouTube. 2- I would start an implicit intent for Andriod OS to play this file using:

Intent intent= new Intent(Intent.ACTION_VIEW, Uri.parse(youTubeVideoWebPath));
startActivity(intent);

where

String youTubeVideoWebPath = "http://www.youtube.com/watch?feature=player_detailpage&v=OZJalBmtGnQ";

after searching some posts on the forum, I found it could be either: 1- VideoView and set its background with the Thumbnail that I will extract from the video Or 2- ImageView which sets its source/background with the extracted Thumbnail

when an item (whether VideoView or ImageView) is clicked, I will send the previous mentioned intent. since I am not going to control playing the video by my application, I guess that it is better to use ImageView, right?

Secondly, I would like to create a video Thumbnail for that remote file so what is the best/easiest way to do that? For me, after doing more search on the forum, I found the following method:

Bitmap thumbAsBitmap = ThumbnailUtils.createVideoThumbnail(filePath, MediaStore.Video.Thumbnails.MINI_KIND);

But it always returns null, I dont know why although that I passed it: filePath: the web path of the file mentioned above second argument: not sure whether it should be MediaStore.Video.Thumbnails.MINI_KIND or MediaStore.Images.Thumbnails.MINI_KIND?

I can only find posts related to extracting VideoThumbnail from files saved in internal/external memory, nothing related to remote files such as my case.

Wael Showair
  • 3,092
  • 2
  • 22
  • 29

1 Answers1

3

Why not fetch YouTube thumbnail? It looks quite simple. Once you got video URL, like this:

https://www.youtube.com/watch?v=dRpFF5Dm-k0

you extract video ID (which in this case is dRpFF5Dm-k0) and your thumbnail is at:

http://i1.ytimg.com/vi/<VIDEOID>/default.jpg

so in this case:

http://i1.ytimg.com/vi/dRpFF5Dm-k0/default.jpg

Not sure if that works for any video (I just found that out to answer your question), but at least it is a good start :)

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • 1
    I was going to answer the same. That IS the correct answer. You want a thumbnail from YouTube you get it from YouTube. – Budius Oct 28 '12 at 14:00
  • This is typically what I have done before I got your answer... Thanks a lot. After searching for about one day trying to create the video thumbnail using andriod APIs, I found out that The data formats of YouTube videos was the most easiest way to get a video thumbnail. – Wael Showair Oct 29 '12 at 15:14