Created
January 16, 2016 15:52
-
-
Save wtuts/88d2756c30b8c0fd9e7c to your computer and use it in GitHub Desktop.
This file contains 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
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