Forum Xamarin.Forms

VIDEO URL TO THUMBNAIL IMAGE

AwodamAwodam ATMember ✭✭

hello,

i have a problem, i can't get thumbnail image from video URL. my code is below

public byte[] GetVideoThumbNailFromVideo(string filePath)
{
Android.Graphics.Bitmap thumb = Android.Media.ThumbnailUtils.CreateVideoThumbnail("http://192.168.2.1/video/myvideo.mp4", Android.Provider.ThumbnailKind.MicroKind);
byte[] bytearray = null;
try
{
var stream = new MemoryStream();
thumb.Compress(Android.Graphics.Bitmap.CompressFormat.Jpeg, 100, stream);
bytearray = stream.ToArray();
}
catch (System.Exception error)
{
var errortext = error;
}
return bytearray ;
}

CreateVideoThumbnail parameters is

filePath
the path of video file
kind
could be MINI_KIND or MICRO_KIND

Sign In or Register to comment.