Skip to content

Instantly share code, notes, and snippets.

@wtuts
Created January 16, 2016 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtuts/88d2756c30b8c0fd9e7c to your computer and use it in GitHub Desktop.
Save wtuts/88d2756c30b8c0fd9e7c to your computer and use it in GitHub Desktop.
public async Task<BitmapImage> FetchThumbnail(StorageFile videofile)
{
//Fetching the thumbnail in form of StorageItemThumbnail
var thumbnail = await videofile.GetThumbnailAsync(ThumbnailMode.VideosView);
var inputBuffer = new Windows.Storage.Streams.Buffer(2048);
IBuffer buf;
IRandomAccessStream stream=new InMemoryRandomAccessStream();
while ((buf = (await thumbnail.ReadAsync(inputBuffer, inputBuffer.Capacity, InputStreamOptions.None))).Length > 0)
await stream.WriteAsync(buf);
var image = new BitmapImage();
image.SetSource(stream);
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment