I need to display a video thumbnail based to a URL into an ImageView
view child of my ListView
items, i have found this post but not worked.
Result
Code
thumb_image.setImageBitmap(new LoadVideoThumbnail().execute(URLs.videos +"/"+videos.get(position).getId()+".mp4").get());
AsyncTask
public class LoadVideoThumbnail extends AsyncTask<String, Object, Bitmap>{
@Override
protected Bitmap doInBackground(String... objectURL) {
//return ThumbnailUtils.createVideoThumbnail(objectURL[0], Thumbnails.MINI_KIND);
return ThumbnailUtils.extractThumbnail(ThumbnailUtils.createVideoThumbnail(objectURL[0], Thumbnails.MINI_KIND), 100, 100);
}
@Override
protected void onPostExecute(Bitmap result){
//img.setImageBitmap(result);
}
}
@CommonsWare,
This is not the case that for every video store individual thumbnail in server. but we have some library
which directly provide the thumbnail from server url with in 10 second.
The sample code for Thumbnail.
Hello try this snippet working in my case
The support class
With glide, i am use with Glide 4.8.0
To display a bitmap preview of a video, just set the video path of the VideoView and let the stream buffer.
For example:
In a few seconds you will see the first frame of the video.
Without downloading video you can generate thumbnail of video by using below method :
Use android ThumbnailUtils class