Is there a way to retrieve a thumbnail of a video using Xamarin Forms?
I use the Xam.Plugin.Media plugin to take and pick videos and save them to a specific location. Is it possible to save a thumbnail of the video as well?
//Pick a Video
private async void BtnPick_Clicked(object sender, EventArgs e) { await CrossMedia.Current.Initialize();
try
{
var file = await CrossMedia.Current.PickVideoAsync();
if (file == null)
return;
await StoreVideos(file.GetStream());
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
//Take Video
private async void BtnTake_Clicked(object sender, EventArgs e)
{
var file = await CrossMedia.Current.TakeVideoAsync(new StoreVideoOptions
{
Name = "video.mp4",
Directory = "DefaultVideos",
});
await StoreVideos(file.GetStream());
if (file == null)
return;
}
public async Task<string> StoreVideos(Stream videoStream)
{
var storageVideo = await new FirebaseStorage("adam-00000.appspot.com")
.Child("ProfileVideos")
.Child(App.UserID + "-" + App.VideoName + ".mp4")
.PutAsync(videoStream);
string imgurl = storageVideo;
return imgurl;
}
I'm looking to grab the thumbnail of the video, save it and then upload it to Firebase.
No, you do not put [Android.Runtime.Register("android/media/ThumbnailUtils", ApiSince=8, DoNotGenerateAcw=true)] public class ThumbnailUtils : Java.Lang.Objec
in you code, you just add this using Android.Media;
in your code, Then call this ThumbnailUtils.CreateVideoThumbnail(filePath,kind);
method to create Thumbnail of video like this link.https://stackoverflow.com/a/44304943/10627299
Note:This method is just suitable for the android platform, If you use Forms, you should achieve it with dependence service.