Skip to content

Instantly share code, notes, and snippets.

@dannycabrera
Created March 1, 2016 15:49
Show Gist options
  • Save dannycabrera/7f83f168b0e07311ee0d to your computer and use it in GitHub Desktop.
Save dannycabrera/7f83f168b0e07311ee0d to your computer and use it in GitHub Desktop.
Xamarin.iOS get video thumbnail
private UIImage GetVideoThumbnail(string path)
{
try {
CMTime actualTime;
NSError outError;
using (var asset = AVAsset.FromUrl (NSUrl.FromFilename (path)))
using (var imageGen = new AVAssetImageGenerator (asset))
using (var imageRef = imageGen.CopyCGImageAtTime (new CMTime (1, 1), out actualTime, out outError)) {
return UIImage.FromImage (imageRef);
}
} catch {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment