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.
Why not fetch YouTube thumbnail? It looks quite simple. Once you got video URL, like this:
you extract video ID (which in this case is
dRpFF5Dm-k0) and your thumbnail is at:so in this case:
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 🙂