Created
March 1, 2016 15:49
-
-
Save dannycabrera/7f83f168b0e07311ee0d to your computer and use it in GitHub Desktop.
Xamarin.iOS get video thumbnail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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