Reputation: 4482
I am trying to display a thumbnail for my videoview, I have an imageview layered ontop that I want to place a thumbnail... I tried this but it is not working not sure if the url which is being passed as a string is the problem? No errors and the image just does not display the placeholder shows though, so it has to do with either the way I am doing the bitmap, the link also shows the video correctly.
String filePath = ""http://unknown.com/v3-1aox9d1.mp4"";
ImageView imageview_micro = (ImageView)findViewById(R.id.thumbnail_micro);
Bitmap bmThumbnail;
//MICRO_KIND, size: 96 x 96 thumbnail
bmThumbnail = ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MICRO_KIND);
imageview_micro.setImageBitmap(bmThumbnail);
Upvotes: 1
Views: 1591
Reputation:
Can you please try below code, it may help you
public static Bitmap retriveVideoFrameFromVideo(String p_videoPath)
throws Throwable
{
Bitmap m_bitmap = null;
MediaMetadataRetriever m_mediaMetadataRetriever = null;
try
{
m_mediaMetadataRetriever = new MediaMetadataRetriever();
m_mediaMetadataRetriever.setDataSource(p_videoPath);
m_bitmap = m_mediaMetadataRetriever.getFrameAtTime();
}
catch (Exception m_e)
{
throw new Throwable(
"Exception in retriveVideoFrameFromVideo(String p_videoPath)"
+ m_e.getMessage());
}
finally
{
if (m_mediaMetadataRetriever != null)
{
m_mediaMetadataRetriever.release();
}
}
return m_bitmap;
}
Bitmap bmThumbnail;
bmThumbnail = retriveVideoFrameFromVideo(filePath);
imageview_micro.setImageBitmap(bmThumbnail);
Upvotes: 0
Reputation: 6460
That is not the way to use createVideoThumbnail
.
The first parameter should be a file path which refers to a local file. You are using a web url.
You have to download the video first or have to search for an other solution.
This answer might help you: https://stackoverflow.com/a/23523205/5038873
Upvotes: 1